Game Engine for 3D games with pre-rendered background in the browser https://victorgiers.com/painted_world/v0.1/painted_world.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v3d.js 1.2MB

1
  1. function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _get(e,t,n){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=_superPropBase(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(n){var r=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(n);return _possibleConstructorReturn(this,r?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).v3d={})}(this,function(t){"use strict";var n;function o(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:0<e?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}),void 0===Object.values&&(Object.values=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}),void 0===Float32Array.prototype.slice&&(Float32Array.prototype.slice=function(e,t){return new this.constructor(this.subarray(e,t))}),String.prototype.endsWith||(String.prototype.endsWith=function(e,t){return(void 0===t||t>this.length)&&(t=this.length),this.substring(t-e.length,t)===e}),Object.assign(o.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){var n,r;void 0!==this._listeners&&(void 0===(n=this._listeners[e])||-1!==(r=n.indexOf(t))&&n.splice(r,1))},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var n=t.slice(0),r=0,i=n.length;r<i;r++)n[r].call(this,e)}}}});for(var Pe="3.2.0",me={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Q=0,K=1,J=2,Y=0,q=1,Z=2,$=3,ee=4,te=5,ne=6,re=0,Le=1,ie=2,s=0,_=2,ae=0,oe=1,se=2,le=3,ce=4,ue=5,de=100,he=101,pe=102,fe=103,ve=104,ge=200,_e=201,ye=202,xe=203,be=204,Me=205,we=206,Ae=207,Se=208,Te=209,Ee=210,Ce=0,Re=1,De=2,Ne=3,Ie=4,Oe=5,Fe=6,Be=7,U=0,V=1,k=2,G=0,ze=1,j=2,W=3,X=4,H=5,Ue=6,Ve=7,ke=8,Ge=301,je=302,We=303,Xe=304,He=305,Ye=306,qe=307,Ze=1e3,Qe=1001,Ke=1002,Je=1003,$e=1004,et=1005,tt=1006,nt=1007,rt=1008,it=1009,i=1010,a=1011,at=1012,l=1013,ot=1014,st=1015,lt=1016,c=1017,u=1018,d=1019,ct=1020,h=1021,ut=1022,dt=1023,p=1024,f=1025,S=dt,ht=1026,pt=1027,ft=1028,m=1029,v=1030,g=1031,y=1032,x=1033,b=33776,M=33777,w=33778,A=33779,T=35840,E=35841,C=35842,P=35843,L=36196,R=37808,D=37809,N=37810,I=37811,O=37812,F=37813,B=37814,z=37815,mt=37816,vt=37817,gt=37818,_t=37819,yt=37820,xt=37821,r=2300,bt=2301,Mt=2302,wt=2400,At=2401,St=2402,Tt=3e3,Et=3001,Ct=3007,Pt=3002,Lt=3003,Rt=3004,Dt=3005,Nt=3006,It=3200,Ot=3201,Ft=3301,Bt=3302,zt=0,Ut=1,Vt=7680,kt=519,Gt=35044,jt=35048,Wt="BLENDER",Xt="__V3DL__03c1cb7bfe",Ht=0,Yt=0,qt=[],Zt=0;Zt<256;Zt++)qt[Zt]=(Zt<16?"0":"")+Zt.toString(16);var Qt,Kt={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(qt[255&e]+qt[e>>8&255]+qt[e>>16&255]+qt[e>>24&255]+"-"+qt[255&t]+qt[t>>8&255]+"-"+qt[t>>16&15|64]+qt[t>>24&255]+"-"+qt[63&n|128]+qt[n>>8&255]+"-"+qt[n>>16&255]+qt[n>>24&255]+qt[255&r]+qt[r>>8&255]+qt[r>>16&255]+qt[r>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-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*Kt.DEG2RAD},radToDeg:function(e){return e*Kt.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,r,i){var a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),c=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),h=o((t-r)/2),p=a((r-t)/2),f=o((r-t)/2);"XYX"===i?e.set(s*u,l*d,l*h,s*c):"YZY"===i?e.set(l*h,s*u,l*d,s*c):"ZXZ"===i?e.set(l*d,l*h,s*u,s*c):"XZX"===i?e.set(s*u,l*f,l*p,s*c):"YXY"===i?e.set(l*p,s*u,l*f,s*c):"ZYZ"===i?e.set(l*f,l*p,s*u,s*c):console.warn("v3d.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")},hashString:function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0},expAverage:function(e,t,n,r){var i=Math.exp(-n/r);return e*i+(1-i)*t},expAverageClamp:function(e,t,n,r,i){var a=this.expAverage(e,t,n,r);return Math.abs(e-t)<i&&(a=t),a},angleToRange_0_2Pi:function(e){return this.clamp(e-2*Math.PI*Math.floor(e/(2*Math.PI)),0,2*Math.PI)},angleToRange_mPi_Pi:function(e){var t=e+Math.PI;return t%=2*Math.PI,t+=2*Math.PI,t%=2*Math.PI,t-=Math.PI},clampAngle:function(e,t,n){var r=this.angleToRange_0_2Pi(e-t),i=this.angleToRange_0_2Pi(n-t);return i<r&&(r=r<i/2+Math.PI?i:0),r+t}};function Jt(e,t){this.x=e||0,this.y=t||0}function $t(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("v3d.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(Jt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(Jt.prototype,{isVector2:!0,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("v3d.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("v3d.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 this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this},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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},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},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},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,n=this.y-e.y;return t*t+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).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,n){return void 0!==n&&console.warn("v3d.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}}),Object.assign($t.prototype,{isMatrix3:!0,set:function(e,t,n,r,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],f=r[0],m=r[3],v=r[6],g=r[1],_=r[4],y=r[7],x=r[2],b=r[5],M=r[8];return i[0]=a*f+o*g+s*x,i[3]=a*m+o*_+s*b,i[6]=a*v+o*y+s*M,i[1]=l*f+c*g+u*x,i[4]=l*m+c*_+u*b,i[7]=l*v+c*y+u*M,i[2]=d*f+h*g+p*x,i[5]=d*m+h*_+p*b,i[8]=d*v+h*y+p*M,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*a*c-t*o*l-n*i*c+n*o*s+r*i*l-r*a*s},getInverse:function(e,t){e&&e.isMatrix4&&console.error("v3d.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var n=e.elements,r=this.elements,i=n[0],a=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],p=h*l-c*d,f=c*u-h*s,m=d*s-l*u,v=i*p+a*f+o*m;if(0==v){if(!0===t)throw new Error("v3d.Matrix3: .getInverse() can't invert matrix, determinant is 0");return this.identity()}var g=1/v;return r[0]=p*g,r[1]=(o*d-h*a)*g,r[2]=(c*a-o*l)*g,r[3]=f*g,r[4]=(h*i-o*u)*g,r[5]=(o*s-c*i)*g,r[6]=m*g,r[7]=(a*u-d*i)*g,r[8]=(l*i-a*s)*g,this},transpose:function(){var e=this.elements,t=e[1];return e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,n,r,i,a,o){var s=Math.cos(i),l=Math.sin(i);this.set(n*s,n*l,-n*(s*a+l*o)+a+e,-r*l,r*s,-r*(-l*a+s*o)+o+t,0,0,1)},scale:function(e,t){var n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this},rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],l=r[4],c=r[7];return r[0]=t*i+n*s,r[3]=t*a+n*l,r[6]=t*o+n*c,r[1]=-n*i+t*s,r[4]=-n*a+t*l,r[7]=-n*o+t*c,this},translate:function(e,t){var n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this},equals:function(e){for(var t=this.elements,n=e.elements,r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var n=0;n<9;n++)this.elements[n]=e[n+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}});var en={getDataURL:function(e){var t,n;return"undefined"==typeof HTMLCanvasElement?e.src:2048<(n=e instanceof HTMLCanvasElement?e:(void 0===Qt&&(Qt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Qt.width=e.width,Qt.height=e.height,t=Qt.getContext("2d"),e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),Qt)).width||2048<n.height?n.toDataURL("image/jpeg",.6):n.toDataURL("image/png")}},tn=0;function nn(e,t,n,r,i,a,o,s,l,c){Object.defineProperty(this,"id",{value:tn++}),this.uuid=Kt.generateUUID(),this.name="",this.image=void 0!==e?e:nn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:nn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:Qe,this.wrapT=void 0!==r?r:Qe,this.magFilter=void 0!==i?i:tt,this.minFilter=void 0!==a?a:rt,this.anisotropy=void 0!==l?l:1,this.format=void 0!==o?o:dt,this.internalFormat=null,this.type=void 0!==s?s:it,this.offset=new Jt(0,0),this.repeat=new Jt(1,1),this.center=new Jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $t,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:Tt,this.version=0,this.onUpdate=null}function rn(e,t,n,r){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==r?r:1}function an(e,t,n){this.width=e,this.height=t,this.scissor=new rn(0,0,e,t),this.scissorTest=!1,this.viewport=new rn(0,0,e,t),n=n||{},this.texture=new nn(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:tt,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function on(e,t,n){an.call(this,e,t,n),this.samples=4,this.disableBlit=!1}function sn(e,t,n,r){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==r?r:1}nn.DEFAULT_IMAGE=void 0,nn.DEFAULT_MAPPING=300,nn.prototype=Object.assign(Object.create(o.prototype),{constructor:nn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r,i=this.image;if(void 0===i.uuid&&(i.uuid=Kt.generateUUID()),!t&&void 0===e.images[i.uuid]){if(Array.isArray(i)){r=[];for(var a=0,o=i.length;a<o;a++)r.push(en.getDataURL(i[a]))}else r=en.getDataURL(i);e.images[i.uuid]={uuid:i.uuid,url:r}}n.image=i.uuid}return t||(e.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case Ze:e.x=e.x-Math.floor(e.x);break;case Qe:e.x=e.x<0?0:1;break;case Ke:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||1<e.y)switch(this.wrapT){case Ze:e.y=e.y-Math.floor(e.y);break;case Qe:e.y=e.y<0?0:1;break;case Ke:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(nn.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties(rn.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(rn.prototype,{isVector4:!0,set:function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,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("v3d.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("v3d.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 this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+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,n,r,i,a=e.elements,o=a[0],s=a[4],l=a[8],c=a[1],u=a[5],d=a[9],h=a[2],p=a[6],f=a[10];if(Math.abs(s-c)<.01&&Math.abs(l-h)<.01&&Math.abs(d-p)<.01){if(Math.abs(s+c)<.1&&Math.abs(l+h)<.1&&Math.abs(d+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,_=(s+c)/4,y=(l+h)/4,x=(d+p)/4;return v<m&&g<m?i=m<.01?(n=0,r=.707106781):(r=_/(n=Math.sqrt(m)),y/n):g<v?i=v<.01?(r=0,n=.707106781):(n=_/(r=Math.sqrt(v)),x/r):g<.01?(r=n=.707106781,i=0):(n=y/(i=Math.sqrt(g)),r=x/i),this.set(n,r,i,t),this}var b=Math.sqrt((p-d)*(p-d)+(l-h)*(l-h)+(c-s)*(c-s));return Math.abs(b)<.001&&(b=1),this.x=(p-d)/b,this.y=(l-h)/b,this.z=(c-s)/b,this.w=Math.acos((o+u+f-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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},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)},manhattanLength: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()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},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,n){return this.subVectors(t,e).multiplyScalar(n).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,n){return void 0!==n&&console.warn("v3d.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}}),an.prototype=Object.assign(Object.create(o.prototype),{constructor:an,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),on.prototype=Object.assign(Object.create(an.prototype),{constructor:on,isWebGLMultisampleRenderTarget:!0,copy:function(e){return an.prototype.copy.call(this,e),this.samples=e.samples,this}}),Object.assign(sn,{slerp:function(e,t,n,r){return n.copy(e).slerp(t,r)},slerpFlat:function(e,t,n,r,i,a,o){var s,l,c,u,d,h,p,f,m=n[r+0],v=n[r+1],g=n[r+2],_=n[r+3],y=i[a+0],x=i[a+1],b=i[a+2],M=i[a+3];_===M&&m===y&&v===x&&g===b||(h=1-o,l=0<=(s=m*y+v*x+g*b+_*M)?1:-1,(c=1-s*s)>Number.EPSILON&&(u=Math.sqrt(c),d=Math.atan2(u,s*l),h=Math.sin(h*d)/u,o=Math.sin(o*d)/u),m=m*h+y*(p=o*l),v=v*h+x*p,g=g*h+b*p,_=_*h+M*p,h===1-o&&(m*=f=1/Math.sqrt(m*m+v*v+g*g+_*_),v*=f,g*=f,_*=f)),e[t]=m,e[t+1]=v,e[t+2]=g,e[t+3]=_}}),Object.defineProperties(sn.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(sn.prototype,{isQuaternion:!0,set:function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this},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=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("v3d.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,r=e._y,i=e._z,a=e.order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(r/2),u=o(i/2),d=s(n/2),h=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p):"YXZ"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p):"ZXY"===a?(this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p):"ZYX"===a?(this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p):"YZX"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p):"XZY"===a&&(this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p),!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],l=n[9],c=n[2],u=n[6],d=n[10],h=r+s+d;return 0<h?(t=.5/Math.sqrt(h+1),this._w=.25/t,this._x=(u-l)*t,this._y=(a-c)*t,this._z=(o-i)*t):s<r&&d<r?(t=2*Math.sqrt(1+r-s-d),this._w=(u-l)/t,this._x=.25*t,this._y=(i+o)/t,this._z=(a+c)/t):d<s?(t=2*Math.sqrt(1+s-r-d),this._w=(a-c)/t,this._x=(i+o)/t,this._y=.25*t,this._z=(l+u)/t):(t=2*Math.sqrt(1+d-r-s),this._w=(o-i)/t,this._x=(a+c)/t,this._y=(l+u)/t,this._z=.25*t),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var n=e.dot(t)+1;return n<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=n,this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Kt.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var r=Math.min(1,t/n);return this.slerp(e,r),this},inverse:function(){return this.conjugate()},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("v3d.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 n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+a*o+r*l-i*s,this._y=r*c+a*s+i*o-n*l,this._z=i*c+a*l+n*s-r*o,this._w=a*c-n*o-r*s-i*l,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*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),1<=o)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var l=1-t;return this._w=l*a+t*this._w,this._x=l*n+t*this._x,this._y=l*r+t*this._y,this._z=l*i+t*this._z,this.normalize(),this._onChangeCallback(),this}var c=Math.sqrt(s),u=Math.atan2(c,o),d=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=a*d+this._w*h,this._x=n*d+this._x*h,this._y=r*d+this._y*h,this._z=i*d+this._z*h,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(){}});var ln=new un,cn=new sn;function un(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(un.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,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("v3d.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("v3d.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("v3d.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 this.x*=e,this.y*=e,this.z*=e,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(e){return e&&e.isEuler||console.error("v3d.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(cn.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(cn.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*r-o*n,c=s*n+o*t-i*r,u=s*r+i*n-a*t,d=-i*t-a*n-o*r;return this.x=l*s+d*-i+c*-o-u*-a,this.y=c*s+d*-a+u*-i-l*-o,this.z=u*s+d*-o+l*-a-c*-i,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},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)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},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,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("v3d.Vector3: .cross() now only accepts one argument. Use .crossVectors(a, b) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)},projectOnPlane:function(e){return ln.copy(this).projectOnVector(e),this.sub(ln)},reflect:function(e){return this.sub(ln.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Kt.clamp(n,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,n){var r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,3*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,n){return void 0!==n&&console.warn("v3d.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}});var dn=new un,hn=new _n,pn=new un(0,0,0),fn=new un(1,1,1),mn=new un,vn=new un,gn=new un;function _n(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("v3d.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(_n.prototype,{isMatrix4:!0,set:function(e,t,n,r,i,a,o,s,l,c,u,d,h,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=l,v[6]=c,v[10]=u,v[14]=d,v[3]=h,v[7]=p,v[11]=f,v[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 _n).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,n=e.elements,r=1/dn.setFromMatrixColumn(e,0).length(),i=1/dn.setFromMatrixColumn(e,1).length(),a=1/dn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("v3d.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t,n,r,i,a,o,s,l,c,u,d,h,p=this.elements,f=e.x,m=e.y,v=e.z,g=Math.cos(f),_=Math.sin(f),y=Math.cos(m),x=Math.sin(m),b=Math.cos(v),M=Math.sin(v);return"XYZ"===e.order?(a=g*b,o=g*M,s=_*b,l=_*M,p[0]=y*b,p[4]=-y*M,p[8]=x,p[1]=o+s*x,p[5]=a-l*x,p[9]=-_*y,p[2]=l-a*x,p[6]=s+o*x,p[10]=g*y):"YXZ"===e.order?(t=y*b,n=y*M,r=x*b,i=x*M,p[0]=t+i*_,p[4]=r*_-n,p[8]=g*x,p[1]=g*M,p[5]=g*b,p[9]=-_,p[2]=n*_-r,p[6]=i+t*_,p[10]=g*y):"ZXY"===e.order?(t=y*b,n=y*M,r=x*b,i=x*M,p[0]=t-i*_,p[4]=-g*M,p[8]=r+n*_,p[1]=n+r*_,p[5]=g*b,p[9]=i-t*_,p[2]=-g*x,p[6]=_,p[10]=g*y):"ZYX"===e.order?(a=g*b,o=g*M,s=_*b,l=_*M,p[0]=y*b,p[4]=s*x-o,p[8]=a*x+l,p[1]=y*M,p[5]=l*x+a,p[9]=o*x-s,p[2]=-x,p[6]=_*y,p[10]=g*y):"YZX"===e.order?(c=g*y,u=g*x,d=_*y,h=_*x,p[0]=y*b,p[4]=h-c*M,p[8]=d*M+u,p[1]=M,p[5]=g*b,p[9]=-_*b,p[2]=-x*b,p[6]=u*M+d,p[10]=c-h*M):"XZY"===e.order&&(c=g*y,u=g*x,d=_*y,h=_*x,p[0]=y*b,p[4]=-M,p[8]=x*b,p[1]=c*M+h,p[5]=g*b,p[9]=u*M-d,p[2]=d*M-u,p[6]=_*b,p[10]=h*M+c),p[3]=0,p[7]=0,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(pn,e,fn)},lookAt:function(e,t,n){var r=this.elements;return gn.subVectors(e,t),0===gn.lengthSq()&&(gn.z=1),gn.normalize(),mn.crossVectors(n,gn),0===mn.lengthSq()&&(1===Math.abs(n.z)?gn.x+=1e-4:gn.z+=1e-4,gn.normalize(),mn.crossVectors(n,gn)),mn.normalize(),vn.crossVectors(gn,mn),r[0]=mn.x,r[4]=vn.x,r[8]=gn.x,r[1]=mn.y,r[5]=vn.y,r[9]=gn.y,r[2]=mn.z,r[6]=vn.z,r[10]=gn.z,this},multiply:function(e,t){return void 0!==t?(console.warn("v3d.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 n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],_=n[7],y=n[11],x=n[15],b=r[0],M=r[4],w=r[8],A=r[12],S=r[1],T=r[5],E=r[9],C=r[13],P=r[2],L=r[6],R=r[10],D=r[14],N=r[3],I=r[7],O=r[11],F=r[15];return i[0]=a*b+o*S+s*P+l*N,i[4]=a*M+o*T+s*L+l*I,i[8]=a*w+o*E+s*R+l*O,i[12]=a*A+o*C+s*D+l*F,i[1]=c*b+u*S+d*P+h*N,i[5]=c*M+u*T+d*L+h*I,i[9]=c*w+u*E+d*R+h*O,i[13]=c*A+u*C+d*D+h*F,i[2]=p*b+f*S+m*P+v*N,i[6]=p*M+f*T+m*L+v*I,i[10]=p*w+f*E+m*R+v*O,i[14]=p*A+f*C+m*D+v*F,i[3]=g*b+_*S+y*P+x*N,i[7]=g*M+_*T+y*L+x*I,i[11]=g*w+_*E+y*R+x*O,i[15]=g*A+_*C+y*D+x*F,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},determinant:function(){var e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(i*s*u-r*l*u-i*o*d+n*l*d+r*o*h-n*s*h)+e[7]*(t*s*h-t*l*d+i*a*d-r*a*h+r*l*c-i*s*c)+e[11]*(t*l*u-t*o*h-i*a*u+n*a*h+i*o*c-n*l*c)+e[15]*(-r*o*c-t*s*u+t*o*d+r*a*u-n*a*d+n*s*c)},transpose:function(){var e=this.elements,t=e[1];return e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(e,t,n){var r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this},getInverse:function(e,t){var n=this.elements,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=r[7],h=r[8],p=r[9],f=r[10],m=r[11],v=r[12],g=r[13],_=r[14],y=r[15],x=p*_*d-g*f*d+g*u*m-c*_*m-p*u*y+c*f*y,b=v*f*d-h*_*d-v*u*m+l*_*m+h*u*y-l*f*y,M=h*g*d-v*p*d+v*c*m-l*g*m-h*c*y+l*p*y,w=v*p*u-h*g*u-v*c*f+l*g*f+h*c*_-l*p*_,A=i*x+a*b+o*M+s*w;if(0==A){if(!0===t)throw new Error("v3d.Matrix4: .getInverse() can't invert matrix, determinant is 0");return this.identity()}var S=1/A;return n[0]=x*S,n[1]=(g*f*s-p*_*s-g*o*m+a*_*m+p*o*y-a*f*y)*S,n[2]=(c*_*s-g*u*s+g*o*d-a*_*d-c*o*y+a*u*y)*S,n[3]=(p*u*s-c*f*s-p*o*d+a*f*d+c*o*m-a*u*m)*S,n[4]=b*S,n[5]=(h*_*s-v*f*s+v*o*m-i*_*m-h*o*y+i*f*y)*S,n[6]=(v*u*s-l*_*s-v*o*d+i*_*d+l*o*y-i*u*y)*S,n[7]=(l*f*s-h*u*s+h*o*d-i*f*d-l*o*m+i*u*m)*S,n[8]=M*S,n[9]=(v*p*s-h*g*s-v*a*m+i*g*m+h*a*y-i*p*y)*S,n[10]=(l*g*s-v*c*s+v*a*d-i*g*d-l*a*y+i*c*y)*S,n[11]=(h*c*s-l*p*s-h*a*d+i*p*d+l*a*m-i*c*m)*S,n[12]=w*S,n[13]=(h*g*o-v*p*o+v*a*f-i*g*f-h*a*_+i*p*_)*S,n[14]=(v*c*o-l*g*o-v*a*u+i*g*u+l*a*_-i*c*_)*S,n[15]=(l*p*o-h*c*o+h*a*u-i*p*u-l*a*f+i*c*f)*S,this},scale:function(e){var t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))},makeTranslation:function(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,l=i*a,c=i*o;return this.set(l*a+n,l*o-r*s,l*s+r*o,0,l*o+r*s,c*o+n,c*s-r*a,0,l*s-r*o,c*s+r*a,i*s*s+n,0,0,0,0,1),this},makeScale:function(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this},makeShear:function(e,t,n){return this.set(1,t,n,0,e,1,n,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,n){var r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,l=i+i,c=a+a,u=o+o,d=i*l,h=i*c,p=i*u,f=a*c,m=a*u,v=o*u,g=s*l,_=s*c,y=s*u,x=n.x,b=n.y,M=n.z;return r[0]=(1-(f+v))*x,r[1]=(h+y)*x,r[2]=(p-_)*x,r[3]=0,r[4]=(h-y)*b,r[5]=(1-(d+v))*b,r[6]=(m+g)*b,r[7]=0,r[8]=(p+_)*M,r[9]=(m-g)*M,r[10]=(1-(d+f))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this},decompose:function(e,t,n){var r=this.elements,i=dn.set(r[0],r[1],r[2]).length(),a=dn.set(r[4],r[5],r[6]).length(),o=dn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],hn.copy(this);var s=1/i,l=1/a,c=1/o;return hn.elements[0]*=s,hn.elements[1]*=s,hn.elements[2]*=s,hn.elements[4]*=l,hn.elements[5]*=l,hn.elements[6]*=l,hn.elements[8]*=c,hn.elements[9]*=c,hn.elements[10]*=c,t.setFromRotationMatrix(hn),n.x=i,n.y=a,n.z=o,this},makePerspective:function(e,t,n,r,i,a){void 0===a&&console.warn("v3d.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,s=2*i/(t-e),l=2*i/(n-r),c=(t+e)/(t-e),u=(n+r)/(n-r),d=-(a+i)/(a-i),h=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=h,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(e,t,n,r,i,a){var o=this.elements,s=1/(t-e),l=1/(n-r),c=1/(a-i),u=(t+e)*s,d=(n+r)*l,h=(a+i)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-h,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(e){for(var t=this.elements,n=e.elements,r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var n=0;n<16;n++)this.elements[n]=e[n+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}});var yn=new _n,xn=new sn;function bn(e,t,n,r){this._x=e||0,this._y=t||0,this._z=n||0,this._order=r||bn.DefaultOrder}function Mn(){this.mask=1}bn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],bn.DefaultOrder="XYZ",Object.defineProperties(bn.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(bn.prototype,{isEuler:!0,set:function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._order=r||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,n){var r=Kt.clamp,i=e.elements,a=i[0],o=i[4],s=i[8],l=i[1],c=i[5],u=i[9],d=i[2],h=i[6],p=i[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(h,c),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,a))):"ZYX"===t?(this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,c))):"YZX"===t?(this._z=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===t?(this._z=Math.asin(-r(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0)):console.warn("v3d.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==n&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,n){return yn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yn,t,n)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return xn.setFromEuler(this),this.setFromQuaternion(xn,e)},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 un(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){},makeAlternative:function(){var e="X"===this._order[1]?-1:1,t="Y"===this._order[1]?-1:1,n="Z"===this._order[1]?-1:1;return this._x=Kt.angleToRange_mPi_Pi(e*(this._x+Math.PI)),this._y=Kt.angleToRange_mPi_Pi(t*(this._y+Math.PI)),this._z=Kt.angleToRange_mPi_Pi(n*(this._z+Math.PI)),this},equalsEps:function(e,t){return Math.abs(this._x-e._x)<t&&Math.abs(this._y-e._y)<t&&Math.abs(this._z-e._z)<t&&this._order===e._order}}),Object.assign(Mn.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask|=1<<e|0},enableAll:function(){this.mask=-1},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},disableAll:function(){this.mask=0},test:function(e){return 0!=(this.mask&e.mask)}});var wn,An=0,Sn=new un,Tn=new sn,En=new _n,Cn=new un,Pn=new un,Ln=new un,Rn=new sn,Dn=new un(1,0,0),Nn=new un(0,1,0),In=new un(0,0,1),On={type:"added"},Fn={type:"removed"};function Bn(){Object.defineProperty(this,"id",{value:An++}),this.uuid=Kt.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Bn.DefaultUp.clone();var e=new un,t=new bn,n=new sn,r=new un(1,1,1);t._onChange(function(){n.setFromEuler(t,!1)}),n._onChange(function(){t.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new _n},normalMatrix:{value:new $t}}),this.matrix=new _n,this.matrixWorld=new _n,this.matrixAutoUpdate=Bn.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Mn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={v3d:{}},this.constraints=[],this.disableChildRendering=!1}function zn(){Bn.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __v3d_DEVTOOLS__&&__v3d_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.postprocessing=[]}Bn.DefaultUp=new un(0,1,0),Bn.DefaultMatrixAutoUpdate=!0,Bn.prototype=Object.assign(Object.create(o.prototype),{constructor:Bn,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return Tn.setFromAxisAngle(e,t),this.quaternion.multiply(Tn),this},rotateOnWorldAxis:function(e,t){return Tn.setFromAxisAngle(e,t),this.quaternion.premultiply(Tn),this},rotateX:function(e){return this.rotateOnAxis(Dn,e)},rotateY:function(e){return this.rotateOnAxis(Nn,e)},rotateZ:function(e){return this.rotateOnAxis(In,e)},translateOnAxis:function(e,t){return Sn.copy(e).applyQuaternion(this.quaternion),this.position.add(Sn.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(Dn,e)},translateY:function(e){return this.translateOnAxis(Nn,e)},translateZ:function(e){return this.translateOnAxis(In,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(En.getInverse(this.matrixWorld))},lookAt:function(e,t,n){e.isVector3?Cn.copy(e):Cn.set(e,t,n);var r=this.parent;this.updateWorldMatrix(!0,!1),Pn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?En.lookAt(Pn,Cn,this.up):En.lookAt(Cn,Pn,this.up),this.quaternion.setFromRotationMatrix(En),r&&(En.extractRotation(r.matrixWorld),Tn.setFromRotationMatrix(En),this.quaternion.premultiply(Tn.inverse()))},add:function(e){if(1<arguments.length){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?console.error("v3d.Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),(e.parent=this).children.push(e),e.dispatchEvent(On)):console.error("v3d.Object3D.add: object not an instance of v3d.Object3D.",e),this},remove:function(e){if(1<arguments.length){for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}var n=this.children.indexOf(e);return-1!==n&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Fn)),this},attach:function(e){return this.updateWorldMatrix(!0,!1),En.getInverse(this.matrixWorld),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),En.multiply(e.parent.matrixWorld)),e.applyMatrix4(En),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var n=0,r=this.children.length;n<r;n++){var i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}},getWorldPosition:function(e){return void 0===e&&(console.warn("v3d.Object3D: .getWorldPosition() target is now required"),e=new un),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return void 0===e&&(console.warn("v3d.Object3D: .getWorldQuaternion() target is now required"),e=new sn),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Pn,e,Ln),e},getWorldScale:function(e){return void 0===e&&(console.warn("v3d.Object3D: .getWorldScale() target is now required"),e=new un),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Pn,Rn,e),e},getWorldDirection:function(e){void 0===e&&(console.warn("v3d.Object3D: .getWorldDirection() target is now required"),e=new un),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[4],t[5],t[6]).normalize()},raycast:function(){},traverse:function(e){e(this);for(var t=this.children,n=0,r=t.length;n<r;n++)t[n].traverse(e)},traverseVisible:function(e){if(!1!==this.visible){e(this);for(var t=this.children,n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.updateConstraints(),this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e=!(this.matrixWorldNeedsUpdate=!1));for(var t=this.children,n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){var n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t)for(var r=this.children,i=0,a=r.length;i<a;i++)r[i].updateWorldMatrix(!1,!0)},toJSON:function(n){var e=void 0===n||"string"==typeof n,t={};e&&(n={geometries:{},materials:{},textures:{},images:{},shapes:{}},t.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var r,i,a,o,s={};function l(e,t){return void 0===e[t.uuid]&&(e[t.uuid]=t.toJSON(n)),t.uuid}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),!0===this.castShadow&&(s.castShadow=!0),!0===this.receiveShadow&&(s.receiveShadow=!0),!1===this.visible&&(s.visible=!1),!1===this.frustumCulled&&(s.frustumCulled=!1),0!==this.renderOrder&&(s.renderOrder=this.renderOrder),!1===this.disableChildRendering&&(s.disableChildRendering=!1),"{}"!==JSON.stringify(this.userData)&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){s.geometry=l(n.geometries,this.geometry);var c=this.geometry.parameters;if(void 0!==c&&void 0!==c.shapes){var u=c.shapes;if(Array.isArray(u))for(var d=0,h=u.length;d<h;d++){var p=u[d];l(n.shapes,p)}else l(n.shapes,u)}}if(void 0!==this.material)if(Array.isArray(this.material)){for(var f=[],d=0,h=this.material.length;d<h;d++)f.push(l(n.materials,this.material[d]));s.material=f}else s.material=l(n.materials,this.material);if(0<this.children.length){s.children=[];for(d=0;d<this.children.length;d++)s.children.push(this.children[d].toJSON(n).object)}return e&&(r=m(n.geometries),i=m(n.materials),a=m(n.textures),o=m(n.images),u=m(n.shapes),0<r.length&&(t.geometries=r),0<i.length&&(t.materials=i),0<a.length&&(t.textures=a),0<o.length&&(t.images=o),0<u.length&&(t.shapes=u)),t.object=s,t;function m(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.disableChildRendering=e.disableChildRendering,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n<e.children.length;n++){var r=e.children[n];this.add(r.clone())}return this},copyTransform:(wn=new _n,function(e){this.matrix.copy(e.matrixWorld),this.parent&&this.matrix.multiplyMatrices(wn.getInverse(this.parent.matrixWorld),this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)}),isVisible:function(){return this.visible},updateConstraints:function(){for(var e=0;e<this.constraints.length;e++)this.constraints[e].update(this)},getWorldPositionNU:function(e){return e.setFromMatrixPosition(this.matrixWorld)},getLocalDirection:function(e){var t=this.matrix.elements;return this.isCamera||this.isLight?e.set(-t[8],-t[9],-t[10]).normalize():e.set(t[8],t[9],t[10]).normalize()},lookAtLocal:function(e,t,n){e.isVector3?Cn.copy(e):Cn.set(e,t,n),Pn.setFromMatrixPosition(this.matrix),this.isCamera||this.isLight?En.lookAt(Pn,Cn,this.up):En.lookAt(Cn,Pn,this.up),this.quaternion.setFromRotationMatrix(En)},findRoot:function(){var t=this;return this.traverseAncestors(function(e){t=e}),t},resolveMultiMaterial:function(){for(var e=[],t=0;t<this.children.length;t++){var n=this.children[t];n.isMesh&&n.isMaterialGeneratedMesh&&e.push(n)}return e.length||e.push(this),e}}),zn.prototype=Object.assign(Object.create(Bn.prototype),{constructor:zn,isScene:!0,copy:function(e,t){return Bn.prototype.copy.call(this,e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var t=Bn.prototype.toJSON.call(this,e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.environment&&(t.object.environment=this.environment.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Un=[new un,new un,new un,new un,new un,new un,new un,new un],Vn=new un,kn=new Jn,Gn=new un,jn=new un,Wn=new un,Xn=new un,Hn=new un,Yn=new un,qn=new un,Zn=new un,Qn=new un,Kn=new un;function Jn(e,t){this.min=void 0!==e?e:new un(1/0,1/0,1/0),this.max=void 0!==t?t:new un(-1/0,-1/0,-1/0)}function $n(e,t,n,r,i){for(var a=0,o=e.length-3;a<=o;a+=3){Kn.fromArray(e,a);var s=i.x*Math.abs(Kn.x)+i.y*Math.abs(Kn.y)+i.z*Math.abs(Kn.z),l=t.dot(Kn),c=n.dot(Kn),u=r.dot(Kn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>s)return!1}return!0}Object.assign(Jn.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,l=e.length;s<l;s+=3){var c=e[s],u=e[s+1],d=e[s+2];c<t&&(t=c),u<n&&(n=u),d<r&&(r=d),i<c&&(i=c),a<u&&(a=u),o<d&&(o=d)}return this.min.set(t,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,l=e.count;s<l;s++){var c=e.getX(s),u=e.getY(s),d=e.getZ(s);c<t&&(t=c),u<n&&(n=u),d<r&&(r=d),i<c&&(i=c),a<u&&(a=u),o<d&&(o=d)}return this.min.set(t,n,r),this.max.set(i,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var n=Vn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return void 0===e&&(console.warn("v3d.Box3: .getCenter() target is now required"),e=new un),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("v3d.Box3: .getSize() target is now required"),e=new un),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(e){e.updateWorldMatrix(!1,!1);var t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),kn.copy(t.boundingBox),kn.applyMatrix4(e.matrixWorld),this.expandByPoint(kn.min),this.expandByPoint(kn.max));for(var n=e.children,r=0,i=n.length;r<i;r++)this.expandByObject(n[r]);return this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.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 void 0===t&&(console.warn("v3d.Box3: .getParameter() target is now required"),t=new un),t.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,Vn),Vn.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,n=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x);return 0<e.normal.y?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(qn),Zn.subVectors(this.max,qn),Gn.subVectors(e.a,qn),jn.subVectors(e.b,qn),Wn.subVectors(e.c,qn),Xn.subVectors(jn,Gn),Hn.subVectors(Wn,jn),Yn.subVectors(Gn,Wn);var t=[0,-Xn.z,Xn.y,0,-Hn.z,Hn.y,0,-Yn.z,Yn.y,Xn.z,0,-Xn.x,Hn.z,0,-Hn.x,Yn.z,0,-Yn.x,-Xn.y,Xn.x,0,-Hn.y,Hn.x,0,-Yn.y,Yn.x,0];return!!$n(t,Gn,jn,Wn,Zn)&&(!!$n(t=[1,0,0,0,1,0,0,0,1],Gn,jn,Wn,Zn)&&(Qn.crossVectors(Xn,Hn),$n(t=[Qn.x,Qn.y,Qn.z],Gn,jn,Wn,Zn)))},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .clampPoint() target is now required"),t=new un),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Vn.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("v3d.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Vn).length(),e},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(e){return this.isEmpty()||(Un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Un)),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)}});var er,tr,nr=new Jn;function rr(e,t){this.center=void 0!==e?e:new un,this.radius=void 0!==t?t:0}Object.assign(rr.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var n=this.center;void 0!==t?n.copy(t):nr.setFromPoints(e).getCenter(n);for(var r=0,i=0,a=e.length;i<a;i++)r=Math.max(r,n.distanceToSquared(e[i]));return this.radius=Math.sqrt(r),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,t){var n=this.center.distanceToSquared(e);return void 0===t&&(console.warn("v3d.Sphere: .clampPoint() target is now required"),t=new un),t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("v3d.Sphere: .getBoundingBox() target is now required"),e=new Jn),e.set(this.center,this.center),e.expandByScalar(this.radius),e},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},union:(er=new un,tr=new un,function(e){var t=this.center,n=this.radius,r=e.center,i=e.radius;er.subVectors(r,t);var a=er.length();if(a+i<=n)return this;if(a+n<=i)return this.copy(e),this;var o=.5*(n+a+i);return tr.copy(er).multiplyScalar((o-n)/a),tr.add(t),this.center.copy(tr),this.radius=o,this})});var ir=new un,ar=new un,or=new un,sr=new un,lr=new un,cr=new un,ur=new un;function dr(e,t){this.origin=void 0!==e?e:new un,this.direction=void 0!==t?t:new un(0,0,-1)}Object.assign(dr.prototype,{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 void 0===t&&(console.warn("v3d.Ray: .at() target is now required"),t=new un),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,ir)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("v3d.Ray: .closestPointToPoint() target is now required"),t=new un),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=ir.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ir.copy(this.direction).multiplyScalar(t).add(this.origin),ir.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,r){ar.copy(e).add(t).multiplyScalar(.5),or.copy(t).sub(e).normalize(),sr.copy(this.origin).sub(ar);var i,a,o,s,l,c=.5*e.distanceTo(t),u=-this.direction.dot(or),d=sr.dot(this.direction),h=-sr.dot(or),p=sr.lengthSq(),f=Math.abs(1-u*u);return a=0<f?(s=u*d-h,l=c*f,0<=(o=u*h-d)?-l<=s?s<=l?(o*=i=1/f)*(o+u*(s*=i)+2*d)+s*(u*o+s+2*h)+p:(s=c,-(o=Math.max(0,-(u*s+d)))*o+s*(s+2*h)+p):(s=-c,-(o=Math.max(0,-(u*s+d)))*o+s*(s+2*h)+p):s<=-l?-(o=Math.max(0,-(-u*c+d)))*o+(s=0<o?-c:Math.min(Math.max(-c,-h),c))*(s+2*h)+p:s<=l?(o=0,(s=Math.min(Math.max(-c,-h),c))*(s+2*h)+p):-(o=Math.max(0,-(u*c+d)))*o+(s=0<o?c:Math.min(Math.max(-c,-h),c))*(s+2*h)+p):(s=0<u?-c:c,-(o=Math.max(0,-(u*s+d)))*o+s*(s+2*h)+p),n&&n.copy(this.direction).multiplyScalar(o).add(this.origin),r&&r.copy(or).multiplyScalar(s).add(ar),a},intersectSphere:function(e,t){ir.subVectors(e.center,this.origin);var n=ir.dot(this.direction),r=ir.dot(ir)-n*n,i=e.radius*e.radius;if(i<r)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return 0<=n?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,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 n,r,i,a,o=1/this.direction.x,s=1/this.direction.y,l=1/this.direction.z,c=this.origin,u=0<=o?(n=(e.min.x-c.x)*o,(e.max.x-c.x)*o):(n=(e.max.x-c.x)*o,(e.min.x-c.x)*o),d=0<=s?(r=(e.min.y-c.y)*s,(e.max.y-c.y)*s):(r=(e.max.y-c.y)*s,(e.min.y-c.y)*s);return d<n||u<r?null:((n<r||n!=n)&&(n=r),(d<u||u!=u)&&(u=d),(a=0<=l?(i=(e.min.z-c.z)*l,(e.max.z-c.z)*l):(i=(e.max.z-c.z)*l,(e.min.z-c.z)*l))<n||u<i?null:((n<i||n!=n)&&(n=i),(a<u||u!=u)&&(u=a),u<0?null:this.at(0<=n?n:u,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,ir)},intersectTriangle:function(e,t,n,r,i){lr.subVectors(t,e),cr.subVectors(n,e),ur.crossVectors(lr,cr);var a,o=this.direction.dot(ur);if(0<o){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}sr.subVectors(this.origin,e);var s=a*this.direction.dot(cr.crossVectors(sr,cr));if(s<0)return null;var l=a*this.direction.dot(lr.cross(sr));if(l<0)return null;if(o<s+l)return null;var c=-a*sr.dot(ur);return c<0?null:this.at(c/o,i)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var hr=new un,pr=new un,fr=new $t;function mr(e,t){this.normal=void 0!==e?e:new un(1,0,0),this.constant=void 0!==t?t:0}Object.assign(mr.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,n){var r=hr.subVectors(n,t).cross(pr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("v3d.Plane: .projectPoint() target is now required"),t=new un),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("v3d.Plane: .intersectLine() target is now required"),t=new un);var n=e.delta(hr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||1<i?void 0:t.copy(n).multiplyScalar(i).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&0<n||n<0&&0<t},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("v3d.Plane: .coplanarPoint() target is now required"),e=new un),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var n=t||fr.getNormalMatrix(e),r=this.coplanarPoint(hr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var vr=new un,gr=new un,_r=new un,yr=new un,xr=new un,br=new un,Mr=new un,wr=new un,Ar=new un,Sr=new un;function Tr(e,t,n){this.a=void 0!==e?e:new un,this.b=void 0!==t?t:new un,this.c=void 0!==n?n:new un}Object.assign(Tr,{getNormal:function(e,t,n,r){void 0===r&&(console.warn("v3d.Triangle: .getNormal() target is now required"),r=new un),r.subVectors(n,t),vr.subVectors(e,t),r.cross(vr);var i=r.lengthSq();return 0<i?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(e,t,n,r,i){vr.subVectors(r,t),gr.subVectors(n,t),_r.subVectors(e,t);var a=vr.dot(vr),o=vr.dot(gr),s=vr.dot(_r),l=gr.dot(gr),c=gr.dot(_r),u=a*l-o*o;if(void 0===i&&(console.warn("v3d.Triangle: .getBarycoord() target is now required"),i=new un),0==u)return i.set(-2,-1,-1);var d=1/u,h=(l*s-o*c)*d,p=(a*c-o*s)*d;return i.set(1-h-p,p,h)},containsPoint:function(e,t,n,r){return Tr.getBarycoord(e,t,n,r,yr),0<=yr.x&&0<=yr.y&&yr.x+yr.y<=1},getUV:function(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,yr),s.set(0,0),s.addScaledVector(i,yr.x),s.addScaledVector(a,yr.y),s.addScaledVector(o,yr.z),s},isFrontFacing:function(e,t,n,r){return vr.subVectors(n,t),gr.subVectors(e,t),vr.cross(gr).dot(r)<0}}),Object.assign(Tr.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),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},getArea:function(){return vr.subVectors(this.c,this.b),gr.subVectors(this.a,this.b),.5*vr.cross(gr).length()},getMidpoint:function(e){return void 0===e&&(console.warn("v3d.Triangle: .getMidpoint() target is now required"),e=new un),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return Tr.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("v3d.Triangle: .getPlane() target is now required"),e=new mr),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return Tr.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,n,r,i){return Tr.getUV(e,this.a,this.b,this.c,t,n,r,i)},containsPoint:function(e){return Tr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return Tr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(console.warn("v3d.Triangle: .closestPointToPoint() target is now required"),t=new un);var n=this.a,r=this.b,i=this.c;xr.subVectors(r,n),br.subVectors(i,n),wr.subVectors(e,n);var a=xr.dot(wr),o=br.dot(wr);if(a<=0&&o<=0)return t.copy(n);Ar.subVectors(e,r);var s=xr.dot(Ar),l=br.dot(Ar);if(0<=s&&l<=s)return t.copy(r);var c=a*l-s*o;if(c<=0&&0<=a&&s<=0)return m=a/(a-s),t.copy(n).addScaledVector(xr,m);Sr.subVectors(e,i);var u=xr.dot(Sr),d=br.dot(Sr);if(0<=d&&u<=d)return t.copy(i);var h=u*o-a*d;if(h<=0&&0<=o&&d<=0)return v=o/(o-d),t.copy(n).addScaledVector(br,v);var p=s*d-u*l;if(p<=0&&0<=l-s&&0<=u-d)return Mr.subVectors(i,r),v=(l-s)/(l-s+(u-d)),t.copy(r).addScaledVector(Mr,v);var f=1/(p+h+c),m=h*f,v=c*f;return t.copy(n).addScaledVector(xr,m).addScaledVector(br,v)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var Er={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Cr={h:0,s:0,l:0},Pr={h:0,s:0,l:0};function Lr(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function Rr(e,t,n){return n<0&&(n+=1),1<n&&--n,n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Dr(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Nr(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function Ir(e,t){return e*Math.pow(2,255*t-128)}function Or(e,t,n,r,i,a){this.a=e,this.b=t,this.c=n,this.normal=r&&r.isVector3?r:new un,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Lr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Lr.prototype,{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,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(e,t,n){var r,i;return e=Kt.euclideanModulo(e,1),t=Kt.clamp(t,0,1),n=Kt.clamp(n,0,1),0===t?this.r=this.g=this.b=n:(i=2*n-(r=n<=.5?n*(1+t):n+t-n*t),this.r=Rr(i,r,e+1/3),this.g=Rr(i,r,e),this.b=Rr(i,r,e-1/3)),this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("v3d.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,l=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c=n[1],u=c.length;if(3===u)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return t&&0<t.length?this.setColorName(t):this},setColorName:function(e){var t=Er[e];return void 0!==t?this.setHex(t):console.warn("v3d.Color: Unknown color "+e),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 n=0<t?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=Dr(e.r),this.g=Dr(e.g),this.b=Dr(e.b),this},copyLinearToSRGB:function(e){return this.r=Nr(e.r),this.g=Nr(e.g),this.b=Nr(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},copyRGBEToLinear:function(e,t){return this.r=Ir(e.r,t),this.g=Ir(e.g,t),this.b=Ir(e.b,t),this},convertRGBEToLinear:function(e){return this.copyRGBEToLinear(this,e),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){void 0===e&&(console.warn("v3d.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,n=this.r,r=this.g,i=this.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(o+a)/2;if(o===a)c=t=0;else{var l=a-o,c=s<=.5?l/(a+o):l/(2-a-o);switch(a){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;case i:t=(n-r)/l+4}t/=6}return e.h=t,e.s=c,e.l=s,e},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(e,t,n){return this.getHSL(Cr),Cr.h+=e,Cr.s+=t,Cr.l+=n,this.setHSL(Cr.h,Cr.s,Cr.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},lerpHSL:function(e,t){this.getHSL(Cr),e.getHSL(Pr);var n=Kt.lerp(Cr.h,Pr.h,t),r=Kt.lerp(Cr.s,Pr.s,t),i=Kt.lerp(Cr.l,Pr.l,t);return this.setHSL(n,r,i),this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},toJSON:function(){return this.getHex()}}),Lr.NAMES=Er,Object.assign(Or.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}});var Fr=0;function Br(){Object.defineProperty(this,"id",{value:Fr++}),this.uuid=Kt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=oe,this.side=re,this.flatShading=!1,this.vertexTangents=!1,this.vertexColors=s,this.opacity=1,this.transparent=!1,this.blendSrc=be,this.blendDst=Me,this.blendEquation=de,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ne,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=kt,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Vt,this.stencilZFail=Vt,this.stencilZPass=Vt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this.receiveShadow=!1,this.castShadow=!1,this.useHDR=!1,this.profile=""}function zr(e){Br.call(this),this.type="MeshBasicMaterial",this.color=new Lr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=U,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}Br.prototype=Object.assign(Object.create(o.prototype),{constructor:Br,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var n,r=e[t];void 0!==r?"shading"!==t?void 0!==(n=this[t])?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[t]=r:console.warn("v3d."+this.type+": '"+t+"' is not a property of this material."):(console.warn("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===r):console.warn("v3d.Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var n,r,i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function a(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}return i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==oe&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),this.side!==re&&(i.side=this.side),this.vertexColors!==s&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),0<this.alphaTest&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),1<this.wireframeLinewidth&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t&&(n=a(e.textures),r=a(e.images),0<n.length&&(i.textures=n),0<r.length&&(i.images=r)),i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,n=null;if(null!==t)for(var r=t.length,n=new Array(r),i=0;i!==r;++i)n[i]=t[i].clone();return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.useHDR=e.useHDR,this.profile=e.profile,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Br.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++},get:function(){return 0!=this.version}}),((zr.prototype=Object.create(Br.prototype)).constructor=zr).prototype.isMeshBasicMaterial=!0,zr.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};var Ur=new un;function Vr(e,t,n){if(Array.isArray(e))throw new TypeError("v3d.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=Gt,this.updateRange={offset:0,count:-1},this.version=0}function kr(e,t,n){Vr.call(this,new Int8Array(e),t,n)}function Gr(e,t,n){Vr.call(this,new Uint8Array(e),t,n)}function jr(e,t,n){Vr.call(this,new Uint8ClampedArray(e),t,n)}function Wr(e,t,n){Vr.call(this,new Int16Array(e),t,n)}function Xr(e,t,n){Vr.call(this,new Uint16Array(e),t,n)}function Hr(e,t,n){Vr.call(this,new Int32Array(e),t,n)}function Yr(e,t,n){Vr.call(this,new Uint32Array(e),t,n)}function qr(e,t,n){Vr.call(this,new Float32Array(e),t,n)}function Zr(e,t,n){Vr.call(this,new Float64Array(e),t,n)}function Qr(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Kr(e){if(0===e.length)return-1/0;for(var t=e[0],n=1,r=e.length;n<r;++n)e[n]>t&&(t=e[n]);return t}function Jr(e){return void 0!==e}function $r(e,t,n){for(var r=0;r<e.length;r++)e[r]=Kt.clamp(e[r],t,n);return e}function ei(){switch(Wt){case"BLENDER":return"for Blender";case"MAX":return"for 3ds Max";case"MAYA":return"for Maya";case"ALL":return"Ultimate";default:return"Unknown"}}function ti(e){return"".concat(e%1?e:"".concat(e,".0"))}function ni(){return"undefined"!=typeof window?window:self}Object.defineProperty(Vr.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Vr.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(var r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,n=0,r=0,i=e.length;r<i;r++){var a=e[r];void 0===a&&(console.warn("v3d.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Lr),t[n++]=a.r,t[n++]=a.g,t[n++]=a.b}return this},copyVector2sArray:function(e){for(var t=this.array,n=0,r=0,i=e.length;r<i;r++){var a=e[r];void 0===a&&(console.warn("v3d.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new Jt),t[n++]=a.x,t[n++]=a.y}return this},copyVector3sArray:function(e){for(var t=this.array,n=0,r=0,i=e.length;r<i;r++){var a=e[r];void 0===a&&(console.warn("v3d.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new un),t[n++]=a.x,t[n++]=a.y,t[n++]=a.z}return this},copyVector4sArray:function(e){for(var t=this.array,n=0,r=0,i=e.length;r<i;r++){var a=e[r];void 0===a&&(console.warn("v3d.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new rn),t[n++]=a.x,t[n++]=a.y,t[n++]=a.z,t[n++]=a.w}return this},applyMatrix3:function(e){for(var t=0,n=this.count;t<n;t++)Ur.x=this.getX(t),Ur.y=this.getY(t),Ur.z=this.getZ(t),Ur.applyMatrix3(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this},applyMatrix4:function(e){for(var t=0,n=this.count;t<n;t++)Ur.x=this.getX(t),Ur.y=this.getY(t),Ur.z=this.getZ(t),Ur.applyMatrix4(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this},applyNormalMatrix:function(e){for(var t=0,n=this.count;t<n;t++)Ur.x=this.getX(t),Ur.y=this.getY(t),Ur.z=this.getZ(t),Ur.applyNormalMatrix(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this},transformDirection:function(e){for(var t=0,n=this.count;t<n;t++)Ur.x=this.getX(t),Ur.y=this.getY(t),Ur.z=this.getZ(t),Ur.transformDirection(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this},setXYZ:function(e,t,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this},setXYZW:function(e,t,n,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),(kr.prototype=Object.create(Vr.prototype)).constructor=kr,(Gr.prototype=Object.create(Vr.prototype)).constructor=Gr,(jr.prototype=Object.create(Vr.prototype)).constructor=jr,(Wr.prototype=Object.create(Vr.prototype)).constructor=Wr,(Xr.prototype=Object.create(Vr.prototype)).constructor=Xr,(Hr.prototype=Object.create(Vr.prototype)).constructor=Hr,(Yr.prototype=Object.create(Vr.prototype)).constructor=Yr,(qr.prototype=Object.create(Vr.prototype)).constructor=qr,(Zr.prototype=Object.create(Vr.prototype)).constructor=Zr,Object.assign(Qr.prototype,{computeGroups:function(e){for(var t,n=[],r=void 0,i=e.faces,a=0;a<i.length;a++){var o=i[a];o.materialIndex!==r&&(r=o.materialIndex,void 0!==t&&(t.count=3*a-t.start,n.push(t)),t={start:3*a,materialIndex:r})}void 0!==t&&(t.count=3*a-t.start,n.push(t)),this.groups=n},fromGeometry:function(e){var t,n=e.faces,r=e.vertices,i=e.faceVertexUvs,a=i[0]&&0<i[0].length,o=i[1]&&0<i[1].length,s=e.morphTargets,l=s.length;if(0<l){t=[];for(var c=0;c<l;c++)t[c]={name:s[c].name,data:[]};this.morphTargets.position=t}var u,d=e.morphNormals,h=d.length;if(0<h){u=[];for(c=0;c<h;c++)u[c]={name:d[c].name,data:[]};this.morphTargets.normal=u}var p=e.skinIndices,f=e.skinWeights,m=p.length===r.length,v=f.length===r.length;0<r.length&&0===n.length&&console.error("v3d.DirectGeometry: Faceless geometries are not supported.");for(c=0;c<n.length;c++){var g=n[c];this.vertices.push(r[g.a],r[g.b],r[g.c]);var _,y=g.vertexNormals;3===y.length?this.normals.push(y[0],y[1],y[2]):(_=g.normal,this.normals.push(_,_,_));var x,b,M=g.vertexColors;3===M.length?this.colors.push(M[0],M[1],M[2]):(x=g.color,this.colors.push(x,x,x)),!0===a&&(void 0!==(b=i[0][c])?this.uvs.push(b[0],b[1],b[2]):(console.warn("v3d.DirectGeometry.fromGeometry(): Undefined vertexUv ",c),this.uvs.push(new Jt,new Jt,new Jt))),!0===o&&(void 0!==(b=i[1][c])?this.uvs2.push(b[0],b[1],b[2]):(console.warn("v3d.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",c),this.uvs2.push(new Jt,new Jt,new Jt)));for(var w=0;w<l;w++){var A=s[w].vertices;t[w].data.push(A[g.a],A[g.b],A[g.c])}for(w=0;w<h;w++){var S=d[w].vertexNormals[c];u[w].data.push(S.a,S.b,S.c)}m&&this.skinIndices.push(p[g.a],p[g.b],p[g.c]),v&&this.skinWeights.push(f[g.a],f[g.b],f[g.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this}});var ri=1,ii=new _n,ai=new Bn,oi=new un,si=new Jn,li=new Jn,ci=new un;function ui(){Object.defineProperty(this,"id",{value:ri+=2}),this.uuid=Kt.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}ui.prototype=Object.assign(Object.create(o.prototype),{constructor:ui,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(65535<Kr(e)?Yr:Xr)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){var t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var n,r=this.attributes.normal;void 0!==r&&(n=(new $t).getNormalMatrix(e),r.applyNormalMatrix(n),r.needsUpdate=!0);var i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return ii.makeRotationX(e),this.applyMatrix4(ii),this},rotateY:function(e){return ii.makeRotationY(e),this.applyMatrix4(ii),this},rotateZ:function(e){return ii.makeRotationZ(e),this.applyMatrix4(ii),this},translate:function(e,t,n){return ii.makeTranslation(e,t,n),this.applyMatrix4(ii),this},scale:function(e,t,n){return ii.makeScale(e,t,n),this.applyMatrix4(ii),this},lookAt:function(e){return ai.lookAt(e),ai.updateMatrix(),this.applyMatrix4(ai.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(oi).negate(),this.translate(oi.x,oi.y,oi.z),this},setFromObject:function(e){var t,n,r,i=e.geometry;return e.isPoints||e.isLine?(t=new qr(3*i.vertices.length,3),n=new qr(3*i.colors.length,3),this.setAttribute("position",t.copyVector3sArray(i.vertices)),this.setAttribute("color",n.copyColorsArray(i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length&&(r=new qr(i.lineDistances.length,1),this.setAttribute("lineDistance",r.copyArray(i.lineDistances))),null!==i.boundingSphere&&(this.boundingSphere=i.boundingSphere.clone()),null!==i.boundingBox&&(this.boundingBox=i.boundingBox.clone())):e.isMesh&&i&&i.isGeometry&&this.fromGeometry(i),this},setFromPoints:function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new qr(t,3)),this},updateFromObject:function(e){var t,n=e.geometry;if(e.isMesh){var r=n.__directGeometry;if(!0===n.elementsNeedUpdate&&(r=void 0,n.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(n);r.verticesNeedUpdate=n.verticesNeedUpdate,r.normalsNeedUpdate=n.normalsNeedUpdate,r.colorsNeedUpdate=n.colorsNeedUpdate,r.uvsNeedUpdate=n.uvsNeedUpdate,r.groupsNeedUpdate=n.groupsNeedUpdate,n.verticesNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.groupsNeedUpdate=!1,n=r}return!0===n.verticesNeedUpdate&&(void 0!==(t=this.attributes.position)&&(t.copyVector3sArray(n.vertices),t.needsUpdate=!0),n.verticesNeedUpdate=!1),!0===n.normalsNeedUpdate&&(void 0!==(t=this.attributes.normal)&&(t.copyVector3sArray(n.normals),t.needsUpdate=!0),n.normalsNeedUpdate=!1),!0===n.colorsNeedUpdate&&(void 0!==(t=this.attributes.color)&&(t.copyColorsArray(n.colors),t.needsUpdate=!0),n.colorsNeedUpdate=!1),n.uvsNeedUpdate&&(void 0!==(t=this.attributes.uv)&&(t.copyVector2sArray(n.uvs),t.needsUpdate=!0),n.uvsNeedUpdate=!1),n.lineDistancesNeedUpdate&&(void 0!==(t=this.attributes.lineDistance)&&(t.copyArray(n.lineDistances),t.needsUpdate=!0),n.lineDistancesNeedUpdate=!1),n.groupsNeedUpdate&&(n.computeGroups(e.geometry),this.groups=n.groups,n.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new Qr).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t,n,r,i,a,o,s=new Float32Array(3*e.vertices.length);for(var l in this.setAttribute("position",new Vr(s,3).copyVector3sArray(e.vertices)),0<e.normals.length&&(t=new Float32Array(3*e.normals.length),this.setAttribute("normal",new Vr(t,3).copyVector3sArray(e.normals))),0<e.colors.length&&(n=new Float32Array(3*e.colors.length),this.setAttribute("color",new Vr(n,3).copyColorsArray(e.colors))),0<e.uvs.length&&(r=new Float32Array(2*e.uvs.length),this.setAttribute("uv",new Vr(r,2).copyVector2sArray(e.uvs))),0<e.uvs2.length&&(i=new Float32Array(2*e.uvs2.length),this.setAttribute("uv2",new Vr(i,2).copyVector2sArray(e.uvs2))),this.groups=e.groups,e.morphTargets){for(var c=[],u=e.morphTargets[l],d=0,h=u.length;d<h;d++){var p=u[d],f=new qr(3*p.data.length,3);f.name=p.name,c.push(f.copyVector3sArray(p.data))}this.morphAttributes[l]=c}return 0<e.skinIndices.length&&(a=new qr(4*e.skinIndices.length,4),this.setAttribute("skinIndex",a.copyVector4sArray(e.skinIndices))),0<e.skinWeights.length&&(o=new qr(4*e.skinWeights.length,4),this.setAttribute("skinWeight",o.copyVector4sArray(e.skinWeights))),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Jn);var e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var n=0,r=t.length;n<r;n++){var i=t[n];si.setFromBufferAttribute(i),this.morphTargetsRelative?(ci.addVectors(this.boundingBox.min,si.min),this.boundingBox.expandByPoint(ci),ci.addVectors(this.boundingBox.max,si.max),this.boundingBox.expandByPoint(ci)):(this.boundingBox.expandByPoint(si.min),this.boundingBox.expandByPoint(si.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('v3d.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rr);var e=this.attributes.position,t=this.morphAttributes.position;if(e){var n=this.boundingSphere.center;if(si.setFromBufferAttribute(e),t)for(var r=0,i=t.length;r<i;r++){var a=t[r];li.setFromBufferAttribute(a),this.morphTargetsRelative?(ci.addVectors(si.min,li.min),si.expandByPoint(ci),ci.addVectors(si.max,li.max),si.expandByPoint(ci)):(si.expandByPoint(li.min),si.expandByPoint(li.max))}si.getCenter(n);for(var o=0,r=0,i=e.count;r<i;r++)ci.fromBufferAttribute(e,r),o=Math.max(o,n.distanceToSquared(ci));if(t)for(r=0,i=t.length;r<i;r++)for(var a=t[r],s=this.morphTargetsRelative,l=0,c=a.count;l<c;l++)ci.fromBufferAttribute(a,l),s&&(oi.fromBufferAttribute(e,l),ci.add(oi)),o=Math.max(o,n.distanceToSquared(ci));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('v3d.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes;if(t.position){var n=t.position.array;if(void 0===t.normal)this.setAttribute("normal",new Vr(new Float32Array(n.length),3));else for(var r=t.normal.array,i=0,a=r.length;i<a;i++)r[i]=0;var o,s,l,c=t.normal.array,u=new un,d=new un,h=new un,p=new un,f=new un;if(e)for(var m=e.array,i=0,a=e.count;i<a;i+=3)o=3*m[i+0],s=3*m[i+1],l=3*m[i+2],u.fromArray(n,o),d.fromArray(n,s),h.fromArray(n,l),p.subVectors(h,d),f.subVectors(u,d),p.cross(f),c[o]+=p.x,c[1+o]+=p.y,c[2+o]+=p.z,c[s]+=p.x,c[1+s]+=p.y,c[2+s]+=p.z,c[l]+=p.x,c[1+l]+=p.y,c[2+l]+=p.z;else for(i=0,a=n.length;i<a;i+=9)u.fromArray(n,i),d.fromArray(n,i+3),h.fromArray(n,i+6),p.subVectors(h,d),f.subVectors(u,d),p.cross(f),c[i]=p.x,c[i+1]=p.y,c[i+2]=p.z,c[i+3]=p.x,c[i+4]=p.y,c[i+5]=p.z,c[i+6]=p.x,c[i+7]=p.y,c[i+8]=p.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("v3d.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var n=this.attributes;for(var r in n)if(void 0!==e.attributes[r])for(var i=n[r].array,a=e.attributes[r],o=a.array,s=a.itemSize*t,l=Math.min(o.length,i.length-s),c=0,u=s;c<l;c++,u++)i[u]=o[c];return this}console.error("v3d.BufferGeometry.merge(): geometry not an instance of v3d.BufferGeometry.",e)},normalizeNormals:function(){for(var e=this.attributes.normal,t=0,n=e.count;t<n;t++)ci.x=e.getX(t),ci.y=e.getY(t),ci.z=e.getZ(t),ci.normalize(),e.setXYZ(t,ci.x,ci.y,ci.z)},toNonIndexed:function(){function e(e,t){for(var n=e.array,r=e.itemSize,i=new n.constructor(t.length*r),a=0,o=0,s=0,l=t.length;s<l;s++){a=t[s]*r;for(var c=0;c<r;c++)i[o++]=n[a++]}return new Vr(i,r)}if(null===this.index)return console.warn("v3d.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new ui,n=this.index.array,r=this.attributes;for(var i in r){var a=e(r[i],n);t.setAttribute(i,a)}var o=this.morphAttributes;for(i in o){for(var s=[],l=o[i],c=0,u=l.length;c<u;c++){a=e(l[c],n);s.push(a)}t.morphAttributes[i]=s}t.morphTargetsRelative=this.morphTargetsRelative;for(var d=this.groups,c=0,h=d.length;c<h;c++){var p=d[c];t.addGroup(p.start,p.count,p.materialIndex)}return t},toJSON:function(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),0<Object.keys(this.userData).length&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var r=this.index;null!==r&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(h=i[n]).toJSON();""!==h.name&&(a.name=h.name),e.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var l=this.morphAttributes[n],c=[],u=0,d=l.length;u<d;u++){var h,a=(h=l[u]).toJSON();""!==h.name&&(a.name=h.name),c.push(a)}0<c.length&&(o[n]=c,s=!0)}s&&(e.data.morphAttributes=o,e.data.morphTargetsRelative=this.morphTargetsRelative);var p=this.groups;0<p.length&&(e.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(e.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),e},clone:function(){return(new ui).copy(this)},copy:function(e){var t;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone());var r=e.attributes;for(t in r){var i=r[t];this.setAttribute(t,i.clone())}var a=e.morphAttributes;for(t in a){for(var o=[],s=a[t],l=0,c=s.length;l<c;l++)o.push(s[l].clone());this.morphAttributes[t]=o}this.morphTargetsRelative=e.morphTargetsRelative;var u=e.groups;for(l=0,c=u.length;l<c;l++){var d=u[l];this.addGroup(d.start,d.count,d.materialIndex)}var h=e.boundingBox;null!==h&&(this.boundingBox=h.clone());var p=e.boundingSphere;return null!==p&&(this.boundingSphere=p.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var di=new _n,hi=new dr,pi=new rr,fi=new un,mi=new un,vi=new un,gi=new un,_i=new un,yi=new un,xi=new un,bi=new un,Mi=new un,wi=new Jt,Ai=new Jt,Si=new Jt,Ti=new un,Ei=new un;function Ci(e,t){Bn.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new ui,this.material=void 0!==t?t:new zr,this.updateMorphTargets(),this.isMaterialGeneratedMesh=!1}function Pi(e,t,n,r,i,a,o,s){var l=t.side===Le?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side!==ie,s);if(null===l)return null;Ei.copy(s),Ei.applyMatrix4(e.matrixWorld);var c=n.ray.origin.distanceTo(Ei);return c<n.near||c>n.far?null:{distance:c,point:Ei.clone(),object:e}}function Li(e,t,n,r,i,a,o,s,l,c,u,d){fi.fromBufferAttribute(i,c),mi.fromBufferAttribute(i,u),vi.fromBufferAttribute(i,d);var h=e.morphTargetInfluences;if(t.morphTargets&&a&&h){xi.set(0,0,0),bi.set(0,0,0),Mi.set(0,0,0);for(var p=0,f=a.length;p<f;p++){var m=h[p],v=a[p];0!==m&&(gi.fromBufferAttribute(v,c),_i.fromBufferAttribute(v,u),yi.fromBufferAttribute(v,d),o?(xi.addScaledVector(gi,m),bi.addScaledVector(_i,m),Mi.addScaledVector(yi,m)):(xi.addScaledVector(gi.sub(fi),m),bi.addScaledVector(_i.sub(mi),m),Mi.addScaledVector(yi.sub(vi),m)))}fi.add(xi),mi.add(bi),vi.add(Mi)}var g,_=Pi(e,t,n,r,fi,mi,vi,Ti);return _&&(s&&(wi.fromBufferAttribute(s,c),Ai.fromBufferAttribute(s,u),Si.fromBufferAttribute(s,d),_.uv=Tr.getUV(Ti,fi,mi,vi,wi,Ai,Si,new Jt)),l&&(wi.fromBufferAttribute(l,c),Ai.fromBufferAttribute(l,u),Si.fromBufferAttribute(l,d),_.uv2=Tr.getUV(Ti,fi,mi,vi,wi,Ai,Si,new Jt)),g=new Or(c,u,d),Tr.getNormal(fi,mi,vi,g.normal),_.face=g),_}Ci.prototype=Object.assign(Object.create(Bn.prototype),{constructor:Ci,isMesh:!0,copy:function(e){return Bn.prototype.copy.call(this,e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.isMaterialGeneratedMesh=e.isMaterialGeneratedMesh,this},updateMorphTargets:function(){var e,t,n,r=this.geometry;if(r.isBufferGeometry){var i=r.morphAttributes,a=Object.keys(i);if(0<a.length){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e<t;e++)n=o[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}else{var s=r.morphTargets;void 0!==s&&0<s.length&&console.error("v3d.Mesh.updateMorphTargets() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}},raycast:function(e,t){var n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0!==r&&(null===n.boundingSphere&&n.computeBoundingSphere(),pi.copy(n.boundingSphere),pi.applyMatrix4(i),!1!==e.ray.intersectsSphere(pi)&&(di.getInverse(i),hi.copy(e.ray).applyMatrix4(di),null===n.boundingBox||!1!==hi.intersectsBox(n.boundingBox))))if(n.isBufferGeometry){var a,o,s,l,c,u,d,h,p,f=n.index,m=n.attributes.position,v=n.morphAttributes.position,g=n.morphTargetsRelative,_=n.attributes.uv,y=n.attributes.uv2,x=n.groups,b=n.drawRange;if(null!==f)if(Array.isArray(r))for(l=0,u=x.length;l<u;l++)for(p=r[(h=x[l]).materialIndex],c=Math.max(h.start,b.start),d=Math.min(h.start+h.count,b.start+b.count);c<d;c+=3)a=f.getX(c),o=f.getX(c+1),s=f.getX(c+2),(N=Li(this,p,e,hi,m,v,g,_,y,a,o,s))&&(N.faceIndex=Math.floor(c/3),N.face.materialIndex=h.materialIndex,t.push(N));else for(l=Math.max(0,b.start),u=Math.min(f.count,b.start+b.count);l<u;l+=3)a=f.getX(l),o=f.getX(l+1),s=f.getX(l+2),(N=Li(this,r,e,hi,m,v,g,_,y,a,o,s))&&(N.faceIndex=Math.floor(l/3),t.push(N));else if(void 0!==m)if(Array.isArray(r))for(l=0,u=x.length;l<u;l++)for(p=r[(h=x[l]).materialIndex],c=Math.max(h.start,b.start),d=Math.min(h.start+h.count,b.start+b.count);c<d;c+=3)(N=Li(this,p,e,hi,m,v,g,_,y,a=c,o=c+1,s=c+2))&&(N.faceIndex=Math.floor(c/3),N.face.materialIndex=h.materialIndex,t.push(N));else for(l=Math.max(0,b.start),u=Math.min(m.count,b.start+b.count);l<u;l+=3)(N=Li(this,r,e,hi,m,v,g,_,y,a=l,o=l+1,s=l+2))&&(N.faceIndex=Math.floor(l/3),t.push(N))}else if(n.isGeometry){var M,w=Array.isArray(r),A=n.vertices,S=n.faces,T=n.faceVertexUvs[0];0<T.length&&(M=T);for(var E=0,C=S.length;E<C;E++){var P,L,R,D,N,I=S[E],O=w?r[I.materialIndex]:r;void 0!==O&&(L=A[I.a],R=A[I.b],D=A[I.c],(N=Pi(this,O,e,hi,L,R,D,Ti))&&(M&&M[E]&&(P=M[E],wi.copy(P[0]),Ai.copy(P[1]),Si.copy(P[2]),N.uv=Tr.getUV(Ti,L,R,D,wi,Ai,Si,new Jt)),N.face=I,N.faceIndex=E,t.push(N)))}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)},getWorldDirection:function(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},isVisible:function(){return this.isMaterialGeneratedMesh&&this.parent?this.visible&&this.parent.visible:this.visible}});var Ri=0,Di=new _n,Ni=new Bn,Ii=new un;function Oi(){Object.defineProperty(this,"id",{value:Ri+=2}),this.uuid=Kt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Fi(e,t,n,r,i,a){Oi.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a},this.fromBufferGeometry(new Bi(e,t,n,r,i,a)),this.mergeVertices()}function Bi(e,t,n,r,i,a){ui.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};var P=this;e=e||1,t=t||1,n=n||1,r=Math.floor(r)||1,i=Math.floor(i)||1,a=Math.floor(a)||1;var L=[],R=[],D=[],N=[],I=0,O=0;function o(e,t,n,r,i,a,o,s,l,c,u){for(var d=a/l,h=o/c,p=a/2,f=o/2,m=s/2,v=l+1,g=c+1,_=0,y=0,x=new un,b=0;b<g;b++)for(var M=b*h-f,w=0;w<v;w++){var A=w*d-p;x[e]=A*r,x[t]=M*i,x[n]=m,R.push(x.x,x.y,x.z),x[e]=0,x[t]=0,x[n]=0<s?1:-1,D.push(x.x,x.y,x.z),N.push(w/l),N.push(1-b/c),_+=1}for(b=0;b<c;b++)for(w=0;w<l;w++){var S=I+w+v*b,T=I+w+v*(b+1),E=I+(w+1)+v*(b+1),C=I+(w+1)+v*b;L.push(S,T,C),L.push(T,E,C),y+=6}P.addGroup(O,y,u),O+=y,I+=_}o("z","y","x",-1,-1,n,t,e,a,i,0),o("z","y","x",1,-1,n,t,-e,a,i,1),o("x","z","y",1,1,e,n,t,r,a,2),o("x","z","y",1,-1,e,n,-t,r,a,3),o("x","y","z",1,-1,e,t,n,r,i,4),o("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(L),this.setAttribute("position",new qr(R,3)),this.setAttribute("normal",new qr(D,3)),this.setAttribute("uv",new qr(N,2))}function zi(e){var t={};for(var n in e)for(var r in t[n]={},e[n]){var i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}return t}function Ui(e){for(var t={},n=0;n<e.length;n++){var r=zi(e[n]);for(var i in r)t[i]=r[i]}return t}Oi.prototype=Object.assign(Object.create(o.prototype),{constructor:Oi,isGeometry:!0,applyMatrix4:function(e){for(var t=(new $t).getNormalMatrix(e),n=0,r=this.vertices.length;n<r;n++){this.vertices[n].applyMatrix4(e)}for(n=0,r=this.faces.length;n<r;n++){var i=this.faces[n];i.normal.applyMatrix3(t).normalize();for(var a=0,o=i.vertexNormals.length;a<o;a++)i.vertexNormals[a].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return Di.makeRotationX(e),this.applyMatrix4(Di),this},rotateY:function(e){return Di.makeRotationY(e),this.applyMatrix4(Di),this},rotateZ:function(e){return Di.makeRotationZ(e),this.applyMatrix4(Di),this},translate:function(e,t,n){return Di.makeTranslation(e,t,n),this.applyMatrix4(Di),this},scale:function(e,t,n){return Di.makeScale(e,t,n),this.applyMatrix4(Di),this},lookAt:function(e){return Ni.lookAt(e),Ni.updateMatrix(),this.applyMatrix4(Ni.matrix),this},fromBufferGeometry:function(e){var o=this,t=null!==e.index?e.index.array:void 0,n=e.attributes;if(void 0===n.position)return console.error("v3d.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var r=n.position.array,s=void 0!==n.normal?n.normal.array:void 0,l=void 0!==n.color?n.color.array:void 0,c=void 0!==n.uv?n.uv.array:void 0,u=void 0!==n.uv2?n.uv2.array:void 0;void 0!==u&&(this.faceVertexUvs[1]=[]);for(var i=0;i<r.length;i+=3)o.vertices.push((new un).fromArray(r,i)),void 0!==l&&o.colors.push((new Lr).fromArray(l,i));function a(e,t,n,r){var i=void 0===l?[]:[o.colors[e].clone(),o.colors[t].clone(),o.colors[n].clone()],a=new Or(e,t,n,void 0===s?[]:[(new un).fromArray(s,3*e),(new un).fromArray(s,3*t),(new un).fromArray(s,3*n)],i,r);o.faces.push(a),void 0!==c&&o.faceVertexUvs[0].push([(new Jt).fromArray(c,2*e),(new Jt).fromArray(c,2*t),(new Jt).fromArray(c,2*n)]),void 0!==u&&o.faceVertexUvs[1].push([(new Jt).fromArray(u,2*e),(new Jt).fromArray(u,2*t),(new Jt).fromArray(u,2*n)])}var d=e.groups;if(0<d.length)for(i=0;i<d.length;i++)for(var h=d[i],p=h.start,f=p,m=p+h.count;f<m;f+=3)void 0!==t?a(t[f],t[f+1],t[f+2],h.materialIndex):a(f,f+1,f+2,h.materialIndex);else if(void 0!==t)for(i=0;i<t.length;i+=3)a(t[i],t[i+1],t[i+2]);else for(i=0;i<r.length/3;i+=3)a(i,i+1,i+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ii).negate(),this.translate(Ii.x,Ii.y,Ii.z),this},normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,n=0===t?1:1/t,r=new _n;return r.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){for(var e=new un,t=new un,n=0,r=this.faces.length;n<r;n++){var i=this.faces[n],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];e.subVectors(s,o),t.subVectors(a,o),e.cross(t),e.normalize(),i.normal.copy(e)}},computeVertexNormals:function(e){var t,n,r,i;for(void 0===e&&(e=!0),i=new Array(this.vertices.length),t=0,n=this.vertices.length;t<n;t++)i[t]=new un;if(e)for(var a,o,s,l=new un,c=new un,u=0,d=this.faces.length;u<d;u++)r=this.faces[u],a=this.vertices[r.a],o=this.vertices[r.b],s=this.vertices[r.c],l.subVectors(s,o),c.subVectors(a,o),l.cross(c),i[r.a].add(l),i[r.b].add(l),i[r.c].add(l);else for(this.computeFaceNormals(),u=0,d=this.faces.length;u<d;u++)i[(r=this.faces[u]).a].add(r.normal),i[r.b].add(r.normal),i[r.c].add(r.normal);for(t=0,n=this.vertices.length;t<n;t++)i[t].normalize();for(u=0,d=this.faces.length;u<d;u++){var h=(r=this.faces[u]).vertexNormals;3===h.length?(h[0].copy(i[r.a]),h[1].copy(i[r.b]),h[2].copy(i[r.c])):(h[0]=i[r.a].clone(),h[1]=i[r.b].clone(),h[2]=i[r.c].clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e<t;e++){var r=(n=this.faces[e]).vertexNormals;3===r.length?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n;for(o=0,s=this.faces.length;o<s;o++)for((n=this.faces[o]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),e=0,t=n.vertexNormals.length;e<t;e++)n.__originalVertexNormals[e]?n.__originalVertexNormals[e].copy(n.vertexNormals[e]):n.__originalVertexNormals[e]=n.vertexNormals[e].clone();var r=new Oi;for(r.faces=this.faces,e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];for(var i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals,o=0,s=this.faces.length;o<s;o++)l=new un,c={a:new un,b:new un,c:new un},i.push(l),a.push(c)}var l,c,u=this.morphNormals[e];for(r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals(),o=0,s=this.faces.length;o<s;o++)n=this.faces[o],l=u.faceNormals[o],c=u.vertexNormals[o],l.copy(n.normal),c.a.copy(n.vertexNormals[0]),c.b.copy(n.vertexNormals[1]),c.c.copy(n.vertexNormals[2])}for(o=0,s=this.faces.length;o<s;o++)(n=this.faces[o]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Jn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rr),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n){if(e&&e.isGeometry){var r,i=this.vertices.length,a=this.vertices,o=e.vertices,s=this.faces,l=e.faces,c=this.colors,u=e.colors;void 0===n&&(n=0),void 0!==t&&(r=(new $t).getNormalMatrix(t));for(var d=0,h=o.length;d<h;d++){var p=o[d].clone();void 0!==t&&p.applyMatrix4(t),a.push(p)}for(d=0,h=u.length;d<h;d++)c.push(u[d].clone());for(d=0,h=l.length;d<h;d++){var f,m,v=l[d],g=v.vertexNormals,_=v.vertexColors,y=new Or(v.a+i,v.b+i,v.c+i);y.normal.copy(v.normal),void 0!==r&&y.normal.applyMatrix3(r).normalize();for(var x=0,b=g.length;x<b;x++)f=g[x].clone(),void 0!==r&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(v.color);for(x=0,b=_.length;x<b;x++)m=_[x],y.vertexColors.push(m.clone());y.materialIndex=v.materialIndex+n,s.push(y)}for(d=0,h=e.faceVertexUvs.length;d<h;d++){var M=e.faceVertexUvs[d];void 0===this.faceVertexUvs[d]&&(this.faceVertexUvs[d]=[]);for(x=0,b=M.length;x<b;x++){for(var w=M[x],A=[],S=0,T=w.length;S<T;S++)A.push(w[S].clone());this.faceVertexUvs[d].push(A)}}}else console.error("v3d.Geometry.merge(): geometry not an instance of v3d.Geometry.",e)},mergeMesh:function(e){e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)):console.error("v3d.Geometry.mergeMesh(): mesh not an instance of v3d.Mesh.",e)},mergeVertices:function(){for(var e,t,n,r,i,a,o={},s=[],l=[],c=Math.pow(10,4),u=0,d=this.vertices.length;u<d;u++)e=this.vertices[u],void 0===o[t=Math.round(e.x*c)+"_"+Math.round(e.y*c)+"_"+Math.round(e.z*c)]?(o[t]=u,s.push(this.vertices[u]),l[u]=s.length-1):l[u]=l[o[t]];var h=[];for(u=0,d=this.faces.length;u<d;u++){(n=this.faces[u]).a=l[n.a],n.b=l[n.b],n.c=l[n.c],r=[n.a,n.b,n.c];for(var p=0;p<3;p++)if(r[p]===r[(p+1)%3]){h.push(u);break}}for(u=h.length-1;0<=u;u--){var f=h[u];for(this.faces.splice(f,1),i=0,a=this.faceVertexUvs.length;i<a;i++)this.faceVertexUvs[i].splice(f,1)}var m=this.vertices.length-s.length;return this.vertices=s,m},setFromPoints:function(e){this.vertices=[];for(var t=0,n=e.length;t<n;t++){var r=e[t];this.vertices.push(new un(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,t=e.length,n=0;n<t;n++)e[n]._id=n;e.sort(function(e,t){return e.materialIndex-t.materialIndex});var r,i,a=this.faceVertexUvs[0],o=this.faceVertexUvs[1];a&&a.length===t&&(r=[]),o&&o.length===t&&(i=[]);for(n=0;n<t;n++){var s=e[n]._id;r&&r.push(a[s]),i&&i.push(o[s])}r&&(this.faceVertexUvs[0]=r),i&&(this.faceVertexUvs[1]=i)},toJSON:function(){var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}for(var r=[],i=0;i<this.vertices.length;i++){var a=this.vertices[i];r.push(a.x,a.y,a.z)}for(var o=[],s=[],l={},c=[],u={},d=[],h={},i=0;i<this.faces.length;i++){var p,f,m,v=this.faces[i],g=void 0!==this.faceVertexUvs[0][i],_=0<v.normal.length(),y=0<v.vertexNormals.length,x=1!==v.color.r||1!==v.color.g||1!==v.color.b,b=0<v.vertexColors.length,M=w(M=0,0,0);M=w(M,1,!0),M=w(M,2,!1),M=w(M,3,g),M=w(M,4,_),M=w(M,5,y),M=w(M,6,x),M=w(M,7,b),o.push(M),o.push(v.a,v.b,v.c),o.push(v.materialIndex),g&&(p=this.faceVertexUvs[0][i],o.push(T(p[0]),T(p[1]),T(p[2]))),_&&o.push(A(v.normal)),y&&(f=v.vertexNormals,o.push(A(f[0]),A(f[1]),A(f[2]))),x&&o.push(S(v.color)),b&&(m=v.vertexColors,o.push(S(m[0]),S(m[1]),S(m[2])))}function w(e,t,n){return n?e|1<<t:e&~(1<<t)}function A(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==l[t]||(l[t]=s.length/3,s.push(e.x,e.y,e.z)),l[t]}function S(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==u[t]||(u[t]=c.length,c.push(e.getHex())),u[t]}function T(e){var t=e.x.toString()+e.y.toString();return void 0!==h[t]||(h[t]=d.length/2,d.push(e.x,e.y)),h[t]}return e.data={},e.data.vertices=r,e.data.normals=s,0<c.length&&(e.data.colors=c),0<d.length&&(e.data.uvs=[d]),e.data.faces=o,e},clone:function(){return(new Oi).copy(this)},copy:function(e){var t,n;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;for(var r=e.vertices,i=0,a=r.length;i<a;i++)this.vertices.push(r[i].clone());var o=e.colors;for(i=0,a=o.length;i<a;i++)this.colors.push(o[i].clone());var s=e.faces;for(i=0,a=s.length;i<a;i++)this.faces.push(s[i].clone());for(i=0,a=e.faceVertexUvs.length;i<a;i++){var l=e.faceVertexUvs[i];for(void 0===this.faceVertexUvs[i]&&(this.faceVertexUvs[i]=[]),t=0,n=l.length;t<n;t++){for(var c=l[t],u=[],d=0,h=c.length;d<h;d++){var p=c[d];u.push(p.clone())}this.faceVertexUvs[i].push(u)}}var f=e.morphTargets;for(i=0,a=f.length;i<a;i++){var m={};if(m.name=f[i].name,void 0!==f[i].vertices)for(m.vertices=[],t=0,n=f[i].vertices.length;t<n;t++)m.vertices.push(f[i].vertices[t].clone());if(void 0!==f[i].normals)for(m.normals=[],t=0,n=f[i].normals.length;t<n;t++)m.normals.push(f[i].normals[t].clone());this.morphTargets.push(m)}var v=e.morphNormals;for(i=0,a=v.length;i<a;i++){var g={};if(void 0!==v[i].vertexNormals)for(g.vertexNormals=[],t=0,n=v[i].vertexNormals.length;t<n;t++){var _=v[i].vertexNormals[t],y={};y.a=_.a.clone(),y.b=_.b.clone(),y.c=_.c.clone(),g.vertexNormals.push(y)}if(void 0!==v[i].faceNormals)for(g.faceNormals=[],t=0,n=v[i].faceNormals.length;t<n;t++)g.faceNormals.push(v[i].faceNormals[t].clone());this.morphNormals.push(g)}var x=e.skinWeights;for(i=0,a=x.length;i<a;i++)this.skinWeights.push(x[i].clone());var b=e.skinIndices;for(i=0,a=b.length;i<a;i++)this.skinIndices.push(b[i].clone());var M=e.lineDistances;for(i=0,a=M.length;i<a;i++)this.lineDistances.push(M[i]);var w=e.boundingBox;null!==w&&(this.boundingBox=w.clone());var A=e.boundingSphere;return null!==A&&(this.boundingSphere=A.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),(Fi.prototype=Object.create(Oi.prototype)).constructor=Fi,(Bi.prototype=Object.create(ui.prototype)).constructor=Bi;var Vi={clone:zi,merge:Ui},ki="void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",Gi="void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}";function ji(e){Br.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.customPrepTokens={},this.vertexShader=ki,this.fragmentShader=Gi,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("v3d.ShaderMaterial: attributes should now be defined in v3d.BufferGeometry instead."),this.setValues(e))}function Wi(){Bn.call(this),this.type="Camera",this.matrixWorldInverse=new _n,this.projectionMatrix=new _n,this.projectionMatrixInverse=new _n,this.controls=null,this.viewportFit={type:Ht,initialAspect:1}}function Xi(e,t,n,r){Wi.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}((ji.prototype=Object.create(Br.prototype)).constructor=ji).prototype.isShaderMaterial=!0,ji.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=zi(e.uniforms),this.defines=Object.assign({},e.defines),this.customPrepTokens=Object.assign({},e.customPrepTokens),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},ji.prototype.toJSON=function(e){var t=Br.prototype.toJSON.call(this,e);for(var n in t.uniforms={},this.uniforms){var r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return 0<Object.keys(i).length&&(t.extensions=i),t},Wi.prototype=Object.assign(Object.create(Bn.prototype),{constructor:Wi,isCamera:!0,copy:function(e,t){return Bn.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),e.controls&&(this.controls={type:e.controls.type,enablePan:e.controls.enablePan,rotateSpeed:e.controls.rotateSpeed,moveSpeed:e.controls.moveSpeed,orbitMinDistance:e.controls.orbitMinDistance,orbitMaxDistance:e.controls.orbitMaxDistance,orbitMinPolarAngle:e.controls.orbitMinPolarAngle,orbitMaxPolarAngle:e.controls.orbitMaxPolarAngle,orbitMinAzimuthAngle:e.controls.orbitMinAzimuthAngle,orbitMaxAzimuthAngle:e.controls.orbitMaxAzimuthAngle},e.controls.orbitTarget&&(this.controls.orbitTarget=e.controls.orbitTarget)),this.viewportFit.type=e.viewportFit.type,this.viewportFit.initialAspect=e.viewportFit.initialAspect,this},getWorldDirection:function(e){void 0===e&&(console.warn("v3d.Camera: .getWorldDirection() target is now required"),e=new un),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){Bn.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){Bn.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(e){return(new this.constructor).copy(this,e)}}),Xi.prototype=Object.assign(Object.create(Wi.prototype),{constructor:Xi,isPerspectiveCamera:!0,copy:function(e,t){return Wi.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*Kt.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*Kt.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*Kt.RAD2DEG*Math.atan(Math.tan(.5*Kt.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,r,i,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e,t,n=this.near,r=n*Math.tan(.5*Kt.DEG2RAD*this.fov)/this.zoom,i=2*r,a=this.aspect*i,o=-.5*a,s=this.view;null!==this.view&&this.view.enabled&&(e=s.fullWidth,t=s.fullHeight,o+=s.offsetX*a/e,r-=s.offsetY*i/t,a*=s.width/e,i*=s.height/t);var l=this.filmOffset;0!==l&&(o+=n*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+a,r,r-i,n,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=Bn.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});function Hi(e,t,n,r){Bn.call(this),this.type="CubeCamera";var a=new Xi(90,1,e,t);a.up.set(0,-1,0),a.lookAt(new un(1,0,0)),this.add(a);var o=new Xi(90,1,e,t);o.up.set(0,-1,0),o.lookAt(new un(-1,0,0)),this.add(o);var s=new Xi(90,1,e,t);s.up.set(0,0,1),s.lookAt(new un(0,1,0)),this.add(s);var l=new Xi(90,1,e,t);l.up.set(0,0,-1),l.lookAt(new un(0,-1,0)),this.add(l);var c=new Xi(90,1,e,t);c.up.set(0,-1,0),c.lookAt(new un(0,0,1)),this.add(c);var u=new Xi(90,1,e,t);u.up.set(0,-1,0),u.lookAt(new un(0,0,-1)),this.add(u),r=r||{format:ut,magFilter:tt,minFilter:tt},this.renderTarget=new Yi(n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var n=e.getRenderTarget(),r=this.renderTarget,i=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,a),e.setRenderTarget(r,1),e.render(t,o),e.setRenderTarget(r,2),e.render(t,s),e.setRenderTarget(r,3),e.render(t,l),e.setRenderTarget(r,4),e.render(t,c),r.texture.generateMipmaps=i,e.setRenderTarget(r,5),e.render(t,u),e.setRenderTarget(n)},this.clear=function(e,t,n,r){for(var i=e.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)e.setRenderTarget(a,o),e.clear(t,n,r);e.setRenderTarget(i)}}function Yi(e,t,n){Number.isInteger(t)&&(console.warn("v3d.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget(size, options)"),t=n),an.call(this,e,e,t)}function qi(e,t,n,r,i,a,o,s,l,c,u,d){nn.call(this,null,a,o,s,l,c,r,i,u,d),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==l?l:Je,this.minFilter=void 0!==c?c:Je,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}(Hi.prototype=Object.create(Bn.prototype)).constructor=Hi,((Yi.prototype=Object.create(an.prototype)).constructor=Yi).prototype.isWebGLCubeRenderTarget=!0,Yi.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var n=new zn,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection(in vec3 dir, in mat4 matrix) {"," return normalize((matrix * vec4(dir, 0.0)).xyz);","}","void main() {"," vWorldDirection = transformDirection(position, modelMatrix);"," #include <begin_vertex>"," #include <project_vertex>","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {"," vec3 direction = normalize(vWorldDirection);"," vec2 sampleUV;"," sampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;"," sampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;"," gl_FragColor = texture2D(tEquirect, sampleUV);","}"].join("\n")},i=new ji({type:"CubemapFromEquirect",uniforms:zi(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Le,blending:ae});i.uniforms.tEquirect.value=t;var a=new Ci(new Bi(5,5,5),i);n.add(a);var o=new Hi(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(e,n),a.geometry.dispose(),a.material.dispose(),this},((qi.prototype=Object.create(nn.prototype)).constructor=qi).prototype.isDataTexture=!0;var Zi=new rr,Qi=new un;function Ki(e,t,n,r,i,a){this.planes=[void 0!==e?e:new mr,void 0!==t?t:new mr,void 0!==n?n:new mr,void 0!==r?r:new mr,void 0!==i?i:new mr,void 0!==a?a:new mr]}Object.assign(Ki.prototype,{set:function(e,t,n,r,i,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromProjectionMatrix:function(e){var t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],_=n[15];return t[0].setComponents(o-r,u-s,f-d,_-m).normalize(),t[1].setComponents(o+r,u+s,f+d,_+m).normalize(),t[2].setComponents(o+i,u+l,f+h,_+v).normalize(),t[3].setComponents(o-i,u-l,f-h,_-v).normalize(),t[4].setComponents(o-a,u-c,f-p,_-g).normalize(),t[5].setComponents(o+a,u+c,f+p,_+g).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)},intersectsSprite:function(e){return Zi.center.set(0,0,0),Zi.radius=.7071067811865476,Zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,r=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(n)<r)return!1}return!0},intersectsBox:function(e){for(var t=this.planes,n=0;n<6;n++){var r=t[n];if(Qi.x=0<r.normal.x?e.max.x:e.min.x,Qi.y=0<r.normal.y?e.max.y:e.min.y,Qi.z=0<r.normal.z?e.max.z:e.min.z,r.distanceToPoint(Qi)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var Ji={common:{diffuse:{value:new Lr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new $t},uv2Transform:{value:new $t},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Jt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Lr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},maxDistance:{},expBias:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new Lr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new $t}},sprite:{diffuse:{value:new Lr(15658734)},opacity:{value:1},center:{value:new Jt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new $t}},mask:{depthTexture:{value:null},cameraNearFar:{value:new Jt(.5,.5)},textureMatrix:{value:new _n}},node:{nodeRGB:{value:[]},nodeValue:{value:[]},flipCubeMap:{value:-1}},ssr:{invProjectionMatrix:{value:new _n},ssrSourceBuffer:{value:null},ssrDepthBuffer:{value:null},ssrBackfaceDepthBuffer:{value:null},ssrStride:{value:20},ssrResolution:{value:new Jt},ssrThickness:{value:.01},ssrJitter:{value:1},ssrMaxDistance:{value:100}}};function $i(){var u={};return{get:function(e,t,n,r){if(void 0!==u[r.id])var i=u[r.id];else{for(var i=[r],a=1;a<4;a++){var o=0!=(1&a),s=0!=(2&a),l=r.clone();l.morphTargets=o,l.skinning=s,i[a]=l}u[r.id]=i}o=!1;n.morphTargets&&(t&&t.isBufferGeometry?o=t.morphAttributes&&t.morphAttributes.position&&0<t.morphAttributes.position.length:t&&t.isGeometry&&(o=t.morphTargets&&0<t.morphTargets.length)),e.isSkinnedMesh&&!1===n.skinning&&console.warn("v3d.OverrideMatVariants: v3d.SkinnedMesh with material.skinning set to false:",e);var c=0;return o&&(c|=1),(s=e.isSkinnedMesh&&n.skinning)&&(c|=2),i[c]},update:function(e){delete u[e.id]},dispose:function(){u={}}}}function ea(){var n=null,r=!1,i=null;function a(e,t){!1!==r&&(i(e,t),n.requestAnimationFrame(a))}return{start:function(){!0!==r&&null!==i&&(n.requestAnimationFrame(a),r=!0)},stop:function(){r=!1},setAnimationLoop:function(e){i=e},setContext:function(e){n=e}}}function ta(l,e){var c=e.isWebGL2,u=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),u.get(e)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var t=u.get(e);t&&(l.deleteBuffer(t.buffer),u.delete(e))},update:function(e,t){e.isInterleavedBufferAttribute&&(e=e.data);var n,r,i,a,o,s=u.get(e);void 0===s?u.set(e,function(e,t){var n=e.array,r=e.usage,i=l.createBuffer();l.bindBuffer(t,i),l.bufferData(t,n,r),e.onUploadCallback();var a=5126;return n instanceof Float32Array?a=5126:n instanceof Float64Array?console.warn("v3d.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?a=5123:n instanceof Int16Array?a=5122:n instanceof Uint32Array?a=5125:n instanceof Int32Array?a=5124:n instanceof Int8Array?a=5120:n instanceof Uint8Array&&(a=5121),{buffer:i,type:a,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version}}(e,t)):s.version<e.version&&(n=s.buffer,i=t,a=(r=e).array,o=r.updateRange,l.bindBuffer(i,n),-1===o.count?l.bufferSubData(i,0,a):(c?l.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):l.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1),s.version=e.version)},dispose:function(){u=new WeakMap}}}function na(e,t,n,r,i,a){Wi.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==e?e:-1,this.right=void 0!==t?t:1,this.top=void 0!==n?n:1,this.bottom=void 0!==r?r:-1,this.near=void 0!==i?i:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function ra(e,t,n,r){Oi.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r},this.fromBufferGeometry(new ia(e,t,n,r)),this.mergeVertices()}function ia(e,t,n,r){ui.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};for(var i=(e=e||1)/2,a=(t=t||1)/2,o=Math.floor(n)||1,s=Math.floor(r)||1,l=o+1,c=s+1,u=e/o,d=t/s,h=[],p=[],f=[],m=[],v=0;v<c;v++)for(var g=v*d-a,_=0;_<l;_++){var y=_*u-i;p.push(y,-g,0),f.push(0,0,1),m.push(_/o),m.push(1-v/s)}for(v=0;v<s;v++)for(_=0;_<o;_++){var x=_+l*v,b=_+l*(v+1),M=_+1+l*(v+1),w=_+1+l*v;h.push(x,b,w),h.push(b,M,w)}this.setIndex(h),this.setAttribute("position",new qr(p,3)),this.setAttribute("normal",new qr(f,3)),this.setAttribute("uv",new qr(m,2))}na.prototype=Object.assign(Object.create(Wi.prototype),{constructor:na,isOrthographicCamera:!0,copy:function(e,t){return Wi.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,n,r,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e,t,n=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,a=(this.top+this.bottom)/2,o=i-n,s=i+n,l=a+r,c=a-r;null!==this.view&&this.view.enabled&&(e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom,s=(o+=e*this.view.offsetX)+e*this.view.width,c=(l-=t*this.view.offsetY)-t*this.view.height),this.projectionMatrix.makeOrthographic(o,s,l,c,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=Bn.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}),(ra.prototype=Object.create(Oi.prototype)).constructor=ra,(ia.prototype=Object.create(ui.prototype)).constructor=ia;var aa={alphamap_fragment:"#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, vUv).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif (diffuseColor.a < ALPHATEST)\ndiscard;\nelse\ndiffuseColor.a = 1.0;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\nfloat ambientOcclusion = (texture2D(aoMap, vUv2).r - 1.0) * aoMapIntensity + 1.0;\nreflectedLight.indirectDiffuse *= ambientOcclusion;\n#if defined(USE_ENVMAP) && defined(STANDARD)\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nreflectedLight.indirectSpecular *= computeSpecularOcclusion(dotNV, ambientOcclusion, material.specularRoughness);\n#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\nuniform sampler2D aoMap;\nuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3(position);",beginnormal_vertex:"vec3 objectNormal = vec3(normal);\n#ifdef USE_TANGENT\nvec3 objectTangent = vec3(tangent.xyz);\n#endif",bsdfs:"\nvec2 integrateSpecularBRDF(const in float dotNV, const in float roughness) {\nconst vec4 c0 = vec4(- 1, - 0.0275, - 0.572, 0.022);\nconst vec4 c1 = vec4(1, 0.0425, 1.04, - 0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(- 9.28 * dotNV)) * r.x + r.y;\nreturn vec2(-1.04, 1.04) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor(float lightDistance, const in float cutoffDistance, const in float decayExponent) {\n#if defined (PHYSICALLY_CORRECT_LIGHTS)\nlightDistance = UNITS_SCALE_FACTOR * lightDistance;\n#ifdef MT_MAYA\nfloat distanceFalloff = 1.0 / pow(lightDistance + 1.0, decayExponent);\n#else\nfloat distanceFalloff = 1.0 / max(pow(lightDistance, decayExponent), 0.01);\n#endif\nif(cutoffDistance > 0.0) {\ndistanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n}\nreturn distanceFalloff;\n#else\nif(cutoffDistance > 0.0 && decayExponent > 0.0) {\nreturn pow(saturate(-lightDistance / cutoffDistance + 1.0), decayExponent);\n}\nreturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor) {\nreturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {\nfloat fresnel = exp2((-5.55473 * dotLH - 6.98316) * dotLH);\nreturn (1.0 - specularColor) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent(const in vec3 F0, const in float dotNV, const in float roughness) {\nfloat fresnel = exp2((-5.55473 * dotNV - 6.98316) * dotNV);\nvec3 Fr = max(vec3(1.0 - roughness), F0) - F0;\nreturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gl = dotNL + sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nfloat gv = dotNV + sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nreturn 1.0 / (gl * gv);\n}\nfloat G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nfloat gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nreturn 0.5 / max(gv + gl, EPSILON);\n}\nfloat D_GGX(const in float alpha, const in float dotNH) {\nfloat a2 = pow2(alpha);\nfloat denom = pow2(dotNH) * (a2 - 1.0) + 1.0;\nreturn RECIPROCAL_PI * a2 / pow2(denom);\n}\nvec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat alpha = pow2(clamp(roughness, 0.04, 1.0));\nvec3 halfDir = normalize(incidentLight.direction + viewDir);\nfloat dotNL = saturate(dot(normal, incidentLight.direction));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\nfloat G = G_GGX_SmithCorrelated(alpha, dotNL, dotNV);\nfloat D = D_GGX(alpha, dotNH);\nreturn F * (G * D);\n}\nvec2 LTC_Uv(const in vec3 N, const in vec3 V, const in float roughness) {\nconst float LUT_SIZE = 64.0;\nconst float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;\nconst float LUT_BIAS = 0.5 / LUT_SIZE;\nfloat dotNV = saturate(dot(N, V));\nvec2 uv = vec2(roughness, sqrt(1.0 - dotNV));\nuv = uv * LUT_SCALE + LUT_BIAS;\nreturn uv;\n}\nfloat LTC_ClippedSphereFormFactor(const in vec3 f) {\nfloat l = length(f);\nreturn max((l * l + f.z) / (l + 1.0), 0.0);\n}\nvec3 LTC_EdgeVectorFormFactor(const in vec3 v1, const in vec3 v2) {\nfloat x = dot(v1, v2);\nfloat y = abs(x);\nfloat a = 0.8543985 + (0.4965155 + 0.0145206 * y) * y;\nfloat b = 3.4175940 + (4.1616724 + y) * y;\nfloat v = a / b;\nfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt(max(1.0 - x * x, 1e-7)) - v;\nreturn cross(v1, v2) * theta_sintheta;\n}\nvec3 LTC_Evaluate(const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[4]) {\nvec3 v1 = rectCoords[1] - rectCoords[0];\nvec3 v2 = rectCoords[3] - rectCoords[0];\nvec3 lightNormal = cross(v1, v2);\nif(dot(lightNormal, P - rectCoords[0]) < 0.0) return vec3(0.0);\nvec3 T1, T2;\nT1 = normalize(V - N * dot(V, N));\nT2 = - cross(N, T1);\nmat3 mat = mInv * transposeMat3(mat3(T1, T2, N));\nvec3 coords[4];\ncoords[0] = mat * (rectCoords[0] - P);\ncoords[1] = mat * (rectCoords[1] - P);\ncoords[2] = mat * (rectCoords[2] - P);\ncoords[3] = mat * (rectCoords[3] - P);\ncoords[0] = normalize(coords[0]);\ncoords[1] = normalize(coords[1]);\ncoords[2] = normalize(coords[2]);\ncoords[3] = normalize(coords[3]);\nvec3 vectorFormFactor = vec3(0.0);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[0], coords[1]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[1], coords[2]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[2], coords[3]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[3], coords[0]);\nfloat result = LTC_ClippedSphereFormFactor(vectorFormFactor);\nreturn vec3(result);\n}\nvec2 get_BRDF_SpecCoeffsBlender(float x, float y) {\nvec3 xyFactors0 = vec3(x * x, y * y, x * y);\nvec3 xyFactors1 = vec3(x, y, 1);\nvec3 a0a1a2 = vec3(0.33749372, 0.15167605, 1.09684597);\nvec3 a3a4a5 = vec3(-1.26123466, -0.927699, 0.9199188);\nvec3 b0b1b2 = vec3(0.41699717, 0.44675109, 0.79947684);\nvec3 b3b4b5 = vec3(-1.19307849, -0.89813958, 0.89305222);\nvec3 c0c1c2 = vec3(0.29920727, 0.09505591, -0.9136233);\nvec3 c3c4c5 = vec3(0.77055201, 0.13006674, -0.23085581);\nvec3 d0d1d2 = vec3(15.05004149, 7.98517355, 13.30473726);\nvec3 d3d4d5 = vec3(-32.00353547, -12.97743434, 17.83646751);\nfloat coeff0 = (dot(xyFactors0, a0a1a2) + dot(xyFactors1, a3a4a5))\n/ (dot(xyFactors0, b0b1b2) + dot(xyFactors1, b3b4b5));\nfloat coeff1 = (dot(xyFactors0, c0c1c2) + dot(xyFactors1, c3c4c5))\n/ (dot(xyFactors0, d0d1d2) + dot(xyFactors1, d3d4d5));\ncoeff1 = clamp(coeff1, 0.0, 1.0);\nreturn vec2(coeff0, coeff1);\n}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nreturn specularColor * brdf.x + brdf.y;\n}\nvec3 BRDF_Specular_GGX_Environment_Blender_Approx(const in GeometricContext geometry,\nconst in vec3 fresnelRefl0, const in vec3 fresnelRefl90,\nconst in float roughness, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\nfloat dotNV = saturate(dot(normal, geometry.viewDir));\nfloat angle = acos(abs(dotNV)) / PI_HALF;\nvec2 specCoeffs = get_BRDF_SpecCoeffsBlender(angle, roughness);\nvec3 specular = specCoeffs.x * fresnelRefl0\n+ specCoeffs.y * fresnelRefl90\n* vec3(saturate(50.0 * linearToRelativeLuminance(fresnelRefl0)));\n#if defined (COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX)\nspecular = saturate(specular);\n#endif\nreturn specular;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 F = F_Schlick_RoughnessDependent(specularColor, dotNV, roughness);\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nvec3 FssEss = F * brdf.x + brdf.y;\nfloat Ess = brdf.x + brdf.y;\nfloat Ems = 1.0 - Ess;\nvec3 Favg = specularColor + (1.0 - specularColor) * 0.047619;\nvec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\nsingleScatter += FssEss;\nmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit() {\nreturn 0.25;\n}\nfloat D_BlinnPhong(const in float shininess, const in float dotNH) {\nreturn RECIPROCAL_PI * (shininess * 0.5 + 1.0) * pow(dotNH, shininess);\n}\nvec3 BRDF_Specular_BlinnPhong(const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess) {\nvec3 halfDir = normalize(incidentLight.direction + geometry.viewDir);\nfloat dotNH = saturate(dot(geometry.normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\nfloat G = G_BlinnPhong_Implicit();\nfloat D = D_BlinnPhong(shininess, dotNH);\nreturn F * (G * D);\n}\nfloat GGXRoughnessToBlinnExponent(const in float ggxRoughness) {\nreturn (2.0 / pow2(ggxRoughness + 0.0001) - 2.0);\n}\nfloat BlinnExponentToGGXRoughness(const in float blinnExponent) {\nreturn sqrt(2.0 / (blinnExponent + 2.0));\n}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness, float NoH) {\nfloat invAlpha = 1.0 / roughness;\nfloat cos2h = NoH * NoH;\nfloat sin2h = max(1.0 - cos2h, 0.0078125);\nreturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\nreturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen(const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor) {\nvec3 N = geometry.normal;\nvec3 V = geometry.viewDir;\nvec3 H = normalize(V + L);\nfloat dotNH = saturate(dot(N, H));\nreturn specularColor * D_Charlie(roughness, dotNH) * V_Neubelt(dot(N, V), dot(N, L));\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx(vUv);\nvec2 dSTdy = dFdy(vUv);\nfloat Hll = bumpScale * texture2D(bumpMap, vUv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, vUv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, vUv + dSTdy).x - Hll;\nreturn vec2(dBx, dBy);\n}\nvec3 perturbNormalArb(vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\nvec3 vSigmaX = vec3(dFdx(surf_pos.x), dFdx(surf_pos.y), dFdx(surf_pos.z));\nvec3 vSigmaY = vec3(dFdy(surf_pos.x), dFdy(surf_pos.y), dFdy(surf_pos.z));\nvec3 vN = surf_norm;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfDet *= (float(gl_FrontFacing) * 2.0 - 1.0);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nreturn normalize(abs(fDet) * surf_norm - vGrad);\n}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\nvec4 plane;\n#pragma unroll_loop\nfor (int i = 0; i < UNION_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nif (dot(vViewPosition, plane.xyz) > plane.w) discard;\n}\n#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\nbool clipped = true;\n#pragma unroll_loop\nfor (int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nclipped = (dot(vViewPosition, plane.xyz) > plane.w) && clipped;\n}\nif (clipped) discard;\n#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n#if !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP)&& !defined(NODE) && !defined(LAMBERT) && !defined(DEPTH)\nvarying vec3 vViewPosition;\n#endif\nuniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE) && !defined(LAMBERT) && !defined(DEPTH)\nvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE) && !defined(LAMBERT) && !defined(DEPTH)\nvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\ndiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#define whiteComplement(a) (1.0 - saturate(a))\n#define RECIPROCAL_3 0.333333333333\nfloat pow2(const in float x) { return x*x; }\nfloat pow3(const in float x) { return x*x*x; }\nfloat pow4(const in float x) { float x2 = x*x; return x2*x2; }\nfloat average(const in vec3 color) { return dot(color, vec3(0.3333)); }\nhighp float rand(const in vec2 uv) {\nconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\nhighp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI);\nreturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v) { return length(v); }\n#else\nfloat max3(vec3 v) { return max(max(v.x, v.y), v.z); }\nfloat precisionSafeLength(vec3 v) {\nfloat maxComponent = max3(abs(v));\nreturn length(v / maxComponent) * maxComponent;\n}\n#endif\nstruct IncidentLight {\nvec3 color;\nvec3 direction;\nbool visible;\n};\nstruct ReflectedLight {\nvec3 directDiffuse;\nvec3 directSpecular;\nvec3 indirectDiffuse;\nvec3 indirectSpecular;\n};\nstruct GeometricContext {\nvec3 position;\nvec3 normal;\nvec3 viewDir;\n#ifdef CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((matrix * vec4(dir, 0.0)).xyz);\n}\nvec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((vec4(dir, 0.0) * matrix).xyz);\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nfloat distance = dot(planeNormal, point - pointOnPlane);\nreturn - distance * planeNormal + point;\n}\nfloat sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn sign(dot(point - pointOnPlane, planeNormal));\n}\nvec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine;\n}\nmat3 transposeMat3(const in mat3 m) {\nmat3 tmp;\ntmp[0] = vec3(m[0].x, m[1].x, m[2].x);\ntmp[1] = vec3(m[0].y, m[1].y, m[2].y);\ntmp[2] = vec3(m[0].z, m[1].z, m[2].z);\nreturn tmp;\n}\nfloat linearToRelativeLuminance(const in vec3 color) {\nvec3 weights = vec3(0.2126, 0.7152, 0.0722);\nreturn dot(weights, color.rgb);\n}\nbool isPerspectiveMatrix(mat4 m) {\nreturn m[2][3] == - 1.0;\n}\nhighp vec3 rand3(const in vec3 v) {\nconst highp float c = 43758.5453;\nconst highp mat3 coeffs = mat3(\n165.15, 253.34, 323.22,\n241.49, 329.07, 147.79,\n376.31, 143.45, 281.63\n);\nhighp vec3 sn = mod(coeffs * v, PI);\nreturn fract(sin(sn) * c);\n}\nfloat powCompat(const in float val, const in float power) {\nif (power == 0.0)\nreturn 1.0;\nelse if (val < 0.0) {\nif (mod(-power, 2.0) == 0.0)\nreturn pow(abs(val), power);\nelse\nreturn -pow(abs(val), power);\n} else if (val == 0.0)\nreturn 0.0;\nreturn pow(abs(val), power);\n}\nfloat maxFromRGB(vec3 rgb) {\nreturn max(max(rgb.r, rgb.g), rgb.b);\n}\nbool isOrtho(const in mat4 m) {\nif (m[3][3] != 0.0)\nreturn true;\nelse\nreturn false;\n}\nvec3 swizzleUpZ(const vec3 vec) {\nreturn vec3(vec[0], -vec[2], vec[1]);\n}\nvec3 swizzleUpY(const vec3 vec) {\nreturn vec3(vec[0], vec[2], -vec[1]);\n}\nvec3 xyz_to_sRGB(vec3 xyz) {\nmat3 convMat = mat3(\n3.2406, -0.9689, 0.0557,\n-1.5372, 1.8758, -0.2040,\n-0.4986, 0.0415, 1.0570\n);\nreturn convMat * xyz;\n}\nvec3 xyY_to_XYZ(float x, float y, float Y) {\nfloat X = 0.0;\nfloat Z = 0.0;\nif (y != 0.0) {\nX = (Y / y) * x;\nZ = (Y / y) * (1.0 - x - y);\n}\nreturn vec3(X, Y, Z);\n}\nvec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) {\noctUV = (1.0 + 2.0 * texelSize) * octUV - texelSize;\noctUV = octUV * 2.0 - 1.0;\nfloat x = octUV.x;\nfloat z = -octUV.y;\nfloat absX = abs(x);\nfloat absZ = abs(z);\nvec3 cubeVec = vec3(x, 1.0 - absX - absZ, z);\nif (absX + absZ > 1.0) {\ncubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z));\n}\nreturn cubeVec;\n}\nvec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) {\ncubeVec /= dot(vec3(1.0), abs(cubeVec));\nvec2 octUV = vec2(cubeVec.x, -cubeVec.z);\nif (cubeVec.y < 0.0) {\noctUV = sign(octUV) * (1.0 - abs(octUV.ts));\n}\noctUV = (octUV + 1.0) / 2.0;\noctUV = (1.0 - 2.0 * texelSize) * octUV + texelSize;\nreturn octUV;\n}\n#if __VERSION__ == 100\nfloat cosh(float x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec2 cosh(vec2 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec3 cosh(vec3 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec4 cosh(vec4 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nfloat sinh(float x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec2 sinh(vec2 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec3 sinh(vec3 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec4 sinh(vec4 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nfloat tanh(float x) {\nfloat exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec2 tanh(vec2 x) {\nvec2 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec3 tanh(vec3 x) {\nvec3 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec4 tanh(vec4 x) {\nvec4 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nfloat trunc(float x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec2 trunc(vec2 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec3 trunc(vec3 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec4 trunc(vec4 x) {\nreturn floor(abs(x)) * sign(x);\n}\n#endif\nfloat getSmoothFactor(float a, float b, float smoothness) {\nreturn max(smoothness - abs(a - b), 0.0) / smoothness;\n}\nfloat smoothMin(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nfloat smoothMax(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nvec3 vec3RotateAxisAngle(vec3 vector, vec3 axis, float angle) {\nvec3 axisNorm = normalize(axis);\nfloat x = axisNorm.x, y = axisNorm.y, z = axisNorm.z;\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nx * x * (1.0 - c) + c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s,\nx * y * (1.0 - c) - z * s, y * y * (1.0 - c) + c, y * z * (1.0 - c) + x * s,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z * (1.0 - c) + c\n) * vector;\n}\nvec3 vec3RotateXAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\n1.0, 0.0, 0.0,\n0.0, c, s,\n0.0, -s, c\n) * vector;\n}\nvec3 vec3RotateYAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nc, 0.0, -s,\n0.0, 1.0, 0.0,\ns, 0.0, c\n) * vector;\n}\nvec3 vec3RotateZAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nc, s, 0.0,\n-s, c, 0.0,\n0.0, 0.0, 1.0\n) * vector;\n}\nvec4 eulerToAxisAngle(vec3 euler) {\nfloat c1 = cos(euler.x / 2.0), c2 = cos(euler.y / 2.0), c3 = cos(euler.z / 2.0);\nfloat s1 = sin(euler.x / 2.0), s2 = sin(euler.y / 2.0), s3 = sin(euler.z / 2.0);\nvec4 axisAngle = vec4(\ns1 * c2 * c3 - c1 * s2 * s3,\nc1 * s2 * c3 + s1 * c2 * s3,\nc1 * c2 * s3 - s1 * s2 * c3,\n2.0 * acos(c1 * c2 * c3 + s1 * s2 * s3)\n);\naxisAngle.xyz = length(axisAngle.xyz) > 0.0 ? normalize(axisAngle.xyz) : vec3(1.0, 0.0, 0.0);\nreturn axisAngle;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\nfloat getFace(vec3 direction) {\nvec3 absDirection = abs(direction);\nfloat face = -1.0;\nif (absDirection.x > absDirection.z) {\nif (absDirection.x > absDirection.y) {\nface = direction.x > 0.0 ? 0.0 : 3.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n} else {\nif (absDirection.z > absDirection.y) {\nface = direction.z > 0.0 ? 2.0 : 5.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n}\nreturn face;\n}\nvec2 getUV(vec3 direction, float face) {\nvec2 uv;\nif (face == 0.0) {\nuv = vec2(-direction.z, direction.y) / abs(direction.x);\n} else if (face == 1.0) {\nuv = vec2(direction.x, -direction.z) / abs(direction.y);\n} else if (face == 2.0) {\nuv = direction.xy / abs(direction.z);\n} else if (face == 3.0) {\nuv = vec2(direction.z, direction.y) / abs(direction.x);\n} else if (face == 4.0) {\nuv = direction.xz / abs(direction.y);\n} else {\nuv = vec2(-direction.x, direction.y) / abs(direction.z);\n}\nreturn 0.5 * (uv + 1.0);\n}\n#ifndef cubeUV_maxTileSize\n#define cubeUV_maxTileSize 256.0\n#endif\n#define cubeUV_lodIdxMin 0.0\n#define cubeUV_lodIdxLastDownscaled 4.0\n#define cubeUV_lodIdxMax 10.0\n#define cubeUV_minTileSize (cubeUV_maxTileSize / exp2(cubeUV_lodIdxLastDownscaled))\nfloat getLodTileSize(float lodIdx) {\nreturn cubeUV_maxTileSize / exp2(min(lodIdx, cubeUV_lodIdxLastDownscaled));\n}\nfloat getLodFilterLevel(float lodIdx) {\nreturn max(lodIdx - cubeUV_lodIdxLastDownscaled, 0.0);\n}\nvec2 fixCubeUVSeams(vec2 uv, float faceSize) {\nfloat BORDER_WIDTH_PX = max(cubeUV_maxTileSize / 256.0 - 1.0, 0.0);\nfloat scale = (faceSize - BORDER_WIDTH_PX) / faceSize;\nfloat offset = 0.5 * BORDER_WIDTH_PX / faceSize;\nreturn uv * scale + offset;\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat face = getFace(direction);\nfloat faceSize = getLodTileSize(lodIdx);\nfloat filterLevel = getLodFilterLevel(lodIdx);\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUV(direction, face);\nuv = fixCubeUVSeams(uv, faceSize);\nuv *= (faceSize - 1.0);\nvec2 f = fract(uv);\nuv += 0.5 - f;\nif (face > 2.0) {\nuv.y += faceSize;\nface -= 3.0;\n}\nuv.x += face * faceSize;\nif (lodIdx > 0.0) {\nuv.y += 2.0 * cubeUV_maxTileSize;\n}\nuv.y += filterLevel * 2.0 * cubeUV_minTileSize;\nuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\nuv *= texelSize;\nvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x += texelSize;\nvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.y += texelSize;\nvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x -= texelSize;\nvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nvec3 tm = mix(tl, tr, f.x);\nvec3 bm = mix(bl, br, f.x);\nreturn mix(tm, bm, f.y);\n}\n#define cubeUV_r0 1.0\n#define cubeUV_v0 0.339\n#define cubeUV_m0 -2.0\n#define cubeUV_r1 0.8\n#define cubeUV_v1 0.276\n#define cubeUV_m1 -1.0\n#define cubeUV_r4 0.4\n#define cubeUV_v4 0.046\n#define cubeUV_m4 2.0\n#define cubeUV_r5 0.305\n#define cubeUV_v5 0.016\n#define cubeUV_m5 3.0\n#define cubeUV_r6 0.21\n#define cubeUV_v6 0.0038\n#define cubeUV_m6 4.0\nfloat roughnessToMip(float roughness) {\nfloat r = roughness;\nfloat r2 = r * r;\nfloat r3 = r2 * r;\nroughness = -1.20278049 * r3 + 1.86860137 * r2 + 0.32478081 * r + 0.0098139;\nreturn roughness * (cubeUV_lodIdxMax - cubeUV_lodIdxMin);\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\nfloat lodIdx = clamp(roughnessToMip(roughness), cubeUV_lodIdxMin,\ncubeUV_lodIdxMax);\nfloat lodIdxF = fract(lodIdx);\nfloat lodIdxI = floor(lodIdx);\nvec3 color0 = bilinearCubeUV(envMap, sampleDir, lodIdxI);\nif (lodIdxF == 0.0) {\nreturn vec4(color0, 1.0);\n} else {\nvec3 color1 = bilinearCubeUV(envMap, sampleDir, lodIdxI + 1.0);\nreturn vec4(mix(color0, color1, lodIdxF), 1.0);\n}\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\ntransformedNormal = mat3(instanceMatrix) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\ntransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\nvec3 transformedTangent = (modelViewMatrix * vec4(objectTangent, 0.0)).xyz;\n#ifdef FLIP_SIDED\ntransformedTangent = - transformedTangent;\n#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\nuniform sampler2D displacementMap;\nuniform float displacementScale;\nuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\ntransformed += normalize(objectNormal) * (texture2D(displacementMap, vUv).x * displacementScale + displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\nvec4 emissiveColor = texture2D(emissiveMap, vUv);\nemissiveColor.rgb = emissiveMapTexelToLinear(emissiveColor).rgb;\ntotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\nuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"\nvec4 LinearToLinear(in vec4 value) {\nreturn value;\n}\nvec4 GammaToLinear(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(gammaFactor)), value.a);\n}\nvec4 LinearToGamma(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(1.0 / gammaFactor)), value.a);\n}\nvec4 sRGBToLinear(in vec4 value) {\nvalue = max(value, vec4(0.0));\nreturn vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.a);\n}\nvec4 LinearTosRGB(in vec4 value) {\nvalue = max(value, vec4(0.0));\nreturn vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.a);\n}\nvec4 RGBEToLinear(in vec4 value) {\nreturn vec4(value.rgb * exp2(value.a * 255.0 - 128.0), 1.0);\n}\nvec4 LinearToRGBE(in vec4 value) {\nfloat maxComponent = max(max(value.r, value.g), value.b);\nfloat fExp = clamp(ceil(log2(maxComponent)), -128.0, 127.0);\nreturn vec4(value.rgb / exp2(fExp), (fExp + 128.0) / 255.0);\n}\nvec4 RGBMToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * value.a * maxRange, 1.0);\n}\nvec4 LinearToRGBM(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat M = clamp(maxRGB / maxRange, 0.0, 1.0);\nM = ceil(M * 255.0) / 255.0;\nreturn vec4(value.rgb / (M * maxRange), M);\n}\nvec4 RGBDToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * ((maxRange / 255.0) / value.a), 1.0);\n}\nvec4 LinearToRGBD(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat D = max(maxRange / maxRGB, 1.0);\nD = clamp(floor(D) / 255.0, 0.0, 1.0);\nreturn vec4(value.rgb * (D * (255.0 / maxRange)), D);\n}\nconst mat3 cLogLuvM = mat3(0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969);\nvec4 LinearToLogLuv(in vec4 value) {\nvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\nXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\nvec4 vResult;\nvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\nfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\nvResult.w = fract(Le);\nvResult.z = (Le - (floor(vResult.w * 255.0)) / 255.0) / 255.0;\nreturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3(6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268);\nvec4 LogLuvToLinear(in vec4 value) {\nfloat Le = value.z * 255.0 + value.w;\nvec3 Xp_Y_XYZp;\nXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\nXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\nXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\nvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\nreturn vec4(max(vRGB, 0.0), 1.0);\n}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;\nif (isOrthographic) {\ncameraToFrag = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToFrag = normalize(vWorldPosition - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec = reflect(cameraToFrag, worldNormal);\n#else\nvec3 reflectVec = refract(cameraToFrag, worldNormal, refractionRatio);\n#endif\n#else\nvec3 reflectVec = vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor = textureCube(envMap, vec3(flipEnvMap * reflectVec.x, reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor = textureCubeUV(envMap, reflectVec, 0.0);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nreflectVec = normalize(reflectVec);\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.5;\nvec4 envColor = texture2D(envMap, sampleUV);\n#elif defined(ENVMAP_TYPE_SPHERE)\nreflectVec = normalize(reflectVec);\nvec3 reflectView = normalize((viewMatrix * vec4(reflectVec, 0.0)).xyz + vec3(0.0, 0.0, 1.0));\nvec4 envColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5);\n#else\nvec4 envColor = vec4(0.0);\n#endif\n#ifndef ENVMAP_TYPE_CUBE_UV\nenvColor = envMapTexelToLinear(envColor);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight = mix(outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight = mix(outgoingLight, envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight += envColor.xyz * specularStrength * reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;\nuniform float flipEnvMap;\nuniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#if defined(ENVMAP_TYPE_CUBE) && defined(NODE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat calcGeometryRoughness(vec3 geometryNormal) {\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nreturn max(max(dxy.x, dxy.y), dxy.z);\n}\nfloat calcCubeUVAdjustedRoughness(float origRoughness, float geomRoughness) {\nreturn min(max(origRoughness, 0.0525) + geomRoughness, 1.0);\n}\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) ||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\n\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;\nuniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel) {\nvec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, float(maxMIPLevel));\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, float(maxMIPLevel));\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec, 1.0);\n#else\nvec4 envMapColor = vec4(0.0);\n#endif\nreturn PI * envMapColor.rgb * envMapIntensity;\n}\nfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\nfloat maxMIPLevelScalar = float(maxMIPLevel);\nfloat clapmedBlinnShininessExponent = min(blinnShininessExponent, 30000.0);\nfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248\n- 0.5 * log2(pow2(clapmedBlinnShininessExponent) + 1.0);\nreturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n}\nvec3 _getLightProbeIndirect(const float blinnShininessExponent,\nconst int maxMIPLevel, vec3 directionVec) {\nfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, specularMIPLevel);\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec,\nBlinnExponentToGGXRoughness(blinnShininessExponent));\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nsampleUV.y = asin(clamp(directionVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(directionVec.z, directionVec.x) * RECIPROCAL_PI2 + 0.5;\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = texture2DLodEXT(envMap, sampleUV, specularMIPLevel);\n#else\nvec4 envMapColor = texture2D(envMap, sampleUV, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_SPHERE)\nvec3 reflectView = normalize((viewMatrix * vec4(directionVec, 0.0)).xyz + vec3(0.0,0.0,1.0));\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = texture2DLodEXT(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n#else\nvec4 envMapColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#endif\nreturn envMapColor.rgb * envMapIntensity;\n}\nvec3 getLightProbeIndirectRadiance(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 directionVec = reflect(-geometry.viewDir, normal);\n#else\nvec3 directionVec = refract(-geometry.viewDir, normal, refractionRatio);\n#endif\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\n}\nvec3 getLightProbeIndirectRefraction(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const float refrRatio) {\nvec3 directionVec = refract(-geometry.viewDir, geometry.normal, refrRatio);\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\n}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvWorldPosition = worldPosition.xyz;\n#else\nvec3 cameraToVertex;\nif (isOrthographic) { \ncameraToVertex = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToVertex = normalize(worldPosition.xyz - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvReflect = reflect(cameraToVertex, worldNormal);\n#else\nvReflect = refract(cameraToVertex, worldNormal, refractionRatio);\n#endif\n#endif\n#endif",fog_vertex:"#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor = 1.0 - exp(- fogDensity * fogDensity * fogDepth * fogDepth);\n#else\nfloat fogFactor = smoothstep(fogNear, fogFar, fogDepth);\n#endif\ngl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\nvarying float fogDepth;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\nuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance(vec3 normal, vec3 lightDirection) {\nfloat dotNL = dot(normal, lightDirection);\nvec2 coord = vec2(dotNL * 0.5 + 0.5, 0.0);\n#ifdef USE_GRADIENTMAP\nreturn texture2D(gradientMap, coord).rgb;\n#else\nreturn (coord.x < 0.7) ? vec3(0.7) : vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += PI * lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;\nuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3(1.0);\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize(transformedNormal);\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(-mvPosition.xyz);\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3(0.0);\nvIndirectFront = vec3(0.0);\n#ifdef DOUBLE_SIDED\nvLightBack = vec3(0.0);\nvIndirectBack = vec3(0.0);\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(pointLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_DIR_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nvIndirectFront += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack += getHemisphereLightIrradiance(hemisphereLights[i], backGeometry);\n#endif\n}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[9];\nvec3 shGetIrradianceAt(in vec3 normal, in vec3 shCoefficients[9]) {\nfloat x = normal.x, y = normal.y, z = normal.z;\nvec3 result = shCoefficients[0] * 0.886227;\nresult += shCoefficients[1] * 2.0 * 0.511664 * y;\nresult += shCoefficients[2] * 2.0 * 0.511664 * z;\nresult += shCoefficients[3] * 2.0 * 0.511664 * x;\nresult += shCoefficients[4] * 2.0 * 0.429043 * x * y;\nresult += shCoefficients[5] * 2.0 * 0.429043 * y * z;\nresult += shCoefficients[6] * (0.743125 * z * z - 0.247708);\nresult += shCoefficients[7] * 2.0 * 0.429043 * x * z;\nresult += shCoefficients[8] * 0.429043 * (x * x - y * y);\nreturn result;\n}\nvec3 getLightProbeIrradiance(const in vec3 lightProbe[9], const in GeometricContext geometry) {\nvec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\nvec3 irradiance = shGetIrradianceAt(worldNormal, lightProbe);\nreturn irradiance;\n}\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\nvec3 irradiance = ambientLightColor;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\nstruct DirectionalLight {\nvec3 direction;\nvec3 color;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat maxDistance;\nfloat expBias;\nfloat shadowCameraNear;\n};\nuniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];\nvoid getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight) {\ndirectLight.color = directionalLight.color;\ndirectLight.direction = directionalLight.direction;\ndirectLight.visible = true;\n}\n#endif\n#if NUM_POINT_LIGHTS > 0\nstruct PointLight {\nvec3 position;\nvec3 color;\nfloat distance;\nfloat decay;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLight pointLights[NUM_POINT_LIGHTS];\nvoid getPointDirectLightIrradiance(const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = pointLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\ndirectLight.color = pointLight.color;\ndirectLight.color *= punctualLightIntensityToIrradianceFactor(lightDistance, pointLight.distance, pointLight.decay);\ndirectLight.visible = (directLight.color != vec3(0.0));\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\nstruct SpotLight {\nvec3 position;\nvec3 direction;\nvec3 color;\nfloat distance;\nfloat decay;\nfloat coneCos;\nfloat penumbraCos;\nint shadow;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLight spotLights[NUM_SPOT_LIGHTS];\nvoid getSpotDirectLightIrradiance(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = spotLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\nfloat angleCos = dot(directLight.direction, spotLight.direction);\n#if defined(MT_MAX) && defined(PHYSICALLY_CORRECT_LIGHTS)\nfloat coneCosDecayed = 2.0 * spotLight.coneCos - spotLight.penumbraCos;\nif (angleCos > coneCosDecayed) {\nfloat spotEffect = pow(max(angleCos, 0.0), log(0.5) / log(spotLight.penumbraCos) - 1.0);\nif (angleCos < spotLight.coneCos) {\nfloat decayFac = 1.0 + (spotLight.coneCos - angleCos)\n/ (spotLight.coneCos - spotLight.penumbraCos);\nspotEffect *= pow2(decayFac) * (3.0 - 2.0 * decayFac);\n}\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.visible = false;\n}\n#else\nif (angleCos > spotLight.coneCos) {\nfloat spotEffect = smoothstep(spotLight.coneCos, spotLight.penumbraCos, angleCos);\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.visible = false;\n}\n#endif\n}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\nstruct RectAreaLight {\nvec3 color;\nvec3 position;\nvec3 halfWidth;\nvec3 halfHeight;\n};\nuniform sampler2D ltc_1;\nuniform sampler2D ltc_2;\nuniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS > 0\nstruct HemisphereLight {\nvec3 direction;\nvec3 skyColor;\nvec3 groundColor;\n};\nuniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];\nvec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight, const in GeometricContext geometry) {\nfloat dotNL = dot(geometry.normal, hemiLight.direction);\nfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\nvec3 irradiance = mix(hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight);\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn irradiance;\n}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nfloat specularShininess;\nfloat specularStrength;\n};\nvoid RE_Direct_Toon(const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\nvec3 irradiance = getGradientIrradiance(geometry.normal, directLight.direction) * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(directLight, geometry, material.specularColor, material.specularShininess) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon(const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material) (0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nfloat specularShininess;\nfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong(const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(directLight, geometry, material.specularColor, material.specularShininess) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material) (0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * (1.0 - metalnessFactor);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(roughnessFactor, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\n#ifdef REFLECTIVITY\nmaterial.specularColor = mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity)), diffuseColor.rgb, metalnessFactor);\n#else\nmaterial.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), diffuseColor.rgb, metalnessFactor);\n#endif\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = max(clearcoatRoughness, 0.0525);\nmaterial.clearcoatRoughness += geometryRoughness;\nmaterial.clearcoatRoughness = min(material.clearcoatRoughness, 1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\nvec3 diffuseColor;\nfloat specularRoughness;\nvec3 specularColor;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\nreturn DEFAULT_SPECULAR_COEFFICIENT + (1.0 - DEFAULT_SPECULAR_COEFFICIENT) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n}\n#if NUM_RECT_AREA_LIGHTS > 0\nvoid RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.specularRoughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_Sheen(\nmaterial.specularRoughness,\ndirectLight.direction,\ngeometry,\nmaterial.sheenColor\n);\n#else\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n#endif\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Physical(const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n#ifdef CLEARCOAT\nfloat ccDotNV = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\nfloat ccDotNL = ccDotNV;\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nfloat clearcoatInv = 1.0 - clearcoatDHR;\nvec3 singleScattering = vec3(0.0);\nvec3 multiScattering = vec3(0.0);\nvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\nBRDF_Specular_Multiscattering_Environment(geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering);\nvec3 diffuse = material.diffuseColor * (1.0 - (singleScattering + multiScattering));\nreflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\nreflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\nreflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(vViewPosition);\n#if defined(CLEARCOAT)\ngeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && defined(RE_Direct)\nPointLight pointLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\npointLight = pointLights[i];\ngetPointDirectLightIrradiance(pointLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_POINT_LIGHT_SHADOWS)\ndirectLight.color *= all(bvec2(directLight.visible, receiveShadow)) ?\ngetPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && defined(RE_Direct)\nSpotLight spotLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\nspotLight = spotLights[i];\ngetSpotDirectLightIrradiance(spotLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_SPOT_LIGHT_SHADOWS)\nif (all(bvec2(directLight.visible, receiveShadow))) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= getSpotShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i], distWorld);\n} else if (spotLight.shadow == 2) {\ndirectLight.color *= getSpotOmniShadow(spotLight,\nspotShadowMap[i], vSpotShadowCoord[i]);\n}\n}\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_DIR_LIGHTS > 0) && defined(RE_Direct)\nDirectionalLight directionalLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ndirectionalLight = directionalLights[i];\ngetDirectionalDirectLightIrradiance(directionalLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_DIR_LIGHT_SHADOWS)\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n- directionalLight.direction * directionalLight.shadowCameraNear\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLight.maxDistance))\n? getDirShadow(directionalLight, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_RECT_AREA_LIGHTS > 0) && defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_RECT_AREA_LIGHTS; i++) {\nrectAreaLight = rectAreaLights[i];\nRE_Direct_RectArea(rectAreaLight, geometry, material, reflectedLight);\n}\n#endif\n#if defined(RE_IndirectDiffuse)\nvec3 iblIrradiance = vec3(0.0);\nvec3 irradiance = getAmbientLightIrradiance(ambientLightColor);\nirradiance += getLightProbeIrradiance(lightProbe, geometry);\n#if (NUM_HEMI_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nirradiance += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n#if defined(MT_BLENDER) && !defined(PHYSICAL)\nRE_HemiSpec_Blender(hemisphereLights[i], geometry, material, reflectedLight);\n#endif\n}\n#endif\n#endif\n#if defined(RE_IndirectSpecular)\nvec3 radiance = vec3(0.0);\nvec3 clearcoatRadiance = vec3(0.0);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nvec3 refraction = vec3(0.0);\n#endif",lights_fragment_maps:"#if defined(RE_IndirectDiffuse)\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nvec3 lightMapIrradiance = lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nlightMapIrradiance *= PI;\n#endif\nirradiance += lightMapIrradiance;\n#endif\n#if defined(USE_ENVMAP) && defined(STANDARD) && defined(ENVMAP_TYPE_CUBE_UV)\niblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_IndirectSpecular)\nradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent(material), maxMipLevel, 0);\n#if defined(USE_SSR) && !defined(USE_SSR_REFRACT)\nradiance = computeSSR(radiance, geometry.normal, 0.0);\n#endif\n#ifdef CLEARCOAT\nclearcoatRadiance += getLightProbeIndirectRadiance(geometry, Material_ClearCoat_BlinnShininessExponent(material), maxMipLevel, 1);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nrefraction += getLightProbeIndirectRefraction(geometry,\nMaterial_Refraction_BlinnShininessExponent(material), maxMipLevel,\n1.0 / material.refractionIOR);\n#ifdef USE_SSR_REFRACT\nrefraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n#endif\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\nRE_IndirectDiffuse(irradiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_IndirectSpecular)\nRE_IndirectSpecular(radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nRE_Refraction(refraction, material, refractedLight);\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\ngl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\nuniform float logDepthBufFC;\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#else\nuniform float logDepthBufFC;\n#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvFragDepth = 1.0 + gl_Position.w;\nvIsPerspective = float(isPerspectiveMatrix(projectionMatrix));\n#else\nif (isPerspectiveMatrix(projectionMatrix)) {\ngl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\ngl_Position.z *= gl_Position.w;\n}\n#endif\n#endif",map_fragment:"#ifdef USE_MAP\nvec4 texelColor = texture2D(map, vUv);\ntexelColor = mapTexelToLinear(texelColor);\ndiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nvec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1)).xy;\n#endif\n#ifdef USE_MAP\nvec4 mapTexel = texture2D(map, uv);\ndiffuseColor *= mapTexelToLinear(mapTexel);\n#endif\n#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, uv).g;\n#endif",map_particle_pars_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\nvec4 texelMetalness = texture2D(metalnessMap, vUv);\nmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\nuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 0\nobjectNormal += (morphNormal0 - normal) * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\nobjectNormal += (morphNormal1 - normal) * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\nobjectNormal += (morphNormal2 - normal) * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\nobjectNormal += (morphNormal3 - normal) * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\nobjectNormal += (morphNormal4 - normal) * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\nobjectNormal += (morphNormal5 - normal) * morphTargetInfluences[5];\n#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetBaseInfluence;\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[12];\n#else\nuniform float morphTargetInfluences[6];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\ntransformed *= morphTargetBaseInfluence;\n#if NUM_MORPH_TARGETS > 0\ntransformed += morphTarget0 * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\ntransformed += morphTarget1 * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\ntransformed += morphTarget2 * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\ntransformed += morphTarget3 * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\ntransformed += morphTarget4 * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\ntransformed += morphTarget5 * morphTargetInfluences[5];\n#endif\n#ifndef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 6\ntransformed += morphTarget6 * morphTargetInfluences[6];\n#endif\n#if NUM_MORPH_TARGETS > 7\ntransformed += morphTarget7 * morphTargetInfluences[7];\n#endif\n#if NUM_MORPH_TARGETS > 8\ntransformed += morphTarget8 * morphTargetInfluences[8];\n#endif\n#if NUM_MORPH_TARGETS > 9\ntransformed += morphTarget9 * morphTargetInfluences[9];\n#endif\n#if NUM_MORPH_TARGETS > 10\ntransformed += morphTarget10 * morphTargetInfluences[10];\n#endif\n#if NUM_MORPH_TARGETS > 11\ntransformed += morphTarget1 * morphTargetInfluences[11];\n#endif\n#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\nvec3 fdx = vec3(dFdx(vViewPosition.x), dFdx(vViewPosition.y), dFdx(vViewPosition.z));\nvec3 fdy = vec3(dFdy(vViewPosition.x), dFdy(vViewPosition.y), dFdy(vViewPosition.z));\nvec3 normal = normalize(cross(fdx, fdy));\n#else\nvec3 normal = normalize(vNormal);\n#ifdef DOUBLE_SIDED\n#ifdef FRONT_FACING_VALUE\nbool frontFacing = FRONT_FACING_VALUE;\n#else\nbool frontFacing = gl_FrontFacing;\n#endif\nnormal = normal * (float(frontFacing) * 2.0 - 1.0);\n#endif\n#ifdef USE_TANGENT\nvec3 tangent = normalize(vTangent);\nvec3 bitangent = normalize(vBitangent);\n#ifdef DOUBLE_SIDED\ntangent = tangent * (float(gl_FrontFacing) * 2.0 - 1.0);\nbitangent = bitangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\n#if defined(TANGENTSPACE_NORMALMAP) || defined(USE_CLEARCOAT_NORMALMAP)\nmat3 vTBN = mat3(tangent, bitangent, normal);\n#endif\n#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\nnormal = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n#ifdef FLIP_SIDED\nnormal = - normal;\n#endif\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nnormal = normalize(normalMatrix * normal);\n#elif defined(TANGENTSPACE_NORMALMAP)\nvec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\nmapN.xy *= normalScale;\n#ifdef USE_TANGENT\nnormal = normalize(vTBN * mapN);\n#else\nnormal = perturbNormal2Arb(-vViewPosition, normal, mapN);\n#endif\n#elif defined(USE_BUMPMAP)\nnormal = perturbNormalArb(-vViewPosition, normal, dHdxy_fwd());\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat3 normalMatrix;\n#endif\n#if !defined (USE_TANGENT) && (defined (TANGENTSPACE_NORMALMAP) || defined (USE_CLEARCOAT_NORMALMAP))\nvec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm, vec3 mapN) {\nvec3 q0 = vec3(dFdx(eye_pos.x), dFdx(eye_pos.y), dFdx(eye_pos.z));\nvec3 q1 = vec3(dFdy(eye_pos.x), dFdy(eye_pos.y), dFdy(eye_pos.z));\nvec2 st0 = dFdx(vUv.st);\nvec2 st1 = dFdy(vUv.st);\nfloat scale = sign(st1.t * st0.s - st0.t * st1.s);\nvec3 S = normalize((q0 * st1.t - q1 * st0.t) * scale);\nvec3 T = normalize((- q0 * st1.s + q1 * st0.s) * scale);\nvec3 N = normalize(surf_norm);\nmat3 tsn = mat3(S, T, N);\nmapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\nreturn normalize(tsn * mapN);\n}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\nvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\nvec3 clearcoatMapN = texture2D(clearcoatNormalMap, vUv).xyz * 2.0 - 1.0;\nclearcoatMapN.xy *= clearcoatNormalScale;\n#ifdef USE_TANGENT\nclearcoatNormal = normalize(vTBN * clearcoatMapN);\n#else\nclearcoatNormal = perturbNormal2Arb(- vViewPosition, clearcoatNormal, clearcoatMapN);\n#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\nuniform sampler2D clearcoatNormalMap;\nuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB(const in vec3 normal) {\nreturn normalize(normal) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal(const in vec3 rgb) {\nreturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;\nconst float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.);\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA(const in float v) {\nvec4 r = vec4(fract(v * PackFactors), v);\nr.yzw -= r.xyz * ShiftRight8;\nreturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\nreturn dot(v, UnpackFactors);\n}\nvec4 pack2HalfToRGBA(vec2 v) {\nvec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0));\nreturn vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half(vec4 v) {\nreturn vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0));\n}\nfloat viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) {\nreturn (viewZ + near) / (near - far);\n}\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\nreturn linearClipZ * (near - far) - near;\n}\nfloat viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) {\nreturn ((near + viewZ) * far) / ((far - near) * viewZ);\n}\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\nreturn (near * far) / ((far - near) * invClipZ - far);\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\ngl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\ngl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#ifdef DITHERING\ngl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#ifdef DITHERING\nvec3 dithering(vec3 color) {\nfloat grid_position = rand(gl_FragCoord.xy);\nvec3 dither_shift_RGB = vec3(0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0);\ndither_shift_RGB = mix(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);\nreturn color + dither_shift_RGB;\n}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\nvec4 texelRoughness = texture2D(roughnessMap, vUv);\nroughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\nuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"\n#define BIAS_FRUSTUM_SCALE_COEFF 30.0\n#define ESM_SPOT_SINGLE_BLUR_COEFF 0.25\n#define PCF_POISSON_SPOT_OMNI_BLUR_COEFF 4.0\n#define PCF_POISSON_POINT_BLUR_COEFF 2.5\n#define PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF 0.5\n#define ESM_BIAS_COEFF 100.0\n#ifndef ESM_DISTANCE_SCALE\n#define ESM_DISTANCE_SCALE 1.0\n#endif\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\n#endif\nconst vec3 PERMUTE_DIR_X = vec3(1.0, 0.0, 0.0);\nconst vec3 PERMUTE_DIR_Y = vec3(0.0, 1.0, 0.0);\nconst vec3 PERMUTE_DIR_Z = vec3(0.0, 0.0, 1.0);\nconst mat4 POISSON_DISK_0 = mat4(\n0.954845, 0.242214, -0.623893, -0.235473,\n-0.173288, 0.799228, 0.605969, -0.548050,\n-0.560406, 0.327647, -0.448307, -0.774344,\n0.308258, 0.417332, -0.125623, -0.056098\n);\nconst mat4 POISSON_DISK_1 = mat4(\n0.145585, -0.305634, 0.264060, -0.661648,\n0.617942, 0.652121, -0.041412, -0.893582,\n0.463911, 0.039752, 0.212664, 0.810727,\n-0.955989, -0.014390, -0.652588, 0.671204\n);\nfloat texture2DCompare(sampler2D depths, vec2 uv, float compare) {\nreturn step(compare, unpackRGBAToDepth(texture2D(depths, uv)));\n}\nfloat texture2DShadowLerp(sampler2D depths, vec2 size, vec2 uv, float compare) {\nconst vec2 offset = vec2(0.0, 1.0);\nvec2 texelSize = vec2(1.0) / size;\nvec2 centroidUV = floor(uv * size + 0.5) / size;\nfloat lb = texture2DCompare(depths, centroidUV + texelSize * offset.xx, compare);\nfloat lt = texture2DCompare(depths, centroidUV + texelSize * offset.xy, compare);\nfloat rb = texture2DCompare(depths, centroidUV + texelSize * offset.yx, compare);\nfloat rt = texture2DCompare(depths, centroidUV + texelSize * offset.yy, compare);\nvec2 f = fract(uv * size + 0.5);\nfloat a = mix(lb, lt, f.y);\nfloat b = mix(rb, rt, f.y);\nfloat c = mix(a, b, f.x);\nreturn c;\n}\nvec2 cubeToUV(vec3 v, float texelSizeY) {\nvec3 absV = abs(v);\nfloat scaleToCube = 1.0 / max(absV.x, max(absV.y, absV.z));\nabsV *= scaleToCube;\nv *= scaleToCube * (1.0 - 2.0 * texelSizeY);\nvec2 planar = v.xy;\nfloat almostATexel = 1.5 * texelSizeY;\nfloat almostOne = 1.0 - almostATexel;\nif (absV.z >= almostOne) {\nif (v.z > 0.0)\nplanar.x = 4.0 - v.x;\n} else if (absV.x >= almostOne) {\nfloat signX = sign(v.x);\nplanar.x = v.z * signX + 2.0 * signX;\n} else if (absV.y >= almostOne) {\nfloat signY = sign(v.y);\nplanar.x = v.x + 2.0 * signY + 2.0;\nplanar.y = v.z * signY - 2.0;\n}\nreturn vec2(0.125, 0.25) * planar + vec2(0.375, 0.75);\n}\nfloat texture2DShadowAvgCube(sampler2D depths, vec2 size, vec3 bd3D, float compare) {\nvec2 texelSize = vec2(1.0) / size;\nvec3 dirX = normalize(abs(bd3D.y) < 0.99999 ? vec3(bd3D.z, 0.0, -bd3D.x)\n: vec3(0.0, -bd3D.z, bd3D.y));\nvec3 dirY = cross(bd3D, dirX);\nfloat theta = PI_HALF * texelSize.y;\nvec3 sX = sin(theta) * dirX;\nvec3 sY = sin(theta) * dirY;\nfloat cosT = cos(theta);\nvec3 lbVec = bd3D;\nvec3 ltVec = bd3D * cosT + sY;\nvec3 rbVec = bd3D * cosT + sX;\nvec3 rtVec = rbVec * cosT + sY;\nfloat lb = texture2DCompare(depths, cubeToUV(lbVec, texelSize.y), compare);\nfloat lt = texture2DCompare(depths, cubeToUV(ltVec, texelSize.y), compare);\nfloat rb = texture2DCompare(depths, cubeToUV(rbVec, texelSize.y), compare);\nfloat rt = texture2DCompare(depths, cubeToUV(rtVec, texelSize.y), compare);\nreturn (lb + lt + rb + rt) / 4.0;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord, float distWorld) {\nfloat shadow = 1.0;\nshadowCoord.xyz /= shadowCoord.w;\nbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\nbool inFrustum = all(inFrustumVec);\nbvec3 frustumTestVec = bvec3(inFrustum, shadowCoord.z <= 1.0, shadowCoord.z >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadowCoord.z += shadowBias;\nshadow = texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy, shadowCoord.z);\n#elif defined(SHADOWMAP_TYPE_PCF)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nshadow = (\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nshadow = (\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.x, 0.0, 0.0, shadowRadius * texelSize.y);\nshadow = (\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].zw, shadowCoord.z)\n) / 16.0;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n- length(distWorld) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#else\nshadowCoord.z += shadowBias;\nshadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n#endif\n}\nreturn shadow;\n}\nfloat getOmniShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord,\nfloat shadowCameraNear, float shadowCameraFar) {\nfloat shadow = 1.0;\nvec3 lightToPosition = shadowCoord.xyz;\nfloat dp = (length(lightToPosition) - shadowCameraNear)\n/ (shadowCameraFar - shadowCameraNear);\nbvec2 frustumTestVec = bvec2(dp <= 1.0, dp >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\nfloat biasScaleCoeff = BIAS_FRUSTUM_SCALE_COEFF\n/ (shadowCameraFar - shadowCameraNear);\ndp += shadowBias * biasScaleCoeff;\nvec3 bd3D = normalize(lightToPosition);\nvec2 texelSize = 1.0 / shadowMapSize;\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadow = texture2DShadowAvgCube(shadowMap, shadowMapSize, bd3D, dp);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap,\ncubeVecToOctUV(bd3D, texelSize)).x\n- length(lightToPosition) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\nshadow = (\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxx, texelSize.y), dp)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.y, 0.0, 0.0, shadowRadius * texelSize.y);\nvec3 absBd3D = abs(bd3D);\nabsBd3D /= max(absBd3D.x, max(absBd3D.y, absBd3D.z));\nbvec2 isPointingCubeFace = greaterThan(absBd3D.xy, vec2(0.999));\nmat3 permuteMat = mat3(\nisPointingCubeFace.x ? PERMUTE_DIR_Y : PERMUTE_DIR_X,\nisPointingCubeFace.x || isPointingCubeFace.y ? PERMUTE_DIR_Z : PERMUTE_DIR_Y,\nisPointingCubeFace.x ? PERMUTE_DIR_X : isPointingCubeFace.y ? PERMUTE_DIR_Y : PERMUTE_DIR_Z\n);\nshadow = (\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].zw, 0.0), texelSize.y), dp)\n) / 16.0;\n#else\nshadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n#endif\n}\nreturn shadow;\n}\n#if NUM_DIR_LIGHT_SHADOWS > 0\nfloat getDirShadow(DirectionalLight light, sampler2D shadowMap,\nvec4 shadowCoord, float distWorld) {\nfloat shadowRadius = light.shadowRadius;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, light.shadowBias,\nlight.expBias, shadowRadius, shadowCoord, distWorld);\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nfloat getPointShadow(PointLight light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nfloat getSpotOmniShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_SPOT_OMNI_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\nfloat biasLinearNormalizedToNonlinear(float bias, float near, float far,\nfloat projZ, float projW) {\nreturn (bias * (far + near) + 2.0 * projZ) / (bias * (far - near) + 2.0 * projW)\n- projZ / projW;\n}\nfloat getSpotShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord,\nfloat distWorld) {\nfloat shadowRadius = light.shadowRadius;\nfloat shadowBias = light.shadowBias;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadowRadius *= ESM_SPOT_SINGLE_BLUR_COEFF;\n#endif\nshadowBias *= BIAS_FRUSTUM_SCALE_COEFF\n/ (light.shadowCameraFar - light.shadowCameraNear);\n#if defined(SHADOWMAP_TYPE_BASIC) || defined(SHADOWMAP_TYPE_BILINEAR) || defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT) || defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowBias = biasLinearNormalizedToNonlinear(shadowBias,\nlight.shadowCameraNear, light.shadowCameraFar, shadowCoord.z,\nshadowCoord.w);\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, shadowBias,\nlight.expBias, shadowRadius, shadowCoord, distWorld);\n}\n#endif\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\nvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * worldPosition;\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nvSpotShadowCoord[i] = spotShadowMatrix[i] * worldPosition;\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\nvPointShadowCoord[i] = pointShadowMatrix[i] * worldPosition;\n}\n#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\nfloat shadow = 1.0;\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLight directionalLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\ndirectionalLight = directionalLights[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n- directionalLight.direction * directionalLight.shadowCameraNear\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= all(bvec2(vViewPosition.z < directionalLight.maxDistance,\nreceiveShadow)) ? getDirShadow(directionalLight,\ndirectionalShadowMap[i], vDirectionalShadowCoord[i], distWorld)\n: 1.0;\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLight spotLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nspotLight = spotLights[i];\nif (receiveShadow) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= getSpotShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i],\ndistWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i]);\n}\n}\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nPointLight pointLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\npointLight = pointLights[i];\nshadow *= receiveShadow ? getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n}\n#endif\n#endif\nreturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix(skinIndex.x);\nmat4 boneMatY = getBoneMatrix(skinIndex.y);\nmat4 boneMatZ = getBoneMatrix(skinIndex.z);\nmat4 boneMatW = getBoneMatrix(skinIndex.w);\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 bindMatrix;\nuniform mat4 bindMatrixInverse;\n#ifdef BONE_TEXTURE\nuniform highp sampler2D boneTexture;\nuniform int boneTextureSize;\nmat4 getBoneMatrix(const in float i) {\nfloat j = i * 4.0;\nfloat x = mod(j, float(boneTextureSize));\nfloat y = floor(j / float(boneTextureSize));\nfloat dx = 1.0 / float(boneTextureSize);\nfloat dy = 1.0 / float(boneTextureSize);\ny = dy * (y + 0.5);\nvec4 v1 = texture2D(boneTexture, vec2(dx * (x + 0.5), y));\nvec4 v2 = texture2D(boneTexture, vec2(dx * (x + 1.5), y));\nvec4 v3 = texture2D(boneTexture, vec2(dx * (x + 2.5), y));\nvec4 v4 = texture2D(boneTexture, vec2(dx * (x + 3.5), y));\nmat4 bone = mat4(v1, v2, v3, v4);\nreturn bone;\n}\n#else\nuniform mat4 boneMatrices[MAX_BONES];\nmat4 getBoneMatrix(const in float i) {\nmat4 bone = boneMatrices[int(i)];\nreturn bone;\n}\n#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\nvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\nvec4 skinned = vec4(0.0);\nskinned += boneMatX * skinVertex * skinWeight.x;\nskinned += boneMatY * skinVertex * skinWeight.y;\nskinned += boneMatZ * skinVertex * skinWeight.z;\nskinned += boneMatW * skinVertex * skinWeight.w;\ntransformed = (bindMatrixInverse * skinned).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = mat4(0.0);\nskinMatrix += skinWeight.x * boneMatX;\nskinMatrix += skinWeight.y * boneMatY;\nskinMatrix += skinWeight.z * boneMatZ;\nskinMatrix += skinWeight.w * boneMatW;\nskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\nobjectNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;\n#ifdef USE_TANGENT\nobjectTangent = vec4(skinMatrix * vec4(objectTangent, 0.0)).xyz;\n#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D(specularMap, vUv);\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined(TONE_MAPPING)\ngl_FragColor.rgb = toneMapping(gl_FragColor.rgb);\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#ifndef PI\n#define PI 3.14159265359\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingMidTones;\nuniform float toneMappingPhysicalScale;\nuniform float toneMappingWhitePoint;\nuniform float toneMappingBrightness;\nuniform float toneMappingContrast;\nuniform bool toneMappingChromaticAdaptation;\nuniform vec3 toneMappingWhiteColor;\nuniform bool toneMappingColorDifferentiation;\nuniform bool toneMappingExteriorDaylight;\nuniform vec3 toneMappingWhiteBalance;\nuniform float toneMappingHighlights;\nuniform float toneMappingShadows;\nuniform float toneMappingSaturation;\nuniform float toneMappingAperture;\nuniform float toneMappingShutter;\nuniform float toneMappingISO;\nuniform float toneMappingVignetting;\nuniform vec2 toneMappingResolution;\nconst float FILMIC_BLENDER_LOG_MIN = -12.473931188;\nconst float FILMIC_BLENDER_LOG_MAX = 12.526068812;\nconst float FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO = 0.66;\nvec3 LinearToneMapping(vec3 color) {\nreturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn saturate(color / (vec3(1.0) + color));\n}\n#define Uncharted2Helper(x) max(((x * (0.15 * x + 0.10 * 0.50) + 0.20 * 0.02) / (x * (0.15 * x + 0.50) + 0.20 * 0.30)) - 0.02 / 0.30, vec3(0.0))\nvec3 Uncharted2ToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn saturate(Uncharted2Helper(color) / Uncharted2Helper(vec3(toneMappingWhitePoint)));\n}\nvec3 OptimizedCineonToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(vec3(0.0), color - 0.004);\nreturn pow((color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06), vec3(2.2));\n}\nvec3 ACESFilmicToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn saturate((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14));\n}\n#define ORDERS_OF_MAG 5.0\nfloat toneCalcBrightness(in vec3 color)\n{\nreturn (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082);\n}\nfloat toneApproximateScotopicLuminance(vec3 color)\n{\nreturn (0.062 * color.r + 0.608 * color.g + 0.330 * color.b);\n}\nvec3 LogarithmicMaxToneMapping(vec3 color) {\nfloat inputScaleFactor = toneMappingPhysicalScale / PI;\nfloat brightness = (toneMappingBrightness < 0.0) ? 0.0 : (toneMappingBrightness * 0.7);\nfloat powerBot = toneMappingExteriorDaylight ? 4.0 : 2.0;\nfloat res = 100.0 / ORDERS_OF_MAG;\nfloat mag = floor((50.0 / res));\nfloat power = ((brightness / 20.0 - ORDERS_OF_MAG) - powerBot) + mag;\nfloat stepsize = 9.0 / res;\nfloat step = 50.0 - (mag * res);\nfloat param_c = (0.02 * toneMappingContrast) * 2.0;\nfloat param_b = pow(10.0, power) * (1.0 + (stepsize * step));\nfloat param_a = param_b * (1.0 + param_c);\nparam_c /= pow(2.0, toneMappingMidTones - 1.0);\nparam_b *= PI;\nvec3 whiteConstancyFactor = toneMappingWhiteColor;\nif (toneMappingChromaticAdaptation) {\nfloat luminance = toneCalcBrightness(whiteConstancyFactor);\nwhiteConstancyFactor.r = (whiteConstancyFactor.r > 0.001) ? luminance / whiteConstancyFactor.r : luminance / 0.001;\nwhiteConstancyFactor.g = (whiteConstancyFactor.g > 0.001) ? luminance / whiteConstancyFactor.g : luminance / 0.001;\nwhiteConstancyFactor.b = (whiteConstancyFactor.b > 0.001) ? luminance / whiteConstancyFactor.b : luminance / 0.001;\n}\nvec3 outColor = inputScaleFactor * color;\nif (toneMappingChromaticAdaptation) {\noutColor *= whiteConstancyFactor.rgb;\n}\nfloat luminance = toneCalcBrightness(outColor);\nif (toneMappingColorDifferentiation && (luminance < 5.62)) {\nfloat sLuminance = toneApproximateScotopicLuminance(outColor);\nif (luminance <= 5.62e-3) {\noutColor = vec3(sLuminance);\n} else {\nfloat w = (luminance - 5.62e-3) / 5.61438;\noutColor = outColor * w + sLuminance * (1.0 - w);\n}\n}\noutColor = outColor * (param_a / (param_b * outColor + param_c));\nreturn outColor;\n}\nfloat maxExposurePhotographic(in vec4 color1, in vec4 color2)\n{\nreturn ((color1.r * color2.r) + (color1.g * color2.g)) + (color1.b * color2.b);\n}\nvec3 PhysicalMaxToneMapping(vec3 color) {\nfloat vignettingInfluence = 1.0;\nif (toneMappingVignetting > 0.0) {\nvec3 vignettingCoords = vec3(0.0, 0.0, 0.0);\nfloat aspect = toneMappingResolution.x / toneMappingResolution.y;\nvignettingCoords.x = gl_FragCoord.x / toneMappingResolution.x - 0.5;\nvignettingCoords.y = (gl_FragCoord.y / toneMappingResolution.y - 0.5) / aspect;\nvignettingCoords.z = 1.0;\nvignettingCoords = normalize(vignettingCoords);\nvignettingInfluence = pow(vignettingCoords.z, toneMappingVignetting);\n}\nfloat inputScaleFactor = toneMappingPhysicalScale / PI;\nfloat filmISO = toneMappingISO;\nfloat camShutter = 1.0 / toneMappingShutter;\nfloat fNumber = toneMappingAperture;\nfloat cm2 = 1.0;\nfloat burnHighlights = toneMappingHighlights;\nfloat crushBlacks = toneMappingShadows;\nfloat saturation = toneMappingSaturation;\nvec3 whitePointInfluence = toneMappingWhiteBalance;\nif (whitePointInfluence.r > 0.0) {\nwhitePointInfluence.r = 1.0 / whitePointInfluence.r;\n} else {\nwhitePointInfluence.r = 1.0;\n}\nif (whitePointInfluence.g > 0.0) {\nwhitePointInfluence.g = 1.0 / whitePointInfluence.g;\n} else {\nwhitePointInfluence.g = 1.0;\n}\nif (whitePointInfluence.b > 0.0) {\nwhitePointInfluence.b = 1.0 / whitePointInfluence.b;\n} else {\nwhitePointInfluence.b = 1.0;\n}\nvec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0);\nfloat whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0));\nwhitePointInfluence.r /= whiteLumFactor;\nwhitePointInfluence.g /= whiteLumFactor;\nwhitePointInfluence.b /= whiteLumFactor;\nfloat isoInfluence = 0.0;\nfloat camShutterInv = 1.0 / camShutter;\nif (filmISO > 0.0) {\nisoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber);\n} else {\nisoInfluence = cm2;\n}\nvec3 outColor = inputScaleFactor * color;\noutColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence;\noutColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence;\noutColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence;\noutColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r);\noutColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g);\noutColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b);\nfloat lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0));\nfloat tmpFloat = 1.0 - saturation;\noutColor.r = outColor.r * saturation + lumFactor2 * tmpFloat;\noutColor.g = outColor.g * saturation + lumFactor2 * tmpFloat;\noutColor.b = outColor.b * saturation + lumFactor2 * tmpFloat;\noutColor = max(vec3(0.0), outColor);\nfloat crushBlacksFac = crushBlacks * 2.0 + 1.0;\nfloat crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5);\ntmpFloat = (1.0 - crushBlacksFac2);\nif (crushBlacksFac2 < 1.0) {\noutColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat;\noutColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat;\noutColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat;\n}\nreturn outColor;\n}\nfloat filmicBlenderDesaturationMinIntensity(vec3 color) {\nfloat maxChannel = max(color.r, max(color.g, color.b));\nfloat x = max(maxChannel, 0.6251);\nreturn (1.2192868 * x - 0.63221059)\n* ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231);\n}\nvec3 filmicBlenderDesaturationTransform(vec3 color) {\nconst float CURVE_SMOOTHNESS = 0.03;\nfloat minIntensity = filmicBlenderDesaturationMinIntensity(color);\nvec4 x = vec4(color, 1.0) - minIntensity;\nx = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS);\nreturn (x.rgb - x.a + color + 1.0) / 2.0;\n}\nvec3 filmicBlenderDynamicRangeTransform(vec3 color) {\nreturn pow(\n(0.28882259 * color - 0.15880336)\n/ (pow(color - 0.6229693, vec3(2.0)) + 0.16965022)\n+ 0.20453365 * color + 0.37847142,\nvec3(3.0)\n);\n}\nvec3 FilmicBlenderToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(color, 0.000175);\ncolor = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN)\n/ (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0);\ncolor = filmicBlenderDesaturationTransform(color);\ncolor = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0);\ncolor = filmicBlenderDynamicRangeTransform(color);\nreturn color;\n}",uv_pars_fragment:"#if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY))\nvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n#ifdef UVS_VERTEX_ONLY\nvec2 vUv;\n#else\nvarying vec2 vUv;\n#endif\nuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\nvUv = (uvTransform * vec3(uv, 1)).xy;\n#endif",uv2_pars_fragment:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nattribute vec2 uv2;\nvarying vec2 vUv2;\nuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvUv2 = (uv2Transform * vec3(uv2, 1)).xy;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined(MASK) || defined(NODE)\nvec4 worldPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nworldPosition = instanceMatrix * worldPosition;\n#endif\nworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\nvec4 texColor = texture2D(t2D, vUv);\ngl_FragColor = mapTexelToLinear(texColor);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\nvUv = (uvTransform * vec3(uv, 1)).xy;\ngl_Position = vec4(position.xy, 1.0, 1.0);\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\nvec3 vReflect = vWorldDirection;\n#include <envmap_fragment>\ngl_FragColor = envColor;\ngl_FragColor.a *= opacity;\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_vertex>\ngl_Position.z = gl_Position.w;\n}",depth_frag:"#define DEPTH\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\n#if DEPTH_PACKING == 3200\nuniform float opacity;\n#endif\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst float ONE_MINUS_EPS = 0.9999999;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\n#if DEPTH_PACKING == 3200\ndiffuseColor.a = opacity;\n#endif\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <logdepthbuf_fragment>\n#if DEPTH_PACKING != 3202\nfloat depth = vProjectedPosZW.x / vProjectedPosZW.y;\ndepth = (depth + 1.0) / 2.0;\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(depth), dFdy(depth)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndepth = clamp(depth + max(bias, 1e-6), 0.0, ONE_MINUS_EPS);\n#endif\n#if DEPTH_PACKING == 3200\ngl_FragColor = vec4(vec3(1.0 - depth), opacity);\n#elif DEPTH_PACKING == 3201\ngl_FragColor = packDepthToRGBA(depth);\n#endif\n#else\ngl_FragColor = vec4(vViewPosition.z);\n#endif\n}",depth_vert:"#define DEPTH\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = mvPosition.xyz;\nvProjectedPosZW = mat2(\nprojectionMatrix[2][2], projectionMatrix[2][3],\nprojectionMatrix[3][2], projectionMatrix[3][3]\n) * mvPosition.zw;\n}",distanceRGBA_frag:"#define DISTANCE\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst float ONE_MINUS_EPS = 0.9999999;\n#endif\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#ifndef DISTANCE_SCALE\n#define DISTANCE_SCALE 1.0\n#endif\nvoid main () {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\nfloat dist = length(vWorldPosition - referencePosition);\n#if DISTANCE_PACKING == 3301\ndist = (dist - nearDistance) / (farDistance - nearDistance);\ndist = saturate(dist);\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndist = clamp(dist + bias, 0.0, ONE_MINUS_EPS);\n#endif\ngl_FragColor = packDepthToRGBA(dist);\n#elif DISTANCE_PACKING == 3302\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\ndist += slopeScaledBias * max(dxdy.x, dxdy.y);\n#endif\ngl_FragColor = vec4(dist * DISTANCE_SCALE, 0.0, 0.0, 1.0);\n#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <worldpos_vertex>\n#include <clipping_planes_vertex>\nvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvec3 direction = normalize(vWorldDirection);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\n\nsampleUV.x += offsetU;\nvec4 texColor = texture2D(tEquirect, sampleUV);\ngl_FragColor = mapTexelToLinear(texColor);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nif (mod(vLineDistance, totalSize) > dashSize) {\ndiscard;\n}\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <color_fragment>\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <color_vertex>\nvLineDistance = scale * lineDistance;\nvec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\ngl_Position = projectionMatrix * mvPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_LIGHTMAP\n\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#else\nreflectedLight.indirectDiffuse += vec3(1.0);\n#endif\n#include <aomap_fragment>\nreflectedLight.indirectDiffuse *= diffuseColor.rgb;\nvec3 outgoingLight = reflectedLight.indirectDiffuse;\n#include <envmap_fragment>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <skinbase_vertex>\n#ifdef USE_ENVMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <worldpos_vertex>\n#include <clipping_planes_vertex>\n#include <envmap_vertex>\n#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\n#include <emissivemap_fragment>\nreflectedLight.indirectDiffuse = getAmbientLightIrradiance(ambientLightColor);\n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse += (gl_FrontFacing) ? vIndirectFront : vIndirectBack;\n#else\nreflectedLight.indirectDiffuse += vIndirectFront;\n#endif\n#include <lightmap_fragment>\nreflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse = (gl_FrontFacing) ? vLightFront : vLightBack;\n#else\nreflectedLight.directDiffuse = vLightFront;\n#endif\nreflectedLight.directDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb) * getShadowMask();\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include <envmap_fragment>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <lights_lambert_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\nvec3 viewDir = normalize(vViewPosition);\nvec3 x = normalize(vec3(viewDir.z, 0.0, - viewDir.x));\nvec3 y = cross(viewDir, x);\nvec2 uv = vec2(dot(x, normal), dot(y, normal)) * 0.495 + 0.5;\n#ifdef USE_MATCAP\nvec4 matcapColor = texture2D(matcap, uv);\nmatcapColor = matcapTexelToLinear(matcapColor);\n#else\nvec4 matcapColor = vec4(1.0);\n#endif\nvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\nvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_toon_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_phong_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#include <envmap_fragment>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\nuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;\nuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <roughnessmap_fragment>\n#include <metalnessmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <clearcoat_normal_fragment_begin>\n#include <clearcoat_normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_physical_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#ifdef TRANSPARENCY\ndiffuseColor.a *= saturate(1. - transparency + linearToRelativeLuminance(reflectedLight.directSpecular + reflectedLight.indirectSpecular));\n#endif\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\ngl_FragColor = vec4(packNormalToRGB(normal), opacity);\n}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_particle_fragment>\n#include <color_fragment>\n#include <alphatest_fragment>\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <color_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\ngl_PointSize = size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) gl_PointSize *= (scale / - mvPosition.z);\n#endif\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#endif\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\ngl_FragColor = vec4(color, opacity * (1.0 - getShadowMask()));\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n}",shadow_vert:"#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#endif\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n#include <begin_vertex>\n#include <project_vertex>\n#ifdef USE_SHADOWMAP\nvViewPosition = - mvPosition.xyz;\n#endif\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\nvec4 mvPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\nvec2 scale;\nscale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\nscale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n#ifndef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) scale *= - mvPosition.z;\n#endif\nvec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\nmvPosition.xy += rotatedPosition;\ngl_Position = projectionMatrix * mvPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\n}",equicube_frag:"uniform sampler2D tEquirect;\nuniform int faceIndex;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec2 vUv;\n#include <common>\nvoid main() {\nvec3 direction;\nvec2 uv = vUv * 2.0 - 1.0;\nif (faceIndex==0) {\ndirection = vec3(1.0, -uv.y, -uv.x);\n} else if (faceIndex==1) {\ndirection = vec3(-1.0, -uv.y, uv.x);\n} else if (faceIndex==2) {\ndirection = vec3(uv.x, 1.0, uv.y);\n} else if (faceIndex==3) {\ndirection = vec3(uv.x, -1.0, -uv.y);\n} else if (faceIndex==4) {\ndirection = vec3(uv.x, -uv.y, 1.0);\n} else {\ndirection = vec3(-uv.x, -uv.y, -1.0);\n}\ndirection = normalize(direction);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\n\nsampleUV.x += offsetU;\ngl_FragColor = texture2D(tEquirect, sampleUV);\n}",equicube_vert:"varying vec2 vUv;\n#include <common>\nvoid main() {\nvUv = uv;\n#include <begin_vertex>\n#include <project_vertex>\n}",mask_frag:"#define MASK\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nuniform mat4 projectionMatrix;\nuniform float opacity;\nuniform sampler2D depthTexture;\nuniform vec2 cameraNearFar;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\ndiffuseColor.a = opacity;\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <logdepthbuf_fragment>\nfloat depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\nfloat viewZ;\nif (isOrtho(projectionMatrix))\nviewZ = -orthographicDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nelse\nviewZ = -perspectiveDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nfloat depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0;\ngl_FragColor = vec4(0.0, depthTest, 1.0, 0.0);\n}",mask_vert:"#define MASK\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nuniform mat4 textureMatrix;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\nprojTexCoord = textureMatrix * worldPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n}",meshnode_frag:"#define NODE\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_node_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BUMP_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(NODE_TANGENT_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_SAMPLER_INFO_MY) || defined(SHADOWMAP_TYPE_ESM) && (defined(NODE_BSDF_DIFFUSE_BL) || defined(NODE_BSDF_GLOSSY_BL) || defined(NODE_BSDF_REFRACTION_BL) || defined(NODE_MATERIAL_MX) || defined(NODE_PHYSICAL_MX) || defined(NODE_MATERIAL_GF))\nuniform mat4 invViewMatrix;\n#endif\n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(USE_SSR)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_SAMPLER_INFO_MY)\nuniform mat4 modelMatrix;\nuniform mat4 invModelMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_NORMAL_BUMP_MX) || defined(NODE_MATERIAL_GF) || defined(NODE_BUMP_2D_MY) || defined(NODE_SAMPLER_INFO_MY)\nuniform mat4 modelViewMatrix;\n#endif\n#if defined(NODE_TEX_IMAGE_BL)\nuniform mat3 normalMatrix;\n#endif\n#if defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL)\nuniform vec3 boundingBoxMin;\nuniform vec3 boundingBoxMax;\n#endif\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvarying vec3 vWorldPosition;\n#endif\n#if defined(NODE_TEX_COORD_BL)\nuniform vec2 viewWidthHeight;\n#endif\n#include <ssr_pars_fragment>\n#include <node_common_frag>\n#include <node_pars_fragment>\nvoid main() {\nbool _frontFacingValue = gl_FrontFacing;\n#define FRONT_FACING_VALUE _frontFacingValue\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <normal_fragment_begin>\nvec4 outgoingLight = vec4(0.0);\n#include <node_fragment>\n#if WORLD_NODES == 1\noutgoingLight.a = 1.0;\n#endif\n#ifdef ALPHATEST\nif (outgoingLight.a < ALPHATEST)\ndiscard;\nelse\noutgoingLight.a = 1.0;\n#endif\ngl_FragColor = vec4(outgoingLight);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshnode_vert:"#define NODE\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvarying vec3 vWorldPosition;\n#endif\n#include <node_pars_vertex>\nvoid main() {\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvWorldPosition = worldPosition.xyz;\n#endif\n#include <node_vertex>\n}",lights_node_pars_fragment:"\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct NodeMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 refractionColor;\nfloat refractionRoughness;\nfloat refractionIOR;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n#ifdef PHYSICAL\nvec3 fresnelRefl90;\nfloat specularRoughness;\n#else\nfloat diffuseIntensity;\nfloat specularIntensity;\nfloat specularHardness;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n#define BLENDER_SPECULAR_COEFFICIENT 0.08\nfloat shadeSpecPhong(vec3 normal, vec3 lightDir, vec3 viewDir, float hard)\n{\nfloat specFac;\nvec3 h = normalize(lightDir + viewDir);\nfloat rslt = max(dot(h, normal), 0.0);\nspecFac = pow(rslt, hard);\nreturn specFac;\n}\nfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\nreturn DEFAULT_SPECULAR_COEFFICIENT + (1.0 - DEFAULT_SPECULAR_COEFFICIENT) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n}\n#if NUM_RECT_AREA_LIGHTS > 0\nvoid RE_Direct_RectArea_Node(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.specularRoughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_Direct_Node(const in IncidentLight directLight, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef PHYSICAL\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\n#endif\n#ifdef CLEARCOAT\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal,\nmaterial.specularColor, material.specularRoughness);\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#ifdef CLEARCOAT\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal,\nvec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#endif\n#else\nreflectedLight.directDiffuse += irradiance * material.diffuseIntensity * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += material.specularIntensity *\nshadeSpecPhong(geometry.normal, directLight.direction,\ngeometry.viewDir, material.specularHardness) *\ndirectLight.color * material.specularColor;\n#endif\n}\nvoid RE_IndirectDiffuse_Node(const in vec3 irradiance, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#ifdef PHYSICAL\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(\nmaterial.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\n#ifdef MT_BLENDER\n#ifdef COMPAT_USE_SPEC_ENV_BLENDER_APPROX\nvec3 specEnv = BRDF_Specular_GGX_Environment_Blender_Approx(geometry,\nmaterial.specularColor, material.fresnelRefl90,\nmaterial.specularRoughness, 0);\n#else\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir,\ngeometry.normal, material.specularColor,\nmaterial.specularRoughness);\n#endif\n#elif defined(MT_MAX)\nfloat alphaEnv = pow2(pow2(material.specularRoughness));\nvec3 specEnv = material.specularColor / (1.0 - alphaEnv + PI * alphaEnv);\n#elif defined(MT_MAYA)\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n#else\nvec3 specEnv = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += (1.0 - clearcoatDHR) * radiance * specEnv;\n#ifdef CLEARCOAT\n#ifdef MT_BLENDER\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#elif defined(MT_MAX)\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nvec3 specEnvCC = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * specEnvCC;\n#endif\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#endif\nvoid RE_Refraction_Node(const vec3 refraction, const NodeMaterial material,\ninout vec3 refractedLight) {\nrefractedLight += refraction * material.refractionColor;\n}\n#ifdef MT_BLENDER\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#elif defined(MT_MAX)\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness * exp(0.35*(1.0-pow2(material.specularRoughness))))\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness * exp(0.35*(1.0-pow2(material.refractionRoughness))))\n#else\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#endif\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}\n#define RE_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_Direct_RectArea RE_Direct_RectArea_Node\n#ifdef PHYSICAL\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#endif\n#define RE_Refraction RE_Refraction_Node",ssr_pars_fragment:"#ifdef USE_SSR\nuniform sampler2D ssrSourceBuffer;\nuniform sampler2D ssrDepthBuffer;\nuniform sampler2D ssrBackfaceDepthBuffer;\nuniform mat4 invProjectionMatrix;\nuniform vec2 ssrResolution;\nuniform float ssrThickness;\nuniform float ssrStride;\nuniform float ssrJitter;\nuniform float ssrMaxDistance;\n#ifdef USE_SSR_REFRACT\n#define STEPS_FADE_AMOUNT 0.1\n#define SCREEN_FADE_THRESHOLD 0.6\n#else\n#define STEPS_FADE_AMOUNT 1.0\n#define SCREEN_FADE_THRESHOLD 0.4\n#endif\nvec3 deproject(vec3 p) {\nvec4 res = invProjectionMatrix * vec4(p, 1);\nreturn res.xyz / res.w;\n}\nbool doesIntersect(float rayzmax, float rayzmin, vec2 uv) {\nfloat sceneZMin = texture2D(ssrDepthBuffer, uv).r;\n#ifdef USE_SSR_REFRACT\nreturn rayzmin >= (sceneZMin-ssrThickness) && rayzmax <= sceneZMin;\n#else\nfloat sceneZMax = texture2D(ssrBackfaceDepthBuffer, uv).r;\nreturn rayzmin >= sceneZMax && rayzmax <= sceneZMin;\n#endif\n}\nfloat distanceSquared(vec2 a, vec2 b) { a -= b; return dot(a, a); }\nvoid swapIfBigger(inout float a, inout float b) {\nif (a > b) {\nfloat t = a;\na = b;\nb = t;\n}\n}\nbool isOutsideUvBounds(float x) { return x < 0.0 || x > 1.0; }\nbool isOutsideUvBounds(vec2 uv) { return isOutsideUvBounds(uv.x) || isOutsideUvBounds(uv.y); }\nvec3 computeSSR(vec3 color, vec3 normal, float ior) {\nvec2 uv = gl_FragCoord.xy / ssrResolution;\nvec2 screenCoord = uv * 2.0 - vec2(1, 1);\nfloat nearClip = deproject(vec3(0, 0, -1)).z;\nvec3 ray = deproject(vec3(screenCoord, -1));\nray /= ray.z;\nfloat depthSample = -vViewPosition.z;\nvec3 vpos = depthSample * ray;\n#ifdef USE_SSR_REFRACT\nvec3 dir = normalize(refract(normalize(vpos), normalize(normal), 1.0/ior));\n#else\nvec3 dir = normalize(reflect(normalize(vpos), normalize(normal)));\n#endif\nfloat maxDist = ssrMaxDistance;\nfloat rayLength = (vpos.z + dir.z * maxDist) > nearClip ? (nearClip - vpos.z) / dir.z : maxDist;\nvec3 csOrig = vpos;\nvec3 csEndPoint = csOrig + dir * rayLength;\nvec4 H0 = projectionMatrix * vec4(csOrig, 1.0);\nvec4 H1 = projectionMatrix * vec4(csEndPoint, 1.0);\nfloat k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\nvec3 Q0 = csOrig.xyz * k0, Q1 = csEndPoint.xyz * k1;\nvec2 P0 = H0.xy * k0, P1 = H1.xy * k1;\nP0 = P0 * 0.5 + vec2(0.5), P1 = P1 * 0.5 + vec2(0.5);\n#ifndef SSR_SIMPLE_REFRACT\nP0 *= ssrResolution, P1 *= ssrResolution;\nP1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);\nvec2 delta = P1 - P0;\nbool permute = false;\nif (abs(delta.x) < abs(delta.y)) {\npermute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;\n}\nfloat stepDir = sign(delta.x);\nfloat invdx = stepDir / delta.x;\nvec3 dQ = (Q1 - Q0) * invdx;\nfloat dk = (k1 - k0) * invdx;\nvec2 dP = vec2(stepDir, delta.y * invdx);\nfloat pixelStride = ssrStride;\nfloat jitterMod = (gl_FragCoord.x + gl_FragCoord.y) * 0.25;\nvec4 PQK = vec4(P0, Q0.z, k0);\nvec4 dPQK = vec4(dP, dQ.z, dk);\ndPQK *= pixelStride;\nPQK += dPQK * mod(jitterMod, 1.0) * ssrJitter;\nfloat end = P1.x * stepDir;\nfloat prevZMaxEstimate = PQK.z / PQK.w;\nfloat rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfloat stepped = 0.0;\nvec2 hitUV;\nbool intersected = false;\nfor (float stepCount = 1.0; stepCount <= float(MAX_STEPS); stepCount ++) {\nPQK += dPQK;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\n\nstepped = stepCount;\nhitUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nif (isOutsideUvBounds(hitUV)) break;\nintersected = doesIntersect(rayZMax, rayZMin, hitUV);\nif (intersected || (P0.x * stepDir) > end) break;\n}\nif (intersected && pixelStride > 1.0) {\nPQK -= dPQK;\ndPQK /= ssrStride;\nfloat ogStride = pixelStride * 0.5;\nfloat currStride = pixelStride;\nprevZMaxEstimate = PQK.z / PQK.w;\nrayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfor(int j = 0; j < int(BINARY_SEARCH_ITERATIONS); j ++) {\nPQK += dPQK * currStride;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\nvec2 newUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nogStride *= 0.5;\nif (doesIntersect(rayZMax, rayZMin, newUV)) {\nhitUV = newUV;\ncurrStride = -ogStride;\n} else {\ncurrStride = ogStride;\n}\n}\n}\nvec3 result = color;\n#ifdef USE_SSR_REFRACT\n#endif\nif (intersected) {\nvec4 col = texture2D(ssrSourceBuffer, hitUV);\nvec2 ndc = abs(hitUV * 2.0 - 1.0);\nfloat maxndc = max(ndc.x, ndc.y);\nfloat fadeVal =\n(1.0 - (max(0.0, maxndc - SCREEN_FADE_THRESHOLD) / (1.0 - SCREEN_FADE_THRESHOLD))) *\n(1.0 - STEPS_FADE_AMOUNT * (stepped / float(MAX_STEPS)));\ncol.a = fadeVal;\nresult = mix(result, col.rgb, col.a);\n}\n#else\nvec3 result = texture2D(ssrSourceBuffer, P1).xyz;\n#endif\nreturn result;\n}\n#endif",node_common_frag:"#define LUMENS_PER_WATT 683.0\n#define MAX_ENV_COORDS_DIR 0\n#define MAX_ENV_COORDS_REFLECT 1\n#define MAX_ENV_COORDS_REFRACT 2\nvec4 nodeTexelToLinear(in vec4 color, in int sourceType) {\nif (sourceType == 1)\nreturn sRGBToLinear(color);\nelse if (sourceType == 2)\nreturn RGBEToLinear(color);\nelse\nreturn color;\n}\n#if defined(NODE_COMBHSV_BL) || defined(NODE_SEPHSV_BL) || defined(NODE_HUE_SAT_BL) || defined(NODE_COLOR_CORRECTION_MX) || defined(NODE_COMPOSITE_LAYER_MX)\n#define HSV_NODES\n#endif\n#ifdef HSV_NODES\nvoid hsvToRGB(vec4 hsv, out vec4 outCol)\n{\nfloat i, f, p, q, t, h, s, v;\nvec3 rgb;\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\nif (s == 0.0)\nrgb = vec3(v, v, v);\nelse {\nif (h == 1.0)\nh = 0.0;\nh *= 6.0;\ni = floor(h);\nf = h - i;\nrgb = vec3(f, f, f);\np = v * (1.0 - s);\nq = v * (1.0 - (s * f));\nt = v * (1.0 - (s * (1.0 - f)));\nif (i == 0.0)\nrgb = vec3(v, t, p);\nelse if (i == 1.0)\nrgb = vec3(q, v, p);\nelse if (i == 2.0)\nrgb = vec3(p, v, t);\nelse if (i == 3.0)\nrgb = vec3(p, q, v);\nelse if (i == 4.0)\nrgb = vec3(t, p, v);\nelse\nrgb = vec3(v, p, q);\n}\noutCol = vec4(rgb, hsv.w);\n}\nvoid rgbToHSV(vec4 rgb, out vec4 outCol)\n{\nfloat cmax, cmin, h, s, v, cdelta;\nvec3 c;\ncmax = max(rgb[0], max(rgb[1], rgb[2]));\ncmin = min(rgb[0], min(rgb[1], rgb[2]));\ncdelta = cmax - cmin;\nv = cmax;\nif (cmax != 0.0)\ns = cdelta / cmax;\nelse {\ns = 0.0;\nh = 0.0;\n}\nif (s == 0.0)\nh = 0.0;\nelse {\nc = (vec3(cmax, cmax, cmax) - rgb.xyz) / cdelta;\nif (rgb.x == cmax) h = c[2] - c[1];\nelse if (rgb.y == cmax) h = 2.0 + c[0] - c[2];\nelse h = 4.0 + c[1] - c[0];\nh /= 6.0;\nif (h < 0.0)\nh += 1.0;\n}\noutCol = vec4(h, s, v, rgb.w);\n}\n#endif\nbool isPerspective(const mat4 projMatrix)\n{\nreturn (projMatrix[3][3] == 0.0);\n}\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvec4 sampleEquirectangular(sampler2D map, vec3 reflectVec, mat3 uvTransform, int encoding)\n{\nreflectVec = normalize(reflectVec);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n#ifdef MT_MAYA\nsampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.25;\n#else\nsampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\n#endif\nsampleUV.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (reflectVec.x) / seamWidth) *\nclamp (1.0 - reflectVec.z / seamWidth, 0.0, 1.0);\nsampleUV = (uvTransform * vec3(sampleUV, 1.0)).xy;\nvec4 color = texture2D(map, sampleUV, seamBiasFactor * seam);\ncolor = nodeTexelToLinear(color, encoding);\nreturn color;\n}\n#endif\n#if defined(NODE_FRESNEL_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FALLOFF_MX) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL)\nfloat fresnelReflection(const vec3 dir, const vec3 normal, const float ior) {\nfloat cosTheta = clamp(abs(dot(dir, normal)), -1.0, 1.0);\nfloat gSquared = pow2(ior) + pow2(cosTheta) - 1.0;\nif (gSquared < 0.0) return 1.0;\nfloat g = sqrt(gSquared);\nreturn 0.5 * pow2((g - cosTheta) / (g + cosTheta))\n* (1.0 + pow2(\n((g + cosTheta) * cosTheta - 1.0) /\n((g - cosTheta) * cosTheta + 1.0)\n));\n}\n#endif\n#if defined(NODE_BITMAP_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_GRADIENT_RAMP_MX)\n#define MAPPING_EXPLICIT_MAP_CHANNEL 1\n#define MAPPING_VERTEX_COLOR_CHANNEL 2\n#define MAPPING_PLANAR_OBJECT_XYZ 3\n#define MAPPING_PLANAR_WORLD_XYZ 4\n#define AXIS_XY 1\n#define AXIS_YZ 2\n#define AXIS_ZX 3\n#endif\n#if defined(NODE_BITMAP_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_PLACE_2D_TEXTURE_MY)\nmat3 calcUvTransform(float uOffset, float vOffset, float uTiling, float vTiling, float wAngle)\n{\nif (abs(uOffset) < EPSILON && abs(vOffset) < EPSILON &&\n(abs(uTiling - 1.0)) < EPSILON && (abs(vTiling - 1.0)) < EPSILON &&\nabs(wAngle) < EPSILON)\nreturn mat3(1.0);\nfloat sx = uTiling;\nfloat sy = vTiling;\nfloat c = cos(-wAngle);\nfloat s = sin(-wAngle);\n#if defined(NODE_PLACE_2D_TEXTURE_MY)\nfloat tx = uOffset;\nfloat ty = vOffset;\nfloat cx = 0.5;\nfloat cy = 0.5;\nreturn mat3(c*sx, s*sx, 0.0,\n-s*sy, c*sy, 0.0,\ns*(ty+sy-cy)+c*(tx-cx)+cx, -c*(ty+sy-cy)+s*(tx-cx)-cy+1.0, 1.0);\n#else\nfloat tx = -uOffset;\nfloat ty = -vOffset;\nfloat cx = uOffset + 0.5;\nfloat cy = vOffset + 0.5;\nreturn mat3(sx * c, -sy * s, 0.0,\nsx * s, sy * c, 0.0,\n-sx * (c * cx + s * cy) + cx + tx, -sy * (- s * cx + c * cy) + cy + ty, 1.0);\n#endif\n}\n#endif\n#if defined(NODE_TEX_NOISE_BL) || defined(NODE_TEX_WAVE_BL)\n#define NOISE_AMP_HACK 0.75\n#define NOISE_BLENDER_MEAN 0.78\n#define NOISE_SCALE_HACK 0.5\n#define noiseModulo(x) (x - floor(x * (1.0 / 289.0)) * 289.0)\nvec4 noisePermute(vec4 x) {\nreturn noiseModulo(((x * 34.0) + 1.0) * x);\n}\nvec4 taylorInvSqrt(vec4 r) {\nreturn 1.79284291400159 - 0.85373472095314 * r;\n}\nfloat noisePerlin(vec3 v) {\nconst vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\nconst vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\nvec3 i = floor(v + dot(v, C.yyy));\nvec3 x0 = v - i + dot(i, C.xxx);\nvec3 g = step(x0.yzx, x0.xyz);\nvec3 l = 1.0 - g;\nvec3 i1 = min(g.xyz, l.zxy);\nvec3 i2 = max(g.xyz, l.zxy);\nvec3 x1 = x0 - i1 + C.xxx;\nvec3 x2 = x0 - i2 + C.yyy;\nvec3 x3 = x0 - D.yyy;\ni = noiseModulo(i);\nvec4 p = noisePermute(noisePermute(noisePermute(i.z + vec4(0.0, i1.z, i2.z, 1.0))\n+ i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0));\nfloat n_ = 0.142857142857;\nvec3 ns = n_ * D.wyz - D.xzx;\nvec4 j = p - 49.0 * floor(p * ns.z * ns.z);\nvec4 x_ = floor(j * ns.z);\nvec4 y_ = floor(j - 7.0 * x_);\nvec4 x = x_ * ns.x + ns.yyyy;\nvec4 y = y_ * ns.x + ns.yyyy;\nvec4 h = 1.0 - abs(x) - abs(y);\nvec4 b0 = vec4(x.xy, y.xy);\nvec4 b1 = vec4(x.zw, y.zw);\nvec4 s0 = floor(b0) * 2.0 + 1.0;\nvec4 s1 = floor(b1) * 2.0 + 1.0;\nvec4 sh = -step(h, vec4(0.0));\nvec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\nvec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\nvec3 p0 = vec3(a0.xy, h.x);\nvec3 p1 = vec3(a0.zw, h.y);\nvec3 p2 = vec3(a1.xy, h.z);\nvec3 p3 = vec3(a1.zw, h.w);\nvec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\np0 *= norm.x;\np1 *= norm.y;\np2 *= norm.z;\np3 *= norm.w;\nvec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\nm = m * m;\nreturn 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1),\ndot(p2, x2), dot(p3, x3)));\n}\nfloat noiseBlender(vec3 p) {\nreturn 0.5 * NOISE_AMP_HACK * (noisePerlin(NOISE_SCALE_HACK * vec3(p.x, p.y, p.z))) + 0.5;\n}\nfloat noiseSmooth(vec3 p, float octaveLenPerPixel, float falloffFactor,\nfloat dispersionFactor) {\nfloat mixFac = mix(1.0, smoothstep(0.0, 1.0, octaveLenPerPixel) * falloffFactor,\ndispersionFactor);\nreturn mix(noiseBlender(p), NOISE_BLENDER_MEAN, mixFac);\n}\n#define MAX_OCTAVES_NUM 16\nfloat noiseTurbulence(vec3 p, float octaves, float octaveLenPerPixel,\nfloat falloffFactor, float dispersionFactor) {\nfloat fscale = 1.0;\nfloat amp = 1.0;\nfloat sum = 0.0;\noctaves = clamp(octaves, 0.0, 16.0);\nint octavesInt = int(octaves);\nfor (int i = 0; i <= MAX_OCTAVES_NUM; i++) {\n#if __VERSION__ == 300\nif (i <= octavesInt) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n} else {\ni = MAX_OCTAVES_NUM;\n}\n#else\nif (i > octavesInt) break;\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n#endif\n}\nfloat octavesFrac = fract(octaves);\nfloat octavesCoeff = pow(2.0, float(octavesInt));\nif (octavesFrac != 0.0) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nfloat sum2 = sum + t * amp;\nsum *= octavesCoeff / (2.0 * octavesCoeff - 1.0);\nsum2 *= 2.0 * octavesCoeff / (4.0 * octavesCoeff - 1.0);\nreturn mix(sum, sum2, octavesFrac);\n} else {\nreturn sum * octavesCoeff / (2.0 * octavesCoeff - 1.0);\n}\n}\n#endif",node_normal_frag:"void node_normal(vec3 norParam, out vec3 norOut)\n{\nnorOut = norParam;\n}",node_material_gf_frag:"void node_material(\nvec3 normal, vec3 geometryNormal, vec4 tangent,\nvec4 baseColorFactor, vec4 baseColorTexture,\nfloat metallicFactor, float roughnessFactor, vec3 metallicRoughnessTexture,\nfloat normalmapScale, vec3 normalmapTexture, \nfloat occlusionStrength, float directLightOcclusionFactor, vec3 occlusionTexture,\nvec3 emissiveFactor, vec3 emissiveTexture, \nout vec4 outgoingLight) {\nNodeMaterial material;\nfloat metalness = metallicFactor * metallicRoughnessTexture.b;\nvec3 baseColor = baseColorTexture.rgb * baseColorFactor.rgb;\nmaterial.diffuseColor = baseColor * (1.0 - metalness);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nfloat roughness = roughnessFactor * metallicRoughnessTexture.g;\nmaterial.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), baseColor, metalness);\nif (normalmapScale > 0.0) {\nvec3 normalTex = normalmapTexture * 2.0 - 1.0;\n#ifdef MT_BLENDER\nnormalTex.y = -normalTex.y;\n#endif\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\n\nnormal = mix(normal, normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal), normalmapScale);\n}\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\nfloat ambientOcclusion = occlusionStrength * occlusionTexture.r;\nif (ambientOcclusion < 1.0) {\nreflectedLight.indirectDiffuse *= ambientOcclusion;\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nfloat specularOcclusion = computeSpecularOcclusion(dotNV, ambientOcclusion, material.specularRoughness);\nreflectedLight.indirectSpecular *= specularOcclusion;\nreflectedLight.directDiffuse *= (1.0 + (ambientOcclusion - 1.0) * directLightOcclusionFactor);\nreflectedLight.directSpecular *= (1.0 + (specularOcclusion - 1.0) * directLightOcclusionFactor);\n}\nvec3 totalEmissiveRadiance = emissiveFactor * emissiveTexture;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular\n+ totalEmissiveRadiance;\nfloat alpha = baseColorFactor.a * baseColorTexture.a;\noutgoingLight = vec4(outColor3, alpha);\n}",node_rgb_gf_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_texture_gf_frag:"void node_texture(sampler2D map, vec2 uv, const mat3 uvTransform,\nconst int encoding, out vec3 color)\n{\nuv = (uvTransform * vec3(uv, 1.0)).xy;\ncolor = texture2D(map, uv).rgb;\ncolor = nodeTexelToLinear(vec4(color, 0.0), encoding).rgb;\n}\nvoid node_texture(sampler2D map, vec2 uv, const mat3 uvTransform,\nconst int encoding, out vec4 color)\n{\nuv = (uvTransform * vec3(uv, 1.0)).xy;\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}",node_value_gf_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_add_shader_bl_frag:"void node_add_shader(vec4 color1, vec4 color2, out vec4 outColor) {\noutColor.rgb = color1.rgb + color2.rgb;\noutColor.a = clamp(color1.a + color2.a, 0.0, 1.0);\n}",node_ambient_occlusion_bl_frag:"void node_ambient_occlusion(vec4 color, float distance, vec3 normal,\nout vec4 outColor, out float outAO) {\noutColor = color;\noutAO = 1.0;\n}\nvoid node_ambient_occlusion(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_attribute_bl_frag:"void node_attribute(\nvec3 paramAttr,\nout vec4 outColor, out vec3 outVector, out float outFac)\n{\noutColor = vec4(paramAttr, 1.0);\noutVector = paramAttr;\noutFac = average(paramAttr);\n}",node_background_bl_frag:"void node_background(vec4 color, float strength, out vec4 outColor)\n{\noutColor = strength * color;\n}",node_bevel_bl_frag:"void node_bevel(float radius, vec3 normal, out vec3 outNormal) {\noutNormal = normal;\n}",node_blackbody_bl_frag:"void node_blackbody(float temp, out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_brightcontrast_bl_frag:"\nvoid node_brightcontrast(vec4 color, float bright, float contrast, out vec4 outColor)\n{\nfloat bminc = bright - contrast * 0.5;\noutColor.r = max((1.0 + contrast) * color.r + bminc, 0.0);\noutColor.g = max((1.0 + contrast) * color.g + bminc, 0.0);\noutColor.b = max((1.0 + contrast) * color.b + bminc, 0.0);\noutColor.a = color.a;\n}",node_bsdf_anisotropic_bl_frag:"void node_bsdf_anisotropic(\nvec4 color, float roughness, float anisotropy, float rotation, vec3 normal, vec3 tangent,\nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_diffuse_bl_frag:"\nvoid node_bsdf_diffuse(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_glass_bl_frag:"void node_bsdf_glass(\nvec3 geometryNormal,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = swizzleUpY(normal);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\nmaterial.refractionColor = vec3(1.0);\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0),\nvec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#undef USE_REFRACTED_LIGHT\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\noutColor = vec4(color.rgb * mix(refractedLight, reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_bl_frag:"\nvoid node_bsdf_glossy(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = normalize((viewMatrix * vec4(normal.xyz, 0.0)).xyz);\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(color.rgb * (reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular), 1.0);\n}",node_bsdf_hair_bl_frag:"void node_bsdf_hair(vec4 color, float offset, float roughnessU, float roughnessV, vec3 tangent, out vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_principled_bl_frag:"\nvec3 tintFromColor(vec3 color) {\n\tfloat lum = dot(color, vec3(0.3, 0.6, 0.1));\n\treturn lum > 0.0 ? color / lum : vec3(1.0);\n}\nvec3 fresnelBlend(float ior, float fresnel, vec3 fresnelColor) {\nfloat fresnelFac = fresnelReflection(vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), ior);\n\tfloat mixFac = saturate((fresnel - fresnelFac) / max(1e-8, 1.0 - fresnelFac));\n\treturn mix(fresnelColor, vec3(1.0), mixFac);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission, float alpha,\nvec3 normal, vec3 clearcoatNormal, vec3 tangent,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat dielectric = 1.0 - metallic;\ntransmission *= dielectric;\nmaterial.diffuseColor = baseColor.rgb * dielectric;\n#ifndef CLEARCOAT\nfloat dielReflCoeff = BLENDER_SPECULAR_COEFFICIENT;\n#else\nfloat dielReflCoeff = MAXIMUM_SPECULAR_COEFFICIENT;\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 1.0);\n#endif\nvec3 dielRefl = dielReflCoeff * specular\n* mix(vec3(1.0), tintFromColor(baseColor.rgb), specularTint);\nmaterial.specularColor = mix(dielRefl, baseColor.rgb, metallic);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\nvec3 fresnelColor = mix(vec3(1.0), baseColor.rgb, specularTint);\nmaterial.specularColor = mix(material.specularColor,\nfresnelBlend(ior, fresnel, fresnelColor) * fresnel, transmission);\nfloat isStrictDielectric = step(0.0, -length(vec4(subsurface, clearcoat,\ntransmission, float(metallic == 1.0))));\nmaterial.fresnelRefl90 = mix(vec3(1.0), material.specularColor,\n(1.0 - specular) * metallic * (1.0 - isStrictDielectric));\nmaterial.refractionColor = baseColor.rgb;\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef USE_REFRACTED_LIGHT\nvec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * (1.0 - transmission)\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular\n+ refractedLight * transmission * (1.0 - fresnel)\n+ emission.rgb;\noutColor = vec4(outColor3, alpha);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness,\nvec3 normal, vec3 clearcoatNormal, vec3 tangent,\nout vec4 outColor) {\nnode_bsdf_principled(geometryNormal, baseColor, subsurface, subsurfaceRadius,\nsubsurfaceColor, metallic, specular, specularTint, roughness,\nanisotropic, anisotropicRotation, sheen, sheenTint, clearcoat,\nclearcoatRoughness, ior, transmission, transmissionRoughness,\nvec4(0.0, 0.0, 0.0, 1.0), 1.0, normal, clearcoatNormal, tangent,\noutColor);\n}",node_bsdf_refraction_bl_frag:"#define BSDF_REFRACTION_GGX 0\n#define BSDF_REFRACTION_BECKMANN 1\n#define BSDF_REFRACTION_SHARP 2\nvoid node_bsdf_refraction(\nvec3 geometryNormal, const int distribution,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = swizzleUpY(normal);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.refractionColor = color.rgb;\nmaterial.refractionIOR = ior;\nif (distribution == BSDF_REFRACTION_SHARP) {\nmaterial.refractionRoughness = 0.0;\n} else {\nmaterial.refractionRoughness = pow2(roughness);\n}\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#undef USE_REFRACTED_LIGHT\noutColor = vec4(refractedLight, 1.0);\n}",node_bsdf_toon_bl_frag:"void node_bsdf_toon(\nvec4 color, float size, float smooth, vec3 normal, \nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_translucent_bl_frag:"void node_bsdf_translucent(vec4 color, vec3 normal, out vec4 outColor) {\nnormal = -vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_transparent_bl_frag:"\nvoid node_bsdf_transparent(vec4 color, out vec4 outColor)\n{\nfloat alpha = saturate(1.0 - dot(color.rgb, vec3(0.333333)));\noutColor = vec4(0.0, 0.0, 0.0, alpha);\n}",node_bsdf_velvet_bl_frag:"void node_bsdf_velvet(vec4 color, float sigma, vec3 normal, out vec4 outColor)\n{\noutColor = color;\n}",node_bump_bl_frag:"\nvoid node_bump(\nconst int invert,\nfloat strength, float bumpDist, float height, float height_dx,\nfloat height_dy, vec3 normal,\nout vec3 outNormal) {\nvec3 position = swizzleUpZ(vWorldPosition);\nif (invert == 1)\nbumpDist *= -1.0;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(height);\nfloat dHdy = dFdy(height);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * bumpDist * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, strength)));\n}\nvoid node_bump(\nconst int invert,\nfloat strength, float bumpDist, float height, vec3 normal,\nout vec3 outNormal) {\nnode_bump(invert, strength, bumpDist, height, 0.0, 0.0, normal, outNormal);\n}",node_camera_bl_frag:"\nvoid node_camera(\nvec3 viewPos, const int invCamZ,\nout vec3 outViewVector, out float outViewZDepth, out float outViewDistance)\n{\nviewPos = -viewPos;\nif (invCamZ == 1)\nviewPos.z = -viewPos.z;\noutViewVector = normalize(viewPos);\noutViewZDepth = abs(viewPos.z);\noutViewDistance = length(viewPos);\n}",node_clamp_bl_frag:"void node_clamp(float value, float minVal, float maxVal, out float result) {\nresult = clamp(value, minVal, maxVal);\n}",node_combhsv_bl_frag:"\nvoid node_combhsv(float h, float s, float v, out vec4 col)\n{\nhsvToRGB(vec4(h, s, v, 1.0), col);\n}",node_combrgb_bl_frag:"\nvoid node_combrgb(float r, float g, float b, out vec4 col)\n{\ncol = vec4(r, g, b, 1.0);\n}",node_combxyz_bl_frag:"void node_combxyz(float x, float y, float z, out vec3 outVector)\n{\noutVector = vec3(x, y, z);\n}",node_curve_rgb_bl_frag:"\nvoid node_curve_rgb(sampler2D curveData, float fac, vec4 col, out vec4 outCol)\n{\noutCol.r = texture2D(curveData, vec2(texture2D(curveData, vec2(col.r, 0.0)).a, 0.0)).r;\noutCol.g = texture2D(curveData, vec2(texture2D(curveData, vec2(col.g, 0.0)).a, 0.0)).g;\noutCol.b = texture2D(curveData, vec2(texture2D(curveData, vec2(col.b, 0.0)).a, 0.0)).b;\noutCol = mix(col, outCol, fac);\noutCol.a = col.a;\n}",node_curve_vec_bl_frag:"\nvoid node_curve_vec(sampler2D curveData, float fac, vec3 vec, out vec3 outVec)\n{\noutVec.x = texture2D(curveData, vec2((vec.x + 1.0) * 0.5, 0.0)).x;\noutVec.y = texture2D(curveData, vec2((vec.y + 1.0) * 0.5, 0.0)).y;\noutVec.z = texture2D(curveData, vec2((vec.z + 1.0) * 0.5, 0.0)).z;\noutVec = mix(vec, outVec * 2.0 - vec3(1.0), fac);\n}",node_displacement_bl_frag:"void node_displacement(float height, float midlevel, float scale, vec3 normal, out vec3 outDisplacement) {\noutDisplacement = vec3(0.0);\n}",node_eevee_specular_bl_frag:"void node_eevee_specular(\nvec4 baseColor, vec4 specular, float roughness, vec4 emissiveColor,\nfloat transparency, vec3 normal, float clearcoat, float clearcoatRoughness, \nvec3 clearcoatNormal, float ambientOcclusion,\nout vec4 outColor) {\noutColor = baseColor;\n}",node_emission_bl_frag:"\nvoid node_emission(vec4 color, float strength, out vec4 outColor)\n{\noutColor = vec4(strength * color.rgb, 1.0);\n}",node_fresnel_bl_frag:"void node_fresnel(vec3 viewPos, float IOR, vec3 normal, out float fac)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n}",node_gamma_bl_frag:"\nvoid node_gamma(vec4 col, float gamma, out vec4 outCol)\n{\noutCol = col;\nif (col.r > 0.0)\noutCol.r = powCompat(col.r, gamma);\nif (col.g > 0.0)\noutCol.g = powCompat(col.g, gamma);\nif (col.b > 0.0)\noutCol.b = powCompat(col.b, gamma);\n}",node_hair_info_bl_frag:"void node_hair_info(out float isStrand, out float intercept, out float thickness,\nout vec3 tangentNormal, out float random) {\nisStrand = 0.0;\nintercept = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\nrandom = 0.0;\n}\nvoid node_hair_info(\nout float isStrand, out float intercept, out float thickness, out vec3 tangentNormal)\n{\nisStrand = 0.0;\nintercept = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\n}",node_holdout_bl_frag:"void node_holdout(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_hue_sat_bl_frag:"\nvoid node_hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outCol)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nhsv[0] += (hue - 0.5);\nif (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;\nhsv[1] *= sat;\nif (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;\nhsv[2] *= value;\nif (hsv[2] > 1.0) hsv[2] = 1.0; else if (hsv[2] < 0.0) hsv[2] = 0.0;\nhsvToRGB(hsv, outCol);\noutCol = mix(col, outCol, fac);\n}",node_invert_bl_frag:"\nvoid node_invert(float fac, vec4 col, out vec4 outCol)\n{\noutCol.xyz = mix(col.xyz, vec3(1.0, 1.0, 1.0) - col.xyz, fac);\noutCol.w = col.w;\n}",node_layer_weight_bl_frag:"\nvoid node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(1.0 - blend, EPSILON);\nfresnel = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? 1.0 / eta : eta);\nfacing = abs(dot(worldDir, normal));\nif (blend != 0.5) {\nblend = clamp(blend, 0.0, 1.0 - EPSILON);\nblend = (blend < 0.5) ? blend * 2.0 : 0.5 / (1.0 - blend);\nfacing = pow(facing, blend);\n}\nfacing = 1.0 - facing;\n}",node_light_falloff_bl_frag:"void node_light_falloff(\nfloat strength, float inSmooth,\nout float quadratic, out float linear, out float constant)\n{\nquadratic = 1.0;\nlinear = 1.0;\nconstant = 1.0;\n}",node_light_path_bl_frag:"void node_light_path(\nout float isCameraRay, out float isShadowRay, out float isDiffuseRay, \nout float isGlossyRay, out float isSingularRay, out float isReflectionRay,\nout float isTransmissionRay, out float rayLength, out float rayDepth, \nout float diffuseDepth, out float glossyDepth, out float transparentDepth, \nout float transmissionDepth)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\nisShadowRay = 0.0;\nisDiffuseRay = 0.0;\nisGlossyRay = 0.0;\nisSingularRay = 0.0;\nisReflectionRay = 0.0;\nisTransmissionRay = 0.0;\nrayLength = 1.0;\nrayDepth = 1.0;\ndiffuseDepth = 1.0;\nglossyDepth = 1.0;\ntransparentDepth = 1.0; \ntransmissionDepth = 1.0;\n}",node_mapping_bl_frag:"\nvoid node_mapping(mat4 mat, vec3 minVec, vec3 maxVec, int useMin, int useMax, vec3 vec, out vec3 outVec)\n{\noutVec = (mat * vec4(vec, 1.0)).xyz;\nif (useMin == 1)\noutVec = max(outVec, minVec);\nif (useMax == 1)\noutVec = min(outVec, maxVec);\n}\nmat3 rotationMatrix(float angleX, float angleY, float angleZ) {\nfloat cx = cos(angleX);\nfloat sx = sin(angleX);\nfloat cy = cos(angleY);\nfloat sy = sin(angleY);\nfloat cz = cos(angleZ);\nfloat sz = sin(angleZ);\n\nmat3 mat;\nmat[0][0] = cy * cz;\nmat[0][1] = cy * sz;\nmat[0][2] = -sy;\n\nmat[1][0] = sy * sx * cz - cx * sz;\nmat[1][1] = sy * sx * sz + cx * cz;\nmat[1][2] = cy * sx;\n\nmat[2][0] = sy * cx * cz + sx * sz;\nmat[2][1] = sy * cx * sz - sx * cz;\nmat[2][2] = cy * cx;\n\nreturn mat;\n}\n#define NODE_MAPPING_POINT 1\n#define NODE_MAPPING_TEXTURE 2\n#define NODE_MAPPING_VECTOR 3\n#define NODE_MAPPING_NORMAL 4\nvoid node_mapping(int type, vec3 vec, vec3 loc, vec3 rot, vec3 scale, out vec3 outVec)\n{\nif (type == NODE_MAPPING_POINT)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale) + loc;\nelse if (type == NODE_MAPPING_TEXTURE)\noutVec = transposeMat3(rotationMatrix(rot.x, rot.y, rot.z)) * (vec - loc) / scale;\nelse if (type == NODE_MAPPING_VECTOR)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale);\nelse\noutVec = normalize(rotationMatrix(rot.x, rot.y, rot.z) * vec / scale);\n}",node_map_range_bl_frag:"#define NODE_MAP_RANGE_INTERP_LINEAR 0\n#define NODE_MAP_RANGE_INTERP_STEPPED_LINEAR 1\n#define NODE_MAP_RANGE_INTERP_SMOOTHSTEP 2\n#define NODE_MAP_RANGE_INTERP_SMOOTHERSTEP 3\nvoid node_map_range(const int interpolation, int inClamp, float value, float fromMin, float fromMax,\nfloat toMin, float toMax, float steps, out float result) {\nif (fromMax == fromMin) {\nresult = 0.0;\n} else {\nresult = (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;\n}\nif (inClamp == 1) {\nresult = clamp(result, toMin, toMax);\n}\n}\nvoid node_map_range(const int interpolation, int inClamp, float value,\nfloat fromMin, float fromMax, float toMin, float toMax, out float result) {\nnode_map_range(NODE_MAP_RANGE_INTERP_LINEAR, inClamp, value, fromMin,\nfromMax, toMin, toMax, 0.0, result);\n}",node_math_bl_frag:"\nvoid node_math_add(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = val1 / val2;\n}\nvoid node_math_sine(float val, float val2, float val3, out float outVal)\n{\noutVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, float val3, out float outVal)\n{\noutVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, float val3, out float outVal)\n{\noutVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = asin(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arccosine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = acos(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arctangent(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, float val3, out float outVal)\n{\nif (val1 >= 0.0)\noutVal = powCompat(val1, val2);\nelse {\nfloat val2_mod_1 = mod(abs(val2), 1.0);\nif (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)\noutVal = powCompat(val1, floor(val2 + 0.5));\nelse\noutVal = 0.0;\n}\n}\nvoid node_math_logarithm(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > 0.0 && val2 > 0.0)\noutVal = log2(val1) / log2(val2);\nelse\noutVal = 0.0;\n}\nvoid node_math_sqrt(float val1, float val2, float val3, out float outVal)\n{\noutVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, float val3, out float outVal)\n{\noutVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, float val3, out float outVal)\n{\noutVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, float val3, out float outVal)\n{\noutVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, float val3, out float outVal)\n{\noutVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 < val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_greater_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_modulo(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = mod(val1, val2);\noutVal = (val1 > 0.0) ? outVal : outVal - val2;\n}\nvoid node_math_absolute(float val1, float val2, float val3, out float outVal)\n{\noutVal = abs(val1);\n}\nvoid node_math_compare(float val1, float val2, float val3, out float outVal) {\noutVal = step(abs(val1 - val2), val3);\n}\nvoid node_math_cosh(float val1, float val2, float val3, out float outVal) {\noutVal = cosh(val1);\n}\nvoid node_math_degrees(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / PI * 180.0;\n}\nvoid node_math_exponent(float val1, float val2, float val3, out float outVal) {\noutVal = exp(val1);\n}\nvoid node_math_inverse_sqrt(float val1, float val2, float val3, out float outVal) {\nif (val1 >= 0.0) {\noutVal = 1.0 / sqrt(val1);\n} else {\noutVal = 0.0;\n}\n}\nvoid node_math_multiply_add(float val1, float val2, float val3, out float outVal) {\noutVal = val1 * val2 + val3;\n}\nvoid node_math_pingpong(float val1, float val2, float val3, out float outVal) {\nif (val2 == 0.0) {\noutVal = 0.0;\n} else {\nfloat absVal2 = abs(val2);\nfloat rem = mod(val1, absVal2);\noutVal = mix(rem, absVal2 - rem, mod(floor(val1 / absVal2), 2.0));\n}\n}\nvoid node_math_radians(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / 180.0 * PI;\n}\nvoid node_math_sign(float val1, float val2, float val3, out float outVal) {\noutVal = sign(val1);\n}\nvoid node_math_sinh(float val1, float val2, float val3, out float outVal) {\noutVal = sinh(val1);\n}\nvoid node_math_smooth_max(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMax(val1, val2, val3);\n}\nvoid node_math_smooth_min(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMin(val1, val2, val3);\n}\nvoid node_math_snap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5 * sign(val2);\nfloat quot = val1 / val2;\noutVal = floor(quot) * val2;\n}\nvoid node_math_tanh(float val1, float val2, float val3, out float outVal) {\noutVal = tanh(val1);\n}\nvoid node_math_trunc(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = trunc(val1);\n}\nvoid node_math_wrap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = mod(val1 - val3, val2 - val3) + val3;\n}\nvoid node_math_add(float val1, float val2, out float outVal) {\nnode_math_add(val1, val2, 0.0, outVal);\n}\nvoid node_math_subtract(float val1, float val2, out float outVal) {\nnode_math_subtract(val1, val2, 0.0, outVal);\n}\nvoid node_math_multiply(float val1, float val2, out float outVal) {\nnode_math_multiply(val1, val2, 0.0, outVal);\n}\nvoid node_math_divide(float val1, float val2, out float outVal) {\nnode_math_divide(val1, val2, 0.0, outVal);\n}\nvoid node_math_sine(float val1, float val2, out float outVal) {\nnode_math_sine(val1, val2, 0.0, outVal);\n}\nvoid node_math_cosine(float val1, float val2, out float outVal) {\nnode_math_cosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_tangent(float val1, float val2, out float outVal) {\nnode_math_tangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arcsine(float val1, float val2, out float outVal) {\nnode_math_arcsine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arccosine(float val1, float val2, out float outVal) {\nnode_math_arccosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctangent(float val1, float val2, out float outVal) {\nnode_math_arctangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctan2(float val1, float val2, out float outVal) {\nnode_math_arctan2(val1, val2, 0.0, outVal);\n}\nvoid node_math_power(float val1, float val2, out float outVal) {\nnode_math_power(val1, val2, 0.0, outVal);\n}\nvoid node_math_logarithm(float val1, float val2, out float outVal) {\nnode_math_logarithm(val1, val2, 0.0, outVal);\n}\nvoid node_math_sqrt(float val1, float val2, out float outVal) {\nnode_math_sqrt(val1, val2, 0.0, outVal);\n}\nvoid node_math_maximum(float val1, float val2, out float outVal) {\nnode_math_maximum(val1, val2, 0.0, outVal);\n}\nvoid node_math_minimum(float val1, float val2, out float outVal) {\nnode_math_minimum(val1, val2, 0.0, outVal);\n}\nvoid node_math_round(float val1, float val2, out float outVal) {\nnode_math_round(val1, val2, 0.0, outVal);\n}\nvoid node_math_floor(float val1, float val2, out float outVal) {\nnode_math_floor(val1, val2, 0.0, outVal);\n}\nvoid node_math_ceil(float val1, float val2, out float outVal) {\nnode_math_ceil(val1, val2, 0.0, outVal);\n}\nvoid node_math_fract(float val1, float val2, out float outVal) {\nnode_math_fract(val1, val2, 0.0, outVal);\n}\nvoid node_math_less_than(float val1, float val2, out float outVal) {\nnode_math_less_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_greater_than(float val1, float val2, out float outVal) {\nnode_math_greater_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_modulo(float val1, float val2, out float outVal) {\nnode_math_modulo(val1, val2, 0.0, outVal);\n}\nvoid node_math_absolute(float val1, float val2, out float outVal) {\nnode_math_absolute(val1, val2, 0.0, outVal);\n}",node_mix_rgb_bl_frag:"\nvoid node_mix_rgb_mix(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_add(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 + col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_multiply(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 * col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_screen(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_overlay(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (outCol.r < 0.5)\noutCol.r *= facm + 2.0 * fac * col2.r;\nelse\noutCol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outCol.r);\nif (outCol.g < 0.5)\noutCol.g *= facm + 2.0 * fac * col2.g;\nelse\noutCol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outCol.g);\nif (outCol.b < 0.5)\noutCol.b *= facm + 2.0 * fac * col2.b;\nelse\noutCol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outCol.b);\n}\nvoid node_mix_rgb_subtract(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 - col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_divide(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (col2.r != 0.0) outCol.r = facm * outCol.r + fac * outCol.r / col2.r;\nif (col2.g != 0.0) outCol.g = facm * outCol.g + fac * outCol.g / col2.g;\nif (col2.b != 0.0) outCol.b = facm * outCol.b + fac * outCol.b / col2.b;\n}\nvoid node_mix_rgb_difference(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, abs(col1 - col2), fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_darken(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = min(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_lighten(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = max(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_dodge(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1;\nif (outCol.r != 0.0) {\nfloat tmp = 1.0 - fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 1.0;\nelse if ((tmp = outCol.r / tmp) > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\n}\nif (outCol.g != 0.0) {\nfloat tmp = 1.0 - fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 1.0;\nelse if ((tmp = outCol.g / tmp) > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\n}\nif (outCol.b != 0.0) {\nfloat tmp = 1.0 - fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 1.0;\nelse if ((tmp = outCol.b / tmp) > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n}\nvoid node_mix_rgb_burn(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat tmp, facm = 1.0 - fac;\noutCol = col1;\ntmp = facm + fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.r) / tmp)) < 0.0)\noutCol.r = 0.0;\nelse if (tmp > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\ntmp = facm + fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.g) / tmp)) < 0.0)\noutCol.g = 0.0;\nelse if (tmp > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\ntmp = facm + fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.b) / tmp)) < 0.0)\noutCol.b = 0.0;\nelse if (tmp > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n#ifdef HSV_NODES\nvoid node_mix_rgb_hue(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\nvoid node_mix_rgb_saturation(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2;\nrgbToHSV(outCol, hsv);\nif (hsv.y != 0.0) {\nrgbToHSV(col2, hsv2);\nhsv.y = facm * hsv.y + fac * hsv2.y;\nhsvToRGB(hsv, outCol);\n}\n}\nvoid node_mix_rgb_value(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 hsv, hsv2;\nrgbToHSV(col1, hsv);\nrgbToHSV(col2, hsv2);\nhsv.z = facm * hsv.z + fac * hsv2.z;\nhsvToRGB(hsv, outCol);\n}\nvoid node_mix_rgb_color(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsv.y = hsv2.y;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\n#endif\nvoid node_mix_rgb_soft_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 one = vec4(1.0);\nvec4 scr = one - (one - col2) * (one - col1);\noutCol = facm * col1 + fac * ((one - col1) * col2 * col1 + col1 * scr);\n}\nvoid node_mix_rgb_linear_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1 + fac * (2.0 * (col2 - vec4(0.5)));\n}",node_mix_shader_bl_frag:"\nvoid node_mix_shader(int transpShaderNum,\nfloat fac, vec4 color1, vec4 color2, out vec4 outColor)\n{\nif (transpShaderNum == 0)\ncolor1.rgb = color2.rgb;\nelse if (transpShaderNum == 1)\ncolor2.rgb = color1.rgb;\noutColor = mix(color1, color2, fac);\n}",node_new_geometry_bl_frag:"void node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness, out float randomPerIsland)\n{\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nposition = swizzleUpZ(posWorld.xyz);\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-viewPos), 0.0);\nviewDir = invViewMatrix * viewDir;\nvec3 incomingVec = -swizzleUpZ(viewDir.xyz);\n#if WORLD_NODES == 1\nnormal = incomingVec;\ntangent = vec3(0.0);\n#else\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nnormal = swizzleUpZ(norWorld);\nvec4 posLocal = invModelMatrix * posWorld;\nvec3 posLocalDelta = posLocal.xyz - boundingBoxMin;\nvec3 bbDelta = boundingBoxMax - boundingBoxMin;\nvec3 posOrco = vec3(\nbbDelta.x < 1e-5 ? -sign(posLocal.y) : posLocalDelta.x / bbDelta.x,\n0.0,\nbbDelta.z < 1e-5 ? sign(posLocal.y) : posLocalDelta.z / bbDelta.z\n);\nposOrco -= 0.5;\nvec3 tangWorld = (modelMatrix * vec4(posOrco.z, 0.0, -posOrco.x, 0.0)).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\ntangent = swizzleUpZ(tangWorld);\n#endif\ntrueNormal = normal;\nincoming = incomingVec;\nparametric = vec3(0.0);\nbackfacing = (frontFacing) ? 0.0 : 1.0;\n#if WORLD_NODES == 1\npointiness = 0.0;\n#else\npointiness = 0.5;\n#endif\nrandomPerIsland = 0.0;\n}\nvoid node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness) {\nfloat randomPerIsland;\nnode_new_geometry(frontFacing, viewPos, viewNorm, position, normal, tangent,\ntrueNormal, incoming, parametric, backfacing, pointiness, randomPerIsland);\n}",node_normal_bl_frag:"\nvoid node_normal(vec3 norParam, vec3 norIn, out vec3 norOut, out float dotOut)\n{\nnorOut = norParam;\ndotOut = dot(normalize(norIn), norParam);\n}",node_normal_map_bl_frag:"\nvoid node_normal_map(vec4 tangent, vec3 normal, float strength, vec4 normalColor, out vec3 normalOut)\n{\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, strength);\nnormalOut = normalize((invViewMatrix * vec4(normalOut, 0.0)).xyz);\nnormalOut = swizzleUpZ(normalOut);\n}",node_object_info_bl_frag:"\nvoid node_object_info(out vec3 location, out vec4 color, out float objIndex,\nout float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.5;\n#endif\n}\nvoid node_object_info(out vec3 location, out float objIndex, out float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.5;\n#endif\n}",node_output_lamp_bl_frag:"void node_output_lamp(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_output_material_bl_frag:"\nvoid node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}\nvoid node_output_material(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_output_world_bl_frag:"void node_output_world(vec4 surface, vec4 volume, out vec4 outgoingLight)\n{\noutgoingLight = surface;\n}",node_particle_info_bl_frag:"\nvoid node_particle_info(out float index, out float random, out float age,\nout float lifeTime, out vec3 location, out float size, out vec3 velocity,\nout vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}\nvoid node_particle_info(out float index, out float age, out float lifeTime, out vec3 location,\nout float size, out vec3 velocity, out vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}",node_principled_volume_bl_frag:"void node_principled_volume(vec4 color, float colorAttribute, float density,\nfloat densityAttribute, float anisotropy, vec4 absorptionColor,\nfloat emissionStrength, vec4 emissionColor, float blackbodyIntensity,\nvec4 blackbodyTint, float temperature, float temperatureAttribute,\nout vec4 volume) {\nvolume = vec4(0.0);\n}",node_rgb_bl_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_rgbtobw_bl_frag:"\nvoid node_rgbtobw(vec4 color, out float outVal) {\noutVal = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n}",node_script_bl_frag:"void node_script(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_sephsv_bl_frag:"\nvoid node_sephsv(vec4 col, out float h, out float s, out float v)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\n}",node_seprgb_bl_frag:"\nvoid node_seprgb(vec4 col, out float r, out float g, out float b)\n{\nr = col.r;\ng = col.g;\nb = col.b;\n}",node_sepxyz_bl_frag:"void node_sepxyz(vec3 vector, out float x, out float y, out float z)\n{\nx = vector.x;\ny = vector.y;\nz = vector.z;\n}",node_shadertorgb_bl_frag:"void node_shadertorgb(vec4 shader, out vec4 color, out float alpha) {\ncolor = vec4(shader.rgb, 1.0);\nalpha = shader.a;\n}",node_squeeze_bl_frag:"\nvoid node_squeeze(float val, float width, float center, out float outVal)\n{\noutVal = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));\n}",node_subsurface_scattering_bl_frag:"void node_subsurface_scattering(\nvec4 color, float scale, vec3 radius, float sharpen, float textureBlur, vec3 normal,\nout vec4 outColor)\n{\noutColor = color;\n}",node_tangent_bl_frag:"#define TANGENT_AXIS_X 0\n#define TANGENT_AXIS_Y 1\n#define TANGENT_AXIS_Z 2\nvoid node_tangent(int axis, vec3 viewPos, vec3 viewNorm, out vec3 outTangent) {\noutTangent = vec3(0.0);\n#if WORLD_NODES == 0\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nvec3 posLocal = (invModelMatrix * posWorld).xyz;\nvec3 posOrco = (posLocal - boundingBoxMin)\n/ (boundingBoxMax - boundingBoxMin) - 0.5;\nvec4 posOrcoPermuted;\nif (axis == TANGENT_AXIS_X) {\nposOrcoPermuted = vec4(0.0, -posOrco.z, posOrco.y, 0.0);\n} else if (axis == TANGENT_AXIS_Y) {\nposOrcoPermuted = vec4(-posOrco.y, posOrco.x, 0.0, 0.0);\n} else if (axis == TANGENT_AXIS_Z) {\nposOrcoPermuted = vec4(posOrco.z, 0.0, -posOrco.x, 0.0);\n}\nvec3 tangWorld = (modelMatrix * posOrcoPermuted).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\noutTangent = swizzleUpZ(tangWorld);\n#endif\n}\nvoid node_tangent(vec4 tangent, out vec3 outTangent) {\n#if WORLD_NODES == 0\noutTangent = normalize((modelMatrix * vec4(tangent.xyz, 0.0)).xyz);\noutTangent = swizzleUpZ(outTangent);\n#endif\n}",node_tex_brick_bl_frag:"void node_tex_brick(\nvec3 vector, vec4 color1, vec4 color2, vec4 mortar, float scale,\nfloat mortarSize, float mortarSmooth, float bias, float brickWidth,\nfloat rowHeight,\nout vec4 outColor, out float fac)\n{\noutColor = color1;\n}",node_tex_checker_bl_frag:"void node_tex_checker(vec3 vector, vec4 color1, vec4 color2, float scale, \nout vec4 outColor, out float outFac)\n{\nvec3 p = vector * scale;\np = (p + 0.00001) * 0.99999;\nfloat cx = floor(p.x);\nfloat cy = floor(p.y);\nfloat cz = floor(p.z);\nfloat result = sign(mod(cx + cy + cz, 2.0));\noutFac = max(result, 0.0);\noutColor = mix(color2, color1, outFac);\n}",node_tex_coord_bl_frag:"uniform mat4 nodeTexCoordObjectMatrices[NODE_TEX_COORD_NUM];\nvoid node_tex_coord(\nmat4 objectMat, vec3 viewPos, vec3 viewNorm, vec2 uv,\nout vec3 outGenerated, out vec3 outNormal, out vec3 outUV, out vec3 outObject,\nout vec3 outCamera, out vec3 outWindow, out vec3 outReflection)\n{\nvec4 view = vec4(-viewPos, 1.0);\nvec4 posWorld = invViewMatrix * view;\nvec3 loc = swizzleUpZ((invModelMatrix * posWorld).xyz);\n#if WORLD_NODES == 1\nloc = normalize(loc);\n#endif\n#if WORLD_NODES == 1\noutGenerated = loc;\n#else\nvec3 boxMin = vec3(boundingBoxMin.x, -boundingBoxMax.z, boundingBoxMin.y);\nvec3 boxMax = vec3(boundingBoxMax.x, -boundingBoxMin.z, boundingBoxMax.y);\nvec3 boxSize = boxMax - boxMin;\nif (abs(boxSize.x) < 0.001) {\noutGenerated.x = 0.5;\n} else {\noutGenerated.x = (loc.x - boxMin.x) / boxSize.x;\n}\nif (abs(boxSize.y) < 0.001) {\noutGenerated.y = 0.5;\n} else {\noutGenerated.y = (loc.y - boxMin.y) / boxSize.y;\n}\nif (abs(boxSize.z) < 0.001) {\noutGenerated.z = 0.5;\n} else {\noutGenerated.z = (loc.z - boxMin.z) / boxSize.z;\n}\n#endif\n#if WORLD_NODES == 1\noutNormal = -loc;\n#else\noutNormal = normalize(invModelMatrix * invViewMatrix * vec4(viewNorm, 0.0)).rgb;\noutNormal = swizzleUpZ(outNormal);\n#endif\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n#if WORLD_NODES == 1\noutObject = loc;\n#else\noutObject = swizzleUpZ((objectMat * posWorld).xyz);\n#endif\noutCamera = vec3(view.xy, -view.z);\n#if WORLD_NODES == 1\noutWindow = vec3(0.0);\n#else\noutWindow = vec3(gl_FragCoord.xy / viewWidthHeight, 0.0);\n#endif\n#if WORLD_NODES == 1\noutReflection = -loc;\n#else\nvec4 reflection = (invViewMatrix * vec4(reflect(view.xyz, normalize(viewNorm)), 0.0));\noutReflection = normalize(swizzleUpZ(reflection.xyz));\n#endif\n}",node_tex_environment_bl_frag:"#define TEX_PROJ_EQUIRECTANGULAR 0\n#define TEX_PROJ_MIRROR_BALL 1\nvoid node_tex_environment(sampler2D tex, const int encoding, const int projection, vec3 vector, out vec4 outColor) {\nvec2 uv;\nfloat bias;\nif (projection == TEX_PROJ_EQUIRECTANGULAR) {\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n#if WORLD_NODES == 1\nbias = -16.0;\n#else\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.z) / seamWidth) *\nclamp (1.0 - direction.x / seamWidth, 0.0, 1.0);\nbias = seamBiasFactor * seam;\n#endif\n} else {\nvec3 normal = normalize(vector);\nnormal.y -= 1.0;\nnormal /= (2.0 * sqrt(max(-0.5 * normal.y, 0.0)));\nuv = clamp(0.5 * normal.xz + 0.5, 0.0, 1.0);\nbias = 0.0;\n}\nuv.y = 1.0 - uv.y;\noutColor = texture2D(tex, uv, bias);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_none_bl_frag:"void node_tex_environment_none(vec3 vector, out vec4 outColor) {\noutColor = vec4(1.0, 0.0, 1.0, 1.0);\n}",node_tex_gradient_bl_frag:"#define TEX_GRAD_LINEAR 0\n#define TEX_GRAD_QUADRATIC 1\n#define TEX_GRAD_EASING 2\n#define TEX_GRAD_DIAGONAL 3\n#define TEX_GRAD_SPHERICAL 4\n#define TEX_GRAD_QUADRATIC_SPHERE 5\n#define TEX_GRAD_RADIAL 6\nvoid node_tex_gradient(const int type, vec3 vector, out vec4 outColor, out float outFac)\n{\nfloat x, y, z, r;\nx = vector.x;\ny = vector.y;\nz = vector.z;\nif (type == TEX_GRAD_LINEAR) {\noutFac = x;\n} else if (type == TEX_GRAD_QUADRATIC) {\nr = max(x, 0.0);\noutFac = pow2(r);\n} else if (type == TEX_GRAD_EASING) {\nr = min(max(x, 0.0), 1.0);\noutFac = (3.0 * pow2(r) - 2.0 * pow3(r));\n} else if (type == TEX_GRAD_DIAGONAL) {\noutFac = (x + y) * 0.5;\n} else if (type == TEX_GRAD_RADIAL) {\noutFac = atan(y, x) / PI2 + 0.5;\n} else {\nr = max(0.99999 - sqrt(x * x + y * y + z * z), 0.0);\nif (type == TEX_GRAD_QUADRATIC_SPHERE) {\noutFac = pow2(r);\n} else if (type == TEX_GRAD_SPHERICAL) {\noutFac = r;\n}\n}\noutFac = clamp(outFac, 0.0, 1.0);\noutColor = vec4(outFac, outFac, outFac, 1.0);\n}",node_tex_ies_bl_frag:"void node_tex_ies(vec3 vector, float strength, out float fac) {\nfac = 0.0;\n}",node_tex_image_bl_frag:"#define TEX_PROJ_FLAT 0\n#define TEX_PROJ_BOX 1\n#define TEX_PROJ_SPHERE 2\n#define TEX_PROJ_TUBE 3\nvoid node_tex_image(sampler2D ima, const int encoding, vec3 viewNorm,\nconst int projection, const float projectionBlend, const bool clampToEdgeNoExtend,\nvec3 vector,\nout vec4 outColor, out float outAlpha) {\nif (projection == TEX_PROJ_FLAT) {\nvec2 uv = vector.xy;\nuv.y = 1.0 - uv.y;\nif (clampToEdgeNoExtend && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {\noutColor = vec4(0.0);\noutAlpha = 0.0;\n} else {\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\n}\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_BOX) {\nvec3 norm = normalize(viewNorm * normalMatrix);\nvector = swizzleUpY(vector);\nvec2 uvX = vec2(-sign(norm.x) * vector.z, -vector.y);\nvec2 uvY = vec2(sign(norm.y) * vector.z, -vector.x);\nvec2 uvZ = vec2(sign(norm.z) * vector.x, -vector.y);\nvec4 colX = nodeTexelToLinear(texture2D(ima, uvX), encoding);\nvec4 colY = nodeTexelToLinear(texture2D(ima, uvY), encoding);\nvec4 colZ = nodeTexelToLinear(texture2D(ima, uvZ), encoding);\nvec3 barycentric = abs(norm);\nbarycentric /= barycentric.x + barycentric.y + barycentric.z;\nvec3 edgeShape = min(min(barycentric.yzx, barycentric.zxy),\n(projectionBlend - 1.0) / (projectionBlend - 3.0));\nvec3 edgeValue = (1.0 - projectionBlend) * (1.0 - edgeShape) / 2.0;\nvec3 weight = max((barycentric - edgeValue) / (1.0 - edgeValue), 0.0);\nweight /= (weight.x + weight.y + weight.z);\noutColor = weight.x * colX + weight.y * colY + weight.z * colZ;\noutAlpha = outColor.a;\n} else if (projection == TEX_PROJ_SPHERE) {\nvector = normalize(vector * 2.0 - 1.0);\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, acos(vector.y) / PI);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_TUBE) {\nvector = vector * 2.0 - 1.0;\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, (1.0 - vector.y) / 2.0);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n}\n}",node_tex_image_none_bl_frag:"void node_tex_image_none(vec3 vector, out vec4 color, out float alpha)\n{\ncolor = vec4(1.0, 0.0, 1.0, 1.0);\nalpha = 1.0;\n}",node_tex_magic_bl_frag:"void node_tex_magic(vec3 vector, float scale, float distortion,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_musgrave_bl_frag:"void node_tex_musgrave(vec3 vector, float w, float scale, float detail,\nfloat dimension, float lacunarity, float offset, float gain,\nout float outFac) {\noutFac = 0.0;\n}\nvoid node_tex_musgrave(\nvec3 vector, float scale, float detail, float dimension, float lacunarity,\nfloat offset, float gain,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_noise_bl_frag:"\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float roughness,\nfloat distortion, out float outFac, out vec4 outColor) {\nvec3 p = vector * scale;\nvec3 dx = dFdx(p);\nvec3 dy = dFdy(p);\nfloat octaveLenPerPixel = (length(dx) + length(dy)) / 4.0;\nif (distortion != 0.0) {\nvec3 r, offset = vec3(13.5, 13.5, 13.5);\nr.x = noiseSmooth(p + offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.y = noiseSmooth(p, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.z = noiseSmooth(p - offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\np += r;\n}\noutFac = noiseTurbulence(p, detail, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nvec3 color = vec3(outFac,\nnoiseTurbulence(vec3(p.y, p.x, p.z), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor),\nnoiseTurbulence(vec3(p.y, p.z, p.x), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor)\n);\noutColor = vec4(color, 1.0);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float distortion,\nout float outFac, out vec4 outColor) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, w, scale, detail,\n0.5, distortion, outFac, outColor);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float scale, float detail, float distortion,\nout vec4 outColor, out float outFac) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, 0.0, scale, detail,\ndistortion, outFac, outColor);\n}",node_tex_pointdensity_bl_frag:"void node_tex_pointdensity(\nvec3 vector,\nout vec4 outColor, out float outDensity)\n{\noutColor = vec4(0.0);\noutDensity = 0.0;\n}",node_tex_sky_bl_frag:"\n#define TEX_SKY_PREETHAM 0\n#define TEX_SKY_HOSEK_WILKIE 1\n#define Km 683.0\nvoid node_tex_sky(const int skyType, vec3 param0, vec3 param1, vec3 param2, \nvec3 param3, vec3 param4, vec3 param5, vec3 param6, vec3 param7, \nvec3 param8, vec3 radiance, vec3 sunDirection, vec3 vectorIn, \nout vec4 outColor) {\nif (length(vectorIn) == 0.0) {\nvectorIn = vec3(0.0, 1.0, 0.0);\n} else {\nvectorIn = normalize(vectorIn);\n}\nvectorIn = swizzleUpY(vectorIn);\nsunDirection = swizzleUpY(sunDirection);\nfloat cosGamma = clamp(dot(vectorIn, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(vectorIn.y, 0.0, 1.0);\nif (skyType == TEX_SKY_PREETHAM) {\nvec3 radInternal = (1.0 + param0 * exp(param1 / cosTheta)) * (\n1.0 + param2 * exp(param3 * acos(cosGamma)) \n+ param4 * pow(cosGamma, 2.0)\n);\nvec3 XYZ = xyY_to_XYZ(radInternal.y * radiance.y,\nradInternal.z * radiance.z, radInternal.x * radiance.x);\noutColor = vec4(max(xyz_to_sRGB(XYZ), 0.0), 1.0);\n} else if (skyType == TEX_SKY_HOSEK_WILKIE) {\nfloat cosGammaSq = pow(cosGamma, 2.0);\nvec3 chi = (1.0 + cosGammaSq) / pow(1.0 + pow(param8, vec3(2.0))\n- 2.0 * param8 * cosGamma, vec3(1.5));\nvec3 radInternal = (1.0 + param0 * exp(param1 / (cosTheta + 0.01))) * (\nparam2 + param3 * exp(param4 * acos(cosGamma)) \n+ param5 * cosGammaSq + param6 * chi + param7 * sqrt(cosTheta)\n);\noutColor = vec4(max(xyz_to_sRGB(radInternal * radiance), 0.0) * PI2/Km, 1.0);\n} else {\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}",node_tex_voronoi_bl_frag:"#define DISTANCE_EUCLIDEAN 0\n#define DISTANCE_MANHATTAN 1\n#define DISTANCE_CHEBYCHEV 2\n#define DISTANCE_MINKOWSKI 3\n#define FEATURE_F1 0\n#define FEATURE_F2 1\n#define FEATURE_SMOOTH_F1 2\n#define FEATURE_DISTANCE_TO_EDGE 3\n#define FEATURE_N_SPHERE_RADIUS 4\nstruct VoronoiGridData {\nvec3 point;\nvec3 randVec;\nvec3 toClosest;\nfloat dist;\n};\nfloat worleyLength(vec3 vec, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn length(vec);\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(vec.x) + abs(vec.y) + abs(vec.z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(vec.x), abs(vec.y)), abs(vec.z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nreturn pow(pow(abs(vec.x), exponent)\n+ pow(abs(vec.y), exponent)\n+ pow(abs(vec.z), exponent), 1.0 / exponent);\n}\nreturn 0.0;\n}\nvoid worleyNoise(vec3 pos, int distance, float exponent, int feature,\nfloat smoothness, float randomness, out float outDist, out vec4 outColor,\nout vec3 outPosition, out float outW, out float outRadius) {\nconst highp float RAND_FIX_ZERO = 0.125;\nvec3 posI = floor(pos);\nvec3 posF = fract(pos);\nVoronoiGridData vgd[27];\n#pragma unroll_loop\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop\nfor (int k = 0; k <= 2; k++) {\nvec3 point = vec3((i), (j), (k)) - 1.0;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\nconst int counter = (i) + (j) * 3 + (k) * 9;\nvgd[counter].point = point;\nvgd[counter].randVec = randVec;\nvgd[counter].toClosest = toClosest;\nvgd[counter].dist = worleyLength(toClosest, distance, exponent);\n}\n}\n}\nfloat f1 = 1e10;\nfloat f2 = 1e10;\nvec3 edgeToClosest = vec3(0.0);\nfloat distToEdge = 1e10;\nvec3 randColF1 = vec3(0.0);\nvec3 randColF2 = vec3(0.0);\nvec3 toClosestF1 = vec3(0.0);\nvec3 toClosestF2 = vec3(0.0);\nvec3 radPoint = vec3(0.0);\nvec3 radToClosest = vec3(0.0);\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nif (feature == FEATURE_F1) {\nif (vgd[i].dist < f1) {\nf1 = vgd[i].dist;\nrandColF1 = vgd[i].randVec;\ntoClosestF1 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_F2) {\nif (vgd[i].dist < f1) {\nf2 = f1;\nf1 = vgd[i].dist;\nrandColF2 = randColF1;\nrandColF1 = vgd[i].randVec;\ntoClosestF2 = toClosestF1;\ntoClosestF1 = vgd[i].toClosest;\n} else if (vgd[i].dist < f2) {\nf2 = vgd[i].dist;\nrandColF2 = vgd[i].randVec;\ntoClosestF2 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_SMOOTH_F1) {\nf1 = smoothMin(f1, vgd[i].dist, smoothness);\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nedgeToClosest = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nradPoint = vgd[i].point;\nradToClosest = vgd[i].toClosest;\n}\n}\n}\nif (feature == FEATURE_F1) {\noutDist = f1;\noutColor = vec4(randColF1, 1.0);\noutPosition = pos + toClosestF1;\n} else if (feature == FEATURE_F2) {\noutDist = f2;\noutColor = vec4(randColF2, 1.0);\noutPosition = pos + toClosestF2;\n} else if (feature == FEATURE_SMOOTH_F1) {\noutDist = f1;\nvec3 avgCol = vec3(0.0);\nvec3 avgOff = vec3(0.0);\nfloat sumWeightsCol = 0.0;\nfloat sumWeightsOff = 0.0;\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nfloat smoothFac = getSmoothFactor(f1, vgd[i].dist, smoothness);\nfloat weightOff = smoothFac * smoothFac * smoothFac;\nfloat weightCol = weightOff * smoothFac;\navgCol += vgd[i].randVec * weightCol;\navgOff += vgd[i].toClosest * weightOff;\nsumWeightsCol += weightCol;\nsumWeightsOff += weightOff;\n}\noutColor = vec4(avgCol / sumWeightsCol, 1.0);\noutPosition = pos + avgOff / sumWeightsOff;\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nif (vgd[i].toClosest != edgeToClosest) {\nfloat dist = dot(0.5 * (edgeToClosest + vgd[i].toClosest),\nnormalize(vgd[i].toClosest - edgeToClosest));\ndistToEdge = min(distToEdge, dist);\n}\n}\noutDist = distToEdge;\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat diam = 1e10;\n#pragma unroll_loop\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop\nfor (int k = 0; k <= 2; k++) {\nvec3 localPoint = vec3((i), (j), (k)) - 1.0;\nif (length(localPoint) > 0.0) {\nvec3 point = localPoint + radPoint;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\ndiam = min(diam, length(toClosest - radToClosest));\n}\n}\n}\n}\noutRadius = diam / 2.0;\n}\n}\n#define VORONOI_SMOOTH_COEFF 0.74\nvoid node_tex_voronoi(\nint distance, int feature,\nvec3 vector, float w, float scale, float smoothness, float exponent,\nfloat randomness,\nout float outDistance, out vec4 outColor, out vec3 outPosition,\nout float outW, out float outRadius) {\nvector = scale * (vector - 0.0001);\nsmoothness = clamp(smoothness, 1e-3, 1.0);\nsmoothness *= VORONOI_SMOOTH_COEFF;\nworleyNoise(vector, distance, exponent, feature, smoothness, randomness,\noutDistance, outColor, outPosition, outW, outRadius);\noutPosition /= scale;\n}\n#define DISTANCE_DISTANCE DISTANCE_EUCLIDEAN\n#define FEATURE_F3 5\n#define FEATURE_F4 6\n#define FEATURE_F2F1 7\n#define COLORING_INTENSITY 0\n#define COLORING_CELLS 1\nstruct VoronoiClosest {\nvec4 closestDists;\nvec4 closestInds;\n};\nvoid updateVoronoiClosest(inout VoronoiClosest vf, vec3 newDistances,\nvec3 newIndices) {\n#pragma unroll_loop\nfor (int i = 0; i < 3; i++) {\nfloat currDist = newDistances[i];\nfloat currIdx = newIndices[i];\n#pragma unroll_loop\nfor (int j = 0; j < 4; j++) {\nif (currDist < vf.closestDists[j]) {\nfloat tmp = vf.closestDists[j];\nvf.closestDists[j] = currDist;\ncurrDist = tmp;\ntmp = vf.closestInds[j];\nvf.closestInds[j] = currIdx;\ncurrIdx = tmp;\n}\n}\n}\n}\nvec3 worleyPermute(vec3 x) {\nreturn mod((34.0 * x + 1.0) * x, 289.0);\n}\nvec3 worleyDist(vec3 x, vec3 y, vec3 z, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn x * x + y * y + z * z;\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(x) + abs(y) + abs(z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(x), abs(y)), abs(z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nvec3 expVec = vec3(exponent);\nreturn pow(pow(abs(x), expVec)\n+ pow(abs(y), expVec)\n+ pow(abs(z), expVec), 1.0 / expVec);\n}\nreturn vec3(0.0);\n}\nVoronoiClosest worleyClosest(vec3 P, float jitter, int distance, float exponent) {\nfloat K = 0.142857142857;\nfloat Ko = 0.428571428571;\nfloat K2 = 0.020408163265306;\nfloat Kz = 0.166666666667;\nfloat Kzo = 0.416666666667;\nvec3 Pi = mod(floor(P), 289.0);\nvec3 Pf = fract(P) - 0.5;\nvec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\nvec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\nvec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\nvec3 p = worleyPermute(Pi.x + vec3(-1.0, 0.0, 1.0));\nvec3 p1 = worleyPermute(p + Pi.y - 1.0);\nvec3 p2 = worleyPermute(p + Pi.y);\nvec3 p3 = worleyPermute(p + Pi.y + 1.0);\nvec3 p11 = worleyPermute(p1 + Pi.z - 1.0);\nvec3 p12 = worleyPermute(p1 + Pi.z);\nvec3 p13 = worleyPermute(p1 + Pi.z + 1.0);\nvec3 p21 = worleyPermute(p2 + Pi.z - 1.0);\nvec3 p22 = worleyPermute(p2 + Pi.z);\nvec3 p23 = worleyPermute(p2 + Pi.z + 1.0);\nvec3 p31 = worleyPermute(p3 + Pi.z - 1.0);\nvec3 p32 = worleyPermute(p3 + Pi.z);\nvec3 p33 = worleyPermute(p3 + Pi.z + 1.0);\nvec3 ox11 = fract(p11*K) - Ko;\nvec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\nvec3 oz11 = floor(p11*K2)*Kz - Kzo;\nvec3 ox12 = fract(p12*K) - Ko;\nvec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\nvec3 oz12 = floor(p12*K2)*Kz - Kzo;\nvec3 ox13 = fract(p13*K) - Ko;\nvec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\nvec3 oz13 = floor(p13*K2)*Kz - Kzo;\nvec3 ox21 = fract(p21*K) - Ko;\nvec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\nvec3 oz21 = floor(p21*K2)*Kz - Kzo;\nvec3 ox22 = fract(p22*K) - Ko;\nvec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\nvec3 oz22 = floor(p22*K2)*Kz - Kzo;\nvec3 ox23 = fract(p23*K) - Ko;\nvec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\nvec3 oz23 = floor(p23*K2)*Kz - Kzo;\nvec3 ox31 = fract(p31*K) - Ko;\nvec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\nvec3 oz31 = floor(p31*K2)*Kz - Kzo;\nvec3 ox32 = fract(p32*K) - Ko;\nvec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\nvec3 oz32 = floor(p32*K2)*Kz - Kzo;\nvec3 ox33 = fract(p33*K) - Ko;\nvec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\nvec3 oz33 = floor(p33*K2)*Kz - Kzo;\nvec3 dx11 = Pfx + jitter*ox11;\nvec3 dy11 = Pfy.x + jitter*oy11;\nvec3 dz11 = Pfz.x + jitter*oz11;\nvec3 dx12 = Pfx + jitter*ox12;\nvec3 dy12 = Pfy.x + jitter*oy12;\nvec3 dz12 = Pfz.y + jitter*oz12;\nvec3 dx13 = Pfx + jitter*ox13;\nvec3 dy13 = Pfy.x + jitter*oy13;\nvec3 dz13 = Pfz.z + jitter*oz13;\nvec3 dx21 = Pfx + jitter*ox21;\nvec3 dy21 = Pfy.y + jitter*oy21;\nvec3 dz21 = Pfz.x + jitter*oz21;\nvec3 dx22 = Pfx + jitter*ox22;\nvec3 dy22 = Pfy.y + jitter*oy22;\nvec3 dz22 = Pfz.y + jitter*oz22;\nvec3 dx23 = Pfx + jitter*ox23;\nvec3 dy23 = Pfy.y + jitter*oy23;\nvec3 dz23 = Pfz.z + jitter*oz23;\nvec3 dx31 = Pfx + jitter*ox31;\nvec3 dy31 = Pfy.z + jitter*oy31;\nvec3 dz31 = Pfz.x + jitter*oz31;\nvec3 dx32 = Pfx + jitter*ox32;\nvec3 dy32 = Pfy.z + jitter*oy32;\nvec3 dz32 = Pfz.y + jitter*oz32;\nvec3 dx33 = Pfx + jitter*ox33;\nvec3 dy33 = Pfy.z + jitter*oy33;\nvec3 dz33 = Pfz.z + jitter*oz33;\nvec3 d11 = worleyDist(dx11, dy11, dz11, distance, exponent);\nvec3 d12 = worleyDist(dx12, dy12, dz12, distance, exponent);\nvec3 d13 = worleyDist(dx13, dy13, dz13, distance, exponent);\nvec3 d21 = worleyDist(dx21, dy21, dz21, distance, exponent);\nvec3 d22 = worleyDist(dx22, dy22, dz22, distance, exponent);\nvec3 d23 = worleyDist(dx23, dy23, dz23, distance, exponent);\nvec3 d31 = worleyDist(dx31, dy31, dz31, distance, exponent);\nvec3 d32 = worleyDist(dx32, dy32, dz32, distance, exponent);\nvec3 d33 = worleyDist(dx33, dy33, dz33, distance, exponent);\nVoronoiClosest vf = VoronoiClosest(vec4(1e10), vec4(0.0));\nupdateVoronoiClosest(vf, d11, p11);\nupdateVoronoiClosest(vf, d12, p12);\nupdateVoronoiClosest(vf, d13, p13);\nupdateVoronoiClosest(vf, d21, p21);\nupdateVoronoiClosest(vf, d22, p22);\nupdateVoronoiClosest(vf, d23, p23);\nupdateVoronoiClosest(vf, d31, p31);\nupdateVoronoiClosest(vf, d32, p32);\nupdateVoronoiClosest(vf, d33, p33);\nreturn vf;\n}\nvoid node_tex_voronoi(int coloring, int distance, int feature, vec3 vector,\nfloat scale, float exponent, out vec4 outColor, out float outFac) {\nvector = scale * (vector - 0.0001);\nVoronoiClosest vf = worleyClosest(vector, 1.0, distance, exponent);\nvec4 vorColorData;\nif (coloring == COLORING_INTENSITY) {\nvorColorData = vf.closestDists;\n} else if (coloring == COLORING_CELLS) {\nvorColorData = vf.closestInds;\n}\nfloat vorColorFac;\nif (feature == FEATURE_F1) {\nvorColorFac = vorColorData.x;\n} else if (feature == FEATURE_F2) {\nvorColorFac = vorColorData.y;\n} else if (feature == FEATURE_F3) {\nvorColorFac = vorColorData.z;\n} else if (feature == FEATURE_F4) {\nvorColorFac = vorColorData.w;\n} else if (feature == FEATURE_F2F1) {\nvorColorFac = vorColorData.y - vorColorData.x;\n}\nif (coloring == COLORING_INTENSITY) {\noutFac = vorColorFac;\noutColor = vec4(vec3(outFac), 1.0);\n} else if (coloring == COLORING_CELLS) {\nvorColorFac += 1e-3;\nfloat r = rand(vec2(vorColorFac / 289.0));\nfloat g = rand(vec2(vorColorFac / 23535.0));\nfloat b = rand(vec2(vorColorFac / 4353.0));\noutFac = (r + g + b) / 3.0;\noutColor = vec4(r, g, b, 1.0);\n}\n}",node_tex_wave_bl_frag:"#define TEX_WAVE_TYPE_BANDS 0\n#define TEX_WAVE_TYPE_RINGS 1\n#define TEX_WAVE_PROFILE_SIN 0\n#define TEX_WAVE_PROFILE_SAW 1\n#define TEX_WAVE_PROFILE_TRI 2\n#define TEX_WAVE_BANDS_DIR_X 0\n#define TEX_WAVE_BANDS_DIR_Y 1\n#define TEX_WAVE_BANDS_DIR_Z 2\n#define TEX_WAVE_BANDS_DIR_DIAGONAL 3\n#define TEX_WAVE_RINGS_DIR_X 0\n#define TEX_WAVE_RINGS_DIR_Y 1\n#define TEX_WAVE_RINGS_DIR_Z 2\n#define TEX_WAVE_RINGS_DIR_SPHERICAL 3\nvoid node_tex_wave(\nint waveType, int waveProfile, int bandsDirection, int ringsDirection,\nvec3 vector, float scale, float distortion, float detail, float detailScale,\nfloat detailRoughness, float phaseOffset,\nout vec4 outColor, out float outFac) {\nvec3 coScaled = vector * scale;\nfloat waveFac;\nvec3 waveVec = coScaled;\nif (waveType == TEX_WAVE_TYPE_BANDS) {\nconst float BANDS_AXIS_SCALE = 2.0 / 3.0;\nif (bandsDirection == TEX_WAVE_BANDS_DIR_X) {\nwaveVec = waveVec.xxx * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Y) {\nwaveVec = waveVec.yyy * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Z) {\nwaveVec = waveVec.zzz * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_DIAGONAL) {\n}\nwaveFac = (waveVec.x + waveVec.y + waveVec.z) * 10.0;\n} else {\nif (ringsDirection == TEX_WAVE_RINGS_DIR_X) {\nwaveVec.x = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Y) {\nwaveVec.y = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Z) {\nwaveVec.z = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_SPHERICAL) {\n}\nwaveFac = length(waveVec) * 20.0;\n}\nif (distortion != 0.0) {\nwaveFac += distortion * noiseTurbulence(coScaled * detailScale, detail,\n0.0, 0.0, 1.0);\n}\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nwaveFac = 0.5 + 0.5 * sin(waveFac - PI_HALF + phaseOffset);\n} else if (waveProfile == TEX_WAVE_PROFILE_SAW) {\nwaveFac = fract((waveFac + phaseOffset + 1e-4) / PI2);\n} else if (waveProfile == TEX_WAVE_PROFILE_TRI) {\nwaveFac = abs(2.0 * fract((waveFac + PI + phaseOffset) / PI2) - 1.0);\n}\noutColor = vec4(waveFac, waveFac, waveFac, 1.0);\noutFac = waveFac;\n}\nvoid node_tex_wave(int waveType, int waveProfile, int bandsDirection,\nint ringsDirection, vec3 vector, float scale, float distortion,\nfloat detail, float detailScale, out vec4 outColor, out float outFac) {\nfloat legacyOffset = 0.0;\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nlegacyOffset = PI_HALF;\n}\nnode_tex_wave(waveType, waveProfile, bandsDirection, ringsDirection, vector,\nscale, distortion, detail, detailScale, 0.5, legacyOffset, outColor,\noutFac);\n}",node_tex_white_noise_bl_frag:"void node_tex_white_noise(vec3 vector, float w, out float outValue,\nout vec4 outColor) {\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise(vec3 vector, float w, out float outValue) {\noutValue = 0.0;\n}",node_uvmap_bl_frag:"void node_uvmap(vec2 uv, out vec3 outUV) {\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n}",node_valtorgb_bl_frag:"\nvoid node_valtorgb(sampler2D colormap, float fac, out vec4 colOut, out float alphaOut)\n{\ncolOut = texture2D(colormap, vec2(fac, 0.0));\nalphaOut = colOut.a;\n}",node_value_bl_frag:"\nuniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vect_math_bl_frag:"void node_vect_math_add(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 + v2;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 - v2;\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = v1 * v2;\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : v1.x / v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : v1.y / v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : v1.z / v2.z;\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = cross(v1, v2);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nfloat d = dot(v2, v2);\noutVec = (d != 0.0) ? (dot(v1, v2) / d) * v2 : vec3(0.0);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nif (v2 != vec3(0.0)) {\nv2 = normalize(v2);\n}\noutVec = reflect(v1, v2);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = distance(v1, v2);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = length(v1);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 * val;\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\nif (v1 != vec3(0.0)) {\nv1 = normalize(v1);\n}\noutVec = v1;\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : floor(v1.x / v2.x) * v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : floor(v1.y / v2.y) * v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : floor(v1.z / v2.z) * v2.z;\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = floor(v1);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = ceil(v1);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nvec3 signProduct = sign(v1) * sign(v2);\nv1 += 1e-5 * signProduct;\noutVec.x = signProduct.x > 0.0 ? mod(v1.x, abs(v2.x)) : 0.0;\noutVec.y = signProduct.y > 0.0 ? mod(v1.y, abs(v2.y)) : 0.0;\noutVec.z = signProduct.z > 0.0 ? mod(v1.z, abs(v2.z)) : 0.0;\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = fract(v1);\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = abs(v1);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = min(v1, v2);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = max(v1, v2);\n}\nvoid node_vect_math_cosine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = cos(v1);\n}\nvoid node_vect_math_sine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = sin(v1);\n}\nvoid node_vect_math_tangent(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = tan(v1);\n}\nvoid node_vect_math_wrap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nv1 += 1e-5;\noutVec.x = v2.x == v3.x ? v2.x : mod(v1.x - v3.x, v2.x - v3.x) + v3.x;\noutVec.y = v2.y == v3.y ? v2.y : mod(v1.y - v3.y, v2.y - v3.y) + v3.y;\noutVec.z = v2.z == v3.z ? v2.z : mod(v1.z - v3.z, v2.z - v3.z) + v3.z;\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_absolute(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_add(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_ceil(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_cross_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_distance(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_divide(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_dot_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_floor(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_fraction(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_maximum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_length(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_minimum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_modulo(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_project(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_normalize(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_multiply(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_scale(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_reflect(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_subtract(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_snap(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 + v2;\noutVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 - v2;\noutVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_average(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 + v2;\noutVal = length(outVec);\noutVec = normalize(outVec);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = vec3(0, 0, 0);\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = cross(v1, v2);\noutVal = length(outVec);\noutVec /= outVal;\n}\nvoid node_vect_math_normalize(vec3 v, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVal = length(v);\noutVec = normalize(v);\n}",node_vect_transform_bl_frag:"\n#define VEC_TRANS_NONE 0\n#define VEC_TRANS_W_O 1\n#define VEC_TRANS_W_C 2\n#define VEC_TRANS_O_W 3\n#define VEC_TRANS_O_C 4\n#define VEC_TRANS_C_W 5\n#define VEC_TRANS_C_O 6\n#define VEC_TRANS_W_O_DIR 7\n#define VEC_TRANS_W_C_DIR 8\n#define VEC_TRANS_O_W_DIR 9\n#define VEC_TRANS_O_C_DIR 10\n#define VEC_TRANS_C_W_DIR 11\n#define VEC_TRANS_C_O_DIR 12\nvoid node_vect_transform(const int vecTransType, const int invCamZ, vec3 vIn, out vec3 vOut)\n{\nif (vecTransType == VEC_TRANS_NONE)\nvOut = vIn;\nelse {\nvec4 vec;\nif (vecTransType < VEC_TRANS_W_O_DIR)\nvec = vec4(vIn.xyz, 1.0);\nelse\nvec = vec4(vIn.xyz, 0.0);\nif (vecTransType == VEC_TRANS_W_O || vecTransType == VEC_TRANS_W_O_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = invModelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_W_C || vecTransType == VEC_TRANS_W_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = viewMatrix * vec;\nif (invCamZ == 1)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_O_W || vecTransType == VEC_TRANS_O_W_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_O_C || vecTransType == VEC_TRANS_O_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelViewMatrix * vec;\nif (invCamZ == 1)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_C_W || vecTransType == VEC_TRANS_C_W_DIR) {\nif (invCamZ == 1)\nvec[2] = -vec[2];\nvec = invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_C_O || vecTransType == VEC_TRANS_C_O_DIR) {\nif (invCamZ == 1)\nvec[2] = -vec[2];\nvec = invModelMatrix * invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n}\nvOut = vec.xyz;\n}\n}",node_vector_displacement_bl_frag:"void node_vector_displacement(vec4 vector, float midLevel, float scale,\nout vec3 displacement) {\ndisplacement = vec3(0.0);\n}",node_vector_rotate_bl_frag:"void node_vector_rotate_axis_angle(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nif (length(axis) > 0.0) {\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axis, invert * angle);\noutVector += center;\n} else {\noutVector = vector;\n}\n}\nvoid node_vector_rotate_euler_xyz(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvec4 axisAngle = eulerToAxisAngle(rotation);\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axisAngle.xyz, invert * axisAngle.w);\noutVector += center;\n}\nvoid node_vector_rotate_x_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateXAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_y_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateYAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_z_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateZAngle(vector, invert * angle);\noutVector += center;\n}",node_vertex_color_bl_frag:"void node_vertex_color(vec4 color, out vec4 outColor, out float outAlpha) {\noutColor = color;\noutAlpha = color.a;\n}",node_volume_absorption_bl_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\noutColor = color;\n}",node_volume_info_bl_frag:"void node_volume_info(out vec4 color, out float density, out float flame,\nout float temperature) {\ncolor = vec4(vec3(0.0), 1.0);\ndensity = 0.0;\nflame = 0.0;\ntemperature = 0.0;\n}",node_volume_scatter_bl_frag:"void node_volume_scatter(vec4 color, float density, float anisotropy, out vec4 outColor)\n{\noutColor = vec4(color);\n}",node_wavelength_bl_frag:"void node_wavelength(float wavelength, out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_wireframe_bl_frag:"void node_wireframe(float size, out float outFac)\n{\noutFac = 0.0;\n}",node_bitmap_none_mx_frag:"void node_bitmap_none(out vec4 color)\n{\ncolor = vec4(1.0);\n}",node_bitmap_env_mx_frag:"void node_bitmap_env(sampler2D envMap, int reflectMode, float IOR,\nconst int encoding, const int alphaAsMono, const int alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle, vec3 normal,\nout vec4 color, out float value)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\n#endif\nmat3 uvTransform = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle);\ncolor = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\nif (alphaAsMono == 1)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB == 1)\ncolor = vec4(color.a);\n}",node_bitmap_mx_frag:"void node_bitmap(sampler2D map, const vec2 uvIn, const int mapping, const int axis,\nconst ivec2 clampToEdgeNoExtend,\nconst int encoding, const int alphaAsMono, const int alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 color, out float value)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\ncolor = vec4(0.0, 0.0, 0.0, 1.0);\n} else {\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}\nif (alphaAsMono == 1)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB == 1)\ncolor = vec4(color.a);\n}",node_bump_mx_frag:"void node_bump(sampler2D bumpMap, const vec3 eyePos, const vec3 normal, const vec2 uv,\nout vec3 normalOut)\n{\nvec2 dSTdx = dFdx(uv);\nvec2 dSTdy = dFdy(uv);\nif (any(equal(dSTdx, vec2(0.0))) || any(equal(dSTdy, vec2(0.0)))) {\nnormalOut = normal;\n} else {\nconst float bumpScale = 1.0;\nvec3 vSigmaX = vec3(dFdx(eyePos.x), dFdx(eyePos.y), dFdx(eyePos.z));\nvec3 vSigmaY = vec3(dFdy(eyePos.x), dFdy(eyePos.y), dFdy(eyePos.z));\nvec3 vN = normal;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfloat Hll = bumpScale * texture2D(bumpMap, uv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, uv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, uv + dSTdy).x - Hll;\nvec2 dHdxy = vec2(dBx, dBy);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nnormalOut = normalize(abs(fDet) * normal - vGrad);\n}\n}",node_blend_mx_frag:"void node_blend(\nconst int useCurve, const float curveLower, const float curveUpper,\nconst vec4 color1, const vec4 color2, float mask,\nout vec4 color)\n{\nif (useCurve == 1)\nmask = smoothstep(curveLower, curveUpper, mask);\nelse\nmask = clamp(mask, 0.0, 1.0);\ncolor = mix(color1, color2, mask);\n}",node_color_correction_mx_frag:"#define REWIRE_RED 0\n#define REWIRE_GREEN 1\n#define REWIRE_BLUE 2\n#define REWIRE_ALPHA 3\n#define REWIRE_RED_INV 4\n#define REWIRE_GREEN_INV 5\n#define REWIRE_BLUE_INV 6\n#define REWIRE_ALPHA_INV 7\n#define REWIRE_MONOCHROME 8\n#define REWIRE_ONE 9\n#define REWIRE_ZERO 10\nfloat rewireChannel(int type, vec4 color)\n{\nif (type == REWIRE_RED)\nreturn color.r;\nelse if (type == REWIRE_GREEN)\nreturn color.g;\nelse if (type == REWIRE_BLUE)\nreturn color.b;\nelse if (type == REWIRE_ALPHA)\nreturn color.a;\nelse if (type == REWIRE_RED_INV)\nreturn 1.0-color.r;\nelse if (type == REWIRE_GREEN_INV)\nreturn 1.0-color.g;\nelse if (type == REWIRE_BLUE_INV)\nreturn 1.0-color.b;\nelse if (type == REWIRE_ALPHA_INV)\nreturn 1.0-color.a;\nelse if (type == REWIRE_MONOCHROME)\nreturn average(color.rgb);\nelse if (type == REWIRE_ONE)\nreturn 1.0;\nelse\nreturn 0.0;\n}\nvoid node_color_correction(const ivec4 rewire,\nconst vec4 color, const float hueShift, const float saturation,\nconst vec4 tint, const float tintStrength,\nconst float brightness, const float contrast,\nout vec4 outColor)\n{\nif (all(equal(rewire, ivec4(REWIRE_RED, REWIRE_GREEN, REWIRE_BLUE, REWIRE_ALPHA)))) {\noutColor = color;\n} else {\noutColor.r = rewireChannel(rewire.x, color);\noutColor.g = rewireChannel(rewire.y, color);\noutColor.b = rewireChannel(rewire.z, color);\noutColor.a = rewireChannel(rewire.w, color);\n}\nvec4 hsv;\nrgbToHSV(outColor, hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\nhsv[1] *= (saturation / 100.0 + 1.0);\nhsv[1] = saturate(hsv[1]);\nif (tintStrength > 0.0) {\nvec4 hsvTint;\nrgbToHSV(tint, hsvTint);\nhsv[0] = hsv[0] + (hsvTint[0] - hsv[0]) * tintStrength / 100.0;\n}\nhsvToRGB(hsv, outColor);\noutColor = (outColor - 0.5) * (contrast / 100.0 + 1.0) + 0.5 + brightness / 100.0;\noutColor = max(outColor, 0.0);\n}",node_color_map_mx_frag:"void node_color_map(const int reverseGamma,\nconst vec4 color, const float gamma, const float gain,\nout vec4 outColor)\n{\nfloat p = (reverseGamma == 1) ? gamma : 1.0 / gamma;\nfloat g = (reverseGamma == 1) ? (gain > EPSILON ? 1.0 / gain : 1.0) : gain;\noutColor = vec4(g * pow(abs(color.rgb), vec3(p)), color.a);\n}",node_composite_layer_mx_frag:"#define COMP_BLEND_NORMAL 0\n#define COMP_BLEND_AVERAGE 1\n#define COMP_BLEND_ADD 2\n#define COMP_BLEND_SUBTRACT 3\n#define COMP_BLEND_DARKEN 4\n#define COMP_BLEND_MULTIPLY 5\n#define COMP_BLEND_COLORBURN 6\n#define COMP_BLEND_LINEARBURN 7\n#define COMP_BLEND_LIGHTEN 8\n#define COMP_BLEND_SCREEN 9\n#define COMP_BLEND_COLORDODGE 10\n#define COMP_BLEND_LINEARDODGE 11\n#define COMP_BLEND_SPOT 12\n#define COMP_BLEND_SPOTBLEND 13\n#define COMP_BLEND_OVERLAY 14\n#define COMP_BLEND_SOFTLIGHT 15\n#define COMP_BLEND_HARDLIGHT 16\n#define COMP_BLEND_PINLIGHT 17\n#define COMP_BLEND_HARDMIX 18\n#define COMP_BLEND_DIFFERENCE 19\n#define COMP_BLEND_EXCLUSION 20\n#define COMP_BLEND_HUE 21\n#define COMP_BLEND_SATURATION 22\n#define COMP_BLEND_COLOR 23\n#define COMP_BLEND_VALUE 24\nvec4 calcBlending(const vec4 colorBG, const vec4 colorFG, const int blendMode) {\nif (blendMode == COMP_BLEND_NORMAL)\nreturn colorFG;\nelse if (blendMode == COMP_BLEND_AVERAGE)\nreturn (colorFG + colorBG) / 2.0;\nelse if (blendMode == COMP_BLEND_ADD)\nreturn colorBG + colorFG;\nelse if (blendMode == COMP_BLEND_SUBTRACT)\nreturn colorBG - colorFG;\nelse if (blendMode == COMP_BLEND_DARKEN)\nreturn min(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_MULTIPLY)\nreturn colorBG * colorFG;\nelse if (blendMode == COMP_BLEND_COLORBURN) {\nif (colorFG.r == 0.0 && colorFG.g == 0.0 && colorFG.b == 0.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn max(1.0 - (1.0 - colorBG) / colorFG, 0.0);\n} else if (blendMode == COMP_BLEND_LINEARBURN)\nreturn max(colorFG + colorBG - 1.0, 0.0);\nelse if (blendMode == COMP_BLEND_LIGHTEN)\nreturn max(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_SCREEN)\nreturn colorFG + colorBG - colorFG * colorBG;\nelse if (blendMode == COMP_BLEND_COLORDODGE) {\nif (colorFG.r == 1.0 && colorFG.g == 1.0 && colorFG.b == 1.0)\nreturn vec4(1.0);\nelse\nreturn min(colorBG / (1.0 - colorFG), 1.0);\n} else if (blendMode == COMP_BLEND_LINEARDODGE)\nreturn min(colorFG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOT)\nreturn min(2.0 * colorFG * colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOTBLEND)\nreturn min(colorFG * colorBG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_OVERLAY) {\nif (colorBG.r <= 0.5 && colorBG.g <= 0.5 && colorBG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0 * (1.0-colorFG) * (1.0-colorBG));\n} else if (blendMode == COMP_BLEND_SOFTLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(colorBG * (colorBG + 2.0 * colorFG * (1.0 - colorBG)));\nelse\nreturn saturate(colorBG + (2.0 * colorFG - 1.0) * (sqrt(colorBG) - colorBG));\n} else if (blendMode == COMP_BLEND_HARDLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0*(1.0 - colorFG)*(1.0 - colorBG));\n} else if (blendMode == COMP_BLEND_PINLIGHT) {\nif (((colorFG.r > 0.5 && colorFG.g > 0.5 && colorFG.b > 0.5) && all(greaterThan(colorFG, colorBG))) ||\n((colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5) && all(lessThan(colorFG, colorBG))))\nreturn colorFG;\nelse\nreturn colorBG;\n} else if (blendMode == COMP_BLEND_HARDMIX) {\nif (colorFG.r + colorBG.r <= 1.0 && colorFG.g + colorBG.g <= 1.0 && colorFG.b + colorBG.b <= 1.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn vec4(1.0);\n} else if (blendMode == COMP_BLEND_DIFFERENCE)\nreturn abs(colorFG - colorBG);\nelse if (blendMode == COMP_BLEND_EXCLUSION)\nreturn colorFG + colorBG - 2.0 * colorFG * colorBG;\n}\nvec4 calcBlendingHSV(const vec4 colorBG, const vec4 colorFG, const int blendMode)\n{\nvec4 hsvBG, hsvFG;\nvec4 outColor;\nif (blendMode == COMP_BLEND_HUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvBG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_SATURATION) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_COLOR) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_VALUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvBG[1], hsvFG[2], 1.0), outColor);\n}\nreturn outColor;\n}\nvoid node_composite_layer(const int blendMode, const float opacity, \nconst vec4 colorBG, const vec4 colorFG, const vec4 mask,\nout vec4 outColor)\n{\nfloat fac = saturate(opacity * average(mask.rgb));\nif (blendMode < COMP_BLEND_HUE)\noutColor = calcBlending(colorBG, colorFG, blendMode);\nelse\noutColor = calcBlendingHSV(colorBG, colorFG, blendMode);\noutColor = mix(colorBG, outColor, fac);\n}",node_falloff_mx_frag:"void node_falloff(vec3 viewPos, float IOR,\nconst vec4 color1, const vec4 color2, vec3 normal, out vec4 color)\n{\nfloat fac;\n\nvec3 dir = normalize(viewPos);\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(dir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\ncolor = mix(color1, color2, fac);\n}",node_gradient_ramp_mx_frag:"#define GRAD_TYPE_4_CORNER 0\n#define GRAD_TYPE_BOX 1\n#define GRAD_TYPE_DIAGONAL 2\n#define GRAD_TYPE_LIGHTING 3\n#define GRAD_TYPE_LINEAR 4\n#define GRAD_TYPE_MAPPED 5\n#define GRAD_TYPE_NORMAL 6\n#define GRAD_TYPE_PONG 7\n#define GRAD_TYPE_RADIAL 8\n#define GRAD_TYPE_SPIRAL 9\n#define GRAD_TYPE_SWEEP 10\n#define GRAD_TYPE_TARTAN 11\nvoid node_gradient_ramp(\nsampler2D gradientData, int gradientType, vec2 uvIn, vec3 geometryNormal,\nvec3 viewPos, int mapping, int axis, ivec2 clampToEdgeNoExtend,\nvec4 sourceMap, float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 outCol)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nfloat coord = uvIn.x;\nuvIn = coordsOut.xy;\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\noutCol = vec4(0.0, 0.0, 0.0, 1.0);\nreturn;\n}\nuvIn = fract(uvIn);\nif (gradientType == GRAD_TYPE_4_CORNER) {\ncoord = pow(uvIn.x, 2.0);\n} else if (gradientType == GRAD_TYPE_BOX) {\nvec2 boxUv = abs(uvIn - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (gradientType == GRAD_TYPE_DIAGONAL) {\ncoord = abs(uvIn.x - uvIn.y) * sqrt(2.0);\n} else if (gradientType == GRAD_TYPE_LIGHTING) {\nIncidentLight directLight;\nGeometricContext geometry;\ngeometry.position = -viewPos;\nvec3 irr = vec3(0.0);\n#if (NUM_POINT_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(pointLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if (NUM_SPOT_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if (NUM_DIR_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if defined(PHYSICALLY_CORRECT_LIGHTS)\nirr /= PI;\n#endif\nvec3 ambIrr = getAmbientLightIrradiance(ambientLightColor);\n#if !defined(PHYSICALLY_CORRECT_LIGHTS)\nambIrr /= PI;\n#endif\nirr += ambIrr;\ncoord = (irr.x + irr.y + irr.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_LINEAR) {\ncoord = uvIn.x;\n} else if (gradientType == GRAD_TYPE_MAPPED) {\ncoord = (sourceMap.x + sourceMap.y + sourceMap.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_NORMAL) {\nfloat angle = acos(clamp(dot(geometryNormal, normalize(viewPos)), -1.0, 1.0));\nfloat k = 100.0;\ncoord = 1.0 - sin(pow2(k) - k * sqrt(pow2(k) - pow2(angle)));\n} else if (gradientType == GRAD_TYPE_PONG) {\nfloat y = min(uvIn.y, uvIn.x);\nfloat x = max(uvIn.y, uvIn.x);\ncoord = y / x;\n} else if (gradientType == GRAD_TYPE_RADIAL) {\ncoord = length(uvIn - vec2(0.5)) * 2.0;\n} else if (gradientType == GRAD_TYPE_SPIRAL) {\nvec2 uvSpiral = mat2(0.0, 1.0, -1.0, 0.0) * (uvIn - vec2(0.5));\ncoord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n} else if (gradientType == GRAD_TYPE_SWEEP) {\ncoord = atan(uvIn.x, uvIn.y) / PI_HALF;\n} else if (gradientType == GRAD_TYPE_TARTAN) {\nvec2 uvTartan = abs(uvIn - vec2(0.5));\ncoord = 1.0 - min(uvTartan.x, uvTartan.y) * 2.0;\n}\noutCol = texture2D(gradientData, vec2(coord, 0.0));\n}",node_map_mx_frag:"\nvoid node_map(const vec4 colorIn, out vec4 color)\n{\ncolor = colorIn;\n}",node_mask_mx_frag:"void node_mask(const int maskInverted, \nconst vec4 color, vec4 mask,\nout vec4 outColor)\n{\nmask = (maskInverted == 1) ? vec4(vec3(1.0) - mask.rgb, mask.a) : mask;\noutColor = color * mask;\n}",node_material_mx_frag:"\nvoid node_material(\nfloat reflectionRatio, const float refractionRatio,\nconst int selfIllumColorOn,\nconst vec4 ambientColor, const vec4 diffuseColor, const vec4 specularColor,\nconst float glossiness, const float specularLevel, const vec4 selfIllum,\nconst float opacity, const vec4 filterColor, const vec3 normal,\nconst vec4 reflection, const vec4 refraction, const float displacement,\nout vec4 outColor)\n{\nvec3 diffuse, specular;\nNodeMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specularColor.rgb;\nmaterial.diffuseIntensity = 1.0;\nmaterial.specularHardness = 4.0 * exp2(glossiness * 10.0);\nmaterial.specularIntensity = specularLevel;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\ndiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nif (selfIllumColorOn == 1) {\ndiffuse += selfIllum.rgb;\n} else {\ndiffuse = mix(diffuse, material.diffuseColor, selfIllum[0]);\n}\nspecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nfloat specularStrength = maxFromRGB(specular);\noutColor = vec4(saturate(diffuse + specular), 1.0);\nfloat alpha = opacity - saturate(maxFromRGB(specular)) * (opacity - 1.0);\noutColor += reflection * specularColor * reflectionRatio;\noutColor += refraction * refractionRatio;\nalpha += saturate(maxFromRGB(reflection.rgb) * maxFromRGB(specularColor.rgb)) * reflectionRatio;\nalpha += saturate(maxFromRGB(refraction.rgb)) * refractionRatio;\noutColor.a = alpha;\n}",node_mix_mx_frag:"void node_mix(const vec4 color1, const vec4 color2, const float amount, out vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_normal_bump_mx_frag:"void node_normal_bump(const vec4 tangent, const vec3 normal, ivec2 flip,\nvec4 normalColor, vec3 additionalBump, float normalMult, float addBumpMult,\nout vec3 normalOut)\n{\nif (flip[0] == 1)\nnormalColor.x = 1.0 - normalColor.x;\nif (flip[1] == 0)\nnormalColor.y = 1.0 - normalColor.y;\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize(modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, normalMult);\nadditionalBump = mix(normal, additionalBump, addBumpMult);\nnormalOut = normalize(normalOut + additionalBump);\n}",node_output_map_mx_frag:"vec4 processOutputColor(vec4 color, const bool invert, const bool clampColor, const bool alphaFromRGB,\nconst float rgbLevel, const float rgbOffset, const float outputAmount)\n{\nvec3 color3 = color.rgb;\ncolor3 = clampColor ? saturate(color3) : color3;\ncolor3 = color3 * rgbLevel + vec3(rgbOffset);\ncolor3 = invert ? (vec3(1.0) - color3) : color3;\ncolor = outputAmount * vec4(color3, color.a);\ncolor.a = alphaFromRGB ? average(color.rgb) : color.a;\nreturn color;\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB,\nconst vec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\noutColor = processOutputColor(color, invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB, sampler2D colormap,\nvec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\nfloat r = texture2D(colormap, vec2(color.r, 0.0)).r;\nfloat g = texture2D(colormap, vec2(color.g, 0.0)).g;\nfloat b = texture2D(colormap, vec2(color.b, 0.0)).b;\noutColor = processOutputColor(vec4(r, g, b, color.a),\ninvert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}",node_output_mx_frag:"void node_output(vec4 color, out vec4 outgoingLight)\n{\noutgoingLight = color;\n}",node_physical_mx_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_physical(\nvec3 geometryNormal, const float emitLuminance, const int useCustomReflCurve,\nconst float reflFacing, const float reflEdge, const float reflSlope,\nconst bool roughnessInv, const bool transRoughnessLock, const bool transRoughnessInv,\nconst bool thinWalled,\nconst float baseWeight, const vec4 baseColor, const float reflectivity,\nconst vec4 reflColor, const float roughness, const float metalness,\nconst float diffRoughness, const float anisotropy, const float anisoangle,\nconst float transparency, const vec4 transColor, const float transRoughness,\nconst float ior, const float scattering, const vec4 sssColor,\nconst float sssScale, const float emission, const vec4 emitColor,\nconst float coating, const vec4 coatColor, const float coatRoughness,\nconst vec3 normal, const vec3 clearcoatNormal, const float displacement,\nconst float cutout,\nout vec4 outColor)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = baseWeight * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - transparency);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coating);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\n#endif\nfloat facing, edge, slope;\nif (useCustomReflCurve == 1) {\nfacing = reflFacing;\nedge = reflEdge;\nslope = reflSlope;\n} else {\nfacing = pow2((1.0 - ior) / (1.0 + ior));\nedge = DEFAULT_REFLECTION_EDGE;\nslope = DEFAULT_REFLECTION_SLOPE;\n}\nfloat cosTheta = saturate(dot(normal, normalize(vViewPosition)));\nfloat fresnelRefl = (facing + (edge - facing) * pow(1.0 - cosTheta, slope))\n* saturate(reflectivity + metalness);\nfloat kd = 1.0 - (metalness * (1.0 - fresnelRefl) + fresnelRefl);\nmaterial.specularColor = mix(metalness * baseColorWeighted, reflColor.rgb, fresnelRefl);\nmaterial.diffuseColor *= kd;\nmaterial.specularRoughness = clamp(roughnessInv ? (1.0 - roughness) : roughness, 0.0, 1.0);\nmaterial.refractionColor = pow(transparency * (1.0 - metalness) * transColor.rgb, vec3(2.0));\nmaterial.refractionIOR = ior;\nfloat tRough;\nif (transRoughnessLock) {\ntRough = roughnessInv ? 1.0 - roughness : roughness;\n} else {\ntRough = transRoughnessInv ? 1.0 - transRoughness : transRoughness;\n}\nmaterial.refractionRoughness = pow2(tRough);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef USE_REFRACTED_LIGHT\nvec3 totalEmissiveRadiance = emitLuminance / LUMENS_PER_WATT * emission * emitColor.rgb;\nvec3 specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nspecular + totalEmissiveRadiance;\nfloat alpha = 1.0;\nif (thinWalled) {\nalpha = 1.0 - saturate(transparency) + maxFromRGB(specular) * saturate(transparency);\n} else {\noutColor3 += refractedLight;\n}\noutColor = vec4(outColor3, saturate(alpha));\n}",node_phy_sun_sky_env_mx_frag:"vec3 perezSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 direction)\n{\nfloat cosGamma = clamp(dot(direction, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(direction.y, 0.0, 1.0);\nvec3 radInternal = (1.0 + paramA * exp(paramB / cosTheta)) * (\n1.0 + paramC * exp(paramD * acos(cosGamma))\n+ paramE * pow(cosGamma, 2.0)\n);\nfloat ciex = radInternal.y * radiance.y;\nfloat ciey = radInternal.z * radiance.z;\nfloat cieY = clamp(radInternal.x * radiance.x, 0.0, 1000000.0);\nvec3 XYZ = xyY_to_XYZ(ciex, ciey, cieY);\nreturn max(xyz_to_sRGB(XYZ), 0.0);\n}\n#define GROUND_SKY_SAMPLES 16\nvec3 groundSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE, vec3 radiance, vec3 sunDirection, vec3 sunIlluminance)\n{\nconst int horizSamples = GROUND_SKY_SAMPLES;\nconst int vertSamples = GROUND_SKY_SAMPLES / 2;\nvec3 result = vec3(0.0);\nfor (int horizSampleIdx = 0; horizSampleIdx < horizSamples; horizSampleIdx++) {\nfloat horizSample = float(horizSampleIdx) / float(horizSamples);\nfloat horizAngle = PI2 * horizSample;\nfor (int vertSampleIdx = 0; vertSampleIdx < vertSamples; vertSampleIdx++) {\nfloat vertSample = float(vertSampleIdx) / float(vertSamples);\nfloat y = 1.0 - vertSample;\nfloat x = sqrt(1.0 - y*y) * cos(horizAngle);\nfloat z = -sqrt(1.0 - y*y) * sin(horizAngle);\nvec3 direction = vec3(x, y, z);\nvec3 sampleColor = perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, direction);\n\nresult += direction.y * sampleColor;\n}\n}\nresult /= float(horizSamples * vertSamples);\nresult += (sunIlluminance * sunDirection.y) / PI;\nreturn result;\n}\nvoid node_phy_sun_sky_env(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 sunIlluminance, vec3 sunLuminance, \nfloat globalIntensity, vec4 groundColor,\nout vec4 outColor) \n{\nvec3 dir = vWorldPosition;\nif (length(dir) == 0.0) {\ndir = vec3(0.0, 0.0, -1.0);\n} else {\ndir = normalize(dir);\n}\nif (dir.y < 0.0) {\noutColor = groundColor * vec4(groundSky(paramA, paramB, paramC, paramD, paramE, radiance, sunDirection, sunIlluminance), 1.0);\n} else {\noutColor = vec4(perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, dir), 1.0);\n}\noutColor = globalIntensity * outColor;\n}",node_reflect_refract_mx_frag:"void node_reflect_refract(sampler2D envMap,\nint reflectMode, const float IOR, const int encoding,\nvec3 normal, out vec4 color)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\nreflectVec = normalize(reflectVec);\ncolor = sampleEquirectangular(envMap, reflectVec, mat3(1.0), encoding);\n}",node_reflect_refract_color_mx_frag:"void node_reflect_refract_color(const vec4 colorIn, out vec4 color)\n{\ncolor = vec4(colorIn);\n}",node_rgb_multiply_mx_frag:"void node_rgb_multiply(const vec4 color1, const vec4 color2, out vec4 color)\n{\ncolor = color1 * color2;\n}",node_rgb_tint_mx_frag:"void node_rgb_tint(const vec4 color, const vec4 red, const vec4 green, const vec4 blue,\nout vec4 outColor)\n{\nmat3 tintMatrix = mat3(red.rgb, green.rgb, blue.rgb);\noutColor = vec4(tintMatrix * color.rgb, color.a);\n}",node_rgb_mx_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_shellac_mx_frag:"void node_shellac(const vec4 color1, const vec4 color2, const float amount,\nout vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_tex_environment_mx_frag:"\nvoid node_tex_environment(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nvec2 uv;\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.x, direction.z) * RECIPROCAL_PI2 + 0.5;\nuv.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.x) / seamWidth) *\nclamp (1.0 - direction.z / seamWidth, 0.0, 1.0);\noutColor = texture2D(tex, uv, seamBiasFactor * seam);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_value_mx_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vertex_color_mx_frag:"void node_vertex_color(vec3 color, out vec4 outColor)\n{\noutColor = vec4(color, 1.0);\n}",node_ai_facing_ratio_my_frag:"void node_ai_facing_ratio(\nvec3 viewNorm,\nconst float bias, const float gain, const bool invert, const bool linear,\nout float outValue)\n{\noutValue = dot(normalize(viewNorm), normalize(vViewPosition));\n}",node_ai_flat_my_frag:"void node_ai_flat(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_ai_mix_shader_my_frag:"void node_ai_mix_shader(const int mode, \nconst float mixAmt, const vec3 shader1, const vec3 shader2,\nout vec3 color)\n{\nif (mode == 0)\ncolor = mix(shader1, shader2, clamp(mixAmt, 0.0, 1.0));\nelse\ncolor = shader1 + shader2;\n}",node_ai_normal_map_my_frag:"void node_ai_normal_map(\nvec4 tangentParam,\nvec3 inputVal, vec3 normal, float strength, vec3 tangent,\nout vec3 outValue) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = inputVal.xyz * 2.0 - 1.0;\nvec3 bitangent = tangentParam.w * cross(normal, tangent);\noutValue = normalize(normalTex.x * tangent + normalTex.y * bitangent + normalTex.z * normal);\noutValue = mix(normal, outValue, strength);\n}",node_ai_skydome_light_my_frag:"void node_ai_skydome_light(sampler2D envMap, int encoding, vec3 normal,\nfloat intensity,\nout vec4 outgoingLight)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec = normalize(cameraToVertex);\nmat3 uvTransform = mat3(1.0);\nvec4 color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n#if LIGHT_PATH_IS_CAM_RAY\nintensity = 1.0;\n#endif\noutgoingLight = color * intensity;\n}",node_blend_colors_my_frag:"\nvoid node_blend_colors(float blender, vec4 color1, vec4 color2, out vec4 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}",node_bump_2d_my_frag:"void node_bump_2d(\nvec3 normal,\nfloat bumpDepth, float bumpValue,\nout vec3 outNormal) {\nvec3 position = vViewPosition;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(bumpValue);\nfloat dHdy = dFdy(bumpValue);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, bumpDepth)));\n}\nvoid node_bump_2d(\nvec3 normal, vec4 tangent,\nfloat bumpDepth, vec3 bumpValue,\nout vec3 outNormal) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (bumpValue.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\noutNormal = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\noutNormal = mix(normal, outNormal, bumpDepth);\n}",node_file_my_frag:"void node_file(sampler2D ima, const int encoding,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor, out vec2 outSize, out vec3 outTransparency) {\nvec2 uv = vec2(uvCoord.x, 1.0 - uvCoord.y);\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb;\noutAlpha = tex.a;\noutSize = vec2(0.0);\noutTransparency = vec3(1.0 - outAlpha, 1.0 - outAlpha, 1.0 - outAlpha);\n}",node_lambert_my_frag:"\nvoid node_lambert(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + incandescence, alpha);\n}",node_layered_texture_layer_my_frag:"#define LAYER_BLEND_MODE_NONE 0.0\n#define LAYER_BLEND_MODE_OVER 1.0\n#define LAYER_BLEND_MODE_IN 2.0\n#define LAYER_BLEND_MODE_OUT 3.0\n#define LAYER_BLEND_MODE_ADD 4.0\n#define LAYER_BLEND_MODE_SUBTRACT 5.0\n#define LAYER_BLEND_MODE_MULTIPLY 6.0\n#define LAYER_BLEND_MODE_DIFFERENCE 7.0\n#define LAYER_BLEND_MODE_LIGHTEN 8.0\n#define LAYER_BLEND_MODE_DARKEN 9.0\n#define LAYER_BLEND_MODE_SATURATE 10.0\n#define LAYER_BLEND_MODE_DESATURATE 11.0\n#define LAYER_BLEND_MODE_ILLUMINATE 12.0\nvoid node_layered_texture_layer(\nconst float alphaBG, const vec3 colorBG, \nconst vec3 color, const float alpha, const float blendMode, const bool isVisible,\nout float outAlpha, out vec3 outColor)\n{\noutAlpha = alphaBG;\noutColor = colorBG;\nif (!isVisible)\nreturn;\nif (blendMode == LAYER_BLEND_MODE_NONE) {\noutColor = color;\n} else if (blendMode == LAYER_BLEND_MODE_OVER) {\noutColor = mix(colorBG, color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_IN) {\noutColor = alpha * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_OUT) {\noutColor = (1.0 - alpha) * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_ADD) {\noutColor = mix(colorBG, colorBG + color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_SUBTRACT) {\noutColor = mix(colorBG, colorBG - color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_MULTIPLY) {\noutColor = mix(colorBG, colorBG * color, alpha);\n} else {\noutColor = mix(colorBG, color, alpha);\n}\n}",node_light_path_my_frag:"void node_light_path(out float isCameraRay)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\n}",node_output_my_frag:"void node_output(vec4 rgb, out vec4 outgoingLight)\n{\noutgoingLight = rgb;\n}",node_place_2d_texture_my_frag:"void node_place_2d_texture(const vec2 inUv,\nvec2 offset, vec2 repeatUv, float rotateUv,\nout vec2 outUv)\n{\noutUv = (calcUvTransform(offset.x, offset.y, repeatUv.x, repeatUv.y, rotateUv) * vec3(inUv, 1.0)).xy;\noutUv.y = 1.0 - outUv.y;\n}",node_ramp_my_frag:"void node_ramp(\nsampler2D rampData, int rampType,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor)\n{\nfloat coord;\nif (rampType == 0)\ncoord = uvCoord.y;\nelse if (rampType == 1)\ncoord = uvCoord.x;\nelse if (rampType == 2)\ncoord = abs(uvCoord.x + uvCoord.y) / 2.0;\nelse\ncoord = uvCoord.x;\nvec4 tex = texture2D(rampData, vec2(coord, 0.0));\noutAlpha = tex.w;\noutColor = tex.xyz;\n}",node_remap_hsv_my_frag:"void node_remap_hsv(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_sampler_info_my_frag:"void node_sampler_info(\nbool frontFacing, vec3 viewNorm, vec4 tangent, vec2 uv,\nout float facingRatio, out bool flippedNormal, out mat4 matrixEyeToWorld,\nout vec3 normalCamera, out vec2 pixelCenter, out vec3 pointCamera,\nout vec3 pointObj, out vec3 pointWorld,\nout vec3 tangentUCamera, out vec3 tangentVCamera, out vec2 uvCoord)\n{\nvec4 worldPos = invViewMatrix * vec4(-vViewPosition, 1.0);\nfacingRatio = dot(normalize(viewNorm), normalize(vViewPosition));\nflippedNormal = frontFacing;\nmatrixEyeToWorld = invViewMatrix;\nnormalCamera = viewNorm;\npixelCenter = vec2(1.0);\npointCamera = -vViewPosition;\npointObj = (invModelMatrix * worldPos).xyz;\npointWorld = worldPos.xyz;\ntangentUCamera = normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz);\ntangentVCamera = tangent.w * cross(viewNorm, tangentUCamera);\nuvCoord = vec2(uv.x, 1.0-uv.y);\n}",node_shading_engine_my_frag:"void node_shading_engine(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_standard_surface_my_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal,\nout vec4 outColor, out vec3 outTransparency)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = base * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - metalness);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coat);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(specularRoughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nvec3 dielRefl = DEFAULT_SPECULAR_COEFFICIENT * specular * specularColor;\nmaterial.specularColor = mix(dielRefl, baseColorWeighted, metalness);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef USE_REFRACTED_LIGHT\nvec3 totalEmissiveRadiance = emission * emissionColor;\nvec3 outSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\noutSpecular + totalEmissiveRadiance;\nfloat alpha = average(opacity);\noutColor = vec4(outColor3, saturate(alpha));\noutTransparency = outColor3;\n}",node_surface_shader_my_frag:"void node_surface_shader(\nvec3 color, vec3 glowColor, vec3 matteOpacity, vec3 transparency,\nout vec3 outColor, out vec3 outGlowColor, out vec3 outMatteOpacity, out vec3 outTransparency)\n{\noutColor = color;\noutGlowColor = glowColor;\noutMatteOpacity = matteOpacity;\noutTransparency = transparency;\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",pp_bloom_composite_frag:"varying vec2 vUv;\nuniform sampler2D blurTexture1;\nuniform sampler2D blurTexture2;\nuniform sampler2D blurTexture3;\nuniform sampler2D blurTexture4;\nuniform sampler2D blurTexture5;\nuniform sampler2D dirtTexture;\nuniform float bloomStrength;\nuniform float bloomRadius;\nuniform float bloomFactors[NUM_MIPS];\nuniform vec3 bloomTintColors[NUM_MIPS];\nfloat lerpBloomFactor(const in float factor) {\nfloat mirrorFactor = 1.2 - factor;\nreturn mix(factor, mirrorFactor, bloomRadius);\n}\nvoid main() {\ngl_FragColor = bloomStrength * (\nlerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\nlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\nlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\nlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\nlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv)\n);\n}",pp_bloom_lum_high_pass_frag:"uniform sampler2D tDiffuse;\nuniform vec3 defaultColor;\nuniform float defaultOpacity;\nuniform float luminosityThreshold;\nuniform float smoothWidth;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat v = dot(texel.xyz, luma);\nvec4 outputColor = vec4(defaultColor.rgb, defaultOpacity);\nfloat alpha = smoothstep(luminosityThreshold, luminosityThreshold + smoothWidth, v);\ngl_FragColor = mix(outputColor, texel, alpha);\ngl_FragColor = clamp(gl_FragColor, 0.0, 10.0);\n}",pp_bloom_separable_blur_frag:"#include <common>\nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma)) / sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat fSigma = float(SIGMA);\nfloat weightSum = gaussianPdf(0.0, fSigma);\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\nfor (int i = 1; i < KERNEL_RADIUS; i++) {\nfloat x = float(i);\nfloat w = gaussianPdf(x, fSigma);\nvec2 uvOffset = direction * invSize * x;\nvec3 sample1 = texture2D(colorTexture, vUv + uvOffset).rgb;\nvec3 sample2 = texture2D(colorTexture, vUv - uvOffset).rgb;\ndiffuseSum += (sample1 + sample2) * w;\nweightSum += 2.0 * w;\n}\ngl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n}",pp_blur_frag:"#include <common>\nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nuniform float kernelRadius;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\n#if LOG_SPACE == 1\nvec3 origDiffuse = texture2D(colorTexture, vUv).rgb;\nvec3 diffuseSum = vec3(weightSum);\n#else\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n#endif\nvec2 delta = direction * invSize * kernelRadius/float(MAX_SAMPLE_RADIUS);\nvec2 uvOffset = delta;\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeDir = normalize(octUVToCubeVec(vUv, invSize));\nvec3 dirX = normalize(abs(cubeDir.y) < 0.99999 ? vec3(cubeDir.z, 0.0, -cubeDir.x)\n: vec3(0.0, -cubeDir.z, cubeDir.y));\nvec3 dirY = cross(cubeDir, dirX);\n#endif\n#pragma unroll_loop\nfor (int i = 1; i <= MAX_SAMPLE_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeOffset = uvOffset.x * dirX + uvOffset.y * dirY;\nvec2 uv1 = cubeVecToOctUV(cubeDir + cubeOffset, invSize);\nvec2 uv2 = cubeVecToOctUV(cubeDir - cubeOffset, invSize);\n#else\nvec2 uv1 = vUv + uvOffset;\nvec2 uv2 = vUv - uvOffset;\n#endif\nvec3 sample1 = texture2D(colorTexture, uv1).rgb;\nvec3 sample2 = texture2D(colorTexture, uv2).rgb;\n#if LOG_SPACE == 1\ndiffuseSum += (\nclamp(exp(sample1 - origDiffuse), 0.0, 1e38) +\nclamp(exp(sample2 - origDiffuse), 0.0, 1e38)\n) * w;\n#else\ndiffuseSum += ((sample1 + sample2) * w);\n#endif\nweightSum += 2.0 * w;\nuvOffset += delta;\n}\n#if LOG_SPACE == 1\ngl_FragColor = vec4(origDiffuse + log(diffuseSum/weightSum), 1.0);\n#else\ngl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n#endif\n}",pp_brightness_contrast_frag:"\nuniform sampler2D tDiffuse;\nuniform float brightness;\nuniform float contrast;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\ntexel.rgb += brightness;\nif (contrast > 0.0)\ntexel.rgb = (texel.rgb - 0.5) / (1.0 - contrast) + 0.5;\nelse\ntexel.rgb = (texel.rgb - 0.5) * (1.0 + contrast) + 0.5;\ngl_FragColor = texel;\n}",pp_bokeh_frag:"#include <common>\nvarying vec2 vUv;\nuniform sampler2D tColor;\nuniform sampler2D tDepth;\nuniform float maxblur;\nuniform float aperture;\nuniform float nearClip;\nuniform float farClip;\nuniform float focus;\nuniform float aspect;\nuniform float depthLeakThreshold;\n#include <packing>\nfloat getDepth(const in vec2 screenPosition) {\n#if DEPTH_PACKING == 1\nreturn unpackRGBAToDepth(texture2D(tDepth, screenPosition));\n#else\nreturn texture2D(tDepth, screenPosition).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\nreturn perspectiveDepthToViewZ(depth, nearClip, farClip);\n#else\nreturn orthoDepthToViewZ(depth, nearClip, farClip);\n#endif\n}\nvec4 blurSample(vec2 uvOffset, vec4 centerCol, float viewZCenter) {\nfloat viewZ = -getViewZ(getDepth(vUv + uvOffset));\nfloat blurFactor = (viewZ >= viewZCenter) ? 1.0 : \nmin(depthLeakThreshold * abs((focus - viewZ) / aperture), 1.0);\nreturn mix(centerCol, texture2D(tColor, vUv + uvOffset), blurFactor);\n}\nvoid main() {\nvec2 aspectcorrect = vec2(1.0, aspect);\nfloat viewZ = -getViewZ(getDepth(vUv));\nfloat factor = abs(focus - viewZ);\n\nfloat dofblur = maxblur * min(factor / aperture, 1.0);\nfloat dofblur9 = dofblur * 0.9;\nfloat dofblur7 = dofblur * 0.7;\nfloat dofblur4 = dofblur * 0.4;\nvec4 centerCol = texture2D(tColor, vUv);\nvec4 col = centerCol;\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ngl_FragColor = col / 41.0;\ngl_FragColor.a = centerCol.a;\n}",pp_copy_frag:"uniform sampler2D tDiffuse;\nuniform float opacity;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = (texture2D(tDiffuse, vUv));\n#if MAP_TEXELS == 1\ntexel = mapTexelToLinear(texel);\n#endif\ngl_FragColor = opacity * texel;\n#if MAP_TEXELS == 1\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#endif\n}",pp_cube_octahedral_proj_frag:"#include <common>\nuniform samplerCube tCube;\nuniform vec2 texelSize;\nvarying vec2 vUv;\nvoid main() {\ngl_FragColor = textureCube(tCube, octUVToCubeVec(gl_FragCoord.xy * texelSize,\ntexelSize));\n}",pp_fxaa_frag:"precision highp float;\nuniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\n#define FXAA_PC 1\n#define FXAA_GLSL_100 1\n#define FXAA_QUALITY_PRESET 12\n#define FXAA_GREEN_AS_LUMA 1\n#ifndef FXAA_PC_CONSOLE\n#define FXAA_PC_CONSOLE 0\n#endif\n#ifndef FXAA_GLSL_120\n#define FXAA_GLSL_120 0\n#endif\n#ifndef FXAA_GLSL_130\n#define FXAA_GLSL_130 0\n#endif\n#ifndef FXAA_HLSL_3\n#define FXAA_HLSL_3 0\n#endif\n#ifndef FXAA_HLSL_4\n#define FXAA_HLSL_4 0\n#endif\n#ifndef FXAA_HLSL_5\n#define FXAA_HLSL_5 0\n#endif\n#ifndef FXAA_GREEN_AS_LUMA\n#define FXAA_GREEN_AS_LUMA 0\n#endif\n#ifndef FXAA_EARLY_EXIT\n#define FXAA_EARLY_EXIT 1\n#endif\n#ifndef FXAA_DISCARD\n#define FXAA_DISCARD 1\n#endif\n#ifndef FXAA_FAST_PIXEL_OFFSET\n#ifdef GL_EXT_gpu_shader4\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifdef GL_NV_gpu_shader5\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifdef GL_ARB_gpu_shader5\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifndef FXAA_FAST_PIXEL_OFFSET\n#define FXAA_FAST_PIXEL_OFFSET 0\n#endif\n#endif\n#ifndef FXAA_GATHER4_ALPHA\n#if (FXAA_HLSL_5 == 1)\n#define FXAA_GATHER4_ALPHA 1\n#endif\n#ifdef GL_ARB_gpu_shader5\n#define FXAA_GATHER4_ALPHA 1\n#endif\n#ifdef GL_NV_gpu_shader5\n#define FXAA_GATHER4_ALPHA 1\n#endif\n#ifndef FXAA_GATHER4_ALPHA\n#define FXAA_GATHER4_ALPHA 0\n#endif\n#endif\n#ifndef FXAA_QUALITY_PRESET\n#define FXAA_QUALITY_PRESET 12\n#endif\n#if (FXAA_QUALITY_PRESET == 10)\n#define FXAA_QUALITY_PS 3\n#define FXAA_QUALITY_P0 1.5\n#define FXAA_QUALITY_P1 3.0\n#define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n#define FXAA_QUALITY_PS 4\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 3.0\n#define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n#define FXAA_QUALITY_PS 5\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 4.0\n#define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n#define FXAA_QUALITY_PS 6\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 4.0\n#define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n#define FXAA_QUALITY_PS 7\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 4.0\n#define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n#define FXAA_QUALITY_PS 8\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 4.0\n#define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n#define FXAA_QUALITY_PS 3\n#define FXAA_QUALITY_P0 1.5\n#define FXAA_QUALITY_P1 2.0\n#define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n#define FXAA_QUALITY_PS 4\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n#define FXAA_QUALITY_PS 5\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n#define FXAA_QUALITY_PS 6\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n#define FXAA_QUALITY_PS 7\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 3.0\n#define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n#define FXAA_QUALITY_PS 8\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 4.0\n#define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n#define FXAA_QUALITY_PS 9\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 4.0\n#define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n#define FXAA_QUALITY_PS 10\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 4.0\n#define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n#define FXAA_QUALITY_PS 11\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 4.0\n#define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n#define FXAA_QUALITY_PS 12\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 2.0\n#define FXAA_QUALITY_P10 4.0\n#define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n#define FXAA_QUALITY_PS 12\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.0\n#define FXAA_QUALITY_P2 1.0\n#define FXAA_QUALITY_P3 1.0\n#define FXAA_QUALITY_P4 1.0\n#define FXAA_QUALITY_P5 1.5\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 2.0\n#define FXAA_QUALITY_P10 4.0\n#define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n#define FxaaBool bool\n#define FxaaDiscard discard\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 ivec2\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTex sampler2D\n#else\n#define FxaaBool bool\n#define FxaaDiscard clip(-1)\n#define FxaaFloat float\n#define FxaaFloat2 float2\n#define FxaaFloat3 float3\n#define FxaaFloat4 float4\n#define FxaaHalf half\n#define FxaaHalf2 half2\n#define FxaaHalf3 half3\n#define FxaaHalf4 half4\n#define FxaaSat(x) saturate(x)\n#endif\n#if (FXAA_GLSL_100 == 1)\n#define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n#endif\n#if (FXAA_GLSL_120 == 1)\n#define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n#if (FXAA_FAST_PIXEL_OFFSET == 1)\n#define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n#else\n#define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n#endif\n#if (FXAA_GATHER4_ALPHA == 1)\n#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n#endif\n#endif\n#if (FXAA_GLSL_130 == 1)\n#define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n#if (FXAA_GATHER4_ALPHA == 1)\n#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n#endif\n#endif\n#if (FXAA_HLSL_3 == 1)\n#define FxaaInt2 float2\n#define FxaaTex sampler2D\n#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n#endif\n#if (FXAA_HLSL_4 == 1)\n#define FxaaInt2 int2\nstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n#endif\n#if (FXAA_HLSL_5 == 1)\n#define FxaaInt2 int2\nstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n#define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n#define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n#endif\n#if (FXAA_GREEN_AS_LUMA == 0)\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n#else\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n#endif\n#if (FXAA_PC == 1)\nFxaaFloat4 FxaaPixelShader(\nFxaaFloat2 pos,\nFxaaFloat4 fxaaConsolePosPos,\nFxaaTex tex,\nFxaaTex fxaaConsole360TexExpBiasNegOne,\nFxaaTex fxaaConsole360TexExpBiasNegTwo,\nFxaaFloat2 fxaaQualityRcpFrame,\nFxaaFloat4 fxaaConsoleRcpFrameOpt,\nFxaaFloat4 fxaaConsoleRcpFrameOpt2,\nFxaaFloat4 fxaaConsole360RcpFrameOpt2,\nFxaaFloat fxaaQualitySubpix,\nFxaaFloat fxaaQualityEdgeThreshold,\nFxaaFloat fxaaQualityEdgeThresholdMin,\nFxaaFloat fxaaConsoleEdgeSharpness,\nFxaaFloat fxaaConsoleEdgeThreshold,\nFxaaFloat fxaaConsoleEdgeThresholdMin,\nFxaaFloat4 fxaaConsole360ConstDir\n) {\nFxaaFloat2 posM;\nposM.x = pos.x;\nposM.y = pos.y;\n#if (FXAA_GATHER4_ALPHA == 1)\n#if (FXAA_DISCARD == 0)\nFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n#if (FXAA_GREEN_AS_LUMA == 0)\n#define lumaM rgbyM.w\n#else\n#define lumaM rgbyM.y\n#endif\n#endif\n#if (FXAA_GREEN_AS_LUMA == 0)\nFxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\nFxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n#else\nFxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\nFxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n#endif\n#if (FXAA_DISCARD == 1)\n#define lumaM luma4A.w\n#endif\n#define lumaE luma4A.z\n#define lumaS luma4A.x\n#define lumaSE luma4A.y\n#define lumaNW luma4B.w\n#define lumaN luma4B.z\n#define lumaW luma4B.x\n#else\nFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n#if (FXAA_GREEN_AS_LUMA == 0)\n#define lumaM rgbyM.w\n#else\n#define lumaM rgbyM.y\n#endif\n#if (FXAA_GLSL_100 == 1)\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 0.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n#endif\n#endif\nFxaaFloat maxSM = max(lumaS, lumaM);\nFxaaFloat minSM = min(lumaS, lumaM);\nFxaaFloat maxESM = max(lumaE, maxSM);\nFxaaFloat minESM = min(lumaE, minSM);\nFxaaFloat maxWN = max(lumaN, lumaW);\nFxaaFloat minWN = min(lumaN, lumaW);\nFxaaFloat rangeMax = max(maxWN, maxESM);\nFxaaFloat rangeMin = min(minWN, minESM);\nFxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\nFxaaFloat range = rangeMax - rangeMin;\nFxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\nFxaaBool earlyExit = range < rangeMaxClamped;\nif(earlyExit)\n#if (FXAA_DISCARD == 1)\nreturn rgbyM;\n#else\nreturn rgbyM;\n#endif\n#if (FXAA_GATHER4_ALPHA == 0)\n#if (FXAA_GLSL_100 == 1)\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\n#else\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\nFxaaFloat lumaNS = lumaN + lumaS;\nFxaaFloat lumaWE = lumaW + lumaE;\nFxaaFloat subpixRcpRange = 1.0/range;\nFxaaFloat subpixNSWE = lumaNS + lumaWE;\nFxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\nFxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\nFxaaFloat lumaNESE = lumaNE + lumaSE;\nFxaaFloat lumaNWNE = lumaNW + lumaNE;\nFxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\nFxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\nFxaaFloat lumaNWSW = lumaNW + lumaSW;\nFxaaFloat lumaSWSE = lumaSW + lumaSE;\nFxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\nFxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\nFxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\nFxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\nFxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\nFxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\nFxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\nFxaaFloat lengthSign = fxaaQualityRcpFrame.x;\nFxaaBool horzSpan = edgeHorz >= edgeVert;\nFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\nif(!horzSpan) lumaN = lumaW;\nif(!horzSpan) lumaS = lumaE;\nif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\nFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\nFxaaFloat gradientN = lumaN - lumaM;\nFxaaFloat gradientS = lumaS - lumaM;\nFxaaFloat lumaNN = lumaN + lumaM;\nFxaaFloat lumaSS = lumaS + lumaM;\nFxaaBool pairN = abs(gradientN) >= abs(gradientS);\nFxaaFloat gradient = max(abs(gradientN), abs(gradientS));\nif(pairN) lengthSign = -lengthSign;\nFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\nFxaaFloat2 posB;\nposB.x = posM.x;\nposB.y = posM.y;\nFxaaFloat2 offNP;\noffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\noffNP.y = (horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\nif(!horzSpan) posB.x += lengthSign * 0.5;\nif(horzSpan) posB.y += lengthSign * 0.5;\nFxaaFloat2 posN;\nposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\nposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\nFxaaFloat2 posP;\nposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\nposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\nFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\nFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\nFxaaFloat subpixE = subpixC * subpixC;\nFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\nif(!pairN) lumaNN = lumaSS;\nFxaaFloat gradientScaled = gradient * 1.0/4.0;\nFxaaFloat lumaMM = lumaM - lumaNN * 0.5;\nFxaaFloat subpixF = subpixD * subpixE;\nFxaaBool lumaMLTZero = lumaMM < 0.0;\nlumaEndN -= lumaNN * 0.5;\nlumaEndP -= lumaNN * 0.5;\nFxaaBool doneN = abs(lumaEndN) >= gradientScaled;\nFxaaBool doneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\nFxaaBool doneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n#if (FXAA_QUALITY_PS > 3)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n#if (FXAA_QUALITY_PS > 4)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n#if (FXAA_QUALITY_PS > 5)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n#if (FXAA_QUALITY_PS > 6)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n#if (FXAA_QUALITY_PS > 7)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n#if (FXAA_QUALITY_PS > 8)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n#if (FXAA_QUALITY_PS > 9)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n#if (FXAA_QUALITY_PS > 10)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n#if (FXAA_QUALITY_PS > 11)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n#if (FXAA_QUALITY_PS > 12)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\nFxaaFloat dstN = posM.x - posN.x;\nFxaaFloat dstP = posP.x - posM.x;\nif(!horzSpan) dstN = posM.y - posN.y;\nif(!horzSpan) dstP = posP.y - posM.y;\nFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\nFxaaFloat spanLength = (dstP + dstN);\nFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\nFxaaFloat spanLengthRcp = 1.0/spanLength;\nFxaaBool directionN = dstN < dstP;\nFxaaFloat dst = min(dstN, dstP);\nFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\nFxaaFloat subpixG = subpixF * subpixF;\nFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\nFxaaFloat subpixH = subpixG * fxaaQualitySubpix;\nFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\nFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\nif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\nif(horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n#if (FXAA_DISCARD == 1)\nreturn FxaaTexTop(tex, posM);\n#else\nreturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n#endif\n}\n#endif\nvoid main() {\ngl_FragColor = FxaaPixelShader(\nvUv,\nvec4(0.0),\ntDiffuse,\ntDiffuse,\ntDiffuse,\nresolution,\nvec4(0.0),\nvec4(0.0),\nvec4(0.0),\n0.75,\n0.166,\n0.0833,\n0.0,\n0.0,\n0.0,\nvec4(0.0)\n);\n\n}",pp_grayscale_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat bw = texel.r * 0.35 + texel.g * 0.45 + texel.b * 0.2;\ntexel = vec4(bw, bw, bw, texel.a);\ngl_FragColor = texel;\n}",pp_outline_edge_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform vec2 texSize;\nuniform vec4 visibleEdgeColor;\nuniform vec4 hiddenEdgeColor;\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\nvec4 c1 = texture2D(maskTexture, vUv + uvOffset.xy);\nvec4 c2 = texture2D(maskTexture, vUv - uvOffset.xy);\nvec4 c3 = texture2D(maskTexture, vUv + uvOffset.yw);\nvec4 c4 = texture2D(maskTexture, vUv - uvOffset.yw);\nfloat diff1 = (c1.r - c2.r) * 0.5;\nfloat diff2 = (c3.r - c4.r) * 0.5;\nfloat d = length(vec2(diff1, diff2));\nfloat a1 = min(c1.g, c2.g);\nfloat a2 = min(c3.g, c4.g);\nfloat visibilityFactor = min(a1, a2);\nvec4 edgeColor = (1.0 - visibilityFactor > 0.001) ? visibleEdgeColor : hiddenEdgeColor;\ngl_FragColor = edgeColor * vec4(d);\n}",pp_outline_blur_frag:"#include <common>\nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nuniform float kernelRadius;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\nvec4 diffuseSum = texture2D(colorTexture, vUv);\n#if defined(LOG_SPACE)\ndiffuseSum = exp(diffuseSum);\n#endif\ndiffuseSum *= weightSum;\nvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\nvec2 uvOffset = delta;\nfor (int i = 1; i <= MAX_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\nvec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\nvec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n#if defined(LOG_SPACE)\nsample1 = exp(sample1);\nsample2 = exp(sample2);\n#endif\ndiffuseSum += ((sample1 + sample2) * w);\nweightSum += (2.0 * w);\nuvOffset += delta;\n}\nvec4 finalCol = diffuseSum / weightSum;\n#if defined(LOG_SPACE)\nfinalCol = log(finalCol);\n#endif\ngl_FragColor = finalCol;\n}",pp_outline_overlay_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform sampler2D edgeTexture1;\nuniform sampler2D edgeTexture2;\nuniform sampler2D patternTexture;\nuniform float edgeStrength;\nuniform float edgeGlow;\nuniform bool usePatternTexture;\nvoid main() {\nvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\nvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\nvec4 maskColor = texture2D(maskTexture, vUv);\nvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\nfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\nvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\nvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\nif (usePatternTexture)\nfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\nfloat maxChannel = max(finalColor.r, max(finalColor.g, finalColor.b));\nif (maxChannel != 0.0) {\nfinalColor.rgb /= maxChannel;\n}\ngl_FragColor = finalColor;\n}",pp_ssao_blur_frag:"uniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\nvoid main() {\nvec2 texelSize = (1.0 / resolution);\nfloat result = 0.0;\nfor (int i = - 2; i <= 2; i++) {\nfor (int j = - 2; j <= 2; j ++) {\nvec2 offset = (vec2(float(i), float(j))) * texelSize;\nresult += texture2D(tDiffuse, vUv + offset).r;\n}\n}\ngl_FragColor = vec4(vec3(result / (5.0 * 5.0)), 1.0);\n}",pp_ssao_depth_frag:"uniform sampler2D tDepth;\nuniform float cameraNear;\nuniform float cameraFar;\nvarying vec2 vUv;\n#include <packing>\nfloat getLinearDepth(const in vec2 screenPosition) {\n#if PERSPECTIVE_CAMERA == 1\nfloat fragCoordZ = texture2D(tDepth, screenPosition).x;\nfloat viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\nreturn viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n#else\nreturn texture2D(depthSampler, coord).x;\n#endif\n}\nvoid main() {\nfloat depth = getLinearDepth(vUv);\ngl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n}",pp_ssao_frag:"uniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform vec3 kernel[KERNEL_SIZE];\nuniform vec2 resolution;\nuniform float cameraNear;\nuniform float cameraFar;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraInverseProjectionMatrix;\nuniform float kernelRadius;\nuniform float minDistance;\nuniform float maxDistance;\nvarying vec2 vUv;\n#include <packing>\nfloat getDepth(const in vec2 screenPosition) {\nreturn texture2D(tDepth, screenPosition).x;\n}\nfloat getLinearDepth(const in vec2 screenPosition) {\n#if PERSPECTIVE_CAMERA == 1\nfloat fragCoordZ = texture2D(tDepth, screenPosition).x;\nfloat viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\nreturn viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n#else\nreturn texture2D(depthSampler, coord).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\nreturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n#else\nreturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n#endif\n}\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ) {\nfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\nvec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\nclipPosition *= clipW;\nreturn (cameraInverseProjectionMatrix * clipPosition).xyz;\n}\nvec3 getViewNormal(const in vec2 screenPosition) {\nreturn unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n}\nvoid main() {\nfloat depth = getDepth(vUv);\nfloat viewZ = getViewZ(depth);\nvec3 viewPosition = getViewPosition(vUv, depth, viewZ);\nvec3 viewNormal = getViewNormal(vUv);\nvec2 noiseScale = vec2(resolution.x / 4.0, resolution.y / 4.0);\nvec3 random = texture2D(tNoise, vUv * noiseScale).xyz;\nvec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\nvec3 bitangent = cross(viewNormal, tangent);\nmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\nfloat occlusion = 0.0;\nfor (int i = 0; i < KERNEL_SIZE; i++) {\nvec3 sampleVector = kernelMatrix * kernel[i];\nvec3 samplePoint = viewPosition + (sampleVector * kernelRadius);\nvec4 samplePointNDC = cameraProjectionMatrix * vec4(samplePoint, 1.0);\nsamplePointNDC /= samplePointNDC.w;\nvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5;\nfloat realDepth = getLinearDepth(samplePointUv);\nfloat sampleDepth = viewZToOrthographicDepth(samplePoint.z, cameraNear, cameraFar);\nfloat delta = sampleDepth - realDepth;\nif (delta > minDistance && delta < maxDistance) {\nocclusion += 1.0;\n}\n}\nocclusion = clamp(occlusion / float(KERNEL_SIZE), 0.0, 1.0);\ngl_FragColor = vec4(vec3(1.0 - occlusion), 1.0);\n}",pp_tonemap_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat alpha = clamp(texel.a, 0.0, 1.0);\ngl_FragColor = texel;\ngl_FragColor.rgb /= alpha;\n#include <tonemapping_fragment>\ngl_FragColor = LinearTosRGB(gl_FragColor);\ngl_FragColor.rgb *= alpha;\n}",raw_meshline_frag:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D alphaMap;\nuniform float useMap;\nuniform float useAlphaMap;\nuniform float visibility;\nuniform float alphaTest;\nuniform vec2 repeat;\nuniform vec3 color;\nuniform float opacity;\nvarying vec2 vUV;\nvarying float vCounters;\n#include <encodings_pars_fragment>\nvoid main() {\nvec4 c = vec4(color, opacity);\nif (useMap == 1.0) {\nc *= texture2D(map, vUV * repeat);\n}\nif (useAlphaMap == 1.0) {\nc.a *= texture2D(alphaMap, vUV * repeat).a;\n}\nif (c.a < alphaTest) {\ndiscard;\n}\ngl_FragColor = c;\ngl_FragColor.a *= step(vCounters, visibility);\ngl_FragColor = LinearTosRGB(gl_FragColor);\n}",raw_meshline_vert:"precision highp float;\nattribute vec3 position;\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\nattribute vec2 uv;\nattribute float counters;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform vec2 resolution;\nuniform float lineWidth;\nuniform float sizeAttenuation;\nvarying float vCounters;\nvarying vec2 vUV;\nconst float EQ_EPS = 0.000001;\nvec2 fix(vec4 i, float aspect) {\nvec2 res = i.xy / i.w;\nres.x *= aspect;\nreturn res;\n}\nbool posEqual(vec2 pos0, vec2 pos1) {\nreturn length(pos0 - pos1) < EQ_EPS;\n}\nvoid main() {\nfloat aspect = resolution.x / resolution.y;\nvCounters = counters;\nvUV = uv;\nmat4 m = projectionMatrix * modelViewMatrix;\nvec4 finalPosition = m * vec4(position, 1.0);\nvec4 prevPos = m * vec4(previous, 1.0);\nvec4 nextPos = m * vec4(next, 1.0);\nvec2 currentP = fix(finalPosition, aspect);\nvec2 prevP = fix(prevPos, aspect);\nvec2 nextP = fix(nextPos, aspect);\nfloat w = lineWidth * width;\nif (sizeAttenuation == 0.0) {\nw *= finalPosition.w / resolution.x;\n}\nvec2 dir;\nif (posEqual(nextP, currentP)) {\ndir = normalize(currentP - prevP);\n} else if (posEqual(prevP, currentP)) {\ndir = normalize(nextP - currentP);\n} else {\nvec2 dir1 = normalize(currentP - prevP);\nvec2 dir2 = normalize(nextP - currentP);\ndir = normalize(dir1 + dir2);\n}\nvec2 offset = vec2(-dir.y, dir.x);\noffset.y *= aspect;\noffset *= w;\nfinalPosition.xy += offset * side;\ngl_Position = finalPosition;\n}"},oa={basic:{uniforms:Ui([Ji.common,Ji.specularmap,Ji.envmap,Ji.aomap,Ji.lightmap,Ji.fog]),vertexShader:aa.meshbasic_vert,fragmentShader:aa.meshbasic_frag},lambert:{uniforms:Ui([Ji.common,Ji.specularmap,Ji.envmap,Ji.aomap,Ji.lightmap,Ji.emissivemap,Ji.fog,Ji.lights,{emissive:{value:new Lr(0)}}]),vertexShader:aa.meshlambert_vert,fragmentShader:aa.meshlambert_frag},phong:{uniforms:Ui([Ji.common,Ji.specularmap,Ji.envmap,Ji.aomap,Ji.lightmap,Ji.emissivemap,Ji.bumpmap,Ji.normalmap,Ji.displacementmap,Ji.fog,Ji.lights,{emissive:{value:new Lr(0)},specular:{value:new Lr(1118481)},shininess:{value:30}}]),vertexShader:aa.meshphong_vert,fragmentShader:aa.meshphong_frag},standard:{uniforms:Ui([Ji.common,Ji.envmap,Ji.aomap,Ji.lightmap,Ji.emissivemap,Ji.bumpmap,Ji.normalmap,Ji.displacementmap,Ji.roughnessmap,Ji.metalnessmap,Ji.fog,Ji.lights,{emissive:{value:new Lr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:aa.meshphysical_vert,fragmentShader:aa.meshphysical_frag},toon:{uniforms:Ui([Ji.common,Ji.specularmap,Ji.aomap,Ji.lightmap,Ji.emissivemap,Ji.bumpmap,Ji.normalmap,Ji.displacementmap,Ji.gradientmap,Ji.fog,Ji.lights,{emissive:{value:new Lr(0)},specular:{value:new Lr(1118481)},shininess:{value:30}}]),vertexShader:aa.meshtoon_vert,fragmentShader:aa.meshtoon_frag},matcap:{uniforms:Ui([Ji.common,Ji.bumpmap,Ji.normalmap,Ji.displacementmap,Ji.fog,{matcap:{value:null}}]),vertexShader:aa.meshmatcap_vert,fragmentShader:aa.meshmatcap_frag},points:{uniforms:Ui([Ji.points,Ji.fog]),vertexShader:aa.points_vert,fragmentShader:aa.points_frag},dashed:{uniforms:Ui([Ji.common,Ji.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:aa.linedashed_vert,fragmentShader:aa.linedashed_frag},depth:{uniforms:Ui([Ji.common,Ji.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:aa.depth_vert,fragmentShader:aa.depth_frag},normal:{uniforms:Ui([Ji.common,Ji.bumpmap,Ji.normalmap,Ji.displacementmap,{opacity:{value:1}}]),vertexShader:aa.normal_vert,fragmentShader:aa.normal_frag},sprite:{uniforms:Ui([Ji.sprite,Ji.fog]),vertexShader:aa.sprite_vert,fragmentShader:aa.sprite_frag},background:{uniforms:{uvTransform:{value:new $t},t2D:{value:null}},vertexShader:aa.background_vert,fragmentShader:aa.background_frag},cube:{uniforms:Ui([Ji.envmap,{opacity:{value:1}}]),vertexShader:aa.cube_vert,fragmentShader:aa.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:aa.equirect_vert,fragmentShader:aa.equirect_frag},distanceRGBA:{uniforms:Ui([Ji.common,Ji.displacementmap,{referencePosition:{value:new un},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:aa.distanceRGBA_vert,fragmentShader:aa.distanceRGBA_frag},shadow:{uniforms:Ui([Ji.lights,Ji.fog,{color:{value:new Lr(0)},opacity:{value:1}}]),vertexShader:aa.shadow_vert,fragmentShader:aa.shadow_frag},mask:{uniforms:Ui([Ji.common,Ji.displacementmap,Ji.mask]),vertexShader:aa.mask_vert,fragmentShader:aa.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:aa.equicube_vert,fragmentShader:aa.equicube_frag},node:{uniforms:Ui([Ji.common,Ji.displacementmap,Ji.envmap,Ji.fog,Ji.lights,Ji.ssr,Ji.node,{envMapIntensity:{value:1}}]),vertexShader:aa.meshnode_vert,fragmentShader:aa.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new Jt(.5,.5)}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_cube_octahedral_proj_frag}};function sa(h,n,p,r){var f,m,v,g,_=new Lr(0),y=0,x=null,b=0,M=null;function w(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return _},setClearColor:function(e,t){_.set(e),w(_,y=void 0!==t?t:1)},getClearAlpha:function(){return y},setClearAlpha:function(e){w(_,y=e)},dispose:function(){m&&(m.geometry.dispose(),m.material.dispose()),m=f=void 0,v&&(v.geometry.dispose(),v.material.dispose()),v=void 0,g&&(g.geometry.dispose(),g.material.dispose()),g=void 0},render:function(e,t,n,r){var i=t.background&&t.background.isSceneBackground,a=i?t.background.data:t.background,o=h.xr,s=o.getSession&&o.getSession();s&&"additive"===s.environmentBlendMode&&(a=null),null===a?w(_,y):a&&a.isColor&&(w(a,1),r=!0),(h.autoClear||r)&&h.clear(h.autoClearColor,h.autoClearDepth,h.autoClearStencil);var l,c,u,d=!!i&&t.background.useHDR;a&&(a.isCubeTexture||a.isWebGLCubeRenderTarget||a.mapping===Ye)?(void 0===v&&((v=new Ci(new Bi(1,1,1),new ji({type:"BackgroundCubeMaterial",uniforms:Vi.clone(oa.cube.uniforms),vertexShader:oa.cube.vertexShader,fragmentShader:oa.cube.fragmentShader,side:Le,depthTest:!1,depthWrite:!1,fog:!1,polygonOffset:!0,useHDR:d}))).geometry.deleteAttribute("normal"),v.geometry.deleteAttribute("uv"),v.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(v.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),p.update(v)),l=a.isWebGLCubeRenderTarget?a.texture:a,v.material.uniforms.envMap.value=l,v.material.uniforms.flipEnvMap.value=l.isCubeTexture?-1:1,x===a&&b===l.version&&M===h.toneMapping||(v.material.needsUpdate=!0,x=a,b=l.version,M=h.toneMapping),e.unshift(v,v.geometry,v.material,0,0,null)):a&&a.isTexture&&(a.mapping===We?(c=!!i&&t.background.equirecInvertU,u=i?t.background.equirecOffsetU:0,void 0===g&&((g=new Ci(new Bi(1,1,1),new ji({vertexShader:oa.equirect.vertexShader,fragmentShader:oa.equirect.fragmentShader,uniforms:oa.equirect.uniforms,side:Le,depthTest:!1,depthWrite:!1,polygonOffset:!0,useHDR:d}))).geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)}),p.update(g),g.material.uniforms.invertU.value=c,g.material.uniforms.offsetU.value=u,g.material.uniforms.tEquirect.value=a,e.unshift(g,g.geometry,g.material,0,0,null)):(void 0===f&&(f=new na(-1,1,1,-1,0,1),m=new Ci(new ia(2,2),new zr({depthTest:!1,depthWrite:!1,fog:!1}))),p.update(m),m.material.map=a,h.renderBufferDirect(f,null,m.geometry,m.material,m,null)))}}}function la(o,s,l,e){var c,u=e.isWebGL2;this.setMode=function(e){c=e},this.render=function(e,t){o.drawArrays(c,e,t),l.update(t,c)},this.renderInstances=function(e,t,n,r){if(0!==r){var i,a;if(u)i=o,a="drawArraysInstanced";else if(a="drawArraysInstancedANGLE",null===(i=s.get("ANGLE_instanced_arrays")))return void console.error("v3d.WebGLBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");i[a](c,t,n,r),l.update(n,c,r)}}}function ca(t,n,e){var r;function i(e){if("highp"===e){if(0<t.getShaderPrecisionFormat(35633,36338).precision&&0<t.getShaderPrecisionFormat(35632,36338).precision)return"highp";e="mediump"}return"mediump"===e&&0<t.getShaderPrecisionFormat(35633,36337).precision&&0<t.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==e.precision?e.precision:"highp",s=i(o);s!==o&&(console.warn("v3d.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===e.logarithmicDepthBuffer,c=t.getParameter(34930),u=t.getParameter(35660),d=t.getParameter(3379),h=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=0<u,_=a||!!n.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var e=n.get("EXT_texture_filter_anisotropic");return r=null!==e?t.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:_,floatVertexTextures:g&&_,maxSamples:a?t.getParameter(36183):0}}function ua(){var u=this,d=null,h=0,p=!1,f=!1,m=new mr,v=new $t,g={value:null,needsUpdate:!1};function _(){g.value!==d&&(g.value=d,g.needsUpdate=0<h),u.numPlanes=h,u.numIntersection=0}function y(e,t,n,r){var i=null!==e?e.length:0,a=null;if(0!==i){if(a=g.value,!0!==r||null===a){var o=n+4*i,s=t.matrixWorldInverse;v.getNormalMatrix(s),(null===a||a.length<o)&&(a=new Float32Array(o));for(var l=0,c=n;l!==i;++l,c+=4)m.copy(e[l]).applyMatrix4(s,v),m.normal.toArray(a,c),a[c+3]=m.constant}g.value=a,g.needsUpdate=!0}return u.numPlanes=i,a}this.uniform=g,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,n){var r=0!==e.length||t||0!==h||p;return p=t,d=y(e,n,0),h=e.length,r},this.beginShadows=function(){f=!0,y(null)},this.endShadows=function(){f=!1,_()},this.setState=function(e,t,n,r,i,a){if(!p||null===e||0===e.length||f&&!n)f?y(null):_();else{var o=f?0:h,s=4*o,l=i.clippingState||null;g.value=l,l=y(e,r,s,a);for(var c=0;c!==s;++c)l[c]=d[c];i.clippingState=l,this.numIntersection=t?this.numPlanes:0,this.numPlanes+=o}}}function da(n){var r={};return{get:function(e){if(void 0!==r[e])return r[e];var t;switch(e){case"WEBGL_depth_texture":t=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":t=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":t=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":t=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:t=n.getExtension(e)}return null===t&&console.warn("v3d.WebGLRenderer: "+e+" extension not supported."),r[e]=t}}}function ha(e,p,a){var o=new WeakMap,f=new WeakMap;function s(e){var t=e.target,n=o.get(t);for(var r in null!==n.index&&p.remove(n.index),n.attributes)p.remove(n.attributes[r]);t.removeEventListener("dispose",s),o.delete(t);var i=f.get(n);i&&(p.remove(i),f.delete(n)),a.memory.geometries--}function r(e){var t=[],n=e.index,r=e.attributes.position,i=0;if(null!==n)for(var a=n.array,i=n.version,o=0,s=a.length;o<s;o+=3){var l=a[o+0],c=a[o+1],u=a[o+2];t.push(l,c,c,u,u,l)}else{a=r.array;i=r.version;for(o=0,s=a.length/3-1;o<s;o+=3){l=o+0,c=o+1,u=o+2;t.push(l,c,c,u,u,l)}}var d=new(65535<Kr(t)?Yr:Xr)(t,1);d.version=i,p.update(d,34963);var h=f.get(e);h&&p.remove(h),f.set(e,d)}return{get:function(e,t){var n=o.get(t);return n||(t.addEventListener("dispose",s),t.isBufferGeometry?n=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new ui).setFromObject(e)),n=t._bufferGeometry),o.set(t,n),a.memory.geometries++,n)},update:function(e){var t=e.index,n=e.attributes;for(var r in null!==t&&p.update(t,34963),n)p.update(n[r],34962);var i=e.morphAttributes;for(var r in i)for(var a=i[r],o=0,s=a.length;o<s;o++)p.update(a[o],34962)},getWireframeAttribute:function(e){var t,n=f.get(e);return(!n||null!==(t=e.index)&&n.version<t.version)&&r(e),f.get(e)}}}function pa(o,s,l,e){var c,u,d,h=e.isWebGL2;this.setMode=function(e){c=e},this.setIndex=function(e){u=e.type,d=e.bytesPerElement},this.render=function(e,t){o.drawElements(c,t,u,e*d),l.update(t,c)},this.renderInstances=function(e,t,n,r){if(0!==r){var i,a;if(h)i=o,a="drawElementsInstanced";else if(a="drawElementsInstancedANGLE",null===(i=s.get("ANGLE_instanced_arrays")))return void console.error("v3d.WebGLIndexedBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");i[a](c,n,u,t*d,r),l.update(n,c,r)}}}function fa(e){var a={geometries:0,textures:0,textureSpecs:new Map},r={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:a,render:r,programs:null,autoReset:!0,reset:function(){r.frame++,r.calls=0,r.triangles=0,r.points=0,r.lines=0},update:function(e,t,n){switch(n=n||1,r.calls++,t){case 4:r.triangles+=n*(e/3);break;case 1:r.lines+=n*(e/2);break;case 3:r.lines+=n*(e-1);break;case 2:r.lines+=n*e;break;case 0:r.points+=n*e;break;default:console.error("v3d.WebGLInfo: Unknown draw mode:",t)}},addTextureSpec:function(e){var t,n,r,i;i=e.isWebGLRenderTarget?(t=e.texture.name,n="WebGLRenderTarget",r=e.width,e.height):(t=e.name,n="Texture",r=e.image.width,e.image.height),a.textureSpecs.set(e,{name:t,type:n,width:r,height:i})},removeTextureSpec:function(e){a.textureSpecs.delete(e)}}}function ma(e,t){return Math.abs(t[1])-Math.abs(e[1])}function va(m){var v={},g=new Float32Array(8);return{update:function(e,t,n,r){var i=e.morphTargetInfluences,a=void 0===i?0:i.length,o=v[t.id];if(void 0===o){o=[];for(var s=0;s<a;s++)o[s]=[s,0];v[t.id]=o}for(var l=n.morphTargets&&t.morphAttributes.position,c=n.morphNormals&&t.morphAttributes.normal,s=0;s<a;s++){0!==(u=o[s])[1]&&(l&&t.deleteAttribute("morphTarget"+s),c&&t.deleteAttribute("morphNormal"+s))}for(s=0;s<a;s++){(u=o[s])[0]=s,u[1]=i[s]}o.sort(ma);for(var u,d=0,s=0;s<8;s++){if(u=o[s]){var h=u[0],p=u[1];if(p){l&&t.setAttribute("morphTarget"+s,l[h]),c&&t.setAttribute("morphNormal"+s,c[h]),d+=g[s]=p;continue}}g[s]=0}var f=t.morphTargetsRelative?1:1-d;r.getUniforms().setValue(m,"morphTargetBaseInfluence",f),r.getUniforms().setValue(m,"morphTargetInfluences",g)}}}function ga(e,i,a,o){var s={};return{update:function(e){var t=o.render.frame,n=e.geometry,r=i.get(e,n);return s[r.id]!==t&&(n.isGeometry&&r.updateFromObject(e),i.update(r),s[r.id]=t),e.isInstancedMesh&&a.update(e.instanceMatrix,34962),r},dispose:function(){s={}}}}function _a(e,t,n,r,i,a,o,s,l,c){nn.call(this,e=void 0!==e?e:[],t=void 0!==t?t:Ge,n,r,i,a,o=void 0!==o?o:ut,s,l,c),this.flipY=!1}function ya(e,t,n,r){nn.call(this,null),this.image={data:e||null,width:t||1,height:n||1,depth:r||1},this.magFilter=Je,this.minFilter=Je,this.wrapR=Qe,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function xa(e,t,n,r){nn.call(this,null),this.image={data:e||null,width:t||1,height:n||1,depth:r||1},this.magFilter=Je,this.minFilter=Je,this.wrapR=Qe,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}oa.physical={uniforms:Ui([oa.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new Lr(0)},clearcoatNormalScale:{value:new Jt(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:aa.meshphysical_vert,fragmentShader:aa.meshphysical_frag},oa.copy={defines:{MAP_TEXELS:0},uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_copy_frag},oa.bokeh={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:1},nearClip:{value:1},farClip:{value:1e3},depthLeakThreshold:{value:.2}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_bokeh_frag},oa.fxaa={uniforms:{tDiffuse:{value:null},resolution:{value:new Jt(1/1024,1/512)}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_fxaa_frag},oa.grayscale={uniforms:{tDiffuse:{value:null}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_grayscale_frag},oa.brightness_contrast={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_brightness_contrast_frag},oa.bloomLumHighPass={uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new Lr(0)},defaultOpacity:{type:"f",value:0}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_bloom_lum_high_pass_frag},oa.blur={defines:{LOG_SPACE:0,OCTAHEDRAL_MAP:0},uniforms:{colorTexture:{value:null},texSize:{value:new Jt(.5,.5)},direction:{value:new Jt(.5,.5)},kernelRadius:{value:1}},customPrepTokens:{MAX_SAMPLE_RADIUS:4},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_blur_frag},oa.tonemap={uniforms:{tDiffuse:{value:null}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_tonemap_frag},((_a.prototype=Object.create(nn.prototype)).constructor=_a).prototype.isCubeTexture=!0,Object.defineProperty(_a.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),((ya.prototype=Object.create(nn.prototype)).constructor=ya).prototype.isDataTexture2DArray=!0,((xa.prototype=Object.create(nn.prototype)).constructor=xa).prototype.isDataTexture3D=!0;var ba=new nn,Ma=new ya,wa=new xa,Aa=new _a,Sa=[],Ta=[],Ea=new Float32Array(16),Ca=new Float32Array(9),Pa=new Float32Array(4);function La(e,t,n){var r=e[0];if(r<=0||0<r)return e;var i=t*n,a=Sa[i];if(void 0===a&&(a=new Float32Array(i),Sa[i]=a),0!==t){r.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function Ra(e,t){if(e.length===t.length){for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return;return 1}}function Da(e,t){for(var n=0,r=t.length;n<r;n++)e[n]=t[n]}function Na(e,t){var n=Ta[t];void 0===n&&(n=new Int32Array(t),Ta[t]=n);for(var r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function Ia(e,t){var n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Oa(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ra(n,t))return;e.uniform2fv(this.addr,t),Da(n,t)}}function Fa(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ra(n,t))return;e.uniform3fv(this.addr,t),Da(n,t)}}function Ba(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ra(n,t))return;e.uniform4fv(this.addr,t),Da(n,t)}}function za(e,t){var n=this.cache,r=t.elements;if(void 0===r){if(Ra(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Da(n,t)}else{if(Ra(n,r))return;Pa.set(r),e.uniformMatrix2fv(this.addr,!1,Pa),Da(n,r)}}function Ua(e,t){var n=this.cache,r=t.elements;if(void 0===r){if(Ra(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Da(n,t)}else{if(Ra(n,r))return;Ca.set(r),e.uniformMatrix3fv(this.addr,!1,Ca),Da(n,r)}}function Va(e,t){var n=this.cache,r=t.elements;if(void 0===r){if(Ra(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Da(n,t)}else{if(Ra(n,r))return;Ea.set(r),e.uniformMatrix4fv(this.addr,!1,Ea),Da(n,r)}}function ka(e,t,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(t||ba,i)}function Ga(e,t,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||Ma,i)}function ja(e,t,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||wa,i)}function Wa(e,t,n){var r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(t||Aa,i)}function Xa(e,t){var n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Ha(e,t){var n=this.cache;Ra(n,t)||(e.uniform2iv(this.addr,t),Da(n,t))}function Ya(e,t){var n=this.cache;Ra(n,t)||(e.uniform3iv(this.addr,t),Da(n,t))}function qa(e,t){var n=this.cache;Ra(n,t)||(e.uniform4iv(this.addr,t),Da(n,t))}function Za(e,t){var n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Qa(e,t){e.uniform1fv(this.addr,t)}function Ka(e,t){e.uniform1iv(this.addr,t)}function Ja(e,t){e.uniform2iv(this.addr,t)}function $a(e,t){e.uniform3iv(this.addr,t)}function eo(e,t){e.uniform4iv(this.addr,t)}function to(e,t){var n=La(t,this.size,2);e.uniform2fv(this.addr,n)}function no(e,t){var n=La(t,this.size,3);e.uniform3fv(this.addr,n)}function ro(e,t){var n=La(t,this.size,4);e.uniform4fv(this.addr,n)}function io(e,t){var n=La(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function ao(e,t){var n=La(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function oo(e,t){var n=La(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function so(e,t,n){var r=t.length,i=Na(n,r);e.uniform1iv(this.addr,i);for(var a=0;a!==r;++a)n.safeSetTexture2D(t[a]||ba,i[a])}function lo(e,t,n){var r=t.length,i=Na(n,r);e.uniform1iv(this.addr,i);for(var a=0;a!==r;++a)n.safeSetTextureCube(t[a]||Aa,i[a])}function co(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Ia;case 35664:return Oa;case 35665:return Fa;case 35666:return Ba;case 35674:return za;case 35675:return Ua;case 35676:return Va;case 5124:case 35670:return Xa;case 35667:case 35671:return Ha;case 35668:case 35672:return Ya;case 35669:case 35673:return qa;case 5125:return Za;case 35678:case 36198:case 36298:case 36306:case 35682:return ka;case 35679:case 36299:case 36307:return ja;case 35680:case 36300:case 36308:case 36293:return Wa;case 36289:case 36303:case 36311:case 36292:return Ga}}(t.type)}function uo(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Qa;case 35664:return to;case 35665:return no;case 35666:return ro;case 35674:return io;case 35675:return ao;case 35676:return oo;case 5124:case 35670:return Ka;case 35667:case 35671:return Ja;case 35668:case 35672:return $a;case 35669:case 35673:return eo;case 35678:case 36198:case 36298:case 36306:case 35682:return so;case 35680:case 36300:case 36308:case 36293:return lo}}(t.type)}function ho(e){this.id=e,this.seq=[],this.map={}}uo.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Da(t,e)},ho.prototype.setValue=function(e,t,n){for(var r=this.seq,i=0,a=r.length;i!==a;++i){var o=r[i];o.setValue(e,t[o.id],n)}};var po=/([\w\d_]+)(\])?(\[|\.)?/g;function fo(e,t){e.seq.push(t),e.map[t.id]=t}function mo(e,t){this.seq=[],this.map={};for(var n=e.getProgramParameter(t,35718),r=0;r<n;++r){var i=e.getActiveUniform(t,r);!function(e,t,n){var r=e.name,i=r.length;for(po.lastIndex=0;;){var a=po.exec(r),o=po.lastIndex,s=a[1],l="]"===a[2],c=a[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===i){fo(n,new(void 0===c?co:uo)(s,e,t));break}var u=n.map[s];void 0===u&&fo(n,u=new ho(s)),n=u}}(i,e.getUniformLocation(t,i.name),this)}}function vo(e,t,n){var r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}mo.prototype.setValue=function(e,t,n,r){var i=this.map[t];void 0!==i&&i.setValue(e,n,r)},mo.prototype.setOptional=function(e,t,n){var r=t[n];void 0!==r&&this.setValue(e,n,r)},mo.upload=function(e,t,n,r){for(var i=0,a=t.length;i!==a;++i){var o=t[i],s=n[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,r)}},mo.seqWithValue=function(e,t){for(var n=[],r=0,i=e.length;r!==i;++r){var a=e[r];a.id in t&&n.push(a)}return n};var go=0;function _o(e){switch(e){case Tt:return["Linear","(value)"];case Et:return["sRGB","(value)"];case Pt:return["RGBE","(value)"];case Rt:return["RGBM","(value, 7.0)"];case Dt:return["RGBM","(value, 16.0)"];case Nt:return["RGBD","(value, 256.0)"];case Ct:return["Gamma","(value, float(GAMMA_FACTOR))"];case Lt:return["LogLuv","(value)"];default:throw new Error("unsupported encoding: "+e)}}function yo(e,t,n){var r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();return r&&""===i?"":"v3d.WebGLShader: gl.getShaderInfoLog() "+n+"\n"+i+function(e){for(var t=e.split("\n"),n=0;n<t.length;n++)t[n]=n+1+": "+t[n];return t.join("\n")}(e.getShaderSource(t))}function xo(e,t){var n=_o(t);return"vec4 "+e+"(vec4 value) { return "+n[0]+"ToLinear"+n[1]+"; }"}function bo(e){return""!==e}function Mo(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function wo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Ao(e,t){var n=Object.keys(t);if(n.length){var r=new RegExp(n.join("|"),"g");return e.replace(r,function(e){return t[e]})}return e}function So(e,t){for(var n in t)e=e.replace("#include <"+n+">",t[n]);return e}var To=/^[ \t]*#include +<([\w\d./]+)>/gm;function Eo(e){return e.replace(To,Co)}function Co(e,t){var n=aa[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Eo(n)}function Po(e){for(var t,n=new RegExp("#pragma unroll_loop[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\w+)\\+\\+\\) \\{"),r=new RegExp("\\{|\\}","g");t=n.exec(e);){for(var i,a,o=i=r.lastIndex=t.index+t[0].length,s=1;(a=r.exec(e))&&("{"==a[0]?s++:"}"==a[0]&&s--,i=a.index),a&&0<s;);if(0==s){for(var l=e.substring(t.index,r.lastIndex),c=e.substring(o,i),u=new RegExp("\\[".concat(t[1],"\\]"),"g"),d=new RegExp("\\(".concat(t[1],"\\)"),"g"),h="",p=parseInt(t[2]),f=parseInt(t[5])+("="===t[4]?1:0),m=p;m<f;m++)h+="{"+c.replace(u,"[".concat(m,"]")).replace(d,"(".concat(m,")"))+"}";e=e.replace(l,h)}}return e}function Lo(e){var t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Ro(e,t,n){var r,i,a,o,s,l,c,u,d,h,p=e.getContext(),f=n.defines,m=n.vertexShader,v=n.fragmentShader,g=(i="SHADOWMAP_TYPE_BASIC",(r=n).shadowMapType===q?i="SHADOWMAP_TYPE_PCF":r.shadowMapType===Z?i="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===$?i="SHADOWMAP_TYPE_VSM":r.shadowMapType===ee?i="SHADOWMAP_TYPE_ESM":r.shadowMapType===te?i="SHADOWMAP_TYPE_PCF_POISSON_DISK":r.shadowMapType===ne&&(i="SHADOWMAP_TYPE_BILINEAR"),i),_=function(e){var t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Ge:case je:t="ENVMAP_TYPE_CUBE";break;case Ye:case qe:t="ENVMAP_TYPE_CUBE_UV";break;case We:case Xe:t="ENVMAP_TYPE_EQUIREC";break;case He:t="ENVMAP_TYPE_SPHERE"}return t}(n),y=function(e){var t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case je:case Xe:t="ENVMAP_MODE_REFRACTION"}return t}(n),x=function(e){var t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case U:t="ENVMAP_BLENDING_MULTIPLY";break;case V:t="ENVMAP_BLENDING_MIX";break;case k:t="ENVMAP_BLENDING_ADD"}return t}(n),b=0<e.gammaFactor?e.gammaFactor:1,M=n.unitsScaleFactor%1?String(n.unitsScaleFactor):String(n.unitsScaleFactor)+".0",w=n.isWebGL2?"":[(a=n).extensionDerivatives||a.envMapCubeUV||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||"physical"===a.shaderID||a.useSlopeScaledBias?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(bo).join("\n"),A=function(e){var t=[];for(var n in e){var r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(f),S=p.createProgram(),T=n.numMultiviewViews;n.isRawShaderMaterial?(0<(o=[A].filter(bo).join("\n")).length&&(o+="\n"),0<(s=[w,A].filter(bo).join("\n")).length&&(s+="\n")):(o=[Lo(n),"#define SHADER_NAME "+n.shaderName,e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",A,n.instancing?"#define USE_INSTANCING":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+b,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+y:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"","#define NUM_MORPH_TARGETS "+n.numMorphTargets,n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+g:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","\n uniform mat4 modelMatrix;\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n uniform mat4 viewMatrix;\n uniform mat3 normalMatrix;\n uniform vec3 cameraPosition;\n uniform bool isOrthographic;\n\n #ifdef USE_INSTANCING\n attribute mat4 instanceMatrix;\n #endif\n\n attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n\n #ifdef USE_TANGENT\n attribute vec4 tangent;\n #endif\n\n #ifdef USE_COLOR\n attribute vec3 color;\n #endif\n\n #ifdef USE_MORPHTARGETS\n #if NUM_MORPH_TARGETS > 0\n attribute vec3 morphTarget0;\n #endif\n #if NUM_MORPH_TARGETS > 1\n attribute vec3 morphTarget1;\n #endif\n #if NUM_MORPH_TARGETS > 2\n attribute vec3 morphTarget2;\n #endif\n #if NUM_MORPH_TARGETS > 3\n attribute vec3 morphTarget3;\n #endif\n #if NUM_MORPH_TARGETS > 4\n attribute vec3 morphTarget4;\n #endif\n #if NUM_MORPH_TARGETS > 5\n attribute vec3 morphTarget5;\n #endif\n\n #ifdef USE_MORPHNORMALS\n #if NUM_MORPH_TARGETS > 0\n attribute vec3 morphNormal0;\n #endif\n #if NUM_MORPH_TARGETS > 1\n attribute vec3 morphNormal1;\n #endif\n #if NUM_MORPH_TARGETS > 2\n attribute vec3 morphNormal2;\n #endif\n #if NUM_MORPH_TARGETS > 3\n attribute vec3 morphNormal3;\n #endif\n #if NUM_MORPH_TARGETS > 4\n attribute vec3 morphNormal4;\n #endif\n #if NUM_MORPH_TARGETS > 5\n attribute vec3 morphNormal5;\n #endif\n #else\n #if NUM_MORPH_TARGETS > 6\n attribute vec3 morphTarget6;\n #endif\n #if NUM_MORPH_TARGETS > 7\n attribute vec3 morphTarget7;\n #endif\n #if NUM_MORPH_TARGETS > 8\n attribute vec3 morphTarget8;\n #endif\n #if NUM_MORPH_TARGETS > 9\n attribute vec3 morphTarget9;\n #endif\n #if NUM_MORPH_TARGETS > 10\n attribute vec3 morphTarget10;\n #endif\n #if NUM_MORPH_TARGETS > 11\n attribute vec3 morphTarget11;\n #endif\n #endif\n #endif\n\n #ifdef USE_SKINNING\n attribute vec4 skinIndex;\n attribute vec4 skinWeight;\n #endif\n "].filter(bo).join("\n"),s=[w,Lo(n),"#define SHADER_NAME "+n.shaderName,A,function(e){switch(e){case"blender":return"#define MT_BLENDER";case"max":return"#define MT_MAX";case"maya":return"#define MT_MAYA";default:return""}}(n.materialProfile),e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+_:"",n.envMap?"#define "+y:"",n.envMap?"#define "+x:"",0!==n.envMapCubeUVTileSize?"#define cubeUV_maxTileSize ".concat(ti(n.envMapCubeUVTileSize)):"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+g:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",n.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+M:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping===G||n.useHDR?"":"#define TONE_MAPPING",n.toneMapping===G||n.useHDR?"":aa.tonemapping_pars_fragment,n.toneMapping===G||n.useHDR?"":function(e,t){var n;switch(t){case ze:n="Linear";break;case j:n="Reinhard";break;case W:n="Uncharted2";break;case X:n="OptimizedCineon";break;case H:n="ACESFilmic";break;case Ue:n="LogarithmicMax";break;case Ve:n="PhysicalMax";break;case ke:n="FilmicBlender";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}("toneMapping",n.toneMapping),n.dithering?"#define DITHERING":"",n.outputEncoding||n.mapEncoding||n.matcapEncoding||n.envMapEncoding||n.emissiveMapEncoding||n.lightMapEncoding?aa.encodings_pars_fragment:"",n.mapEncoding?xo("mapTexelToLinear",n.mapEncoding):"",n.matcapEncoding?xo("matcapTexelToLinear",n.matcapEncoding):"",n.envMapEncoding?xo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?xo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMapEncoding?xo("lightMapTexelToLinear",n.lightMapEncoding):"",n.outputEncoding?(l="linearToOutputTexel",c=n.outputEncoding,u=_o(c),"vec4 "+l+"(vec4 value) { return LinearTo"+u[0]+u[1]+"; }"):"",n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"","#define ESM_DISTANCE_SCALE ".concat(ti(n.esmDistanceScale)),"\n"].filter(bo).join("\n")),n.isMeshNodeMaterial&&(m=So(m,n.nodeChunks),v=So(v,n.nodeChunks)),m=wo(m=Mo(m=Eo(m),n),n),n.customPrepTokens&&(m=Ao(m,n.customPrepTokens)),v=wo(v=Mo(v=Eo(v),n),n),n.customPrepTokens&&(v=Ao(v,n.customPrepTokens)),m=Po(m),v=Po(v),n.isWebGL2&&!n.isRawShaderMaterial&&(d=!1,h=/^\s*#version\s+300\s+es\s*\n/,n.isShaderMaterial&&null!==m.match(h)&&null!==v.match(h)&&(d=!0,m=m.replace(h,""),v=v.replace(h,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",d?"":"out highp vec4 pc_fragColor;",d?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,0<T&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+T+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+T+"];","uniform mat4 projectionMatrices["+T+"];","uniform mat4 viewMatrices["+T+"];","uniform mat3 normalMatrices["+T+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+T+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));var E,C,P,L,R,D,N,I,O,F=s+v,B=vo(p,35633,o+m),z=vo(p,35632,F);return p.attachShader(S,B),p.attachShader(S,z),void 0!==n.index0AttributeName?p.bindAttribLocation(S,0,n.index0AttributeName):!0===n.morphTargets&&p.bindAttribLocation(S,0,"position"),p.linkProgram(S),e.debug.checkShaderErrors&&(E=p.getProgramInfoLog(S).trim(),C=p.getShaderInfoLog(B).trim(),P=p.getShaderInfoLog(z).trim(),!(R=L=!0)===p.getProgramParameter(S,35714)?(L=!1,D=yo(p,B,"vertex"),N=yo(p,z,"fragment"),console.error("v3d.WebGLProgram: shader error: ",p.getError(),"35715",p.getProgramParameter(S,35715),"gl.getProgramInfoLog",E,D,N)):""!==E?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",E):""!==C&&""!==P||(R=!1),R&&(this.diagnostics={runnable:L,programLog:E,vertexShader:{log:C,prefix:o},fragmentShader:{log:P,prefix:s}})),p.deleteShader(B),p.deleteShader(z),this.getUniforms=function(){return void 0===I&&(I=new mo(p,S)),I},this.getAttributes=function(){return void 0===O&&(O=function(e,t){for(var n={},r=e.getProgramParameter(t,35721),i=0;i<r;i++){var a=e.getActiveAttrib(t,i).name;n[a]=e.getAttribLocation(t,a)}return n}(p,S)),O},this.getTexUniformCount=function(){return this.getUniforms().seq.reduce(function(e,t){if(t.info)switch(t.info.type){case 35678:case 35679:case 35680:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:e+=t.info.size}return e},0)},this.destroy=function(){p.deleteProgram(S),this.program=void 0},this.name=n.shaderName,this.id=go++,this.cacheKey=t,this.usedTimes=1,this.program=S,this.vertexShader=B,this.fragmentShader=z,this.numMultiviewViews=T,this.profile={calcRenderTime:!1,renderTime:0,timerQueries:[],materials:[]},this.beginTimerQuery=function(e,t){var n,r;!this.profile.calcRenderTime||(n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query"))&&(t?(r=e.createQuery(),e.beginQuery(n.TIME_ELAPSED_EXT,r)):(r=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,r)),this.profile.timerQueries.push(r))},this.endTimerQuery=function(e,t){if(this.profile.calcRenderTime){var n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(n){t?e.endQuery(n.TIME_ELAPSED_EXT):n.endQueryEXT(n.TIME_ELAPSED_EXT);for(var r=this.profile.timerQueries,i=r.length-1;0<=i;i--){var a,o=r[i],s=t?e.getQueryParameter(o,34919):n.getQueryObjectEXT(o,n.QUERY_RESULT_AVAILABLE_EXT),l=e.getParameter(n.GPU_DISJOINT_EXT);s&&!l&&(a=t?e.getQueryParameter(o,34918):n.getQueryObjectEXT(o,n.QUERY_RESULT_EXT),this.profile.renderTime+=a/1e6,r.splice(i,1))}}}},this}function Do(x,b,M){var s=[],w=M.isWebGL2,A=M.logarithmicDepthBuffer,S=M.floatVertexTextures,T=M.precision,E=M.maxVertexUniforms,C=M.vertexTextures,P={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite",MeshMaskMaterial:"mask",MeshNodeMaterial:"node"},i=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","numMultiviewViews","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","distancePacking","useSlopeScaledBias","numMorphTargets","unitsScaleFactor","useHDR","esmDistanceScale"];function L(e){var t;return e?e.isTexture?t=e.encoding:e.isWebGLRenderTarget&&(console.warn("v3d.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=Tt,t}this.getParameters=function(e,t,n,r,i,a,o){var s=r.fog,l=e.isMeshStandardMaterial?r.environment:null,c=e.envMap||l,u=P[e.type],d=o.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(S)return 1024;var n=Math.floor((E-20)/4),r=Math.min(n,t.length);return r<t.length?(console.warn("v3d.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+r+"."),0):r}(o):0;null!==e.precision&&(T=M.getMaxPrecision(e.precision))!==e.precision&&console.warn("v3d.WebGLProgram.getParameters:",e.precision,"not supported, using",T,"instead.");var h,p,f,m=(h=e,(p=u)?(f=oa[p],{name:h.type,uniforms:Vi.clone(f.uniforms),vertexShader:f.vertexShader,fragmentShader:f.fragmentShader}):{name:h.type,uniforms:h.uniforms,vertexShader:h.vertexShader,fragmentShader:h.fragmentShader});e.onBeforeCompile(m,x);var v=x.getRenderTarget(),g=o.geometry,_=v&&v.isWebGLMultiviewRenderTarget?v.numViews:0,y=!!c&&(c.mapping===Ye||c.mapping===qe);return{isWebGL2:w,shaderID:u,shaderName:m.name,uniforms:m.uniforms,vertexShader:m.vertexShader,fragmentShader:m.fragmentShader,defines:e.defines,isRawShaderMaterial:e.isRawShaderMaterial,isShaderMaterial:e.isShaderMaterial,precision:T,instancing:!0===o.isInstancedMesh,supportsVertexTextures:C,numMultiviewViews:_,outputEncoding:null!==v?L(v.texture):x.outputEncoding,map:!!e.map,mapEncoding:L(e.map),matcap:!!e.matcap,matcapEncoding:L(e.matcap),envMap:!!c,envMapMode:c&&c.mapping,envMapEncoding:L(c),envMapCubeUV:y,envMapCubeUVTileSize:y&&void 0!==c.image?c.image.width/3:0,lightMap:!!e.lightMap,lightMapEncoding:L(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:L(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:e.normalMapType===Ut,tangentSpaceNormalMap:e.normalMapType===zt,clearcoatNormalMap:!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,sheen:!!e.sheen,combine:e.combine,vertexTangents:e.normalMap&&(e.vertexTangents||g&&g.isBufferGeometry&&g.getAttribute("tangent")),vertexColors:e.vertexColors,vertexUvs:!!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||e.displacementMap),uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||!e.displacementMap),fog:!!s,useFog:e.fog,fogExp2:s&&s.isFogExp2,flatShading:e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:A,skinning:e.skinning&&0<d,maxBones:d,useVertexTexture:S,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:x.maxMorphTargets,maxMorphNormals:x.maxMorphNormals,numDirLights:t.directional.length,numPointLights:t.point.length,numSpotLights:t.spot.length,numRectAreaLights:t.rectArea.length,numHemiLights:t.hemi.length,numDirLightShadows:t.directionalShadowMap.length,numPointLightShadows:t.pointShadowMap.length,numSpotLightShadows:t.spotShadowMap.length,numClippingPlanes:i,numClipIntersection:a,dithering:e.dithering,shadowMapEnabled:x.shadowMap.enabled&&0<n.length,shadowMapType:x.shadowMap.type,toneMapping:e.toneMapped?x.toneMapping:G,physicallyCorrectLights:x.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===ie,flipSided:e.side===Le,depthPacking:void 0!==e.depthPacking&&e.depthPacking,numMorphTargets:Math.min((o.morphTargetInfluences||[]).length,x.maxMorphTargets),distancePacking:void 0!==e.distancePacking&&e.distancePacking,useSlopeScaledBias:void 0!==e.useSlopeScaledBias&&e.useSlopeScaledBias,esmDistanceScale:x.shadowMap.esmDistanceScale,materialName:e.name,materialProfile:e.profile,unitsScaleFactor:x.unitsScaleFactor,useHDR:!!e.useHDR,customPrepTokens:e.customPrepTokens,isMeshNodeMaterial:e.isMeshNodeMaterial,nodeChunks:e.nodeChunks,nodeChunksHash:e.nodeChunksHash,index0AttributeName:e.index0AttributeName,extensionDerivatives:e.extensions&&e.extensions.derivatives,extensionFragDepth:e.extensions&&e.extensions.frawbuffers,extensionDrawbuffers:e.extensions&&e.extensions.drawbuffers,extensionShaderTextureLOD:e.extensions&&e.extensions.shaderTextureLOD,rendererExtensionFragDepth:w||null!==b.get("EXT_frag_depth"),rendererExtensionDrawBuffers:w||null!==b.get("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:w||null!==b.get("EXT_shader_texture_lod"),onBeforeCompile:e.onBeforeCompile}},this.getProgramCacheKey=function(e){var t=[];if(e.shaderID?t.push(e.shaderID):(t.push(e.fragmentShader),t.push(e.vertexShader)),void 0!==e.defines)for(var n in e.defines)t.push(n),t.push(e.defines[n]);if(void 0!==e.customPrepTokens)for(var n in e.customPrepTokens)t.push(n),t.push(e.customPrepTokens[n]);if(void 0===e.isRawShaderMaterial){for(var r=0;r<i.length;r++)t.push(e[i[r]]);t.push(x.outputEncoding),t.push(x.gammaFactor)}return t.push(e.onBeforeCompile.toString()),void 0!==e.nodeChunksHash&&t.push(e.nodeChunksHash),t.join()},this.acquireProgram=function(e,t){for(var n,r=0,i=s.length;r<i;r++){var a=s[r];if(a.cacheKey===t){++(n=a).usedTimes;break}}void 0===n&&(n=new Ro(x,t,e),s.push(n));var o=n.profile.materials;return e.materialName&&o.indexOf(e.materialName)<0&&o.push(e.materialName),n},this.releaseProgram=function(e){var t;0==--e.usedTimes&&(t=s.indexOf(e),s[t]=s[s.length-1],s.pop(),e.destroy())},this.programs=s}function No(){var r=new WeakMap;return{get:function(e){var t=r.get(e);return void 0===t&&(t={},r.set(e,t)),t},remove:function(e){r.delete(e)},update:function(e,t,n){r.get(e)[t]=n},dispose:function(){r=new WeakMap}}}function Io(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Oo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Fo(){var s=[],l=0,c=[],u=[],d={id:-1};function h(e,t,n,r,i,a){var o=s[l];return void 0===o?(o={id:e.id,object:e,geometry:t,material:n,program:n.program||d,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a},s[l]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=n,o.program=n.program||d,o.groupOrder=r,o.renderOrder=e.renderOrder,o.z=i,o.group=a),l++,o}return{opaque:c,transparent:u,init:function(){l=0,c.length=0,u.length=0},push:function(e,t,n,r,i,a){var o=h(e,t,n,r,i,a);(!0===n.transparent?u:c).push(o)},unshift:function(e,t,n,r,i,a){var o=h(e,t,n,r,i,a);(!0===n.transparent?u:c).unshift(o)},sort:function(e,t){1<c.length&&c.sort(e||Io),1<u.length&&u.sort(t||Oo)}}}function Bo(){var i=new WeakMap;function a(e){var t=e.target;t.removeEventListener("dispose",a),i.delete(t)}return{get:function(e,t){var n,r=i.get(e);return void 0===r?(n=new Fo,i.set(e,new WeakMap),i.get(e).set(t,n),e.addEventListener("dispose",a)):void 0===(n=r.get(t))&&(n=new Fo,r.set(t,n)),n},dispose:function(){i=new WeakMap}}}function zo(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new Jt(512,512),this.map=null,this.mapPass=null,this.matrix=new _n,this._frustum=new Ki,this._frameExtents=new Jt(1,1),this._viewportCount=1,this._viewports=[new rn(0,0,1,1)],this.expBias=1,this.slopeScaledBias=0,this._additionalMap2D=null,this._additionalMapCube=null}function Uo(){zo.call(this,new Xi(50,1,.5,500)),this.useMinFov90=!1}function Vo(){var n={};return{get:function(e){if(void 0!==n[e.id])return n[e.id];var t;switch(e.type){case"DirectionalLight":t={direction:new un,color:new Lr,shadowBias:0,shadowRadius:1,shadowMapSize:new Jt,position:new un,maxDistance:0,expBias:1,shadowCameraNear:1};break;case"SpotLight":t={position:new un,direction:new un,color:new Lr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Jt,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"PointLight":t={position:new un,color:new Lr,distance:0,decay:0,shadowBias:0,shadowRadius:1,shadowMapSize:new Jt,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"HemisphereLight":t={direction:new un,skyColor:new Lr,groundColor:new Lr};break;case"RectAreaLight":t={color:new Lr,position:new un,halfWidth:new un,halfHeight:new un}}return n[e.id]=t}}}Object.assign(zo.prototype,{isLightShadow:!0,_projScreenMatrix:new _n,_lightPositionWorld:new un,_lookTarget:new un,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){var t=this.camera,n=this.matrix,r=this._projScreenMatrix,i=this._lookTarget,a=this._lightPositionWorld;a.setFromMatrixPosition(e.matrixWorld),t.position.copy(a),i.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(i),t.updateMatrixWorld(),r.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this.expBias=e.expBias,this.slopeScaledBias=e.slopeScaledBias,this},clone:function(){return(new this.constructor).copy(this)},dispose:function(){null!==this.map&&this.map.dispose(),null!==this._additionalMap2D&&this._additionalMap2D.dispose(),null!==this._additionalMapCube&&this._additionalMapCube.dispose()},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),Uo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Uo,isSpotLightShadow:!0,updateMatrices:function(e){var t=this.camera,n=2*Kt.RAD2DEG*e.angle,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),zo.prototype.updateMatrices.call(this,e)},copy:function(e){return zo.prototype.copy.call(this,e),this.useMinFov90=e.useMinFov90,this}}),Uo.OMNI_MAP_ANGLE=Math.PI/4;var ko=0;function Go(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function jo(){for(var T=new Vo,E={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},e=0;e<9;e++)E.probe.push(new un);var C=new un,P=new _n,L=new _n;return{setup:function(e,t,n){for(var r=0,i=0,a=0,o=0;o<9;o++)E.probe[o].set(0,0,0);var s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=n.matrixWorldInverse;e.sort(Go);for(var o=0,v=e.length;o<v;o++){var g,_,y=e[o],x=y.color,b=y.intensity,M=y.distance,w=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)r+=x.r*b,i+=x.g*b,a+=x.b*b;else if(y.isLightProbe)for(var A=0;A<9;A++)E.probe[A].addScaledVector(y.sh.coefficients[A],b);else{y.isDirectionalLight?((_=T.get(y)).position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),_.color.copy(y.color).multiplyScalar(y.intensity),_.direction.setFromMatrixPosition(y.matrixWorld),C.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(C),_.direction.transformDirection(m),y.castShadow&&(g=y.shadow,_.shadowBias=g.bias,_.shadowRadius=g.radius,_.shadowMapSize=g.mapSize,E.directionalShadowMap[s]=w,E.directionalShadowMatrix[s]=y.shadow.matrix,h++,_.expBias=g.expBias,_.maxDistance=g.isDirectionalLightShadowCSM?g.maxDistance:n.far,_.shadowCameraNear=g.camera.near),E.directional[s]=_,s++):y.isSpotLight?((_=T.get(y)).position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),_.color.copy(x).multiplyScalar(b),_.distance=M,_.direction.setFromMatrixPosition(y.matrixWorld),C.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(C),_.direction.transformDirection(m),_.coneCos=Math.cos(y.angle),_.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),_.decay=y.decay,_.shadow=y.castShadow?y.angle>Uo.OMNI_MAP_ANGLE?2:1:0,y.castShadow&&(g=y.shadow,_.shadowBias=g.bias,_.expBias=g.expBias,_.shadowRadius=g.radius,_.shadowMapSize=g.mapSize,E.spotShadowMap[c]=w,E.spotShadowMatrix[c]=y.shadow.matrix,f++,_.shadowCameraNear=g.camera.near,_.shadowCameraFar=g.camera.far),E.spot[c]=_,c++):y.isRectAreaLight?((_=T.get(y)).color.copy(x).multiplyScalar(b),_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),L.identity(),P.copy(y.matrixWorld),P.premultiply(m),L.extractRotation(P),_.halfWidth.set(.5*y.width,0,0),_.halfHeight.set(0,.5*y.height,0),_.halfWidth.applyMatrix4(L),_.halfHeight.applyMatrix4(L),E.rectArea[u]=_,u++):y.isPointLight?((_=T.get(y)).position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),_.color.copy(y.color).multiplyScalar(y.intensity),_.distance=y.distance,_.decay=y.decay,y.castShadow&&(g=y.shadow,_.shadowBias=g.bias,_.expBias=g.expBias,_.shadowRadius=g.radius,_.shadowMapSize=g.mapSize,_.shadowCameraNear=g.camera.near,_.shadowCameraFar=g.camera.far,E.pointShadowMap[l]=w,E.pointShadowMatrix[l]=y.shadow.matrix,p++),E.point[l]=_,l++):y.isHemisphereLight&&((_=T.get(y)).direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(m),_.direction.normalize(),_.skyColor.copy(y.color).multiplyScalar(b),_.groundColor.copy(y.groundColor).multiplyScalar(b),E.hemi[d]=_,d++)}}E.ambient[0]=r,E.ambient[1]=i,E.ambient[2]=a;var S=E.hash;S.directionalLength===s&&S.pointLength===l&&S.spotLength===c&&S.rectAreaLength===u&&S.hemiLength===d&&S.numDirectionalShadows===h&&S.numPointShadows===p&&S.numSpotShadows===f||(E.directional.length=s,E.spot.length=c,E.rectArea.length=u,E.point.length=l,E.hemi.length=d,E.directionalShadowMap.length=h,E.pointShadowMap.length=p,E.spotShadowMap.length=f,E.directionalShadowMatrix.length=h,E.pointShadowMatrix.length=p,E.spotShadowMatrix.length=f,S.directionalLength=s,S.pointLength=l,S.spotLength=c,S.rectAreaLength=u,S.hemiLength=d,S.numDirectionalShadows=h,S.numPointShadows=p,S.numSpotShadows=f,E.version=ko++)},state:E}}function Wo(){var t=new jo,n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:t},setupLights:function(e){t.setup(n,r,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function Xo(){var r=new WeakMap;function i(e){var t=e.target;t.removeEventListener("dispose",i),r.delete(t)}return{get:function(e,t){var n;return!1===r.has(e)?(n=new Wo,r.set(e,new WeakMap),r.get(e).set(t,n),e.addEventListener("dispose",i)):!1===r.get(e).has(t)?(n=new Wo,r.get(e).set(t,n)):n=r.get(e).get(t),n},dispose:function(){r=new WeakMap}}}function Ho(e){Br.call(this),this.type="MeshDepthMaterial",this.depthPacking=It,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}function Yo(e){Br.call(this),this.type="MeshDistanceMaterial",this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=Ft,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.referencePosition=new un,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}((Ho.prototype=Object.create(Br.prototype)).constructor=Ho).prototype.isMeshDepthMaterial=!0,Ho.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},((Yo.prototype=Object.create(Br.prototype)).constructor=Yo).prototype.isMeshDistanceMaterial=!0,Yo.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.defines=Object.assign({},e.defines),this.distancePacking=e.distancePacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var qo=.8,Zo=.2,Qo=.8,Ko=50;function Jo(_,v,d){var g=new Ki,h=new _n,p=new _n,f=new Jt,m=new Jt(d.maxTextureSize,d.maxTextureSize),y=new un,x=new un,b=1,M=2,e=1+(b|M),w=new Array(e),A=new Array(e),S={},T=new un,E={0:Le,1:re,2:ie},C=[new un(1,0,0),new un(-1,0,0),new un(0,1,0),new un(0,-1,0),new un(0,0,1),new un(0,0,-1)],P=[new un(0,1,0),new un(0,1,0),new un(0,0,1),new un(0,0,-1),new un(0,1,0),new un(0,1,0)],u=[new rn,new rn,new rn,new rn,new rn,new rn],L=new rr,R=[new un,new un,new un,new un,new un,new un,new un,new un],c=new Ci(new ia(1,1,1,1));c.name="esmFarPlane",c.castShadow=!0,c.material.shadowSide=re;var D=0,N=1,I=0,O=1,F=new na(-1,1,1,-1,0,10),B=new Ci(new ia(2,2)),z=new ji({type:"ShadowCubeOctahedral",defines:Object.assign({},oa.cubeOctahedral.defines),uniforms:Vi.clone(oa.cubeOctahedral.uniforms),vertexShader:oa.cubeOctahedral.vertexShader,fragmentShader:oa.cubeOctahedral.fragmentShader}),U={};var V={};function k(e,t,n,r,i,a,o){var s,l,c=B.material=o===I?((l=r)in U||((U[l]=new ji({type:"ShadowBlur",defines:Object.assign({},oa.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:Vi.clone(oa.blur.uniforms),customPrepTokens:Object.assign({},oa.blur.customPrepTokens),vertexShader:oa.blur.vertexShader,fragmentShader:oa.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=l),U[l]):((s=r)in V||((V[s]=new ji({type:"ShadowBlur",defines:Object.assign({},oa.blur.defines,{LOG_SPACE:1}),uniforms:Vi.clone(oa.blur.uniforms),customPrepTokens:Object.assign({},oa.blur.customPrepTokens),vertexShader:oa.blur.vertexShader,fragmentShader:oa.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=s),V[s]);c.uniforms.direction.value.set(+(a===D),+(a===N)),c.uniforms.colorTexture.value=t.texture,c.uniforms.texSize.value.set(t.width,t.height),c.uniforms.kernelRadius.value=i,c.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(B),e.renderBufferDirect(F,!1,B.geometry,c,B,null)}for(var t=0;t!==e;++t){var n=0!=(t&b),r=0!=(t&M),i=new Ho({depthPacking:Ot,morphTargets:n,skinning:r});w[t]=i;var a=new Yo({distancePacking:Ft,morphTargets:n,skinning:r});A[t]=a}var G=this;function j(e,t,n,r,i,a,o){var s,l,c,u,d,h,p,f=e.geometry,m=null,v=w,g=e.customDepthMaterial;switch(!r&&G.type!==ee||(v=A,g=e.customDistanceMaterial),m=g||(s=!1,t.morphTargets&&(f&&f.isBufferGeometry?s=f.morphAttributes&&f.morphAttributes.position&&0<f.morphAttributes.position.length:f&&f.isGeometry&&(s=f.morphTargets&&0<f.morphTargets.length)),e.isSkinnedMesh&&!1===t.skinning&&console.warn("v3d.WebGLShadowMap: v3d.SkinnedMesh with material.skinning set to false:",e),l=e.isSkinnedMesh&&t.skinning,c=0,s&&(c|=b),l&&(c|=M),v[c]),_.localClippingEnabled&&!0===t.clipShadows&&0!==t.clippingPlanes.length&&(u=m.uuid,d=t.uuid,void 0===(h=S[u])&&(h={},S[u]=h),void 0===(p=h[d])&&(p=m.clone(),h[d]=p),m=p),m.visible=t.visible,m.wireframe=t.wireframe,m.side=null!=t.shadowSide?t.shadowSide:E[t.side],m.clipShadows=t.clipShadows,m.clippingPlanes=t.clippingPlanes,m.clipIntersection=t.clipIntersection,m.wireframeLinewidth=t.wireframeLinewidth,m.linewidth=t.linewidth,(r||G.type===ee)&&m.isMeshDistanceMaterial&&(m.referencePosition.copy(i),m.nearDistance=a,m.farDistance=o,m.distancePacking=G.type===ee?Bt:Ft),G.type===ee&&(m.defines.DISTANCE_SCALE=ti(G.esmDistanceScale)),G.type){case Y:case ne:case q:case Z:case te:m.useSlopeScaledBias=!0,m.slopeScaledBias=n.shadow.slopeScaledBias;break;case ee:m.useSlopeScaledBias=!0,m.slopeScaledBias=.5}return m}function W(e,t,n,r,i){if(!1!==e.visible){if(e.layers.test(t.layers)&&(e.isMesh||e.isLine||e.isPoints)&&e.castShadow&&(!e.frustumCulled||g.intersectsObject(e))){e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld);var a=v.update(e),o=e.material;if(Array.isArray(o))for(var s=a.groups,l=0,c=s.length;l<c;l++){var u,d=s[l],h=o[d.materialIndex];h&&h.visible&&(u=j(e,h,i,r,x,n.near,n.far),_.renderBufferDirect(n,null,a,u,e,d))}else o.visible&&(u=j(e,o,i,r,x,n.near,n.far),_.renderBufferDirect(n,null,a,u,e,null))}for(var p=e.children,f=0,m=p.length;f<m;f++)W(p[f],t,n,r,i)}}function X(e,t,n,r){for(var i=Kt.clamp(t.maxDistance,e.near,e.far)/e.far,a=0;a<R.length;a++){var o=R[a],s=1&a;o.set(a>>2&1,a>>1&1,s).multiplyScalar(2).subScalar(1).applyMatrix4(e.projectionMatrixInverse),1==s&&o.multiplyScalar(i)}r.setFromPoints(R),p.multiplyMatrices(t.camera.matrixWorldInverse,e.matrixWorld);var l=r.center.applyMatrix4(p),c=r.radius*=p.getMaxScaleOnAxis(),u=n.x/2/c,d=n.y/2/c;return l.x=Math.round(l.x*u)/u,l.y=Math.round(l.y*d)/d,r}function H(e,t,n){var r,i,a,o,s,l;t.isPerspectiveCamera?(r=i=0,o=s=2*-(a=-.999*t.far)*Math.tan(Kt.degToRad(t.fov)/2),l=1):t.isOrthographicCamera&&(r=(t.right+t.left)/2,i=(t.top+t.bottom)/2,a=-.999*t.far,o=t.right-t.left,s=t.top-t.bottom,l=1),t.add(c),c.scale.set(o,s,l),c.position.set(r,i,a),c.updateMatrixWorld(),W(c,e,t,!0,n)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=q,this.esmDistanceScale=1,this.render=function(e,t,n){if(G.type==$&&(G.type=q,console.warn("v3d.WebGLShadowMap: disable unsupported VSM shadow maps")),!1!==G.enabled&&(!1!==G.autoUpdate||!1!==G.needsUpdate)&&0!==e.length){var r=_.getRenderTarget(),i=_.getActiveCubeFace(),a=_.getActiveMipmapLevel(),o=_.state;o.setBlending(ae),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var s=0,l=e.length;s<l;s++){var c=e[s];if(void 0!==c.shadow)if(c.shadow.updateMatrices(c),c.isPointLight||c.isSpotLight&&c.angle>Uo.OMNI_MAP_ANGLE)switch(G.type){case Y:case ne:case q:case Z:case te:!function(e,t,n){var r=n.shadow,i=r.camera,a=r.matrix,o=f.copy(r.mapSize);{var s;o.x*=4,o.y*=2,o.min(m),o.x/=4,o.y/=2,u[0].set(2*o.x,o.y,o.x,o.y),u[1].set(0,o.y,o.x,o.y),u[2].set(3*o.x,0,o.x,o.y),u[3].set(o.x,0,o.x,o.y),u[4].set(3*o.x,o.y,o.x,o.y),u[5].set(o.x,o.y,o.x,o.y),!n.isSpotLight||r.map&&r.map.width/r.map.height!=2&&(s=r.map,r.map=r._additionalMap2D,r._additionalMap2D=s)}null===r.map&&(r.map=new an(4*o.x,2*o.y,{minFilter:Je,magFilter:Je,format:dt,type:it}),r.map.texture.name=n.name+".shadowMap");x.setFromMatrixPosition(n.matrixWorld),i.position.copy(x),n.isSpotLight&&(i.fov=90,i.updateProjectionMatrix());a.makeTranslation(-x.x,-x.y,-x.z),_.state.buffers.color.setClear(1,1,1,1),_.setRenderTarget(r.map),_.clear();for(var l=0;l<6;l++)_.state.viewport(u[l]),y.copy(i.position),y.add(C[l]),i.up.copy(P[l]),i.lookAt(y),i.updateMatrixWorld(),h.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),g.setFromProjectionMatrix(h),W(e,t,i,!0,n)}(t,n,c);break;case ee:!function(e,t,n){var r=n.shadow,i=r.camera,a=r.matrix,o=n.isPointLight?2:1,s=f.copy(r.mapSize).multiplyScalar(o).min(m).multiplyScalar(1/o);null===r._additionalMapCube&&(r._additionalMapCube=new Yi(s.x,{minFilter:tt,magFilter:tt,format:d.isWebGL2?ft:dt,type:lt}),r._additionalMapCube.texture.name=n.name+".shadowMap.tmpCube");null===r._additionalMap2D&&(r._additionalMap2D=new an(s.x*o,s.y*o,{minFilter:tt,magFilter:tt,format:d.isWebGL2?ft:dt,type:lt}),r._additionalMap2D.texture.name=n.name+".shadowMap.tmp2D");null===r.map&&(r.map=new an(s.x*o,s.y*o,{minFilter:tt,magFilter:tt,format:d.isWebGL2?ft:dt,type:lt}),r.map.texture.name=n.name+".shadowMap");x.setFromMatrixPosition(n.matrixWorld),i.position.copy(x),n.isSpotLight&&(i.fov=90,i.updateProjectionMatrix());a.makeTranslation(-x.x,-x.y,-x.z);for(var l=0;l<6;l++)y.copy(i.position),y.add(C[l]),i.up.copy(P[l]),2!==l&&3!==l&&i.up.multiplyScalar(-1),i.lookAt(y),i.updateMatrixWorld(),h.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),g.setFromProjectionMatrix(h),_.setRenderTarget(r._additionalMapCube,l),_.clearDepth(),H(t,i,n),W(e,t,i,!0,n);var c=Math.max(r.radius*o,.001),u=function(e){return Math.ceil(Zo*e)}(c);(function(e,t,n){var r=B.material=z;r.uniforms.tCube.value=t.texture,r.uniforms.texelSize.value.set(1/n.width,1/n.height),r.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(B),e.renderBufferDirect(F,!1,B.geometry,r,B,null)})(_,r._additionalMapCube,r.map),k(_,r.map,r._additionalMap2D,u,c,N,I),k(_,r._additionalMap2D,r.map,u,c,D,I)}(t,n,c);break;default:continue}else{if(!c.isSpotLight&&!c.isDirectionalLight)continue;switch(G.type){case Y:case ne:case q:case Z:case te:!function(e,t,n){var r=n.shadow,i=r.camera,a=r.matrix,o=f.copy(r.mapSize).min(m);{var s;n.isSpotLight&&r.map&&r.map.width!==r.map.height&&(s=r.map,r.map=r._additionalMap2D,r._additionalMap2D=s)}null===r.map&&(r.map=new an(o.x,o.y,{minFilter:Je,magFilter:Je,format:dt,type:it}),r.map.texture.name=n.name+".shadowMap");r.isSpotLightShadow&&r.updateMatrices(n);{var l;x.setFromMatrixPosition(n.matrixWorld),i.position.copy(x),y.setFromMatrixPosition(n.target.matrixWorld),i.lookAt(y),i.updateMatrixWorld(),n.isDirectionalLight&&n.shadow.isDirectionalLightShadowCSM?(l=X(t,r,o,L),i.left=l.center.x-l.radius,i.right=l.center.x+l.radius,i.top=l.center.y+l.radius,i.bottom=l.center.y-l.radius,i.near=-l.center.z-l.radius,i.far=-l.center.z+l.radius,i.updateProjectionMatrix()):n.isSpotLight&&r.useMinFov90&&(i.fov=90,i.updateProjectionMatrix())}a.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),a.multiply(i.projectionMatrix),a.multiply(i.matrixWorldInverse),_.state.buffers.color.setClear(1,1,1,1),_.setRenderTarget(r.map),_.clear(),h.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),g.setFromProjectionMatrix(h),W(e,t,i,!1,n)}(t,n,c);break;case ee:!function(e,t,n){var r=n.shadow,i=r.camera,a=r.matrix,o=f.copy(r.mapSize).min(m);null===r._additionalMap2D&&(r._additionalMap2D=new an(o.x,o.y,{minFilter:tt,magFilter:tt,format:d.isWebGL2?ft:dt,type:lt}),r._additionalMap2D.texture.name=n.name+".shadowMap.tmp2D");null===r.map&&(r.map=new an(o.x,o.y,{minFilter:tt,magFilter:tt,format:d.isWebGL2?ft:dt,type:lt}),r.map.texture.name=n.name+".shadowMap");{var s,l;x.setFromMatrixPosition(n.matrixWorld),i.position.copy(x),y.setFromMatrixPosition(n.target.matrixWorld),i.lookAt(y),i.updateMatrixWorld(),n.isDirectionalLight?(n.shadow.isDirectionalLightShadowCSM&&(s=X(t,r,o,L),i.left=s.center.x-s.radius,i.right=s.center.x+s.radius,i.top=s.center.y+s.radius,i.bottom=s.center.y-s.radius,i.near=-s.center.z-s.radius,i.far=-s.center.z+s.radius,i.updateProjectionMatrix()),l=n.getWorldDirection(T),x.addScaledVector(l,i.near)):n.isSpotLight&&r.useMinFov90&&(i.fov=90,i.updateProjectionMatrix())}{var c;a.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),a.multiply(i.projectionMatrix),a.multiply(i.matrixWorldInverse),h.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),g.setFromProjectionMatrix(h),_.setRenderTarget(r.map),_.clearDepth(),H(t,i,n),W(e,t,i,!1,n),c=n.isDirectionalLight&&n.shadow.isDirectionalLightShadowCSM?function(e,t){return Ko*e/t}(r.radius,(i.right-i.left)/2):n.isSpotLight?r.radius*Qo:r.radius}var u=function(e){return Math.ceil(qo*e)}(c=Math.max(c,.001));k(_,r.map,r._additionalMap2D,u,c,D,O),k(_,r._additionalMap2D,r.map,u,c,N,O)}(t,n,c);break;default:continue}}else console.warn("v3d.WebGLShadowMap:",c,"has no shadow.")}G.needsUpdate=!1,_.setRenderTarget(r,i,a)}}}function $o(u,n,e){var t,r,i=e.isWebGL2;var a=new function(){var t=!1,a=new rn,n=null,o=new rn(0,0,0,0);return{setMask:function(e){n===e||t||(u.colorMask(e,e,e,e),n=e)},setLocked:function(e){t=e},setClear:function(e,t,n,r,i){!0===i&&(e*=r,t*=r,n*=r),a.set(e,t,n,r),!1===o.equals(a)&&(u.clearColor(e,t,n,r),o.copy(a))},reset:function(){t=!1,n=null,o.set(-1,0,0,0)}}},o=new function(){var t=!1,n=null,r=null,i=null;return{setTest:function(e){(e?V:k)(2929)},setMask:function(e){n===e||t||(u.depthMask(e),n=e)},setFunc:function(e){if(r!==e){if(e)switch(e){case Ce:u.depthFunc(512);break;case Re:u.depthFunc(519);break;case De:u.depthFunc(513);break;case Ne:u.depthFunc(515);break;case Ie:u.depthFunc(514);break;case Oe:u.depthFunc(518);break;case Fe:u.depthFunc(516);break;case Be:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);r=e}},setLocked:function(e){t=e},setClear:function(e){i!==e&&(u.clearDepth(e),i=e)},reset:function(){t=!1,i=r=n=null}}},s=new function(){var t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?V:k)(2960)},setMask:function(e){n===e||t||(u.stencilMask(e),n=e)},setFunc:function(e,t,n){r===e&&i===t&&a===n||(u.stencilFunc(e,t,n),r=e,i=t,a=n)},setOp:function(e,t,n){o===e&&s===t&&l===n||(u.stencilOp(e,t,n),o=e,s=t,l=n)},setLocked:function(e){t=e},setClear:function(e){c!==e&&(u.clearStencil(e),c=e)},reset:function(){t=!1,c=l=s=o=a=i=r=n=null}}},l=u.getParameter(34921),c=new Uint8Array(l),d=new Uint8Array(l),h=new Uint8Array(l),p={},f=null,m=null,v=null,g=null,_=null,y=null,x=null,b=null,M=null,w=!1,A=null,S=null,T=null,E=null,C=null,P=u.getParameter(35661),L=!1,R=0,D=u.getParameter(7938);-1!==D.indexOf("WebGL")?(R=parseFloat(/^WebGL\ ([0-9])/.exec(D)[1]),L=1<=R):-1!==D.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(D)[1]),L=2<=R);var N=null,I={},O=new rn,F=new rn;function B(e,t,n){var r=new Uint8Array(4),i=u.createTexture();u.bindTexture(e,i),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(var a=0;a<n;a++)u.texImage2D(t+a,0,6408,1,1,0,6408,5121,r);return i}var z={};function U(e,t){c[e]=1,0===d[e]&&(u.enableVertexAttribArray(e),d[e]=1),h[e]!==t&&((i?u:n.get("ANGLE_instanced_arrays"))[i?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](e,t),h[e]=t)}function V(e){!0!==p[e]&&(u.enable(e),p[e]=!0)}function k(e){!1!==p[e]&&(u.disable(e),p[e]=!1)}z[3553]=B(3553,3553,1),z[34067]=B(34067,34069,6),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),V(2929),o.setFunc(Ne),H(!1),Y(K),V(2884),X(ae);var G,j=(_defineProperty(t={},de,32774),_defineProperty(t,he,32778),_defineProperty(t,pe,32779),t);i?(j[fe]=32775,j[ve]=32776):null!==(G=n.get("EXT_blend_minmax"))&&(j[fe]=G.MIN_EXT,j[ve]=G.MAX_EXT);var W=(_defineProperty(r={},ge,0),_defineProperty(r,_e,1),_defineProperty(r,ye,768),_defineProperty(r,be,770),_defineProperty(r,Ee,776),_defineProperty(r,Se,774),_defineProperty(r,we,772),_defineProperty(r,xe,769),_defineProperty(r,Me,771),_defineProperty(r,Te,775),_defineProperty(r,Ae,773),r);function X(e,t,n,r,i,a,o,s){if(e!==ae){if(m||(V(3042),m=!0),e===ue)i=i||t,a=a||n,o=o||r,t===g&&i===x||(u.blendEquationSeparate(j[t],j[i]),g=t,x=i),n===_&&r===y&&a===b&&o===M||(u.blendFuncSeparate(W[n],W[r],W[a],W[o]),_=n,y=r,b=a,M=o),v=e,w=null;else if(e!==v||s!==w){if(g===de&&x===de||(u.blendEquation(32774),x=g=de),s)switch(e){case oe:u.blendFuncSeparate(1,771,1,771);break;case se:u.blendFunc(1,1);break;case le:u.blendFuncSeparate(0,0,769,771);break;case ce:u.blendFuncSeparate(0,768,0,770);break;default:console.error("v3d.WebGLState: Invalid blending: ",e)}else switch(e){case oe:u.blendFuncSeparate(770,771,1,771);break;case se:u.blendFunc(770,1);break;case le:u.blendFunc(0,769);break;case ce:u.blendFunc(0,768);break;default:console.error("v3d.WebGLState: Invalid blending: ",e)}M=b=y=_=null,v=e,w=s}}else m&&(k(3042),m=!1)}function H(e){A!==e&&(e?u.frontFace(2304):u.frontFace(2305),A=e)}function Y(e){e!==Q?(V(2884),e!==S&&(e===K?u.cullFace(1029):e===J?u.cullFace(1028):u.cullFace(1032))):k(2884),S=e}function q(e,t,n){e?(V(32823),E===t&&C===n||(u.polygonOffset(t,n),E=t,C=n)):k(32823)}function Z(e){void 0===e&&(e=33984+P-1),N!==e&&(u.activeTexture(e),N=e)}return{buffers:{color:a,depth:o,stencil:s},initAttributes:function(){for(var e=0,t=c.length;e<t;e++)c[e]=0},enableAttribute:function(e){U(e,0)},enableAttributeAndDivisor:U,disableUnusedAttributes:function(){for(var e=0,t=d.length;e!==t;++e)d[e]!==c[e]&&(u.disableVertexAttribArray(e),d[e]=0)},enable:V,disable:k,useProgram:function(e){return f!==e&&(u.useProgram(e),f=e,!0)},setBlending:X,setMaterial:function(e,t){(e.side===ie?k:V)(2884);var n=e.side===Le;t&&(n=!n),H(n),e.blending===oe&&!1===e.transparent?X(ae):X(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),o.setFunc(e.depthFunc),o.setTest(e.depthTest),o.setMask(e.depthWrite),a.setMask(e.colorWrite);var r=e.stencilWrite;s.setTest(r),r&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),q(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:H,setCullFace:Y,setLineWidth:function(e){e!==T&&(L&&u.lineWidth(e),T=e)},setPolygonOffset:q,setScissorTest:function(e){(e?V:k)(3089)},activeTexture:Z,bindTexture:function(e,t){null===N&&Z();var n=I[N];void 0===n&&(n={type:void 0,texture:void 0},I[N]=n),n.type===e&&n.texture===t||(u.bindTexture(e,t||z[e]),n.type=e,n.texture=t)},unbindTexture:function(){var e=I[N];void 0!==e&&void 0!==e.type&&(u.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{u.compressedTexImage2D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage2D:function(){try{u.texImage2D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage3D:function(){try{u.texImage3D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},scissor:function(e){!1===O.equals(e)&&(u.scissor(e.x,e.y,e.z,e.w),O.copy(e))},viewport:function(e){!1===F.equals(e)&&(u.viewport(e.x,e.y,e.z,e.w),F.copy(e))},reset:function(){for(var e=0;e<d.length;e++)1===d[e]&&(u.disableVertexAttribArray(e),d[e]=0);p={},I={},S=A=v=f=N=null,a.reset(),o.reset(),s.reset()}}}function es(y,x,b,M,i,w,A){var e,t,c,S=i.isWebGL2,n=i.maxTextures,v=i.maxCubemapSize,m=i.maxTextureSize,r=i.maxSamples,o=new WeakMap,a=!1;try{a="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function u(e,t){return a?new OffscreenCanvas(e,t):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(e,t,n,r){var i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?Kt.floorPowerOfTwo:Math.floor,o=a(i*e.width),s=a(i*e.height);void 0===c&&(c=u(o,s));var l=n?u(o,s):c;return l.width=o,l.height=s,l.getContext("2d").drawImage(e,0,0,o,s),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),l}return"data"in e&&console.warn("v3d.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function T(e){return Kt.isPowerOfTwo(e.width)&&Kt.isPowerOfTwo(e.height)}function E(e,t){return e.generateMipmaps&&t&&e.minFilter!==Je&&e.minFilter!==tt}function C(e,t,n,r){y.generateMipmap(e),M.get(t).__maxMipLevel=Math.log(Math.max(n,r))*Math.LOG2E}function P(e,t,n){if(!1===S)return t;if(null!==e){if(void 0!==y[e])return y[e];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?x.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("v3d.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function s(e){return e===Je||e===$e||e===et?9728:9729}function l(e){var t=e.target;t.removeEventListener("dispose",l),function(e){var t=M.get(e);if(void 0===t.__webglInit)return;y.deleteTexture(t.__webglTexture),M.remove(e)}(t),t.isVideoTexture&&o.delete(t),A.memory.textures--,A.removeTextureSpec(t)}function L(e){var t=e.target;t.removeEventListener("dispose",L),function(e){var t=M.get(e),n=M.get(e.texture);if(!e)return;void 0!==n.__webglTexture&&y.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(var r=0;r<6;r++)y.deleteFramebuffer(t.__webglFramebuffer[r]),t.__webglDepthbuffer&&y.deleteRenderbuffer(t.__webglDepthbuffer[r]);else y.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&y.deleteRenderbuffer(t.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){y.deleteTexture(t.__webglColorTexture),y.deleteTexture(t.__webglDepthStencilTexture),A.memory.textures-=2;for(var r=0,i=t.__webglViewFramebuffers.length;r<i;r++)y.deleteFramebuffer(t.__webglViewFramebuffers[r])}M.remove(e.texture),M.remove(e)}(t),A.memory.textures--,A.removeTextureSpec(t)}var d=0;function h(e,t){var n,r,i=M.get(e);if(e.isVideoTexture&&(n=e,r=A.render.frame,o.get(n)!==r&&(o.set(n,r),n.update())),0<e.version&&i.__version!==e.version){var a=e.image;if(void 0===a)console.warn("v3d.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void I(i,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}b.activeTexture(33984+t),b.bindTexture(3553,i.__webglTexture)}function p(e,t){if(6===e.image.length){var n=M.get(e);if(0<e.version&&n.__version!==e.version){N(n,e),b.activeTexture(33984+t),b.bindTexture(34067,n.__webglTexture),y.pixelStorei(37440,e.flipY);for(var r=e&&(e.isCompressedTexture||e.image[0].isCompressedTexture),i=e.image[0]&&e.image[0].isDataTexture,a=[],o=0;o<6;o++)a[o]=r||i?i?e.image[o].image:e.image[o]:g(e.image[o],!1,!0,v);var s,l=a[0],c=T(l)||S,u=w.convert(e.format),d=w.convert(e.type),h=P(e.internalFormat,u,d);if(D(34067,e,c),r){for(o=0;o<6;o++){s=a[o].mipmaps;for(var p=0;p<s.length;p++){var f=s[p];e.format!==dt&&e.format!==ut?null!==u?b.compressedTexImage2D(34069+o,p,h,f.width,f.height,0,f.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):b.texImage2D(34069+o,p,h,f.width,f.height,0,u,d,f.data)}}n.__maxMipLevel=s.length-1}else{s=e.mipmaps;for(o=0;o<6;o++)if(i){b.texImage2D(34069+o,0,h,a[o].width,a[o].height,0,u,d,a[o].data);for(p=0;p<s.length;p++){var m=(f=s[p]).image[o].image;b.texImage2D(34069+o,p+1,h,m.width,m.height,0,u,d,m.data)}}else{b.texImage2D(34069+o,0,h,u,d,a[o]);for(p=0;p<s.length;p++){f=s[p];b.texImage2D(34069+o,p+1,h,u,d,f.image[o])}}n.__maxMipLevel=s.length}E(e,c)&&C(34067,e,l.width,l.height),n.__version=e.version,e.onUpdate&&e.onUpdate(e)}else b.activeTexture(33984+t),b.bindTexture(34067,n.__webglTexture)}}function f(e,t){b.activeTexture(33984+t),b.bindTexture(34067,M.get(e).__webglTexture)}var _=(_defineProperty(e={},Ze,10497),_defineProperty(e,Qe,33071),_defineProperty(e,Ke,33648),e),R=(_defineProperty(t={},Je,9728),_defineProperty(t,$e,9984),_defineProperty(t,et,9986),_defineProperty(t,tt,9729),_defineProperty(t,nt,9985),_defineProperty(t,rt,9987),t);function D(e,t,n){n?(y.texParameteri(e,10242,_[t.wrapS]),y.texParameteri(e,10243,_[t.wrapT]),32879!==e&&35866!==e||y.texParameteri(e,32882,_[t.wrapR]),y.texParameteri(e,10240,R[t.magFilter]),y.texParameteri(e,10241,R[t.minFilter])):(y.texParameteri(e,10242,33071),y.texParameteri(e,10243,33071),32879!==e&&35866!==e||y.texParameteri(e,32882,33071),t.wrapS===Qe&&t.wrapT===Qe||console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to v3d.ClampToEdgeWrapping."),y.texParameteri(e,10240,s(t.magFilter)),y.texParameteri(e,10241,s(t.minFilter)),t.minFilter!==Je&&t.minFilter!==tt&&console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to v3d.NearestFilter or v3d.LinearFilter."));var r=x.get("EXT_texture_filter_anisotropic");if(r){if(t.type===st&&null===x.get("OES_texture_float_linear"))return;if(t.type===lt&&null===(S||x.get("OES_texture_half_float_linear")))return;(1<t.anisotropy||M.get(t).__currentAnisotropy)&&(y.texParameterf(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy())),M.get(t).__currentAnisotropy=t.anisotropy)}}function N(e,t){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",l),e.__webglTexture=y.createTexture(),A.memory.textures++,A.addTextureSpec(t))}function I(e,t,n){var r=3553;t.isDataTexture2DArray&&(r=35866),t.isDataTexture3D&&(r=32879),N(e,t),b.activeTexture(33984+n),b.bindTexture(r,e.__webglTexture),y.pixelStorei(37440,t.flipY),y.pixelStorei(37441,t.premultiplyAlpha),y.pixelStorei(3317,t.unpackAlignment);var i,a=(i=t,!S&&(i.wrapS!==Qe||i.wrapT!==Qe||i.minFilter!==Je&&i.minFilter!==tt)&&!1===T(t.image)),o=g(t.image,a,!1,m),s=T(o)||S,l=w.convert(t.format),c=w.convert(t.type),u=P(t.internalFormat,l,c);D(r,t,s);var d,h=t.mipmaps;if(t.isDepthTexture){if(u=6402,t.type===st){if(!1===S)throw new Error("Float Depth Texture only supported in WebGL2.0");u=36012}else S&&(u=33189);t.format===ht&&6402===u&&t.type!==at&&t.type!==ot&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),t.type=at,c=w.convert(t.type)),t.format===pt&&(u=34041,t.type!==ct&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),t.type=ct,c=w.convert(t.type))),b.texImage2D(3553,0,u,o.width,o.height,0,l,c,null)}else if(t.isDataTexture)if(0<h.length&&s){for(var p=0,f=h.length;p<f;p++)d=h[p],b.texImage2D(3553,p,u,d.width,d.height,0,l,c,d.data);t.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else b.texImage2D(3553,0,u,o.width,o.height,0,l,c,o.data),e.__maxMipLevel=0;else if(t.isCompressedTexture){for(p=0,f=h.length;p<f;p++)d=h[p],t.format!==dt&&t.format!==ut?null!==l?b.compressedTexImage2D(3553,p,u,d.width,d.height,0,d.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):b.texImage2D(3553,p,u,d.width,d.height,0,l,c,d.data);e.__maxMipLevel=h.length-1}else if(t.isDataTexture2DArray)b.texImage3D(35866,0,u,o.width,o.height,o.depth,0,l,c,o.data),e.__maxMipLevel=0;else if(t.isDataTexture3D)b.texImage3D(32879,0,u,o.width,o.height,o.depth,0,l,c,o.data),e.__maxMipLevel=0;else if(0<h.length&&s){for(p=0,f=h.length;p<f;p++)d=h[p],b.texImage2D(3553,p,u,l,c,d);t.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else b.texImage2D(3553,0,u,l,c,o),e.__maxMipLevel=0;E(t,s)&&C(r,t,o.width,o.height),e.__version=t.version,t.onUpdate&&t.onUpdate(t)}function O(e,t,n,r){var i=w.convert(t.texture.format),a=w.convert(t.texture.type),o=P(t.texture.internalFormat,i,a);b.texImage2D(r,0,o,t.width,t.height,0,i,a,null),y.bindFramebuffer(36160,e),y.framebufferTexture2D(36160,n,r,M.get(t.texture).__webglTexture,0),y.bindFramebuffer(36160,null)}function F(e,t,n){var r,i,a,o;y.bindRenderbuffer(36161,e),t.depthBuffer&&!t.stencilBuffer?(n?(o=z(t),y.renderbufferStorageMultisample(36161,o,33189,t.width,t.height)):y.renderbufferStorage(36161,33189,t.width,t.height),y.framebufferRenderbuffer(36160,36096,36161,e)):t.depthBuffer&&t.stencilBuffer?(n?(o=z(t),y.renderbufferStorageMultisample(36161,o,35056,t.width,t.height)):y.renderbufferStorage(36161,34041,t.width,t.height),y.framebufferRenderbuffer(36160,33306,36161,e)):(r=w.convert(t.texture.format),i=w.convert(t.texture.type),a=P(t.texture.internalFormat,r,i),n?(o=z(t),y.renderbufferStorageMultisample(36161,o,a,t.width,t.height)):y.renderbufferStorage(36161,a,t.width,t.height)),y.bindRenderbuffer(36161,null)}function B(e){var t=M.get(e),n=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,t){if(t&&t.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(y.bindFramebuffer(36160,e),!t.depthTexture||!t.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of v3d.DepthTexture");M.get(t.depthTexture).__webglTexture&&t.depthTexture.image.width===t.width&&t.depthTexture.image.height===t.height||(t.depthTexture.image.width=t.width,t.depthTexture.image.height=t.height,t.depthTexture.needsUpdate=!0),h(t.depthTexture,0);var n=M.get(t.depthTexture).__webglTexture;if(t.depthTexture.format===ht)y.framebufferTexture2D(36160,36096,3553,n,0);else{if(t.depthTexture.format!==pt)throw new Error("Unknown depthTexture format");y.framebufferTexture2D(36160,33306,3553,n,0)}}(t.__webglFramebuffer,e)}else if(n){t.__webglDepthbuffer=[];for(var r=0;r<6;r++)y.bindFramebuffer(36160,t.__webglFramebuffer[r]),t.__webglDepthbuffer[r]=y.createRenderbuffer(),F(t.__webglDepthbuffer[r],e)}else y.bindFramebuffer(36160,t.__webglFramebuffer),t.__webglDepthbuffer=y.createRenderbuffer(),F(t.__webglDepthbuffer,e);y.bindFramebuffer(36160,null)}function z(e){return S&&e.isWebGLMultisampleRenderTarget?Math.min(r,e.samples):0}var U=!1,V=!1;this.allocateTextureUnit=function(){var e=d;return n<=e&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+n),d+=1,e},this.resetTextureUnits=function(){d=0},this.setTexture2D=h,this.setTexture2DArray=function(e,t){var n=M.get(e);0<e.version&&n.__version!==e.version?I(n,e,t):(b.activeTexture(33984+t),b.bindTexture(35866,n.__webglTexture))},this.setTexture3D=function(e,t){var n=M.get(e);0<e.version&&n.__version!==e.version?I(n,e,t):(b.activeTexture(33984+t),b.bindTexture(32879,n.__webglTexture))},this.setTextureCube=p,this.setTextureCubeDynamic=f,this.setupRenderTarget=function(e){var t=M.get(e),n=M.get(e.texture);e.addEventListener("dispose",L),n.__webglTexture=y.createTexture(),A.memory.textures++,A.addTextureSpec(e);var r,i,a,o,s=!0===e.isWebGLCubeRenderTarget,l=!0===e.isWebGLMultisampleRenderTarget,c=!0===e.isWebGLMultiviewRenderTarget,u=T(e)||S;if(s){t.__webglFramebuffer=[];for(var d=0;d<6;d++)t.__webglFramebuffer[d]=y.createFramebuffer()}else{if(t.__webglFramebuffer=y.createFramebuffer(),l)S?(t.__webglMultisampledFramebuffer=y.createFramebuffer(),t.__webglColorRenderbuffer=y.createRenderbuffer(),y.bindRenderbuffer(36161,t.__webglColorRenderbuffer),r=w.convert(e.texture.format),i=w.convert(e.texture.type),a=P(e.texture.internalFormat,r,i),o=z(e),y.renderbufferStorageMultisample(36161,o,a,e.width,e.height),y.bindFramebuffer(36160,t.__webglMultisampledFramebuffer),y.framebufferRenderbuffer(36160,36064,36161,t.__webglColorRenderbuffer),y.bindRenderbuffer(36161,null),e.depthBuffer&&(t.__webglDepthRenderbuffer=y.createRenderbuffer(),F(t.__webglDepthRenderbuffer,e,!0)),y.bindFramebuffer(36160,null)):console.warn("v3d.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(c){var h=e.width,p=e.height,f=e.numViews;y.bindFramebuffer(36160,t.__webglFramebuffer);var m=x.get("OVR_multiview2");A.memory.textures+=2;var v=y.createTexture();y.bindTexture(35866,v),y.texParameteri(35866,10240,9728),y.texParameteri(35866,10241,9728),y.texImage3D(35866,0,32856,h,p,f,0,6408,5121,null),m.framebufferTextureMultiviewOVR(36160,36064,v,0,0,f);var g=y.createTexture();y.bindTexture(35866,g),y.texParameteri(35866,10240,9728),y.texParameteri(35866,10241,9728),y.texImage3D(35866,0,35056,h,p,f,0,34041,34042,null),m.framebufferTextureMultiviewOVR(36160,33306,g,0,0,f);for(var _=new Array(f),d=0;d<f;++d)_[d]=y.createFramebuffer(),y.bindFramebuffer(36160,_[d]),y.framebufferTextureLayer(36160,36064,v,0,d);t.__webglColorTexture=v,t.__webglDepthStencilTexture=g,t.__webglViewFramebuffers=_,y.bindFramebuffer(36160,null),y.bindTexture(35866,null)}}if(s){b.bindTexture(34067,n.__webglTexture),D(34067,e.texture,u);for(d=0;d<6;d++)O(t.__webglFramebuffer[d],e,36064,34069+d);E(e.texture,u)&&C(34067,e.texture,e.width,e.height),b.bindTexture(34067,null)}else c||(b.bindTexture(3553,n.__webglTexture),D(3553,e.texture,u),O(t.__webglFramebuffer,e,36064,3553),E(e.texture,u)&&C(3553,e.texture,e.width,e.height),b.bindTexture(3553,null));e.depthBuffer&&B(e)},this.updateRenderTargetMipmap=function(e){var t,n,r=e.texture;E(r,T(e)||S)&&(t=e.isWebGLCubeRenderTarget?34067:3553,n=M.get(r).__webglTexture,b.bindTexture(t,n),C(t,r,e.width,e.height),b.bindTexture(t,null))},this.updateMultisampleRenderTarget=function(e){var t,n,r,i;e.isWebGLMultisampleRenderTarget&&!e.disableBlit&&(S?(t=M.get(e),y.bindFramebuffer(36008,t.__webglMultisampledFramebuffer),y.bindFramebuffer(36009,t.__webglFramebuffer),n=e.width,r=e.height,i=16384,e.depthBuffer&&(i|=256),e.stencilBuffer&&(i|=1024),y.blitFramebuffer(0,0,n,r,0,0,n,r,i,9728)):console.warn("v3d.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."))},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===U&&(console.warn("v3d.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),U=!0),e=e.texture),h(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===V&&(console.warn("v3d.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),V=!0),e=e.texture),(e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?p:f)(e,t)}}function ts(e,n,t){var r=t.isWebGL2;return{convert:function(e){var t;if(e===it)return 5121;if(e===c)return 32819;if(e===u)return 32820;if(e===d)return 33635;if(e===i)return 5120;if(e===a)return 5122;if(e===at)return 5123;if(e===l)return 5124;if(e===ot)return 5125;if(e===st)return 5126;if(e===lt)return r?5131:null!==(t=n.get("OES_texture_half_float"))?t.HALF_FLOAT_OES:null;if(e===h)return 6406;if(e===ut)return 6407;if(e===dt)return 6408;if(e===p)return 6409;if(e===f)return 6410;if(e===ht)return 6402;if(e===pt)return 34041;if(e===ft)return 6403;if(e===m)return 36244;if(e===v)return 33319;if(e===g)return 33320;if(e===y)return 36248;if(e===x)return 36249;if(e===b||e===M||e===w||e===A){if(null===(t=n.get("WEBGL_compressed_texture_s3tc")))return null;if(e===b)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===M)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===w)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===A)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===T||e===E||e===C||e===P){if(null===(t=n.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===T)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===E)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===C)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===P)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}return e===L?null!==(t=n.get("WEBGL_compressed_texture_etc1"))?t.COMPRESSED_RGB_ETC1_WEBGL:null:e===R||e===D||e===N||e===I||e===O||e===F||e===B||e===z||e===mt||e===vt||e===gt||e===_t||e===yt||e===xt?null!==(t=n.get("WEBGL_compressed_texture_astc"))?e:null:e===ct?r?34042:null!==(t=n.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}function ns(e,t,n,r){an.call(this,e,t,r),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=n}function rs(r,h){var p,i,a,o,n,f,s,l=2,c=r.extensions,m=r.properties,u=0;function d(e){return e.isArrayCamera?e.cameras:(n[0]=e,n)}this.isAvailable=function(){if(void 0===s){var e=c.get("OVR_multiview2");if(s=null!==e&&!1===h.getContextAttributes().antialias){u=h.getParameter(e.MAX_VIEWS_OVR),p=new ns(0,0,l),f=new Jt,o=[],a=[],n=[];for(var t=0;t<u;t++)o[t]=new _n,a[t]=new $t}}return s},this.attachCamera=function(e){var t,n;!1!==function(e){if(void 0===e.isArrayCamera)return!0;var t=e.cameras;if(t.length>u)return!1;for(var n=1,r=t.length;n<r;n++)if(t[0].viewport.z!==t[n].viewport.z||t[0].viewport.w!==t[n].viewport.w)return!1;return!0}(e)&&(i=r.getRenderTarget(),t=e,i?f.set(i.width,i.height):r.getDrawingBufferSize(f),t.isArrayCamera?(n=t.cameras[0].viewport,p.setSize(n.z,n.w),p.setNumViews(t.cameras.length)):(p.setSize(f.x,f.y),p.setNumViews(l)),r.setRenderTarget(p))},this.detachCamera=function(e){p===r.getRenderTarget()&&(r.setRenderTarget(i),function(e){var t=p,n=t.numViews,r=m.get(t).__webglViewFramebuffers,i=t.width,a=t.height;if(e.isArrayCamera)for(var o=0;o<n;o++){var s=e.cameras[o].viewport,l=s.x,c=s.y,u=l+s.z,d=c+s.w;h.bindFramebuffer(36008,r[o]),h.blitFramebuffer(0,0,i,a,l,c,u,d,16384,9728)}else h.bindFramebuffer(36008,r[0]),h.blitFramebuffer(0,0,i,a,0,0,f.x,f.y,16384,9728)}(e))},this.updateCameraProjectionMatricesUniform=function(e,t){for(var n=d(e),r=0;r<n.length;r++)o[r].copy(n[r].projectionMatrix);t.setValue(h,"projectionMatrices",o)},this.updateCameraViewMatricesUniform=function(e,t){for(var n=d(e),r=0;r<n.length;r++)o[r].copy(n[r].matrixWorldInverse);t.setValue(h,"viewMatrices",o)},this.updateObjectMatricesUniforms=function(e,t,n){for(var r=d(t),i=0;i<r.length;i++)o[i].multiplyMatrices(r[i].matrixWorldInverse,e.matrixWorld),a[i].getNormalMatrix(o[i]);n.setValue(h,"modelViewMatrices",o),n.setValue(h,"normalMatrices",a)}}function is(e){Xi.call(this),this.cameras=e||[]}function as(){Bn.call(this),this.type="Group"}ns.prototype=Object.assign(Object.create(an.prototype),{constructor:ns,isWebGLMultiviewRenderTarget:!0,copy:function(e){return an.prototype.copy.call(this,e),this.numViews=e.numViews,this},setNumViews:function(e){return this.numViews!==e&&(this.numViews=e,this.dispose()),this}}),is.prototype=Object.assign(Object.create(Xi.prototype),{constructor:is,isArrayCamera:!0}),as.prototype=Object.assign(Object.create(Bn.prototype),{constructor:as,isGroup:!0,getWorldDirection:function(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}});var os={checkWebGL:function(){try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},checkWebGL2:function(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},checkWorkers:function(){return!!window.Worker},checkFileAPI:function(){return window.File&&window.FileReader&&window.FileList&&window.Blob},genWebGLErrorMessage:function(){var e=document.createElement("div");return e.setAttribute("class","v3d-webgl-error"),e.innerHTML=window.WebGLRenderingContext?["Ouch! Your graphics card does not support WebGL.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.'].join("\n"):["Ouch! Your browser does not support WebGL.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.'].join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild(os.genWebGLErrorMessage());var t=document.getElementById("v3d_preloader_container");t&&(t.style.visibility="hidden")},checkIOS:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&1<navigator.maxTouchPoints)&&!window.MSStream},checkAndroid:function(){return!!navigator.userAgent.match(/Android/i)},checkFloatTex:function(e,t){var n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(!n.getExtension("OES_texture_float")||t&&!n.getExtension("OES_texture_float_linear"))},checkHalfFloatTex:function(e,t){var n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float"))||!(!n.getExtension("OES_texture_half_float")||t&&!n.getExtension("OES_texture_half_float_linear"))},checkDepthTex:function(e){var t=e.getContext();return!(!e.capabilities.isWebGL2&&!t.getExtension("WEBGL_depth_texture"))},getGPUVendor:function(e){var t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl"),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_VENDOR_WEBGL):""},getGPUModel:function(e){var t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl"),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_RENDERER_WEBGL):""},checkWebXR:function(e,t,n){"xr"in navigator&&navigator.xr.isSessionSupported?navigator.xr.isSessionSupported(e).then(function(e){(e?t:n)()}).catch(n):n()},checkNativeWebXR:function(){var e="polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill;return"xr"in navigator&&(!e||e&&polyfill.nativeWebXR)},checkCardboard:function(){if(!("polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill))return!1;for(var e=Object.getOwnPropertySymbols(navigator.xr),t=0;t<e.length;t++){var n=e[t];if("Symbol(@@webxr-polyfill/XR)"==n.toString()){var r=navigator.xr[n].device;if(r&&"CardboardXRDevice"==r.constructor.name)return!0}}return!1},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)}};function ss(e,t,n,r){this.ray=new dr(e,t),this.near=n||0,this.far=r||1/0,this.camera=null,this.params={Mesh:{omitGeometry:!1},Line:{},LOD:{},Points:{threshold:1},Sprite:{},checkVisibility:!0},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("v3d.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function ls(e,t){return e.distance-t.distance}function cs(e,t,n,r,i){if(!(i&&(!1===e.visible||e.isMesh&&e.isMaterialGeneratedMesh&&e.parent&&!e.parent.visible)||(e.raycast(t,n),!0!==r)))for(var a=e.children,o=0,s=a.length;o<s;o++)cs(a[o],t,n,!0,i)}function us(p,i){var t=this,f=null,a=1,m=null,o="local-floor",v=null,g=[],s=new Map,l=new Xi;l.layers.enable(1),l.viewport=new rn;var c=new Xi;c.layers.enable(2),c.viewport=new rn;var _=new is([l,c]);_.layers.enable(1),_.layers.enable(2);var u=null,d=null,y=null,x=null,b=null,M=null,w=null;function h(e){var t=s.get(e.inputSource);t&&(t.targetRay&&t.targetRay.dispatchEvent({type:e.type}),t.grip&&t.grip.dispatchEvent({type:e.type}))}function A(){s.forEach(function(e,t){e.targetRay&&(e.targetRay.dispatchEvent({type:"disconnected",data:t}),e.targetRay.visible=!1),e.grip&&(e.grip.dispatchEvent({type:"disconnected",data:t}),e.grip.visible=!1)}),s.clear(),p.setFramebuffer(null),p.setRenderTarget(p.getRenderTarget()),n.stop(),t.isPresenting=!1,t.dispatchEvent({type:"sessionend"})}function S(e){m=e,n.setContext(f),n.start(),t.isPresenting=!0,t.dispatchEvent({type:"sessionstart"})}function T(e){for(var t=x||f.inputSources,n=0;n<g.length;n++)s.set(t[n],g[n]);for(n=0;n<e.removed.length;n++){var r=e.removed[n];(i=s.get(r))&&(i.targetRay&&i.targetRay.dispatchEvent({type:"disconnected",data:r}),i.grip&&i.grip.dispatchEvent({type:"disconnected",data:r}),s.delete(r))}for(n=0;n<e.added.length;n++){var i,r=e.added[n];(i=s.get(r))&&(i.targetRay&&(x?setTimeout(function(){i.targetRay.dispatchEvent({type:"connected",data:r})},0):i.targetRay.dispatchEvent({type:"connected",data:r})),i.grip&&i.grip.dispatchEvent({type:"connected",data:r}))}}this.enabled=!1,this.isPresenting=!1,this.getController=function(e){var t=g[e];return void 0===t&&(t={},g[e]=t),void 0===t.targetRay&&(t.targetRay=new as,t.targetRay.matrixAutoUpdate=!1,t.targetRay.visible=!1,t.targetRay.name="XR_CONTROLLER_"+String(e)),t.targetRay},this.getControllerGrip=function(e){var t=g[e];return void 0===t&&(t={},g[e]=t),void 0===t.grip&&(t.grip=new as,t.grip.matrixAutoUpdate=!1,t.grip.visible=!1),t.grip},this.setFramebufferScaleFactor=function(e){a=e},this.setReferenceSpaceType=function(e){o=e},this.getReferenceSpace=function(){return m},this.getSession=function(){return f},this.setSession=function(e){var t,n,r;null!==(f=e)&&(f.addEventListener("select",h),f.addEventListener("selectstart",h),f.addEventListener("selectend",h),f.addEventListener("squeeze",h),f.addEventListener("squeezestart",h),f.addEventListener("squeezeend",h),f.addEventListener("end",A),n={antialias:(t=i.getContextAttributes()).antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:a},r=new XRWebGLLayer(f,i,n),f.updateRenderState({baseLayer:r}),f.requestReferenceSpace(o).then(S),f.addEventListener("inputsourceschange",T),os.checkCardboard()&&(T({added:x=[{gamepad:null,gripSpace:null,handedness:"none",targetRayMode:"gaze",targetRaySpace:{},profiles:[]}],removed:[]}),document.addEventListener("touchstart",function(){var e=g[0];e&&e.targetRay&&e.targetRay.dispatchEvent({type:"selectstart"})}),document.addEventListener("touchend",function(){var e=g[0];e&&e.targetRay&&(e.targetRay.dispatchEvent({type:"selectend"}),e.targetRay.dispatchEvent({type:"select"}))})))};var E=new un,C=new un;function P(e,t){y=null===t?(e.matrixWorld.copy(e.matrix),null):(e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),t.matrixWorld),e.matrixWorldInverse.getInverse(e.matrixWorld)}this.getCamera=function(e){_.near=c.near=l.near=e.near,_.far=c.far=l.far=e.far,u===_.near&&d===_.far||(f.updateRenderState({depthNear:_.near,depthFar:_.far}),u=_.near,d=_.far);var t=e.parent,n=_.cameras;P(_,t);for(var r=0;r<n.length;r++)P(n[r],t);e.matrixWorld.copy(_.matrixWorld),e.matrix.getInverse(t.matrixWorld),e.matrix.multiply(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale);for(var i=e.children,r=0,a=i.length;r<a;r++)i[r].updateMatrixWorld(!0);return function(e,t,n){E.setFromMatrixPosition(t.matrixWorld),C.setFromMatrixPosition(n.matrixWorld);var r=E.distanceTo(C),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],h=o*u,p=o*d,f=r/(d-u),m=f*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.getInverse(e.matrixWorld);var v=o+f,g=s+f,_=h-m,y=r-m+p,x=l*s/g*v,b=c*s/g*v;e.projectionMatrix.makePerspective(_,y,x,b,v,g)}(_,l,c),_};var L=null;var n=new ea;n.setAnimationLoop(function(e,t){if(null!==(v=t.getViewerPose(m))){var n=v.views,r=f.renderState.baseLayer;p.setFramebuffer(r.framebuffer);for(var i=0;i<n.length;i++){var a=n[i],o=r.getViewport(a),s=_.cameras[i];s.matrix.fromArray(a.transform.matrix),s.projectionMatrix.fromArray(a.projectionMatrix),s.viewport.set(o.x,o.y,o.width,o.height),0===i&&_.matrix.copy(s.matrix)}}for(var l=f.inputSources,i=0;i<g.length;i++){var c=g[i],u=l[i],d=null,h=null;u&&(c.targetRay&&null!==(d=t.getPose(u.targetRaySpace,m))&&(c.targetRay.matrix.fromArray(d.transform.matrix),y&&c.targetRay.matrix.multiplyMatrices(y,c.targetRay.matrix),c.targetRay.matrix.decompose(c.targetRay.position,c.targetRay.rotation,c.targetRay.scale)),c.grip&&u.gripSpace&&null!==(h=t.getPose(u.gripSpace,m))&&(c.grip.matrix.fromArray(h.transform.matrix),c.grip.matrix.decompose(c.grip.position,c.grip.rotation,c.grip.scale))),x&&x[i]&&c.targetRay&&(c.targetRay.matrix.copy(_.matrix),y&&c.targetRay.matrix.multiplyMatrices(y,c.targetRay.matrix),c.targetRay.matrix.decompose(c.targetRay.position,c.targetRay.rotation,c.targetRay.scale),d={}),function(e){{var t,n,r,i;b&&((t=e.getHitTestResults(b)).length?(n=t[0].getPose(m),r=(new _n).fromArray(n.transform.matrix),(i=new un).setFromMatrixPosition(r),M(i)):w())}}(t),c.targetRay&&(c.targetRay.visible=null!==d),c.grip&&(c.grip.visible=null!==h)}L&&L(e,t)}),this.setAnimationLoop=function(e){L=e},this.dispose=function(){},this.arHitTest=function(e,t,n,r){var i;f&&XRSession.prototype.requestHitTestSource&&(M=n||function(){},w=r||function(){},this.raycaster=this.raycaster||new ss,this.raycaster.setFromCamera({x:e,y:t},_.cameras[0]),i=this.raycaster.ray,new XRRay(i.origin,i.direction),f.requestReferenceSpace("viewer").then(function(e){var t={space:e};f.requestHitTestSource(t).then(function(e){b=e})}))}}Object.assign(ss.prototype,{linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("v3d.Raycaster: Unsupported camera type.")},intersectObject:function(e,t,n){var r=n||[];return cs(e,this,r,t,this.params.checkVisibility),r.sort(ls),r},intersectObjects:function(e,t,n){var r=n||[];if(!1===Array.isArray(e))return console.warn("v3d.Raycaster.intersectObjects: objects is not an Array."),r;for(var i=0,a=e.length;i<a;i++)cs(e[i],this,r,t,this.params.checkVisibility);return r.sort(ls),r}}),Object.assign(us.prototype,o.prototype);var ds=16;function hs(e){var r=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),t=void 0!==e.context?e.context:null,n=void 0!==e.alpha&&e.alpha,i=void 0===e.depth||e.depth,a=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat,d="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;console.log("Verge3D "+Pe+" "+ei()+" ("+(3483952072==Kt.hashString(Xt)?"Trial":"License")+", "+(d?"WebGL 2.0":"WebGL 1.0")+")");var m=null,O=null;this.domElement=r,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Tt,this.physicallyCorrectLights=!1,this.unitsScaleFactor=1,this.toneMapping=ze,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=12,this.maxMorphNormals=6,this.compatSettings={useSpecEnvBlenderApprox:!0,saturateSpecEnvBlenderApprox:!1};var F,w,B,z,h,U,V,A,S,v,_,p,f,g,T,E,C,y,x,k=this,b=!1,M=null,P=0,L=0,R=null,D=null,G=-1,N={geometry:null,program:null,wireframe:!1},j=null,I=null,W=new rn,X=new rn,H=null,Y=r.width,q=r.height,Z=1,Q=null,K=null,J=new rn(0,0,Y,q),$=new rn(0,0,Y,q),ee=!1,te=new Ki,ne=new ua,re=!1,ie=!1,ae=new _n,oe=new _n,se=new _n,le=new Jt,ce=new un;function ue(){return null===R?Z:1}try{var de={alpha:n,depth:i,stencil:a,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u,xrCompatible:!0};if(r.addEventListener("webglcontextlost",ve,!1),r.addEventListener("webglcontextrestored",ge,!1),null===(F=t||r.getContext("webgl",de)||r.getContext("experimental-webgl",de)))throw null!==r.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===F.getShaderPrecisionFormat&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("v3d.WebGLRenderer: "+e.message),e}function he(){w=new da(F),!1===(B=new ca(F,w,e)).isWebGL2&&(w.get("WEBGL_depth_texture"),w.get("OES_texture_float"),w.get("OES_texture_half_float"),w.get("OES_texture_half_float_linear"),w.get("OES_standard_derivatives"),w.get("OES_element_index_uint"),w.get("ANGLE_instanced_arrays")),w.get("OES_texture_float_linear"),y=new ts(0,w,B),(z=new $o(F,w,B)).scissor(X.copy($).multiplyScalar(Z).floor()),z.viewport(W.copy(J).multiplyScalar(Z).floor()),h=new fa,U=new No,V=new es(F,w,z,U,B,y,h),A=new ta(F,B),S=new ha(0,A,h),v=new ga(0,S,A,h),T=new va(F),_=new Do(k,w,B),p=new Bo,f=new Xo,g=new sa(k,z,v,s),E=new la(F,w,h,B),C=new pa(F,w,h,B),h.programs=_.programs,k.capabilities=B,k.extensions=w,k.properties=U,k.renderLists=p,k.state=z,k.info=h,x=new $i}he();var pe=new us(k,F);this.xr=pe;var fe=new rs(k,F),me=new Jo(k,v,B);function ve(e){e.preventDefault(),console.log("v3d.WebGLRenderer: Context Lost."),b=!0}function ge(){console.log("v3d.WebGLRenderer: Context Restored."),b=!1,he()}function _e(e){var t,n=e.target;n.removeEventListener("dispose",_e),ye(t=n),U.remove(t)}function ye(e){var t=U.get(e).program;(e.program=void 0)!==t&&_.releaseProgram(t)}this.shadowMap=me,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){var e=w.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=w.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(e){void 0!==e&&(Z=e,this.setSize(Y,q,!1))},this.getSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),e=new Jt),e.set(Y,q)},this.setSize=function(e,t,n){pe.isPresenting?console.warn("v3d.WebGLRenderer: Can't change size while VR device is presenting."):(Y=e,q=t,r.width=Math.floor(e*Z),r.height=Math.floor(t*Z),!1!==n&&(r.style.width=e+"px",r.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),e=new Jt),e.set(Y*Z,q*Z).floor()},this.setDrawingBufferSize=function(e,t,n){Y=e,q=t,Z=n,r.width=Math.floor(e*n),r.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),e=new rn),e.copy(W)},this.getViewport=function(e){return e.copy(J)},this.setViewport=function(e,t,n,r){e.isVector4?J.set(e.x,e.y,e.z,e.w):J.set(e,t,n,r),z.viewport(W.copy(J).multiplyScalar(Z).floor())},this.getScissor=function(e){return e.copy($)},this.setScissor=function(e,t,n,r){e.isVector4?$.set(e.x,e.y,e.z,e.w):$.set(e,t,n,r),z.scissor(X.copy($).multiplyScalar(Z).floor())},this.getScissorTest=function(){return ee},this.setScissorTest=function(e){z.setScissorTest(ee=e)},this.setOpaqueSort=function(e){Q=e},this.setTransparentSort=function(e){K=e},this.getClearColor=function(){return g.getClearColor()},this.setClearColor=function(){g.setClearColor.apply(g,arguments)},this.getClearAlpha=function(){return g.getClearAlpha()},this.setClearAlpha=function(){g.setClearAlpha.apply(g,arguments)},this.clear=function(e,t,n){var r=0;void 0!==e&&!e||(r|=16384),void 0!==t&&!t||(r|=256),void 0!==n&&!n||(r|=1024),F.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){r.removeEventListener("webglcontextlost",ve,!1),r.removeEventListener("webglcontextrestored",ge,!1),this.disposeInternalCaches(),pe.dispose(),Me.stop()},this.disposeInternalCaches=function(){p.dispose(),f.dispose(),g.dispose(),A.dispose(),v.dispose(),U.dispose(),x.dispose()},this.renderBufferImmediate=function(e,t){z.initAttributes();var n=U.get(e);e.hasPositions&&!n.position&&(n.position=F.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=F.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=F.createBuffer()),e.hasColors&&!n.color&&(n.color=F.createBuffer());var r=t.getAttributes();e.hasPositions&&(F.bindBuffer(34962,n.position),F.bufferData(34962,e.positionArray,35048),z.enableAttribute(r.position),F.vertexAttribPointer(r.position,3,5126,!1,0,0)),e.hasNormals&&(F.bindBuffer(34962,n.normal),F.bufferData(34962,e.normalArray,35048),z.enableAttribute(r.normal),F.vertexAttribPointer(r.normal,3,5126,!1,0,0)),e.hasUvs&&(F.bindBuffer(34962,n.uv),F.bufferData(34962,e.uvArray,35048),z.enableAttribute(r.uv),F.vertexAttribPointer(r.uv,2,5126,!1,0,0)),e.hasColors&&(F.bindBuffer(34962,n.color),F.bufferData(34962,e.colorArray,35048),z.enableAttribute(r.color),F.vertexAttribPointer(r.color,3,5126,!1,0,0)),z.disableUnusedAttributes(),F.drawArrays(4,0,e.count),e.count=0};var xe=new zn;this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=xe);var o=i.isMesh&&i.matrixWorld.determinant()<0,s=Te(e,t,r,i);z.setMaterial(r,o);var l=!1;N.geometry===n.id&&N.program===s.id&&N.wireframe===(!0===r.wireframe)||(N.geometry=n.id,N.program=s.id,N.wireframe=!0===r.wireframe,l=!0),(r.morphTargets||r.morphNormals)&&(T.update(i,n,r,s),l=!0);var c=n.index,u=n.attributes.position;if(null===c){if(void 0===u||0===u.count)return}else if(0===c.count)return;var d,h=1;!0===r.wireframe&&(c=S.getWireframeAttribute(n),h=2);var p=E;null!==c&&(d=A.get(c),(p=C).setIndex(d)),l&&(function(e,t,n,r){if(!1===B.isWebGL2&&(e.isInstancedMesh||t.isInstancedBufferGeometry)&&null===w.get("ANGLE_instanced_arrays"))return;z.initAttributes();var i=t.attributes,a=r.getAttributes(),o=n.defaultAttributeValues;for(var s in a){var l=a[s];if(0<=l){var c=i[s];if(void 0!==c){var u,d=c.normalized,h=c.itemSize;if(void 0===(u=A.get(c)))continue;var p,f,m,v=u.buffer,g=u.type,_=u.bytesPerElement;c.isInterleavedBufferAttribute?(p=c.data,f=p.stride,m=c.offset,p&&p.isInstancedInterleavedBuffer?(z.enableAttributeAndDivisor(l,p.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=p.meshPerAttribute*p.count)):z.enableAttribute(l),F.bindBuffer(34962,v),F.vertexAttribPointer(l,h,g,d,f*_,m*_)):(c.isInstancedBufferAttribute?(z.enableAttributeAndDivisor(l,c.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=c.meshPerAttribute*c.count)):z.enableAttribute(l),F.bindBuffer(34962,v),F.vertexAttribPointer(l,h,g,d,0,0))}else if("instanceMatrix"===s){if(void 0===(u=A.get(e.instanceMatrix)))continue;v=u.buffer,g=u.type;z.enableAttributeAndDivisor(l+0,1),z.enableAttributeAndDivisor(l+1,1),z.enableAttributeAndDivisor(l+2,1),z.enableAttributeAndDivisor(l+3,1),F.bindBuffer(34962,v),F.vertexAttribPointer(l+0,4,g,!1,64,0),F.vertexAttribPointer(l+1,4,g,!1,64,16),F.vertexAttribPointer(l+2,4,g,!1,64,32),F.vertexAttribPointer(l+3,4,g,!1,64,48)}else if(void 0!==o){var y=o[s];if(void 0!==y)switch(y.length){case 2:F.vertexAttrib2fv(l,y);break;case 3:F.vertexAttrib3fv(l,y);break;case 4:F.vertexAttrib4fv(l,y);break;default:F.vertexAttrib1fv(l,y)}}}}z.disableUnusedAttributes()}(i,n,r,s),null!==c&&F.bindBuffer(34963,d.buffer));var f,m=null!==c?c.count:u.count,v=n.drawRange.start*h,g=n.drawRange.count*h,_=null!==a?a.start*h:0,y=null!==a?a.count*h:1/0,x=Math.max(v,_),b=Math.min(m,v+g,_+y)-1,M=Math.max(0,b-x+1);0!==M&&(i.isMesh?!0===r.wireframe?(z.setLineWidth(r.wireframeLinewidth*ue()),p.setMode(1)):p.setMode(4):i.isLine?(void 0===(f=r.linewidth)&&(f=1),z.setLineWidth(f*ue()),i.isLineSegments?p.setMode(1):i.isLineLoop?p.setMode(2):p.setMode(3)):i.isPoints?p.setMode(0):i.isSprite&&p.setMode(4),s.beginTimerQuery(F,B.isWebGL2),i.isInstancedMesh?p.renderInstances(n,x,M,i.count):n.isInstancedBufferGeometry?p.renderInstances(n,x,M,n.maxInstancedCount):p.render(x,M),s.endTimerQuery(F,B.isWebGL2))},this.compile=function(n,e){var r=f.get(n,e);r.init(),n.traverse(function(e){e.isLight&&(r.pushLight(e),e.castShadow&&r.pushShadow(e))}),r.setupLights(e);var i={};n.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var t=0;t<e.material.length;t++)e.material[t].uuid in i==!1&&(Se(e.material[t],n,e,r),i[e.material[t].uuid]=!0);else e.material.uuid in i==!1&&(Se(e.material,n,e,r),i[e.material.uuid]=!0)})},this.compileAsync=function(n,e,a){var o=f.get(n,e);o.init(),n.traverse(function(e){e.isLight&&(o.pushLight(e),e.castShadow&&o.pushShadow(e))}),o.setupLights(e);var s=0,r=Promise.resolve({counter:0,timePrev:performance.now()});n.traverse(function(t){var e;t.material&&((e=Array.isArray(t.material)?t.material:[t.material]).forEach(function(e){r=r.then(function(e,t,n,r){Se(n,e,t,o),a&&a((r.counter+1)/s),r.counter++;var i=performance.now();return i-r.timePrev>ds?(r.timePrev=i,new Promise(function(e){setTimeout(function(){e(r)},1)})):r}.bind(null,n,t,e))}),s+=e.length)}),0===s&&a(1)};var be=null;var Me=new ea;function we(e,t,n,r){for(var i=0,a=e.length;i<a;i++){var o=e[i],s=o.object,l=o.geometry,c=void 0===r?o.material:x.get(s,l,o.material,r),u=o.group;if(n.isArrayCamera)if(I=n,pe.enabled&&fe.isAvailable())Ae(s,t,n,l,c,u);else for(var d=n.cameras,h=0,p=d.length;h<p;h++){var f=d[h];s.layers.test(f.layers)&&(z.viewport(W.copy(f.viewport)),O.setupLights(f),Ae(s,t,f,l,c,u))}else I=null,Ae(s,t,n,l,c,u)}}function Ae(e,t,n,r,i,a){var o,s;e.onBeforeRender(k,t,n,r,i,a),O=f.get(t,I||n),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject?(o=Te(n,t,i,e),z.setMaterial(i),N.geometry=null,N.program=null,N.wireframe=!1,s=o,e.render(function(e){k.renderBufferImmediate(e,s)})):k.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(k,t,n,r,i,a),O=f.get(t,I||n)}function Se(e,t,n,r){var i=U.get(e),a=r.state.lights,o=r.state.shadowsArray,s=a.state.version,l=_.getParameters(e,a.state,o,t,ne.numPlanes,ne.numIntersection,n),c=_.getProgramCacheKey(l),u=i.program,d=!0;if(void 0===u)e.addEventListener("dispose",_e);else if(u.cacheKey!==c)ye(e);else if(i.lightsStateVersion!==s)i.lightsStateVersion=s,d=!1;else{if(void 0!==l.shaderID)return;d=!1}d&&(u=_.acquireProgram(l,c),i.program=u,i.uniforms=l.uniforms,i.environment=e.isMeshStandardMaterial?t.environment:null,i.outputEncoding=k.outputEncoding,e.program=u);var h=u.getAttributes();if(e.morphTargets)for(var p=e.numSupportedMorphTargets=0;p<k.maxMorphTargets;p++)0<=h["morphTarget"+p]&&e.numSupportedMorphTargets++;if(e.morphNormals)for(p=e.numSupportedMorphNormals=0;p<k.maxMorphNormals;p++)0<=h["morphNormal"+p]&&e.numSupportedMorphNormals++;var f,m=i.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=ne.numPlanes,i.numIntersection=ne.numIntersection,m.clippingPlanes=ne.uniform),i.fog=t.fog,i.needsLights=(f=e).isMeshLambertMaterial||f.isMeshToonMaterial||f.isMeshPhongMaterial||f.isMeshStandardMaterial||f.isShadowMaterial||f.isShaderMaterial&&!0===f.lights||f.isMeshNodeMaterial,i.lightsStateVersion=s,i.needsLights&&(m.ambientLightColor.value=a.state.ambient,m.lightProbe.value=a.state.probe,m.directionalLights.value=a.state.directional,m.spotLights.value=a.state.spot,m.rectAreaLights.value=a.state.rectArea,m.pointLights.value=a.state.point,m.hemisphereLights.value=a.state.hemi,m.directionalShadowMap.value=a.state.directionalShadowMap,m.directionalShadowMatrix.value=a.state.directionalShadowMatrix,m.spotShadowMap.value=a.state.spotShadowMap,m.spotShadowMatrix.value=a.state.spotShadowMatrix,m.pointShadowMap.value=a.state.pointShadowMap,m.pointShadowMatrix.value=a.state.pointShadowMatrix),e.nodeValue&&(m.nodeValue.value=e.nodeValue),e.nodeRGBArr&&(m.nodeRGB.value=e.nodeRGBArr);var v=i.program.getUniforms(),g=mo.seqWithValue(v.seq,m);i.uniformsList=g}function Te(e,t,n,r){V.resetTextureUnits();var i,a=t.fog,o=n.isMeshStandardMaterial?t.environment:null,s=U.get(n),l=O.state.lights;if(re&&(!ie&&e===j||(i=e===j&&n.id===G,ne.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,s,i))),n.version===s.__version)(void 0===s.program||n.fog&&s.fog!==a||s.environment!==o||s.needsLights&&s.lightsStateVersion!==l.state.version||void 0!==s.numClippingPlanes&&(s.numClippingPlanes!==ne.numPlanes||s.numIntersection!==ne.numIntersection)||s.outputEncoding!==k.outputEncoding)&&Se(n,t,r,O);else if(Se(n,t,r,O),s.__version=n.version,n.nodeRGBArr)for(var c=0;c<n.nodeRGB.length;c++){n.nodeRGB[c].toArray(n.nodeRGBArr,4*c)}var u,d,h,p,f,m,v,g,_,y,x,b,M,w,A,S,T,E,C,P=!1,L=!1,R=!1,D=s.program,N=D.getUniforms(),I=s.uniforms;return z.useProgram(D.program)&&(R=L=P=!0),n.id!==G&&(G=n.id,L=!0),!P&&j===e||(0<D.numMultiviewViews?fe.updateCameraProjectionMatricesUniform(e,N):N.setValue(F,"projectionMatrix",e.projectionMatrix),B.logarithmicDepthBuffer&&N.setValue(F,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),j!==e&&(j=e,R=L=!0),!(n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.isMeshNodeMaterial||n.envMap)||void 0!==(u=N.map.cameraPosition)&&u.setValue(F,ce.setFromMatrixPosition(e.matrixWorld)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isMeshNodeMaterial)&&N.setValue(F,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isMeshNodeMaterial||n.skinning)&&(0<D.numMultiviewViews?fe.updateCameraViewMatricesUniform(e,N):N.setValue(F,"viewMatrix",e.matrixWorldInverse)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshNodeMaterial||n.isMeshPhysicalMaterial||n.isShadowMaterial)&&N.setValue(F,"invViewMatrix",e.matrixWorld)),n.skinning&&(N.setOptional(F,r,"bindMatrix"),N.setOptional(F,r,"bindMatrixInverse"),(d=r.skeleton)&&(h=d.bones,B.floatVertexTextures?(void 0===d.boneTexture&&(p=Math.sqrt(4*h.length),p=Kt.ceilPowerOfTwo(p),p=Math.max(p,4),(f=new Float32Array(p*p*4)).set(d.boneMatrices),m=new qi(f,p,p,dt,st),d.boneMatrices=f,d.boneTexture=m,d.boneTextureSize=p),N.setValue(F,"boneTexture",d.boneTexture,V),N.setValue(F,"boneTextureSize",d.boneTextureSize)):N.setOptional(F,d,"boneMatrices"))),!L&&s.receiveShadow===r.receiveShadow||(s.receiveShadow=r.receiveShadow,N.setValue(F,"receiveShadow",r.receiveShadow)),!n.needsBoundingBox||(v=r.geometry)&&(null===v.boundingBox&&v.computeBoundingBox(),N.setValue(F,"boundingBoxMin",v.boundingBox.min),N.setValue(F,"boundingBoxMax",v.boundingBox.max)),L&&(N.setValue(F,"toneMappingExposure",k.toneMappingExposure),N.setValue(F,"toneMappingWhitePoint",k.toneMappingWhitePoint),k.toneMapping==Ue?(N.setValue(F,"toneMappingBrightness",k.toneMappingBrightness),N.setValue(F,"toneMappingContrast",k.toneMappingContrast),N.setValue(F,"toneMappingMidTones",k.toneMappingMidTones),N.setValue(F,"toneMappingPhysicalScale",k.toneMappingPhysicalScale),N.setValue(F,"toneMappingChromaticAdaptation",k.toneMappingChromaticAdaptation),N.setValue(F,"toneMappingWhiteColor",k.toneMappingWhiteColor),N.setValue(F,"toneMappingColorDifferentiation",k.toneMappingColorDifferentiation),N.setValue(F,"toneMappingExteriorDaylight",k.toneMappingExteriorDaylight)):k.toneMapping==Ve&&(N.setValue(F,"toneMappingResolution",le.set(Y,q)),N.setValue(F,"toneMappingWhiteBalance",k.toneMappingWhiteBalance),N.setValue(F,"toneMappingHighlights",k.toneMappingHighlights),N.setValue(F,"toneMappingMidTones",k.toneMappingMidTones),N.setValue(F,"toneMappingShadows",k.toneMappingShadows),N.setValue(F,"toneMappingSaturation",k.toneMappingSaturation),N.setValue(F,"toneMappingPhysicalScale",k.toneMappingPhysicalScale),N.setValue(F,"toneMappingAperture",k.toneMappingAperture),N.setValue(F,"toneMappingShutter",k.toneMappingShutter),N.setValue(F,"toneMappingISO",k.toneMappingISO),N.setValue(F,"toneMappingVignetting",k.toneMappingVignetting)),s.needsLights&&(C=R,(E=I).ambientLightColor.needsUpdate=C,E.lightProbe.needsUpdate=C,E.directionalLights.needsUpdate=C,E.pointLights.needsUpdate=C,E.spotLights.needsUpdate=C,E.rectAreaLights.needsUpdate=C,E.hemisphereLights.needsUpdate=C),a&&n.fog&&(T=a,(S=I).fogColor.value.copy(T.color),T.isFog?(S.fogNear.value=T.near,S.fogFar.value=T.far):T.isFogExp2&&(S.fogDensity.value=T.density)),n.ssrParams&&(A=n,(w=I).invProjectionMatrix.value=A.ssrParams.invProjectionMatrix,w.ssrSourceBuffer.value=A.ssrParams.sourceBuffer.texture,w.ssrDepthBuffer.value=A.ssrParams.depthBuffer.texture,w.ssrBackfaceDepthBuffer.value=A.ssrParams.backfaceDepthBuffer.texture,w.ssrResolution.value=new Jt(A.ssrParams.sourceBuffer.width,A.ssrParams.sourceBuffer.height),w.ssrStride.value=A.ssrParams.stride,w.ssrThickness.value=A.ssrParams.thickness,w.ssrMaxDistance.value=A.ssrParams.maxDistance,w.ssrJitter.value=A.ssrParams.jitter),n.isMeshBasicMaterial?Ee(I,n):n.isMeshLambertMaterial?(Ee(I,n),b=I,(M=n).emissiveMap&&(b.emissiveMap.value=M.emissiveMap)):n.isMeshToonMaterial?(Ee(I,n),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Le&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Le&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(I,n)):n.isMeshPhongMaterial?(Ee(I,n),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Le&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Le&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(I,n)):n.isMeshStandardMaterial?(Ee(I,n,o),(n.isMeshPhysicalMaterial?function(e,t,n){Ce(e,t,n),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen);t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===Le&&e.clearcoatNormalScale.value.negate());e.transparency.value=t.transparency}:Ce)(I,n,o)):n.isMeshMatcapMaterial?(Ee(I,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Le&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Le&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(I,n)):n.isMeshDepthMaterial?(Ee(I,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.slopeScaledBias.value=t.slopeScaledBias}(I,n)):n.isMeshDistanceMaterial?(Ee(I,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance,e.slopeScaledBias.value=t.slopeScaledBias}(I,n)):n.isMeshNormalMaterial?(Ee(I,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Le&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Le&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(I,n)):n.isLineBasicMaterial?(x=n,(y=I).diffuse.value.copy(x.color),y.opacity.value=x.opacity,n.isLineDashedMaterial&&(_=n,(g=I).dashSize.value=_.dashSize,g.totalSize.value=_.dashSize+_.gapSize,g.scale.value=_.scale)):n.isPointsMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*Z,e.scale.value=.5*q,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(I,n):n.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(I,n):n.isShadowMaterial?(I.color.value.copy(n.color),I.opacity.value=n.opacity):n.isMeshMaskMaterial?(Ee(I,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);t.cameraNearFar&&(e.cameraNearFar.value=t.cameraNearFar);e.depthTexture.value=t.depthTexture,t.textureMatrix&&(e.textureMatrix.value=t.textureMatrix)}(I,n)):n.isMeshNodeMaterial?function(e,t,n,r){var i=n.envMap||r;i&&(e.envMap.value=i,e.flipEnvMap.value=i.isCubeTexture?-1:1,e.reflectivity.value=n.reflectivity,e.refractionRatio.value=n.refractionRatio,e.maxMipLevel.value=U.get(i).__maxMipLevel);for(var a in n.nodeTextures)t.setValue(F,a,n.nodeTextures[a],V);n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias)}(I,N,n,o):n.isMeshLineMaterial&&function(e,t){e.lineWidth.value=t.lineWidth,e.sizeAttenuation.value=t.sizeAttenuation,e.color.value=t.color,e.opacity.value=t.opacity,e.useMap.value=t.useMap,t.map&&(e.map.value=t.map);e.useAlphaMap.value=t.useAlphaMap,t.alphaMap&&(e.alphaMap.value=t.alphaMap);e.resolution.value.set(Y,q),e.visibility.value=t.visibility,e.alphaTest.value=t.alphaTest,e.repeat.value=t.repeat}(I,n),void 0!==I.ltc_1&&(I.ltc_1.value=Ji.LTC_1),void 0!==I.ltc_2&&(I.ltc_2.value=Ji.LTC_2),mo.upload(F,s.uniformsList,I,V),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(mo.upload(F,s.uniformsList,I,V),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&N.setValue(F,"center",r.center),n.isMeshNodeMaterial&&(oe.getInverse(r.matrixWorld),N.setValue(F,"invModelMatrix",oe),N.setValue(F,"viewWidthHeight",le.set(W.z-W.x,W.w-W.y)),n.nodeTexCoordObject.forEach(function(e,t){(null===e?oe:se.getInverse(e.matrixWorld)).toArray(n.nodeTexCoordObjectArr,16*t)}),n.nodeTexCoordObjectArr&&N.setValue(F,"nodeTexCoordObjectMatrices",n.nodeTexCoordObjectArr)),0<D.numMultiviewViews?fe.updateObjectMatricesUniforms(r,e,N):(N.setValue(F,"modelViewMatrix",r.modelViewMatrix),N.setValue(F,"normalMatrix",r.normalMatrix)),N.setValue(F,"modelMatrix",r.matrixWorld),D}function Ee(e,t,n){e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap);var r,i,a=t.envMap||n;a&&(e.envMap.value=a,e.flipEnvMap.value=a.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=U.get(a).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),t.aoMap?i=t.aoMap:t.lightMap&&(i=t.lightMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uv2Transform.value.copy(i.matrix))}function Ce(e,t,n){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Le&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Le&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),(t.envMap||n)&&(e.envMapIntensity.value=t.envMapIntensity)}Me.setAnimationLoop(function(e){pe.isPresenting||be&&be(e)}),"undefined"!=typeof window&&Me.setContext(window),this.setAnimationLoop=function(e){be=e,pe.setAnimationLoop(e),Me.start()},this.render=function(e,t){var n,r,i,a,o,s;void 0!==arguments[2]&&(console.warn("v3d.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("v3d.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),t&&t.isCamera?b||(N.geometry=null,N.program=null,N.wireframe=!1,G=-1,!(j=null)===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),pe.enabled&&pe.isPresenting&&(t=pe.getCamera(t)),(O=f.get(e,t)).init(),e.onBeforeRender(k,e,t,n||R),ae.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),te.setFromProjectionMatrix(ae),ie=this.localClippingEnabled,re=ne.init(this.clippingPlanes,ie,t),(m=p.get(e,t)).init(),function e(t,n,r,i){t.isAnnotationControl&&t.update(n);if(t.visible){var a=t.layers.test(n.layers);if(a)if(t.isGroup)r=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(n);else if(t.isLight)O.pushLight(t),t.castShadow&&O.pushShadow(t);else if(t.isSprite){t.frustumCulled&&!te.intersectsSprite(t)||(i&&ce.setFromMatrixPosition(t.matrixWorld).applyMatrix4(ae),o=v.update(t),s=t.material,m.push(t,o,s,r,ce.z,null))}else if(t.isImmediateRenderObject)i&&ce.setFromMatrixPosition(t.matrixWorld).applyMatrix4(ae),m.push(t,null,t.material,r,ce.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||te.intersectsObject(t))){i&&ce.setFromMatrixPosition(t.matrixWorld).applyMatrix4(ae);var o=v.update(t),s=t.material;if(Array.isArray(s))for(var l=o.groups,c=0,u=l.length;c<u;c++){var d=l[c],h=s[d.materialIndex];h&&h.visible&&m.push(t,o,h,r,ce.z,d)}else s.visible&&m.push(t,o,s,r,ce.z,null)}}else var a=!1;if(t.disableChildRendering)return;var p=t.children;for(var c=0,u=p.length;c<u;c++){var f=p[c];!a&&f.isMesh&&f.isMaterialGeneratedMesh||e(f,n,r,i)}}(e,t,0,k.sortObjects),!0===k.sortObjects&&m.sort(Q,K),re&&ne.beginShadows(),i=O.state.shadowsArray,me.render(i,e,t),O.setupLights(t),re&&ne.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),pe.enabled&&fe.isAvailable()&&fe.attachCamera(t),g.render(m,e,t,r),a=m.opaque,o=m.transparent,e.overrideMaterial?(s=e.overrideMaterial,a.length&&we(a,e,t,s),o.length&&we(o,e,t,s)):(a.length&&we(a,e,t),o.length&&we(o,e,t)),e.onAfterRender(k,e,t),null!==R&&(V.updateRenderTargetMipmap(R),V.updateMultisampleRenderTarget(R)),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1),pe.enabled&&fe.isAvailable()&&fe.detachCamera(t),O=m=null):console.error("v3d.WebGLRenderer.render: camera is not an instance of v3d.Camera.")},this.setFramebuffer=function(e){M!==e&&null===R&&F.bindFramebuffer(36160,e),M=e},this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return R},this.setRenderTarget=function(e,t,n){P=t,L=n,(R=e)&&void 0===U.get(e).__webglFramebuffer&&V.setupRenderTarget(e);var r,i,a=M,o=!1;H=e?(r=U.get(e).__webglFramebuffer,e.isWebGLCubeRenderTarget?(a=r[t||0],o=!0):a=e.isWebGLMultisampleRenderTarget?U.get(e).__webglMultisampledFramebuffer:r,W.copy(e.viewport),X.copy(e.scissor),e.scissorTest):(W.copy(J).multiplyScalar(Z).floor(),X.copy($).multiplyScalar(Z).floor(),ee),D!==a&&(F.bindFramebuffer(36160,a),D=a),z.viewport(W),z.scissor(X),z.setScissorTest(H),o&&(i=U.get(e.texture),F.framebufferTexture2D(36160,36064,34069+(t||0),i.__webglTexture,n||0))},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(e&&e.isWebGLRenderTarget){var s=U.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){var l=!1;s!==D&&(F.bindFramebuffer(36160,s),l=!0);try{var c=e.texture,u=c.format,d=c.type;if(u!==dt&&y.convert(u)!==F.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(d===it||y.convert(d)===F.getParameter(35738)||d===st&&(B.isWebGL2||w.get("OES_texture_float")||w.get("WEBGL_color_buffer_float"))||d===lt&&(B.isWebGL2?w.get("EXT_color_buffer_float"):w.get("EXT_color_buffer_half_float"))))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===F.checkFramebufferStatus(36160)?0<=t&&t<=e.width-r&&0<=n&&n<=e.height-i&&F.readPixels(t,n,r,i,y.convert(u),y.convert(d),a):console.error("v3d.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{l&&F.bindFramebuffer(36160,D)}}}else console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not v3d.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r),o=y.convert(t.format);V.setTexture2D(t,0),F.copyTexImage2D(3553,n,o,e.x,e.y,i,a,0),z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r){var i=t.image.width,a=t.image.height,o=y.convert(n.format),s=y.convert(n.type);V.setTexture2D(n,0),t.isDataTexture?F.texSubImage2D(3553,r||0,e.x,e.y,i,a,o,s,t.image.data):F.texSubImage2D(3553,r||0,e.x,e.y,o,s,t.image),z.unbindTexture()},this.initTexture=function(e){V.setTexture2D(e,0),z.unbindTexture()},"undefined"!=typeof __v3d_DEVTOOLS__&&__v3d_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.updateGeometry=function(e){return v.update(e)},this.renderObject=Ae,this.setCanvas=function(e){r=e,this.domElement=e}}function ps(e,t){this.name="",this.color=new Lr(e),this.density=void 0!==t?t:25e-5}function fs(e,t,n){this.name="",this.color=new Lr(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function ms(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Gt,this.updateRange={offset:0,count:-1},this.version=0}Object.assign(ps.prototype,{isFogExp2:!0,clone:function(){return new ps(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(fs.prototype,{isFog:!0,clone:function(){return new fs(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(ms.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(ms.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(var r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}});var vs,gs=new un;function _s(e,t,n,r){this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}function ys(e){Br.call(this),this.type="SpriteMaterial",this.color=new Lr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}Object.defineProperties(_s.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(_s.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(var t=0,n=this.data.count;t<n;t++)gs.x=this.getX(t),gs.y=this.getY(t),gs.z=this.getZ(t),gs.applyMatrix4(e),this.setXYZ(t,gs.x,gs.y,gs.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this},setXYZ:function(e,t,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this},setXYZW:function(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}}),((ys.prototype=Object.create(Br.prototype)).constructor=ys).prototype.isSpriteMaterial=!0,ys.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};var xs=new un,bs=new un,Ms=new un,ws=new Jt,As=new Jt,Ss=new _n,Ts=new un,Es=new un,Cs=new un,Ps=new Jt,Ls=new Jt,Rs=new Jt;function Ds(e){var t;Bn.call(this),this.type="Sprite",void 0===vs&&(vs=new ui,t=new ms(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5),vs.setIndex([0,1,2,0,2,3]),vs.setAttribute("position",new _s(t,3,0,!1)),vs.setAttribute("uv",new _s(t,2,3,!1))),this.geometry=vs,this.material=void 0!==e?e:new ys,this.center=new Jt(.5,.5)}function Ns(e,t,n,r,i,a){ws.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(As.x=a*ws.x-i*ws.y,As.y=i*ws.x+a*ws.y):As.copy(ws),e.copy(t),e.x+=As.x,e.y+=As.y,e.applyMatrix4(Ss)}Ds.prototype=Object.assign(Object.create(Bn.prototype),{constructor:Ds,isSprite:!0,raycast:function(e,t){var n,r,i,a,o;null!==e.camera?(bs.setFromMatrixScale(this.matrixWorld),Ss.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ms.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&bs.multiplyScalar(-Ms.z),0!==(n=this.material.rotation)&&(i=Math.cos(n),r=Math.sin(n)),a=this.center,Ns(Ts.set(-.5,-.5,0),Ms,a,bs,r,i),Ns(Es.set(.5,-.5,0),Ms,a,bs,r,i),Ns(Cs.set(.5,.5,0),Ms,a,bs,r,i),Ps.set(0,0),Ls.set(1,0),Rs.set(1,1),null===e.ray.intersectTriangle(Ts,Es,Cs,!1,xs)&&(Ns(Es.set(-.5,.5,0),Ms,a,bs,r,i),Ls.set(0,1),null===e.ray.intersectTriangle(Ts,Cs,Es,!1,xs))||((o=e.ray.origin.distanceTo(xs))<e.near||o>e.far||t.push({distance:o,point:xs.clone(),uv:Tr.getUV(xs,Ts,Es,Cs,Ps,Ls,Rs,new Jt),face:null,object:this}))):console.error('v3d.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.')},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return Bn.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var Is=new un,Os=new un;function Fs(){Bn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Bs(e,t){e&&e.isGeometry&&console.error("v3d.SkinnedMesh no longer supports v3d.Geometry. Use v3d.BufferGeometry instead."),Ci.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new _n,this.bindMatrixInverse=new _n,this.normalizeSkinWeights()}Fs.prototype=Object.assign(Object.create(Bn.prototype),{constructor:Fs,isLOD:!0,copy:function(e){Bn.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,r=t.length;n<r;n++){var i=t[n];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var n=this.levels,r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,object:e}),this.add(e),this},getObjectForDistance:function(e){var t=this.levels;if(0<t.length){for(var n=1,r=t.length;n<r&&!(e<t[n].distance);n++);return t[n-1].object}return null},raycast:function(e,t){var n;0<this.levels.length&&(Is.setFromMatrixPosition(this.matrixWorld),n=e.ray.origin.distanceTo(Is),this.getObjectForDistance(n).raycast(e,t))},update:function(e){var t=this.levels;if(1<t.length){Is.setFromMatrixPosition(e.matrixWorld),Os.setFromMatrixPosition(this.matrixWorld);var n=Is.distanceTo(Os);t[0].object.visible=!0;for(var r=1,i=t.length;r<i&&n>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(;r<i;r++)t[r].object.visible=!1}},toJSON:function(e){var t=Bn.prototype.toJSON.call(this,e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];for(var n=this.levels,r=0,i=n.length;r<i;r++){var a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance})}return t}}),Bs.prototype=Object.assign(Object.create(Ci.prototype),{constructor:Bs,isSkinnedMesh:!0,bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var e=new rn,t=this.geometry.attributes.skinWeight,n=0,r=t.count;n<r;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);var i=1/e.manhattanLength();i!=1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){Ci.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("v3d.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var zs=new _n,Us=new _n;function Vs(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),this.frame=-1,void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("v3d.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new _n)}}function ks(){Bn.call(this),this.type="Bone"}Object.assign(Vs.prototype,{calculateInverses:function(){this.boneInverses=[];for(var e=0,t=this.bones.length;e<t;e++){var n=new _n;this.bones[e]&&n.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(n)}},pose:function(){for(var e,t=0,n=this.bones.length;t<n;t++)(e=this.bones[t])&&e.matrixWorld.getInverse(this.boneInverses[t]);for(t=0,n=this.bones.length;t<n;t++)(e=this.bones[t])&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){for(var e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture,i=0,a=e.length;i<a;i++){var o=e[i]?e[i].matrixWorld:Us;zs.multiplyMatrices(o,t[i]),zs.toArray(n,16*i)}void 0!==r&&(r.needsUpdate=!0)},clone:function(){return new Vs(this.bones,this.boneInverses)},getBoneByName:function(e){for(var t=0,n=this.bones.length;t<n;t++){var r=this.bones[t];if(r.name===e)return r}}}),ks.prototype=Object.assign(Object.create(Bn.prototype),{constructor:ks,isBone:!0});var Gs=new _n,js=new _n,Ws=[],Xs=new Ci;function Hs(e,t,n){Ci.call(this,e,t),this.instanceMatrix=new Vr(new Float32Array(16*n),16),this.count=n,this.frustumCulled=!1}function Ys(e){Br.call(this),this.type="LineBasicMaterial",this.color=new Lr(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}Hs.prototype=Object.assign(Object.create(Ci.prototype),{constructor:Hs,isInstancedMesh:!0,getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,16*e)},raycast:function(e,t){var n=this.matrixWorld,r=this.count;if(Xs.geometry=this.geometry,Xs.material=this.material,void 0!==Xs.material)for(var i=0;i<r;i++)this.getMatrixAt(i,Gs),js.multiplyMatrices(n,Gs),Xs.matrixWorld=js,Xs.raycast(e,Ws),0<Ws.length&&(Ws[0].instanceId=i,Ws[0].object=this,t.push(Ws[0]),Ws.length=0)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,16*e)},updateMorphTargets:function(){}}),((Ys.prototype=Object.create(Br.prototype)).constructor=Ys).prototype.isLineBasicMaterial=!0,Ys.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this};var qs=new un,Zs=new un,Qs=new _n,Ks=new dr,Js=new rr;function $s(e,t,n){1===n&&console.error("v3d.Line: parameter v3d.LinePieces no longer supported. Use v3d.LineSegments instead."),Bn.call(this),this.type="Line",this.geometry=void 0!==e?e:new ui,this.material=void 0!==t?t:new Ys}$s.prototype=Object.assign(Object.create(Bn.prototype),{constructor:$s,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[0],r=1,i=t.count;r<i;r++)qs.fromBufferAttribute(t,r-1),Zs.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=qs.distanceTo(Zs);e.setAttribute("lineDistance",new qr(n,1))}else console.warn("v3d.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry){var a=e.vertices;(n=e.lineDistances)[0]=0;for(r=1,i=a.length;r<i;r++)n[r]=n[r-1],n[r]+=a[r-1].distanceTo(a[r])}return this},raycast:function(e,t){var n=e.linePrecision,r=this.geometry,i=this.matrixWorld;if(null===r.boundingSphere&&r.computeBoundingSphere(),Js.copy(r.boundingSphere),Js.applyMatrix4(i),Js.radius+=n,!1!==e.ray.intersectsSphere(Js)){Qs.getInverse(i),Ks.copy(e.ray).applyMatrix4(Qs);var a=n/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,s=new un,l=new un,c=new un,u=new un,d=this&&this.isLineSegments?2:1;if(r.isBufferGeometry){var h=r.index,p=r.attributes.position.array;if(null!==h)for(var f=h.array,m=0,v=f.length-1;m<v;m+=d){var g=f[m],_=f[m+1];s.fromArray(p,3*g),l.fromArray(p,3*_),o<Ks.distanceSqToSegment(s,l,u,c)||(u.applyMatrix4(this.matrixWorld),(y=e.ray.origin.distanceTo(u))<e.near||y>e.far||t.push({distance:y,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}else for(m=0,v=p.length/3-1;m<v;m+=d){s.fromArray(p,3*m),l.fromArray(p,3*m+3),o<Ks.distanceSqToSegment(s,l,u,c)||(u.applyMatrix4(this.matrixWorld),(y=e.ray.origin.distanceTo(u))<e.near||y>e.far||t.push({distance:y,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}}else if(r.isGeometry)for(var y,x=r.vertices,b=x.length,m=0;m<b-1;m+=d){o<Ks.distanceSqToSegment(x[m],x[m+1],u,c)||(u.applyMatrix4(this.matrixWorld),(y=e.ray.origin.distanceTo(u))<e.near||y>e.far||t.push({distance:y,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var el=new un,tl=new un;function nl(e,t){$s.call(this,e,t),this.type="LineSegments"}function rl(e,t){$s.call(this,e,t),this.type="LineLoop"}function il(e){Br.call(this),this.type="PointsMaterial",this.color=new Lr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}nl.prototype=Object.assign(Object.create($s.prototype),{constructor:nl,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[],r=0,i=t.count;r<i;r+=2)el.fromBufferAttribute(t,r),tl.fromBufferAttribute(t,r+1),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+el.distanceTo(tl);e.setAttribute("lineDistance",new qr(n,1))}else console.warn("v3d.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry)for(var a=e.vertices,n=e.lineDistances,r=0,i=a.length;r<i;r+=2)el.copy(a[r]),tl.copy(a[r+1]),n[r]=0===r?0:n[r-1],n[r+1]=n[r]+el.distanceTo(tl);return this}}),rl.prototype=Object.assign(Object.create($s.prototype),{constructor:rl,isLineLoop:!0}),((il.prototype=Object.create(Br.prototype)).constructor=il).prototype.isPointsMaterial=!0,il.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};var al=new _n,ol=new dr,sl=new rr,ll=new un;function cl(e,t){Bn.call(this),this.type="Points",this.geometry=void 0!==e?e:new ui,this.material=void 0!==t?t:new il,this.updateMorphTargets()}function ul(e,t,n,r,i,a,o){var s=ol.distanceSqToPoint(e);if(s<n){var l=new un;ol.closestPointToPoint(e,l),l.applyMatrix4(r);var c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:o})}}function dl(e,t,n,r,i,a,o,s,l){nn.call(this,e,t,n,r,i,a,o,s,l),this.format=void 0!==o?o:ut,this.minFilter=void 0!==a?a:tt,this.magFilter=void 0!==i?i:tt,this.generateMipmaps=!1}function hl(e,t,n,r,i,a,o,s,l,c,u,d){nn.call(this,null,a,o,s,l,c,r,i,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function pl(e,t,n,r,i,a,o,s,l){nn.call(this,e,t,n,r,i,a,o,s,l),this.needsUpdate=!0}function fl(e,t,n,r,i,a,o,s,l,c){if((c=void 0!==c?c:ht)!==ht&&c!==pt)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===ht&&(n=at),void 0===n&&c===pt&&(n=ct),nn.call(this,null,r,i,a,o,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:Je,this.minFilter=void 0!==s?s:Je,this.flipY=!1,this.generateMipmaps=!1}function ml(e){ui.call(this),this.type="WireframeGeometry";var t,n,r,i,a,o,s=[],l=[0,0],c={},u=["a","b","c"];if(e&&e.isGeometry){for(var d=e.faces,h=0,p=d.length;h<p;h++)for(var f=d[h],m=0;m<3;m++)i=f[u[m]],a=f[u[(m+1)%3]],l[0]=Math.min(i,a),l[1]=Math.max(i,a),void 0===c[o=l[0]+","+l[1]]&&(c[o]={index1:l[0],index2:l[1]});for(o in c)r=c[o],M=e.vertices[r.index1],s.push(M.x,M.y,M.z),M=e.vertices[r.index2],s.push(M.x,M.y,M.z)}else if(e&&e.isBufferGeometry){var v,g,_,y,x,b,M=new un;if(null!==e.index){for(v=e.attributes.position,g=e.index,0===(_=e.groups).length&&(_=[{start:0,count:g.count,materialIndex:0}]),t=0,n=_.length;t<n;++t)for(p=(h=(y=_[t]).start)+y.count;h<p;h+=3)for(m=0;m<3;m++)i=g.getX(h+m),a=g.getX(h+(m+1)%3),l[0]=Math.min(i,a),l[1]=Math.max(i,a),void 0===c[o=l[0]+","+l[1]]&&(c[o]={index1:l[0],index2:l[1]});for(o in c)r=c[o],M.fromBufferAttribute(v,r.index1),s.push(M.x,M.y,M.z),M.fromBufferAttribute(v,r.index2),s.push(M.x,M.y,M.z)}else for(h=0,p=(v=e.attributes.position).count/3;h<p;h++)for(m=0;m<3;m++)x=3*h+m,M.fromBufferAttribute(v,x),s.push(M.x,M.y,M.z),b=3*h+(m+1)%3,M.fromBufferAttribute(v,b),s.push(M.x,M.y,M.z)}this.setAttribute("position",new qr(s,3))}function vl(e,t,n){Oi.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:n},this.fromBufferGeometry(new gl(e,t,n)),this.mergeVertices()}function gl(e,t,n){ui.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:t,stacks:n};var r=[],i=[],a=[],o=[],s=new un,l=new un,c=new un,u=new un,d=new un;e.length<3&&console.error("v3d.ParametricGeometry: Function must now modify a Vector3 as third parameter.");for(var h=t+1,p=0;p<=n;p++)for(var f=p/n,m=0;m<=t;m++){var v=m/t;e(v,f,l),i.push(l.x,l.y,l.z),0<=v-1e-5?(e(v-1e-5,f,c),u.subVectors(l,c)):(e(1e-5+v,f,c),u.subVectors(c,l)),0<=f-1e-5?(e(v,f-1e-5,c),d.subVectors(l,c)):(e(v,1e-5+f,c),d.subVectors(c,l)),s.crossVectors(u,d).normalize(),a.push(s.x,s.y,s.z),o.push(v,f)}for(p=0;p<n;p++)for(m=0;m<t;m++){var g=p*h+m,_=p*h+m+1,y=(p+1)*h+m+1,x=(p+1)*h+m;r.push(g,_,x),r.push(_,y,x)}this.setIndex(r),this.setAttribute("position",new qr(i,3)),this.setAttribute("normal",new qr(a,3)),this.setAttribute("uv",new qr(o,2))}function _l(e,t,n,r){Oi.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r},this.fromBufferGeometry(new yl(e,t,n,r)),this.mergeVertices()}function yl(r,a,e,t){ui.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:r,indices:a,radius:e,detail:t},e=e||1;var u=[],d=[];function h(e){u.push(e.x,e.y,e.z)}function o(e,t){var n=3*e;t.x=r[0+n],t.y=r[1+n],t.z=r[2+n]}function p(e,t,n,r){r<0&&1===e.x&&(d[t]=e.x-1),0===n.x&&0===n.z&&(d[t]=r/2/Math.PI+.5)}function f(e){return Math.atan2(e.z,-e.x)}!function(e){for(var t=new un,n=new un,r=new un,i=0;i<a.length;i+=3)o(a[i+0],t),o(a[i+1],n),o(a[i+2],r),function(e,t,n,r){var i,a,o=Math.pow(2,r),s=[];for(i=0;i<=o;i++){s[i]=[];var l=e.clone().lerp(n,i/o),c=t.clone().lerp(n,i/o),u=o-i;for(a=0;a<=u;a++)s[i][a]=0===a&&i===o?l:l.clone().lerp(c,a/u)}for(i=0;i<o;i++)for(a=0;a<2*(o-i)-1;a++){var d=Math.floor(a/2);a%2==0?(h(s[i][d+1]),h(s[i+1][d]),h(s[i][d])):(h(s[i][d+1]),h(s[i+1][d+1]),h(s[i+1][d]))}}(t,n,r,e)}(t=t||0),function(e){for(var t=new un,n=0;n<u.length;n+=3)t.x=u[n+0],t.y=u[n+1],t.z=u[n+2],t.normalize().multiplyScalar(e),u[n+0]=t.x,u[n+1]=t.y,u[n+2]=t.z}(e),function(){for(var e=new un,t=0;t<u.length;t+=3){e.x=u[t+0],e.y=u[t+1],e.z=u[t+2];var n=f(e)/2/Math.PI+.5,r=function(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(e)/Math.PI+.5;d.push(n,1-r)}(function(){for(var e=new un,t=new un,n=new un,r=new un,i=new Jt,a=new Jt,o=new Jt,s=0,l=0;s<u.length;s+=9,l+=6){e.set(u[s+0],u[s+1],u[s+2]),t.set(u[s+3],u[s+4],u[s+5]),n.set(u[s+6],u[s+7],u[s+8]),i.set(d[l+0],d[l+1]),a.set(d[l+2],d[l+3]),o.set(d[l+4],d[l+5]),r.copy(e).add(t).add(n).divideScalar(3);var c=f(r);p(i,l+0,e,c),p(a,l+2,t,c),p(o,l+4,n,c)}})(),function(){for(var e=0;e<d.length;e+=6){var t=d[e+0],n=d[e+2],r=d[e+4],i=Math.max(t,n,r),a=Math.min(t,n,r);.9<i&&a<.1&&(t<.2&&(d[e+0]+=1),n<.2&&(d[e+2]+=1),r<.2&&(d[e+4]+=1))}}()}(),this.setAttribute("position",new qr(u,3)),this.setAttribute("normal",new qr(u.slice(),3)),this.setAttribute("uv",new qr(d,2)),0===t?this.computeVertexNormals():this.normalizeNormals()}function xl(e,t){Oi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new bl(e,t)),this.mergeVertices()}function bl(e,t){yl.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Ml(e,t){Oi.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new wl(e,t)),this.mergeVertices()}function wl(e,t){yl.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Al(e,t){Oi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Sl(e,t)),this.mergeVertices()}function Sl(e,t){var n=(1+Math.sqrt(5))/2;yl.call(this,[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Tl(e,t){Oi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new El(e,t)),this.mergeVertices()}function El(e,t){var n=(1+Math.sqrt(5))/2,r=1/n;yl.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Cl(e,t,n,r,i,a){Oi.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("v3d.TubeGeometry: taper has been removed.");var o=new Pl(e,t,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Pl(o,s,l,c,e){ui.call(this),this.type="TubeBufferGeometry",this.parameters={path:o,tubularSegments:s,radius:l,radialSegments:c,closed:e},s=s||64,l=l||1,c=c||8,e=e||!1;var u=o.computeFrenetFrames(s,e);this.tangents=u.tangents,this.normals=u.normals,this.binormals=u.binormals;var i,d,h=new un,p=new un,t=new Jt,f=new un,m=[],v=[],n=[],a=[];function r(e){f=o.getPointAt(e/s,f);var t=u.normals[e],n=u.binormals[e];for(d=0;d<=c;d++){var r=d/c*Math.PI*2,i=Math.sin(r),a=-Math.cos(r);p.x=a*t.x+i*n.x,p.y=a*t.y+i*n.y,p.z=a*t.z+i*n.z,p.normalize(),v.push(p.x,p.y,p.z),h.x=f.x+l*p.x,h.y=f.y+l*p.y,h.z=f.z+l*p.z,m.push(h.x,h.y,h.z)}}!function(){for(i=0;i<s;i++)r(i);r(!1===e?s:0),function(){for(i=0;i<=s;i++)for(d=0;d<=c;d++)t.x=i/s,t.y=d/c,n.push(t.x,t.y)}(),function(){for(d=1;d<=s;d++)for(i=1;i<=c;i++){var e=(c+1)*(d-1)+(i-1),t=(c+1)*d+(i-1),n=(c+1)*d+i,r=(c+1)*(d-1)+i;a.push(e,t,r),a.push(t,n,r)}}()}(),this.setIndex(a),this.setAttribute("position",new qr(m,3)),this.setAttribute("normal",new qr(v,3)),this.setAttribute("uv",new qr(n,2))}function Ll(e,t,n,r,i,a,o){Oi.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},void 0!==o&&console.warn("v3d.TorusKnotGeometry: heightScale has been deprecated. Use .scale(x, y, z) instead."),this.fromBufferGeometry(new Rl(e,t,n,r,i,a)),this.mergeVertices()}function Rl(e,t,n,r,i,a){ui.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},e=e||1,t=t||.4,n=Math.floor(n)||64,r=Math.floor(r)||8,i=i||2,a=a||3;for(var o,s=[],l=[],c=[],u=[],d=new un,h=new un,p=new un,f=new un,m=new un,v=new un,g=new un,_=0;_<=n;++_){var y=_/n*i*Math.PI*2;for(E(y,i,a,e,p),E(.01+y,i,a,e,f),v.subVectors(f,p),g.addVectors(f,p),m.crossVectors(v,g),g.crossVectors(m,v),m.normalize(),g.normalize(),o=0;o<=r;++o){var x=o/r*Math.PI*2,b=-t*Math.cos(x),M=t*Math.sin(x);d.x=p.x+(b*g.x+M*m.x),d.y=p.y+(b*g.y+M*m.y),d.z=p.z+(b*g.z+M*m.z),l.push(d.x,d.y,d.z),h.subVectors(d,p).normalize(),c.push(h.x,h.y,h.z),u.push(_/n),u.push(o/r)}}for(o=1;o<=n;o++)for(_=1;_<=r;_++){var w=(r+1)*(o-1)+(_-1),A=(r+1)*o+(_-1),S=(r+1)*o+_,T=(r+1)*(o-1)+_;s.push(w,A,T),s.push(A,S,T)}function E(e,t,n,r,i){var a=Math.cos(e),o=Math.sin(e),s=n/t*e,l=Math.cos(s);i.x=r*(2+l)*.5*a,i.y=r*(2+l)*o*.5,i.z=r*Math.sin(s)*.5}this.setIndex(s),this.setAttribute("position",new qr(l,3)),this.setAttribute("normal",new qr(c,3)),this.setAttribute("uv",new qr(u,2))}function Dl(e,t,n,r,i){Oi.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},this.fromBufferGeometry(new Nl(e,t,n,r,i)),this.mergeVertices()}function Nl(e,t,n,r,i){ui.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},e=e||1,t=t||.4,n=Math.floor(n)||8,r=Math.floor(r)||6,i=i||2*Math.PI;for(var a,o=[],s=[],l=[],c=[],u=new un,d=new un,h=new un,p=0;p<=n;p++)for(a=0;a<=r;a++){var f=a/r*i,m=p/n*Math.PI*2;d.x=(e+t*Math.cos(m))*Math.cos(f),d.y=(e+t*Math.cos(m))*Math.sin(f),d.z=t*Math.sin(m),s.push(d.x,d.y,d.z),u.x=e*Math.cos(f),u.y=e*Math.sin(f),h.subVectors(d,u).normalize(),l.push(h.x,h.y,h.z),c.push(a/r),c.push(p/n)}for(p=1;p<=n;p++)for(a=1;a<=r;a++){var v=(r+1)*p+a-1,g=(r+1)*(p-1)+a-1,_=(r+1)*(p-1)+a,y=(r+1)*p+a;o.push(v,g,y),o.push(g,_,y)}this.setIndex(o),this.setAttribute("position",new qr(s,3)),this.setAttribute("normal",new qr(l,3)),this.setAttribute("uv",new qr(c,2))}cl.prototype=Object.assign(Object.create(Bn.prototype),{constructor:cl,isPoints:!0,raycast:function(e,t){var n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),sl.copy(n.boundingSphere),sl.applyMatrix4(r),sl.radius+=i,!1!==e.ray.intersectsSphere(sl)){al.getInverse(r),ol.copy(e.ray).applyMatrix4(al);var a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a;if(n.isBufferGeometry){var s=n.index,l=n.attributes.position.array;if(null!==s)for(var c=s.array,u=0,d=c.length;u<d;u++){var h=c[u];ll.fromArray(l,3*h),ul(ll,h,o,r,e,t,this)}else for(var u=0,p=l.length/3;u<p;u++)ll.fromArray(l,3*u),ul(ll,u,o,r,e,t,this)}else for(var f=n.vertices,u=0,p=f.length;u<p;u++)ul(f[u],u,o,r,e,t,this)}},updateMorphTargets:function(){var e,t,n,r=this.geometry;if(r.isBufferGeometry){var i=r.morphAttributes,a=Object.keys(i);if(0<a.length){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e<t;e++)n=o[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}else{var s=r.morphTargets;void 0!==s&&0<s.length&&console.error("v3d.Points.updateMorphTargets() does not support v3d.Geometry. Use v3d.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),dl.prototype=Object.assign(Object.create(nn.prototype),{constructor:dl,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),((hl.prototype=Object.create(nn.prototype)).constructor=hl).prototype.isCompressedTexture=!0,((pl.prototype=Object.create(nn.prototype)).constructor=pl).prototype.isCanvasTexture=!0,((fl.prototype=Object.create(nn.prototype)).constructor=fl).prototype.isDepthTexture=!0,(ml.prototype=Object.create(ui.prototype)).constructor=ml,(vl.prototype=Object.create(Oi.prototype)).constructor=vl,(gl.prototype=Object.create(ui.prototype)).constructor=gl,(_l.prototype=Object.create(Oi.prototype)).constructor=_l,(yl.prototype=Object.create(ui.prototype)).constructor=yl,(xl.prototype=Object.create(Oi.prototype)).constructor=xl,(bl.prototype=Object.create(yl.prototype)).constructor=bl,(Ml.prototype=Object.create(Oi.prototype)).constructor=Ml,(wl.prototype=Object.create(yl.prototype)).constructor=wl,(Al.prototype=Object.create(Oi.prototype)).constructor=Al,(Sl.prototype=Object.create(yl.prototype)).constructor=Sl,(Tl.prototype=Object.create(Oi.prototype)).constructor=Tl,(El.prototype=Object.create(yl.prototype)).constructor=El,(Cl.prototype=Object.create(Oi.prototype)).constructor=Cl,((Pl.prototype=Object.create(ui.prototype)).constructor=Pl).prototype.toJSON=function(){var e=ui.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},(Ll.prototype=Object.create(Oi.prototype)).constructor=Ll,(Rl.prototype=Object.create(ui.prototype)).constructor=Rl,(Dl.prototype=Object.create(Oi.prototype)).constructor=Dl,(Nl.prototype=Object.create(ui.prototype)).constructor=Nl;var Il=function(e,t,n){n=n||2;var r,i,a,o,s,l,c,u=t&&t.length,d=u?t[0]*n:e.length,h=Ol(e,0,d,n,!0),p=[];if(!h||h.next===h.prev)return p;if(u&&(h=function(e,t,n,r){var i,a,o,s,l,c=[];for(i=0,a=t.length;i<a;i++)o=t[i]*r,s=i<a-1?t[i+1]*r:e.length,(l=Ol(e,o,s,r,!1))===l.next&&(l.steiner=!0),c.push(function(e){var t=e,n=e;for(;(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next,t!==e;);return n}(l));for(c.sort(zl),i=0;i<c.length;i++)!function(e,t){{var n;(t=function(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&o<s){if((o=s)===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===o)return n.prev;var l,c=n,u=n.x,d=n.y,h=1/0;r=n.next;for(;r!==c;)i>=r.x&&r.x>=u&&i!==r.x&&Vl(a<d?i:o,a,u,d,a<d?o:i,a,r.x,r.y)&&((l=Math.abs(a-r.y)/(i-r.x))<h||l===h&&r.x>n.x)&&Wl(r,e)&&(n=r,h=l),r=r.next;return n}(e,t))&&Fl(n=Xl(t,e),n.next)}}(c[i],n),n=Fl(n,n.next);return n}(e,t,h,n)),e.length>80*n){r=a=e[0],i=o=e[1];for(var f=n;f<d;f+=n)(s=e[f])<r&&(r=s),(l=e[f+1])<i&&(i=l),a<s&&(a=s),o<l&&(o=l);c=0!==(c=Math.max(a-r,o-i))?1/c:0}return Bl(h,p,n,r,i,c),p};function Ol(e,t,n,r,i){var a,o;if(i===0<function(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}(e,t,n,r))for(a=t;a<n;a+=r)o=Hl(a,e[a],e[a+1],o);else for(a=n-r;t<=a;a-=r)o=Hl(a,e[a],e[a+1],o);return o&&Gl(o,o.next)&&(Yl(o),o=o.next),o}function Fl(e,t){if(!e)return e;t=t||e;var n,r=e;do{if(n=!1,r.steiner||!Gl(r,r.next)&&0!==kl(r.prev,r,r.next))r=r.next;else{if(Yl(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function Bl(e,t,n,r,i,a,o){if(e){!o&&a&&function(e,t,n,r){var i=e;for(;null===i.z&&(i.z=Ul(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next,i!==e;);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,a,o,s,l,c=1;do{for(n=e,a=e=null,o=0;n;){for(o++,r=n,t=s=0;t<c&&(s++,r=r.nextZ);t++);for(l=c;0<s||0<l&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(n=(i=n).nextZ,s--):(r=(i=r).nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,c*=2}while(1<o)}(i)}(e,r,i,a);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?function(e,t,n,r){var i=e.prev,a=e,o=e.next;if(0<=kl(i,a,o))return!1;var s=i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,l=i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,c=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,d=Ul(s,l,t,n,r),h=Ul(c,u,t,n,r),p=e.prevZ,f=e.nextZ;for(;p&&p.z>=d&&f&&f.z<=h;){if(p!==e.prev&&p!==e.next&&Vl(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=kl(p.prev,p,p.next))return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Vl(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=kl(f.prev,f,f.next))return!1;f=f.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&Vl(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=kl(p.prev,p,p.next))return!1;p=p.prevZ}for(;f&&f.z<=h;){if(f!==e.prev&&f!==e.next&&Vl(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=kl(f.prev,f,f.next))return!1;f=f.nextZ}return!0}(e,r,i,a):function(e){var t=e.prev,n=e,r=e.next;if(0<=kl(t,n,r))return!1;var i=e.next.next;for(;i!==e.prev;){if(Vl(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&0<=kl(i.prev,i,i.next))return!1;i=i.next}return!0}(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Yl(e),e=l.next,c=l.next;else if((e=l)===c){o?1===o?Bl(e=function(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!Gl(i,a)&&jl(i,r,r.next,a)&&Wl(i,a)&&Wl(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),Yl(r),Yl(r.next),r=e=a),r=r.next}while(r!==e);return r}(e,t,n),t,n,r,i,a,2):2===o&&function(e,t,n,r,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&jl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&Wl(e,t)&&Wl(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;for(;n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next,n!==e;);return r}(e,t)}(o,s)){var l=Xl(o,s);return o=Fl(o,o.next),l=Fl(l,l.next),Bl(o,t,n,r,i,a),Bl(l,t,n,r,i,a)}s=s.next}o=o.next}while(o!==e)}(e,t,n,r,i,a):Bl(Fl(e),t,n,r,i,a,1);break}}}function zl(e,t){return e.x-t.x}function Ul(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Vl(e,t,n,r,i,a,o,s){return 0<=(i-o)*(t-s)-(e-o)*(a-s)&&0<=(e-o)*(r-s)-(n-o)*(t-s)&&0<=(n-o)*(a-s)-(i-o)*(r-s)}function kl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Gl(e,t){return e.x===t.x&&e.y===t.y}function jl(e,t,n,r){return Gl(e,n)&&Gl(t,r)||Gl(e,r)&&Gl(n,t)||0<kl(e,t,n)!=0<kl(e,t,r)&&0<kl(n,r,e)!=0<kl(n,r,t)}function Wl(e,t){return kl(e.prev,e,e.next)<0?0<=kl(e,t,e.next)&&0<=kl(e,e.prev,t):kl(e,t,e.prev)<0||kl(e,e.next,t)<0}function Xl(e,t){var n=new ql(e.i,e.x,e.y),r=new ql(t.i,t.x,t.y),i=e.next,a=t.prev;return(e.next=t).prev=e,(n.next=i).prev=n,(r.next=n).prev=r,(a.next=r).prev=a,r}function Hl(e,t,n,r){var i=new ql(e,t,n);return r?(i.next=r.next,(i.prev=r).next.prev=i,r.next=i):(i.prev=i).next=i,i}function Yl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ql(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Zl={area:function(e){for(var t=e.length,n=0,r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n},isClockWise:function(e){return Zl.area(e)<0},triangulateShape:function(e,t){var n=[],r=[],i=[];Ql(e),Kl(n,e);var a=e.length;t.forEach(Ql);for(var o=0;o<t.length;o++)r.push(a),a+=t[o].length,Kl(n,t[o]);for(var s=Il(n,r),o=0;o<s.length;o+=3)i.push(s.slice(o,o+3));return i}};function Ql(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function Kl(e,t){for(var n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}function Jl(e,t){Oi.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},this.fromBufferGeometry(new $l(e,t)),this.mergeVertices()}function $l(e,Q){ui.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:Q},e=Array.isArray(e)?e:[e];for(var K=this,J=[],$=[],t=0,n=e.length;t<n;t++){!function(e){var r=[],t=void 0!==Q.curveSegments?Q.curveSegments:12,l=void 0!==Q.steps?Q.steps:1,n=void 0!==Q.depth?Q.depth:100,i=void 0===Q.bevelEnabled||Q.bevelEnabled,a=void 0!==Q.bevelThickness?Q.bevelThickness:6,o=void 0!==Q.bevelSize?Q.bevelSize:a-2,s=void 0!==Q.bevelOffset?Q.bevelOffset:0,c=void 0!==Q.bevelSegments?Q.bevelSegments:3,u=Q.extrudePath,d=void 0!==Q.UVGenerator?Q.UVGenerator:ec;void 0!==Q.amount&&(console.warn("v3d.ExtrudeBufferGeometry: amount has been renamed to depth."),n=Q.amount);var h,p,f,m,v,g,_,y,x=!1;u&&(h=u.getSpacedPoints(l),i=!(x=!0),p=u.computeFrenetFrames(l,!1),f=new un,m=new un,v=new un);i||(s=o=a=c=0);var b=e.extractPoints(t),M=b.shape,w=b.holes;if(!Zl.isClockWise(M))for(M=M.reverse(),_=0,y=w.length;_<y;_++)g=w[_],Zl.isClockWise(g)&&(w[_]=g.reverse());var A=Zl.triangulateShape(M,w),S=M;for(_=0,y=w.length;_<y;_++)g=w[_],M=M.concat(g);function T(e,t,n){return t||console.error("v3d.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}var E,C,P,L,R,D,N=M.length,I=A.length;function O(e,t,n){var r,i=e.x-t.x,a=e.y-t.y,o=n.x-e.x,s=n.y-e.y,l=i*i+a*a,c=i*s-a*o;if(Math.abs(c)>Number.EPSILON){var u,d,h=Math.sqrt(l),p=Math.sqrt(o*o+s*s),f=t.x-a/h,m=t.y+i/h,v=((n.x-s/p-f)*s-(n.y+o/p-m)*o)/(i*s-a*o),g=(u=f+i*v-e.x)*u+(d=m+a*v-e.y)*d;if(g<=2)return new Jt(u,d);r=Math.sqrt(g/2)}else{var _=!1;i>Number.EPSILON?o>Number.EPSILON&&(_=!0):i<-Number.EPSILON?o<-Number.EPSILON&&(_=!0):Math.sign(a)===Math.sign(s)&&(_=!0),r=_?(u=-a,d=i,Math.sqrt(l)):(u=i,d=a,Math.sqrt(l/2))}return new Jt(u/r,d/r)}for(var F=[],B=0,z=S.length,U=z-1,V=B+1;B<z;B++,U++,V++)U===z&&(U=0),V===z&&(V=0),F[B]=O(S[B],S[U],S[V]);var k,G,j=[],W=F.concat();for(_=0,y=w.length;_<y;_++){for(g=w[_],k=[],B=0,z=g.length,U=z-1,V=B+1;B<z;B++,U++,V++)U===z&&(U=0),V===z&&(V=0),k[B]=O(g[B],g[U],g[V]);j.push(k),W=W.concat(k)}for(E=0;E<c;E++){for(P=E/c,L=a*Math.cos(P*Math.PI/2),C=o*Math.sin(P*Math.PI/2)+s,B=0,z=S.length;B<z;B++)H((R=T(S[B],F[B],C)).x,R.y,-L);for(_=0,y=w.length;_<y;_++)for(g=w[_],k=j[_],B=0,z=g.length;B<z;B++)H((R=T(g[B],k[B],C)).x,R.y,-L)}for(C=o+s,B=0;B<N;B++)R=i?T(M[B],W[B],C):M[B],x?(m.copy(p.normals[0]).multiplyScalar(R.x),f.copy(p.binormals[0]).multiplyScalar(R.y),v.copy(h[0]).add(m).add(f),H(v.x,v.y,v.z)):H(R.x,R.y,0);for(G=1;G<=l;G++)for(B=0;B<N;B++)R=i?T(M[B],W[B],C):M[B],x?(m.copy(p.normals[G]).multiplyScalar(R.x),f.copy(p.binormals[G]).multiplyScalar(R.y),v.copy(h[G]).add(m).add(f),H(v.x,v.y,v.z)):H(R.x,R.y,n/l*G);for(E=c-1;0<=E;E--){for(P=E/c,L=a*Math.cos(P*Math.PI/2),C=o*Math.sin(P*Math.PI/2)+s,B=0,z=S.length;B<z;B++)H((R=T(S[B],F[B],C)).x,R.y,n+L);for(_=0,y=w.length;_<y;_++)for(g=w[_],k=j[_],B=0,z=g.length;B<z;B++)R=T(g[B],k[B],C),x?H(R.x,R.y+h[l-1].y,h[l-1].x+L):H(R.x,R.y,n+L)}function X(e,t){var n,r;for(B=e.length;0<=--B;){(r=(n=B)-1)<0&&(r=e.length-1);for(var i=0,a=l+2*c,i=0;i<a;i++){var o=N*i,s=N*(i+1);!function(e,t,n,r){q(e),q(t),q(r),q(t),q(n),q(r);var i=J.length/3,a=d.generateSideWallUV(K,J,i-6,i-3,i-2,i-1);Z(a[0]),Z(a[1]),Z(a[3]),Z(a[1]),Z(a[2]),Z(a[3])}(t+n+o,t+r+o,t+r+s,t+n+s)}}}function H(e,t,n){r.push(e),r.push(t),r.push(n)}function Y(e,t,n){q(e),q(t),q(n);var r=J.length/3,i=d.generateTopUV(K,J,r-3,r-2,r-1);Z(i[0]),Z(i[1]),Z(i[2])}function q(e){J.push(r[3*e+0]),J.push(r[3*e+1]),J.push(r[3*e+2])}function Z(e){$.push(e.x),$.push(e.y)}(function(){var e=J.length/3;if(i){var t=0,n=N*t;for(B=0;B<I;B++)Y((D=A[B])[2]+n,D[1]+n,D[0]+n);for(n=N*(t=l+2*c),B=0;B<I;B++)Y((D=A[B])[0]+n,D[1]+n,D[2]+n)}else{for(B=0;B<I;B++)Y((D=A[B])[2],D[1],D[0]);for(B=0;B<I;B++)Y((D=A[B])[0]+N*l,D[1]+N*l,D[2]+N*l)}K.addGroup(e,J.length/3-e,0)})(),function(){var e=J.length/3,t=0;for(X(S,t),t+=S.length,_=0,y=w.length;_<y;_++)X(g=w[_],t),t+=g.length;K.addGroup(e,J.length/3-e,1)}()}(e[t])}this.setAttribute("position",new qr(J,3)),this.setAttribute("uv",new qr($,2)),this.computeVertexNormals()}((Jl.prototype=Object.create(Oi.prototype)).constructor=Jl).prototype.toJSON=function(){var e=Oi.prototype.toJSON.call(this);return tc(this.parameters.shapes,this.parameters.options,e)},(($l.prototype=Object.create(ui.prototype)).constructor=$l).prototype.toJSON=function(){var e=ui.prototype.toJSON.call(this);return tc(this.parameters.shapes,this.parameters.options,e)};var ec={generateTopUV:function(e,t,n,r,i){var a=t[3*n],o=t[3*n+1],s=t[3*r],l=t[3*r+1],c=t[3*i],u=t[3*i+1];return[new Jt(a,o),new Jt(s,l),new Jt(c,u)]},generateSideWallUV:function(e,t,n,r,i,a){var o=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*r],u=t[3*r+1],d=t[3*r+2],h=t[3*i],p=t[3*i+1],f=t[3*i+2],m=t[3*a],v=t[3*a+1],g=t[3*a+2];return Math.abs(s-u)<.01?[new Jt(o,1-l),new Jt(c,1-d),new Jt(h,1-f),new Jt(m,1-g)]:[new Jt(s,1-l),new Jt(u,1-d),new Jt(p,1-f),new Jt(v,1-g)]}};function tc(e,t,n){if(n.shapes=[],Array.isArray(e))for(var r=0,i=e.length;r<i;r++){var a=e[r];n.shapes.push(a.uuid)}else n.shapes.push(e.uuid);return void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function nc(e,t){Oi.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:t},this.fromBufferGeometry(new rc(e,t)),this.mergeVertices()}function rc(e,t){var n=(t=t||{}).font;if(!n||!n.isFont)return console.error("v3d.TextGeometry: font parameter is not an instance of v3d.Font."),new Oi;var r=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),$l.call(this,r,t),this.type="TextBufferGeometry"}function ic(e,t,n,r,i,a,o){Oi.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new ac(e,t,n,r,i,a,o)),this.mergeVertices()}function ac(e,t,n,r,i,a,o){ui.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},e=e||1,t=Math.max(3,Math.floor(t)||8),n=Math.max(2,Math.floor(n)||6),r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI,a=void 0!==a?a:0,o=void 0!==o?o:Math.PI;for(var s,l=Math.min(a+o,Math.PI),c=0,u=[],d=new un,h=new un,p=[],f=[],m=[],v=[],g=0;g<=n;g++){var _=[],y=g/n,x=0;for(0==g&&0==a?x=.5/t:g==n&&l==Math.PI&&(x=-.5/t),s=0;s<=t;s++){var b=s/t;d.x=-e*Math.cos(r+b*i)*Math.sin(a+y*o),d.y=e*Math.cos(a+y*o),d.z=e*Math.sin(r+b*i)*Math.sin(a+y*o),f.push(d.x,d.y,d.z),h.copy(d).normalize(),m.push(h.x,h.y,h.z),v.push(b+x,1-y),_.push(c++)}u.push(_)}for(g=0;g<n;g++)for(s=0;s<t;s++){var M=u[g][s+1],w=u[g][s],A=u[g+1][s],S=u[g+1][s+1];(0!==g||0<a)&&p.push(M,w,S),(g!==n-1||l<Math.PI)&&p.push(w,A,S)}this.setIndex(p),this.setAttribute("position",new qr(f,3)),this.setAttribute("normal",new qr(m,3)),this.setAttribute("uv",new qr(v,2))}function oc(e,t,n,r,i,a){Oi.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},this.fromBufferGeometry(new sc(e,t,n,r,i,a)),this.mergeVertices()}function sc(e,t,n,r,i,a){ui.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},e=e||.5,t=t||1,i=void 0!==i?i:0,a=void 0!==a?a:2*Math.PI,n=void 0!==n?Math.max(3,n):8;for(var o,s=[],l=[],c=[],u=[],d=e,h=(t-e)/(r=void 0!==r?Math.max(1,r):1),p=new un,f=new Jt,m=0;m<=r;m++){for(g=0;g<=n;g++)o=i+g/n*a,p.x=d*Math.cos(o),p.y=d*Math.sin(o),l.push(p.x,p.y,p.z),c.push(0,0,1),f.x=(p.x/t+1)/2,f.y=(p.y/t+1)/2,u.push(f.x,f.y);d+=h}for(m=0;m<r;m++)for(var v=m*(n+1),g=0;g<n;g++){var _=(o=g+v)+n+1,y=o+n+2,x=o+1;s.push(o,_,x),s.push(_,y,x)}this.setIndex(s),this.setAttribute("position",new qr(l,3)),this.setAttribute("normal",new qr(c,3)),this.setAttribute("uv",new qr(u,2))}function lc(e,t,n,r){Oi.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},this.fromBufferGeometry(new cc(e,t,n,r)),this.mergeVertices()}function cc(e,t,n,r){ui.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t)||12,n=n||0,r=r||2*Math.PI,r=Kt.clamp(r,0,2*Math.PI);var i=[],a=[],o=[],s=1/t,l=new un,c=new Jt;for(M=0;M<=t;M++)for(var u=n+M*s*r,d=Math.sin(u),h=Math.cos(u),p=0;p<=e.length-1;p++)l.x=e[p].x*d,l.y=e[p].y,l.z=e[p].x*h,a.push(l.x,l.y,l.z),c.x=M/t,c.y=p/(e.length-1),o.push(c.x,c.y);for(M=0;M<t;M++)for(p=0;p<e.length-1;p++){var f=(b=p+M*e.length)+e.length,m=b+e.length+1,v=b+1;i.push(b,f,v),i.push(f,m,v)}if(this.setIndex(i),this.setAttribute("position",new qr(a,3)),this.setAttribute("uv",new qr(o,2)),this.computeVertexNormals(),r===2*Math.PI){var g=this.attributes.normal.array,_=new un,y=new un,x=new un,b=t*e.length*3,M=0;for(p=0;M<e.length;M++,p+=3)_.x=g[p+0],_.y=g[p+1],_.z=g[p+2],y.x=g[b+p+0],y.y=g[b+p+1],y.z=g[b+p+2],x.addVectors(_,y).normalize(),g[p+0]=g[b+p+0]=x.x,g[p+1]=g[b+p+1]=x.y,g[p+2]=g[b+p+2]=x.z}}function uc(e,t){Oi.call(this),this.type="ShapeGeometry","object"==typeof t&&(console.warn("v3d.ShapeGeometry: Options parameter has been removed."),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new dc(e,t)),this.mergeVertices()}function dc(e,f){ui.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:f},f=f||12;var m=[],v=[],g=[],_=[],t=0,y=0;if(!1===Array.isArray(e))r(e);else for(var n=0;n<e.length;n++)r(e[n]),this.addGroup(t,y,n),t+=y,y=0;function r(e){var t,n=v.length/3,r=e.extractPoints(f),i=r.shape,a=r.holes;for(!1===Zl.isClockWise(i)&&(i=i.reverse()),s=0,l=a.length;s<l;s++)t=a[s],!0===Zl.isClockWise(t)&&(a[s]=t.reverse());for(var o=Zl.triangulateShape(i,a),s=0,l=a.length;s<l;s++)t=a[s],i=i.concat(t);for(s=0,l=i.length;s<l;s++){var c=i[s];v.push(c.x,c.y,0),g.push(0,0,1),_.push(c.x,c.y)}for(s=0,l=o.length;s<l;s++){var u=o[s],d=u[0]+n,h=u[1]+n,p=u[2]+n;m.push(d,h,p),y+=3}}this.setIndex(m),this.setAttribute("position",new qr(v,3)),this.setAttribute("normal",new qr(g,3)),this.setAttribute("uv",new qr(_,2))}function hc(e,t){if(t.shapes=[],Array.isArray(e))for(var n=0,r=e.length;n<r;n++){var i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}function pc(e,t){ui.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1;var n,r,i,a,o=[],s=Math.cos(Kt.DEG2RAD*t),l=[0,0],c={},u=["a","b","c"];e.isBufferGeometry?(a=new Oi).fromBufferGeometry(e):a=e.clone(),a.mergeVertices(),a.computeFaceNormals();for(var d=a.vertices,h=a.faces,p=0,f=h.length;p<f;p++)for(var m=h[p],v=0;v<3;v++)n=m[u[v]],r=m[u[(v+1)%3]],l[0]=Math.min(n,r),l[1]=Math.max(n,r),void 0===c[i=l[0]+","+l[1]]?c[i]={index1:l[0],index2:l[1],face1:p,face2:void 0}:c[i].face2=p;for(i in c){var g,_=c[i];(void 0===_.face2||h[_.face1].normal.dot(h[_.face2].normal)<=s)&&(g=d[_.index1],o.push(g.x,g.y,g.z),g=d[_.index2],o.push(g.x,g.y,g.z))}this.setAttribute("position",new qr(o,3))}function fc(e,t,n,r,i,a,o,s){Oi.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new mc(e,t,n,r,i,a,o,s)),this.mergeVertices()}function mc(g,_,y,x,b,e,M,w){ui.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:g,radiusBottom:_,height:y,radialSegments:x,heightSegments:b,openEnded:e,thetaStart:M,thetaLength:w};var A=this;g=void 0!==g?g:1,_=void 0!==_?_:1,y=y||1,x=Math.floor(x)||8,b=Math.floor(b)||1,e=void 0!==e&&e,M=void 0!==M?M:0,w=void 0!==w?w:2*Math.PI;var S=[],T=[],E=[],C=[],P=0,L=[],R=y/2,D=0;function t(e){for(var t,n=new Jt,r=new un,i=0,a=!0===e?g:_,o=!0===e?1:-1,s=P,l=1;l<=x;l++)T.push(0,R*o,0),E.push(0,o,0),C.push(.5,.5),P++;for(t=P,l=0;l<=x;l++){var c=l/x*w+M,u=Math.cos(c),d=Math.sin(c);r.x=a*d,r.y=R*o,r.z=a*u,T.push(r.x,r.y,r.z),E.push(0,o,0),n.x=.5*u+.5,n.y=.5*d*o+.5,C.push(n.x,n.y),P++}for(l=0;l<x;l++){var h=s+l,p=t+l;!0===e?S.push(p,p+1,h):S.push(p+1,p,h),i+=3}A.addGroup(D,i,!0===e?1:2),D+=i}!function(){var e,t,n=new un,r=new un,i=0,a=(_-g)/y;for(t=0;t<=b;t++){var o=[],s=t/b,l=s*(_-g)+g;for(e=0;e<=x;e++){var c=e/x,u=c*w+M,d=Math.sin(u),h=Math.cos(u);r.x=l*d,r.y=-s*y+R,r.z=l*h,T.push(r.x,r.y,r.z),n.set(d,a,h).normalize(),E.push(n.x,n.y,n.z),C.push(c,1-s),o.push(P++)}L.push(o)}for(e=0;e<x;e++)for(t=0;t<b;t++){var p=L[t][e],f=L[t+1][e],m=L[t+1][e+1],v=L[t][e+1];S.push(p,f,v),S.push(f,m,v),i+=6}A.addGroup(D,i,0),D+=i}(),!1===e&&(0<g&&t(!0),0<_&&t(!1)),this.setIndex(S),this.setAttribute("position",new qr(T,3)),this.setAttribute("normal",new qr(E,3)),this.setAttribute("uv",new qr(C,2))}function vc(e,t,n,r,i,a,o){fc.call(this,0,e,t,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function gc(e,t,n,r,i,a,o){mc.call(this,0,e,t,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function _c(e,t,n,r){Oi.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new yc(e,t,n,r)),this.mergeVertices()}function yc(e,t,n,r){ui.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],l=[],c=[],u=new un,d=new Jt;for(s.push(0,0,0),l.push(0,0,1),c.push(.5,.5),a=0,i=3;a<=t;a++,i+=3){var h=n+a/t*r;u.x=e*Math.cos(h),u.y=e*Math.sin(h),s.push(u.x,u.y,u.z),l.push(0,0,1),d.x=(s[i]/e+1)/2,d.y=(s[i+1]/e+1)/2,c.push(d.x,d.y)}for(i=1;i<=t;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new qr(s,3)),this.setAttribute("normal",new qr(l,3)),this.setAttribute("uv",new qr(c,2))}(nc.prototype=Object.create(Oi.prototype)).constructor=nc,(rc.prototype=Object.create($l.prototype)).constructor=rc,(ic.prototype=Object.create(Oi.prototype)).constructor=ic,(ac.prototype=Object.create(ui.prototype)).constructor=ac,(oc.prototype=Object.create(Oi.prototype)).constructor=oc,(sc.prototype=Object.create(ui.prototype)).constructor=sc,(lc.prototype=Object.create(Oi.prototype)).constructor=lc,(cc.prototype=Object.create(ui.prototype)).constructor=cc,((uc.prototype=Object.create(Oi.prototype)).constructor=uc).prototype.toJSON=function(){var e=Oi.prototype.toJSON.call(this);return hc(this.parameters.shapes,e)},((dc.prototype=Object.create(ui.prototype)).constructor=dc).prototype.toJSON=function(){var e=ui.prototype.toJSON.call(this);return hc(this.parameters.shapes,e)},(pc.prototype=Object.create(ui.prototype)).constructor=pc,(fc.prototype=Object.create(Oi.prototype)).constructor=fc,(mc.prototype=Object.create(ui.prototype)).constructor=mc,(vc.prototype=Object.create(fc.prototype)).constructor=vc,(gc.prototype=Object.create(mc.prototype)).constructor=gc,(_c.prototype=Object.create(Oi.prototype)).constructor=_c,(yc.prototype=Object.create(ui.prototype)).constructor=yc;var xc=Object.freeze({__proto__:null,WireframeGeometry:ml,ParametricGeometry:vl,ParametricBufferGeometry:gl,TetrahedronGeometry:xl,TetrahedronBufferGeometry:bl,OctahedronGeometry:Ml,OctahedronBufferGeometry:wl,IcosahedronGeometry:Al,IcosahedronBufferGeometry:Sl,DodecahedronGeometry:Tl,DodecahedronBufferGeometry:El,PolyhedronGeometry:_l,PolyhedronBufferGeometry:yl,TubeGeometry:Cl,TubeBufferGeometry:Pl,TorusKnotGeometry:Ll,TorusKnotBufferGeometry:Rl,TorusGeometry:Dl,TorusBufferGeometry:Nl,TextGeometry:nc,TextBufferGeometry:rc,SphereGeometry:ic,SphereBufferGeometry:ac,RingGeometry:oc,RingBufferGeometry:sc,PlaneGeometry:ra,PlaneBufferGeometry:ia,LatheGeometry:lc,LatheBufferGeometry:cc,ShapeGeometry:uc,ShapeBufferGeometry:dc,ExtrudeGeometry:Jl,ExtrudeBufferGeometry:$l,EdgesGeometry:pc,ConeGeometry:vc,ConeBufferGeometry:gc,CylinderGeometry:fc,CylinderBufferGeometry:mc,CircleGeometry:_c,CircleBufferGeometry:yc,BoxGeometry:Fi,BoxBufferGeometry:Bi});function bc(e){Br.call(this),this.type="ShadowMaterial",this.color=new Lr(0),this.transparent=!0,this.setValues(e)}function Mc(e){ji.call(this,e),this.type="RawShaderMaterial"}function wc(e){Br.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Lr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new Jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ac(e){wc.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new Jt(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(e)}function Sc(e){Br.call(this),this.type="MeshPhongMaterial",this.color=new Lr(16777215),this.specular=new Lr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new Jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=U,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Tc(e){Br.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Lr(16777215),this.specular=new Lr(1118481),this.shininess=30,this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new Jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ec(e){Br.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new Jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Cc(e){Br.call(this),this.type="MeshLambertMaterial",this.color=new Lr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=U,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Pc(e){Br.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Lr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zt,this.normalScale=new Jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Lc(e){Ys.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Rc(e){Br.call(this),this.type="MeshMaskMaterial",this.skinning=!1,this.morphTargets=!1,this.side=ie,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.cameraNearFar=null,this.depthTexture=null,this.textureMatrix=null,this.setValues(e)}function Dc(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function Nc(e,t,n,r){Dc.call(this,e,t,n,r)}((bc.prototype=Object.create(Br.prototype)).constructor=bc).prototype.isShadowMaterial=!0,bc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this},((Mc.prototype=Object.create(ji.prototype)).constructor=Mc).prototype.isRawShaderMaterial=!0,((wc.prototype=Object.create(Br.prototype)).constructor=wc).prototype.isMeshStandardMaterial=!0,wc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Ac.prototype=Object.create(wc.prototype)).constructor=Ac).prototype.isMeshPhysicalMaterial=!0,Ac.prototype.copy=function(e){return wc.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearcoat=e.clearcoat,this.clearcoatRoughness=e.clearcoatRoughness,e.sheen?this.sheen=(this.sheen||new Lr).copy(e.sheen):this.sheen=null,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.transparency=e.transparency,this},((Sc.prototype=Object.create(Br.prototype)).constructor=Sc).prototype.isMeshPhongMaterial=!0,Sc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Tc.prototype=Object.create(Br.prototype)).constructor=Tc).prototype.isMeshToonMaterial=!0,Tc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Ec.prototype=Object.create(Br.prototype)).constructor=Ec).prototype.isMeshNormalMaterial=!0,Ec.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Cc.prototype=Object.create(Br.prototype)).constructor=Cc).prototype.isMeshLambertMaterial=!0,Cc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Pc.prototype=Object.create(Br.prototype)).constructor=Pc).prototype.isMeshMatcapMaterial=!0,Pc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},((Lc.prototype=Object.create(Ys.prototype)).constructor=Lc).prototype.isLineDashedMaterial=!0,Lc.prototype.copy=function(e){return Ys.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},((Rc.prototype=Object.create(Br.prototype)).constructor=Rc).prototype.isMeshMaskMaterial=!0,Rc.prototype.copy=function(e){return Br.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},Object.assign(Dc.prototype,{evaluate:function(e){var t,n=this.parameterPositions,r=this._cachedIndex,i=n[r],a=n[r-1];e:{t:{n:{r:if(!(e<i)){for(var o=r+2;;){if(void 0===i){if(e<a)break r;return r=n.length,this._cachedIndex=r,this.afterEnd_(r-1,e,a)}if(r===o)break;if(a=i,e<(i=n[++r]))break t}t=n.length;break n}if(a<=e)break e;var s=n[1];e<s&&(r=2,a=s);for(o=r-2;;){if(void 0===a)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(r===o)break;if(i=a,(a=n[--r-1])<=e)break t}t=r,r=0}for(;r<t;){var l=r+t>>>1;e<n[l]?t=l:r=1+l}if(i=n[r],void 0===(a=n[r-1]))return this._cachedIndex=0,this.beforeStart_(0,e,i);if(void 0===i)return r=n.length,this._cachedIndex=r,this.afterEnd_(r-1,a,e)}this._cachedIndex=r,this.intervalChanged_(r,a,i)}return this.interpolate_(r,a,e,i)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r,a=0;a!==r;++a)t[a]=n[i+a];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Dc.prototype,{beforeStart_:Dc.prototype.copySampleValue_,afterEnd_:Dc.prototype.copySampleValue_}),Nc.prototype=Object.assign(Object.create(Dc.prototype),{constructor:Nc,interpolate_:function(e){return this.copySampleValue_(e-1)}});var Ic={};!function(c){c.less=function(e,t,n){return n(e,t)<0},c.exchange=function(e,t,n){var r=e[t];e[t]=e[n],e[n]=r};c.StackNode=function(e){this.value=e,this.next=null};function e(){this.N=0,this.first=null}e.prototype.push=function(e){this.first=this._push(this.first,e)},e.prototype._push=function(e,t){if(null==e)return this.N++,new c.StackNode(t);var n=e;return this.N++,(e=new c.StackNode(t)).next=n,e},e.prototype.pop=function(){if(null!=this.first){var e=this.first,t=e.value;return this.first=e.next,this.N--,t}},e.prototype.size=function(){return this.N},e.prototype.isEmpty=function(){return 0==this.N},e.prototype.peep=function(){if(null!=this.first)return this.first.value},e.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},c.Stack=e;c.QueueNode=function(e){this.value=e,this.next=null};function t(){this.first=null,this.last=null,this.N=0}t.prototype.enqueue=function(e){var t=this.last;this.last=new c.QueueNode(e),null!=t&&(t.next=this.last),null==this.first&&(this.first=this.last),this.N++},t.prototype.dequeue=function(){if(null!=this.first){var e=this.first,t=e.value;return this.first=e.next,null==this.first&&(this.last=null),this.N--,t}},t.prototype.size=function(){return this.N},t.prototype.isEmpty=function(){return 0==this.N},t.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},c.Queue=t;function n(e){this.s=[],this.N=0,e=e||function(e,t){return e-t},this.compare=e}n.prototype.enqueue=function(e){for(;this.s.lengh<=this.N+1;)this.s.push(0);this.s[++this.N]=e,this.swim(this.N)},n.prototype.swim=function(e){for(;1<e;){var t=Math.floor(e/2);if(!c.less(this.s[e],this.s[t],this.compare))break;c.exchange(this.s,e,t),e=t}},n.prototype.delMin=function(){if(0!=this.N){var e=this.s[1];return c.exchange(this.s,1,this.N--),this.sink(1),e}},n.prototype.sink=function(e){for(;2*e<=this.N;){var t=2*e;if(t<this.N&&c.less(this.s[t+1],this.s[t],this.compare)&&t++,!c.less(this.s[t],this.s[e],this.compare))break;c.exchange(this.s,t,e),e=t}},n.prototype.size=function(){return this.N},n.prototype.isEmpty=function(){return 0==this.N},c.MinPQ=n;function r(e){this.id=[];for(var t=0;t<e;++t)this.id.push(t)}r.prototype.union=function(e,t){var n=this.root(e),r=this.root(t);r!=n&&(this.id[r]=n)},r.prototype.root=function(e){for(;this.id[e]!=e;)e=this.id[e];return e},r.prototype.connected=function(e,t){return this.root(e)==this.root(t)},c.QuickUnion=r;function i(e,t){this.keys=[],this.pq=[],this.qp=[];for(var n=0;n<=e;++n)this.keys.push(null),this.pq.push(0),this.qp.push(-1);this.N=0,t=t||function(e,t){return e-t},this.compare=t}i.prototype.insert=function(e,t){this.keys[e]=t,this.pq[++this.N]=e,this.qp[e]=this.N,this.swim(this.N)},i.prototype.decreaseKey=function(e,t){c.less(t,this.keys[e],this.compare)&&(this.keys[e]=t,this.swim(this.qp[e]))},i.prototype.minKey=function(){return this.keys[this.pq[1]]},i.prototype.min=function(){return this.pq[1]},i.prototype.delMin=function(){var e=this.pq[1];return c.exchange(this.pq,1,this.N),this.qp[this.pq[1]]=1,this.qp[this.pq[this.N]]=-1,this.keys[this.pq[this.N]]=null,this.N--,this.sink(1),e},i.prototype.swim=function(e){for(;1<e;){var t=Math.floor(e/2);if(!c.less(this.keys[this.pq[e]],this.keys[this.pq[t]],this.compare))break;c.exchange(this.pq,e,t),this.qp[this.pq[e]]=e,e=this.qp[this.pq[t]]=t}},i.prototype.sink=function(e){for(;2*e<=this.N;){var t=2*e;if(t<this.N&&c.less(this.keys[this.pq[t+1]],this.keys[this.pq[t]],this.compare)&&t++,!c.less(this.keys[this.pq[t]],this.keys[this.pq[e]],this.compare))break;c.exchange(this.pq,e,t),this.qp[this.pq[e]]=e,e=this.qp[this.pq[t]]=t}},i.prototype.containsIndex=function(e){return-1!=this.qp[e]},i.prototype.isEmpty=function(){return 0==this.N},i.prototype.size=function(){return this.N},c.IndexMinPQ=i;c.LinkMapNode=function(e){this.value=e,this.prev=null,this.next=null};function a(){this.first=null,this.last=null,this.map={}}a.prototype.push=function(e,t){this.map[t]=e,null===this.first?this.first=e:(this.last.next=e).prev=this.last,this.last=e},a.prototype.removeNodeByKey=function(e){var t=this.map[e],n=t.prev,r=t.next;null!==n&&null!==r?(n.next=r).prev=n:null===n&&null!==r?(this.first=r).prev=null:null!==n&&null===r?(this.last=n).next=null:(this.first=null,this.last=null),delete this.map[e]},c.LinkMap=a;function o(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}o.prototype.addNewEdge=function(e,t){this.adjList[e].push(t),this.adjList[t].push(e);var n=t<e?t+"_"+e:e+"_"+t;this.edges[n]=new c.Edge(e,t,0)},o.prototype.adj=function(e){return this.adjList[e]},o.prototype.node=function(e){return this.nodeInfo[e]},o.prototype.len=function(){return this.V},o.prototype.edge=function(e,t){var n=t<e?t+"_"+e:e+"_"+t;return n in this.edges?this.edges[n]:null},c.Graph=o;function d(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}d.prototype.removeAll=function(){this.V=0,this.adjList=[],this.nodeInfo=[],this.edges={}},d.prototype.addNode=function(e){e=e||{},this.V++,this.adjList.push([]),this.nodeInfo.push(e)},d.prototype.addNewEdge=function(e,t){this.adjList[e].push(t);var n=e+"_"+t,r=new c.Edge(e,t,0);return this.edges[n]=r},d.prototype.addEdge=function(e){var t=e.v,n=e.w;this.adjList[t].push(n);var r=t+"_"+n;this.edges[r]=e},d.prototype.removeEdge=function(e,t){for(var n=this.adjList[e],r=0;r<n.length;r++)n[r]==t&&(n.splice(r,1),r--);var i=e+"_"+t;i in this.edges&&delete this.edges[i]},d.prototype.edge=function(e,t){var n=e+"_"+t;return n in this.edges?this.edges[n]:null},d.prototype.adj=function(e){return this.adjList[e]},d.prototype.node=function(e){return this.nodeInfo[e]},d.prototype.nodeIndex=function(e){for(var t=0;t<this.V;++t)if(this.nodeInfo[t]==e)return t;return-1},d.prototype.reverse=function(){for(var e=new d(this.V),t=0;t<this.V;++t)for(var n=this.adjList[t],r=0;r<n.length;++r){var i=n[r];e.addNewEdge(i,t)}return e},d.prototype.len=function(){return this.V},d.prototype.findInEdges=function(e){for(var t=[],n=0;n<this.V;n++)for(var r=this.adjList[n],i=0;i<r.length;i++)r[i]==e&&t.push(this.edge(n,e));return t},d.prototype.findOutEdges=function(e){for(var t=[],n=this.adjList[e],r=0;r<n.length;r++)t.push(this.edge(e,n[r]));return t},d.prototype.disconnect=function(e,t){this.adjList[e].splice(0);for(var n=0;n<this.V;n++){for(var r=this.adjList[n],i=0;i<r.length;i++)r[i]==e&&(r.splice(i,1),i--);var a=n+"_"+e;a in this.edges&&delete this.edges[a],(a=e+"_"+n)in this.edges&&delete this.edges[a]}if(t){for(var o=new d(this.V-1),n=0;n<this.V;n++)if(n!=e)for(r=this.adjList[n],i=0;i<r.length;i++){var s=r[i],l=e<n?n-1:n,c=e<s?s-1:s,u=this.edge(n,s).copy();u.v=l,u.w=c,o.addEdge(u)}this.V--,this.adjList=o.adjList,this.nodeInfo.splice(e,1),this.edges=o.edges}},d.prototype.insert=function(e,t,n){for(var r=this.V,i=e.V,a=0;a<i;a++){this.adjList.push([]),this.nodeInfo.push(function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(e.nodeInfo[a]));for(var o=e.adjList[a],s=0;s<o.length;s++){var l=o[s];(c=e.edge(a,l).copy()).v+=r,c.w+=r,this.addEdge(c)}}this.V+=i;for(s=0;s<t.length;s++){(c=t[s].copy()).w+=r,this.addEdge(c)}for(var c,s=0;s<n.length;s++){(c=n[s].copy()).v+=r,this.addEdge(c)}},d.prototype.vis=function(e){e=e||function(e,t){return String(e)};for(var t="digraph G {",n=0;n<this.V;n++){t+=n+' [label="'+e(n,this.nodeInfo[n])+'"];';for(var r=this.adjList[n],i=0;i<r.length;i++){t+=n+" -> "+r[i]+";"}}t+="}",console.log(t)},c.DiGraph=d;function s(e,t,n){this.v=e,this.w=t,this.weight=n}s.prototype.either=function(){return this.v},s.prototype.other=function(e){return e==this.v?this.w:this.v},s.prototype.from=function(){return this.v},s.prototype.to=function(){return this.w},s.prototype.copy=function(){var e=new s(0,0,0);for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},c.Edge=s;function l(e){this.V=e,this.adjList=[],this.nodeInfo=[];for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}l.prototype.adj=function(e){return this.adjList[e]},l.prototype.edge=function(e,t){for(var n=this.adjList[e],r=0;r<n.length;++r){if(n[r].other(e)==t)return n[r]}return null},l.prototype.node=function(e){return this.nodeInfo[e]},l.prototype.addNewEdge=function(e){var t=e.either(),n=e.other(t);this.adjList[t].push(e),this.adjList[n].push(e)},c.WeightedGraph=l;function u(e){l.call(this,e)}(u.prototype=Object.create(c.WeightedGraph.prototype)).addNewEdge=function(e){var t=e.from();this.adjList[t].push(e)},u.prototype.edge=function(e,t){for(var n=this.adjList[e],r=0;r<n.length;++r){if(n[r].other(e)==t)return n[r]}return null},u.prototype.toDiGraph=function(){for(var e=new c.DiGraph(this.V),t=0;t<this.V;++t)for(var n=this.adjList[t],r=0;r<n.length;++r){var i=n[r].other(t);e.addNewEdge(t,i)}return e},c.WeightedDiGraph=u;function h(e,t,n){this.v=e,this.w=t,this.capacity=n,this.flow=0}h.prototype.residualCapacityTo=function(e){return e==this.v?this.flow:this.capacity-this.flow},h.prototype.addResidualFlowTo=function(e,t){e==this.v?this.flow-=t:e==this.w&&(this.flow+=t)},h.prototype.from=function(){return this.v},h.prototype.to=function(){return this.w},h.prototype.other=function(e){return e==this.v?this.w:this.v},c.FlowEdge=h;function p(e){this.V=e,this.adjList=[],this.nodeInfo=[];for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}p.prototype.node=function(e){return this.nodeInfo[e]},p.prototype.edge=function(e,t){for(var n=this.adjList[e],r=0;r<n.length;++r){if(n[r].other(e)==t)return n[r]}return null},p.prototype.addNewEdge=function(e){var t=e.from();this.adjList[t].push(e);var n=e.other(t);this.adjList[n].push(e)},p.prototype.adj=function(e){return this.adjList[e]},c.FlowNetwork=p;function f(e,t){this.s=t;var n=e.V;this.marked=[],this.edgeTo=[];for(var r=0;r<n;++r)this.marked.push(!1),this.edgeTo.push(-1);this.dfs(e,t)}f.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||(this.edgeTo[i]=t,this.dfs(e,i))}},f.prototype.hasPathTo=function(e){return this.marked[e]},f.prototype.pathTo=function(e){var t=new c.Stack;if(e==this.s)return[e];for(var n=e;n!=this.s;n=this.edgeTo[n])t.push(n);return t.push(this.s),t.toArray()},c.DepthFirstSearch=f;function m(e,t){var n=e.V;this.s=t;var r=new c.Queue;r.enqueue(t),this.marked=[],this.edgeTo=[];for(var i=0;i<n;++i)this.marked.push(!1),this.edgeTo.push(-1);for(;!r.isEmpty();){i=r.dequeue();this.marked[i]=!0;for(var a=e.adj(i),o=0;o<a.length;++o){var s=a[o];this.marked[s]||(this.edgeTo[s]=i,r.enqueue(s))}}}m.prototype.hasPathTo=function(e){return this.marked[e]},m.prototype.pathTo=function(e){var t=new c.Stack;if(e==this.s)return[e];for(var n=e;n!=this.s;n=this.edgeTo[n])t.push(n);return t.push(this.s),t.toArray()},c.BreadthFirstSearch=m;function v(e){this.count=0;var t=e.V;this.marked=[],this.id=[];for(var n=0;n<t;++n)this.marked.push(!1),this.id.push(-1);for(n=0;n<t;++n)this.marked[n]||(this.dfs(e,n),this.count++)}v.prototype.dfs=function(e,t){this.marked[t]=!0,this.id[t]=this.count;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||this.dfs(e,i)}},v.prototype.componentId=function(e){return this.id[e]},v.prototype.componentCount=function(){return this.count},c.ConnectedComponents=v;function g(e){this.postOrder=new c.Stack,this.marked=[];for(var t=e.V,n=0;n<t;++n)this.marked.push(!1);for(n=0;n<t;++n)this.marked[n]||this.dfs(e,n)}g.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||this.dfs(e,i)}this.postOrder.push(t)},g.prototype.order=function(){return this.postOrder.toArray()},c.TopologicalSort=g;function _(e){var t=e.V;this.count=0,this.marked=[],this.id=[];for(var n=0;n<t;++n)this.marked.push(!1),this.id.push(-1);for(var r=new c.TopologicalSort(e.reverse()).order(),i=0;i<r.length;++i){n=r[i];this.marked[n]||(this.dfs(e,n),this.count++)}}_.prototype.dfs=function(e,t){this.marked[t]=!0,this.id[t]=this.count;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||this.dfs(e,i)}},_.prototype.componentId=function(e){return this.id[e]},_.prototype.componentCount=function(){return this.count},c.StronglyConnectedComponents=_;c.KruskalMST=function(e){for(var t=e.V,n=new c.MinPQ(function(e,t){return e.weight-t.weight}),r=0;r<e.V;++r)for(var i=e.adj(r),a=0;a<i.length;++a){(s=i[a]).either()==r&&n.enqueue(s)}this.mst=[];for(var o=new c.QuickUnion(t);!n.isEmpty()&&this.mst.length<t-1;){var s,r=(s=n.delMin()).either(),l=s.other(r);o.connected(r,l)||(o.union(r,l),this.mst.push(s))}};function y(e){var t=e.V;this.marked=[];for(var n=0;n<t;++n)this.marked.push(!1);for(this.pq=new c.MinPQ(function(e,t){return e.weight-t.weight}),this.mst=[],this.visit(e,0);!this.pq.isEmpty()&&this.mst.length<t-1;){var r=this.pq.delMin(),n=r.either(),i=r.other(n);this.marked[n]&&this.marked[i]||(this.mst.push(r),this.marked[n]||this.visit(e,n),this.marked[i]||this.visit(e,i))}}y.prototype.visit=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i.other(t)]||this.pq.enqueue(i)}},c.LazyPrimMST=y;function x(e){var t=e.V;this.pq=new c.IndexMinPQ(t,function(e,t){return e.weight-t.weight}),this.marked=[];for(var n=0;n<t;++n)this.marked.push(!1);for(this.mst=[],this.visit(e,0);!this.pq.isEmpty();){var r=this.pq.minKey(),i=this.pq.delMin();this.mst.push(r),this.marked[i]||this.visit(e,i)}}x.prototype.visit=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r],a=i.other(t);this.marked[a]||(this.pq.containsIndex(a)?this.pq.decreaseKey(a,i):this.pq.insert(a,i))}},c.EagerPrimMST=x;function b(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[],this.pq=new c.IndexMinPQ(n,function(e,t){return t});for(var r=0;r<n;++r)this.marked.push(!1),this.edgeTo.push(null),this.cost.push(Number.MAX_VALUE);for(this.cost[t]=0,this.pq.insert(t,this.cost[t]);!this.pq.isEmpty();){r=this.pq.delMin();this.marked[r]=!0;for(var i=e.adj(r),a=0;a<i.length;++a){var o=i[a];this.relax(o)}}}b.prototype.relax=function(e){var t=e.from(),n=e.to();this.cost[n]>this.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.edgeTo[n]=e,this.pq.containsIndex(n)?this.pq.decreaseKey(n,this.cost[n]):this.pq.insert(n,this.cost[n]))},b.prototype.hasPathTo=function(e){return this.marked[e]},b.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},b.prototype.distanceTo=function(e){return this.cost[e]},c.Dijkstra=b;function M(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var r=0;r<n;++r)this.marked.push(!1),this.edgeTo.push(null),this.cost.push(Number.MAX_VALUE);this.cost[t]=0,this.marked[t]=!0;for(var i=0;i<n;++i)for(r=0;r<n;++r)for(var a=e.adj(r),o=0;o<a.length;++o){var s=a[o];this.relax(s)}}M.prototype.relax=function(e){var t=e.from(),n=e.to();this.cost[n]>this.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.marked[n]=!0,this.edgeTo[n]=e)},M.prototype.hasPathTo=function(e){return this.marked[e]},M.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},M.prototype.distanceTo=function(e){return this.cost[e]},c.BellmanFord=M;function w(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var r=0;r<n;++r)this.marked.push(!1),this.edgeTo.push(null),this.cost.push(Number.MAX_VALUE);this.cost[t]=0,this.marked[t]=!0;for(var i=new c.TopologicalSort(e.toDiGraph()).order(),a=0;a<i.length;++a)for(var r=i[a],o=e.adj(r),s=0;s<o.length;++s){var l=o[s];this.relax(l)}}w.prototype.relax=function(e){var t=e.from(),n=e.to();this.cost[n]>this.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.marked[n]=!0,this.edgeTo[n]=e)},w.prototype.hasPathTo=function(e){return this.marked[e]},w.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},w.prototype.distanceTo=function(e){return this.cost[e]},c.TopologicalSortShortestPaths=w;function A(e,t,n){this.value=0,e.V;var r=Number.MAX_VALUE;for(this.marked=null,this.edgeTo=null,this.s=t,this.t=n;this.hasAugmentedPath(e);){for(var i=this.t;i!=this.s;i=this.edgeTo[i].from())r=Math.min(r,this.edgeTo[i].residualCapacityTo(i));for(i=this.t;i!=this.s;i=this.edgeTo[i].from())this.edgeTo[i].addResidualFlowTo(i,r);this.value+=r}}A.prototype.hasAugmentedPath=function(e){var t=e.V;this.marked=[],this.edgeTo=[];for(var n=0;n<t;++n)this.marked.push(!1),this.edgeTo.push(null);var r=new c.Queue;for(r.enqueue(this.s),this.marked[this.s]=!0;!r.isEmpty();)for(var n=r.dequeue(),i=e.adj(n),a=0;a<i.length;++a){var o=i[a],s=o.other(n);if(!this.marked[s]&&0<o.residualCapacityTo(s)){if(this.edgeTo[s]=o,this.marked[s]=!0,s==this.t)return!0;r.enqueue(s)}}return!1},A.prototype.minCut=function(e){for(var t=[],n=e.V,r=0;r<n;++r)for(var i=e.adj(r),a=0;a<i.length;++a){var o=i[a];o.from()==r&&0==o.residualCapacityTo(o.other(r))&&t.push(o)}return t},c.FordFulkerson=A}(Ic);var Oc=[[-1.117001,-.1867262,-11.13505,12.59865,-.03937339,1.167571,.007100686,3.592678,.6083296,-1.152006,-.1926669,6.152049,-4.770802,-.08704701,.7483626,.03372718,4.464592,.4036546,-1.072371,-.2696632,.2816168,1.820571,-.3742666,2.080607,-.07675295,-2.835366,1.129329,-1.109935,-.1532764,1.198787,-.9015183,.005173015,.5749178,.1075633,4.387949,.2650413,-1.052297,-.2229452,1.952347,.5727205,-4.88507,1.984016,-.1106197,-.4898361,.8907873,-1.070108,-.1600465,1.593886,-4479251e-11,-3.306541,.9390193,.09513168,2.343583,.5335404,-1.113253,-.16996,-10.38822,11.37513,-.04040911,1.037455,.04991792,4.801919,.630271,-1.135747,-.1678594,4.970755,-4.43023,-.06657408,.3636161,.1558009,6.01337,.3959601,-1.095892,-.2732595,.7666496,1.350731,-.4401401,2.470135,-.1707929,-3.260793,1.170337,-1.073668,-.02603929,-.1944589,.4575207,.6878164,-.139077,.3690299,7.885781,.1877694,-1.070091,-.2798957,2.338478,-2.647221,-7.387808,2.32921,-.1644639,-2.00371,.9874527,-1.06712,-.1418866,1.25409,6.053048,-2.918892,.5322812,.1613053,3.018161,.527409,-1.129483,-.1890619,-9.065101,9.659923,-.03607819,.8314359,.08181661,4.768868,.6339777,-1.14642,-.1883579,3.309173,-3.127882,-.06938176,.3987113,.1400581,6.283042,.5267076,-1.128348,-.2641305,1.223176,.05514952,-.3490649,1.997784,-.04123709,-2.251251,.9483466,-1.02582,.0140469,-1.187406,2.7299,.5877588,-.276114,.4602633,8.305125,.3945001,-1.083957,-.2606679,2.207108,-7.202803,-5.968103,2.129455,-.07789512,-1.137688,.8871769,-1.062465,-.1512189,1.042881,14.27839,-4.242214,.40381,.199778,2.814449,.5803196,-1.175099,-.2410789,-11.08587,11.33404,-.018193,.6772942,.09605043,4.231166,.6239972,-1.224207,-.2883527,3.002206,-2.649612,-.04795418,.4984398,.03251434,4.851611,.6551019,-1.136955,-.2423048,1.058823,-.2489236,-.2462179,1.93314,.09106828,-.1905869,.8171065,-1.014535,-.0082625,-1.448017,2.295788,.3510334,-1.477418,.5432449,5.762796,.4908751,-1.070666,-.237978,1.844589,-5.442448,-4.012768,2.945275,.009854725,.08455959,.814503,-1.071525,-.1777132,.807659,9.925865,-3.324623,-.6367437,.2844581,2.248384,.6544022,-1.218818,-.2952382,-13.45975,13.47153,-.006814585,.5079068,.119723,3.776949,.5836961,-1.409868,-.511433,2.776539,-2.039001,-.02673769,.4145288,.0007829342,2.275883,.6629691,-1.069151,-.09434247,.7293972,-1.222473,-.1533461,2.160357,.04626837,3.852415,.859357,-1.021306,-.1149551,-1.108414,4.178343,.4013665,-2.222814,.6929462,1.392652,.4401662,-1.074251,-.2224002,1.372356,-8.858704,-3.92266,3.020018,-.01458724,1.511186,.8288064,-1.062048,-.1526582,.4921067,14.85522,-3.229936,-.8426604,.3916243,2.678994,.6689264,-1.257023,-.33647,-15.27795,15.04223,.002717715,.302991,.1636851,3.561663,.5283161,-1.635124,-.7329993,3.523939,-2.566337,-.01902543,.5505483,-.06242176,1.065992,.6654236,-.9295823,.04845834,-.299299,-.2001327,-.08019339,1.807806,.09020277,5.095372,.8639936,-1.09374,-.2148608,-.521624,2.119777,.09506454,-1.831439,.6961204,.1102084,.4384319,-1.044181,-.1849257,.9071246,-4.648901,-2.279385,2.356502,-.04169147,1.932557,.829655,-1.061451,-.1458745,.2952267,8.967214,-3.726228,-.5022316,.5684877,3.102347,.6658443,-1.332391,-.4127769,-9.328643,9.046194,.003457775,.3377425,.1530909,3.301209,.4997917,-1.932002,-.9947777,-2.042329,3.58694,-.05642182,.8130478,-.08195988,.1118294,.5617231,-.8707374,.1286999,1.820054,-4.674706,.003317471,.5919018,.1975278,6.686519,.9631727,-1.070378,-.3030579,-.9041938,6.200201,.1232207,-.3650628,.5029403,-2.903162,.3811408,-1.063035,-.1637545,.5853072,-7.889906,-1.200641,1.035018,.1192093,3.267054,.8416151,-1.053655,-.1562286,.2423683,11.28575,-4.363262,-.0731416,.5642088,2.514023,.6670457,-1.366112,-.4718287,-7.876222,7.7469,-.009182309,.4716076,.08320252,3.165603,.5392334,-2.468204,-1.33634,-5.386723,7.072672,-.08329266,.8636876,-.01978177,-.1326218,.2979222,-.9653522,-.02373416,1.81025,-6.467262,.1410706,-.4753717,.3003095,6.551163,1.151083,-.8943186,-.2487152,-.230896,8.512648,.1298402,1.034705,.2303509,-3.924095,.2982717,-1.146999,-.2318784,.08992419,-9.933614,-.886092,-.03071656,.2852012,3.046199,.8599001,-1.032399,-.1645145,.2683599,13.27701,-4.40767,.07709869,.4951727,1.957277,.6630943,-1.46907,-.6135092,-6.506263,6.661315,-.03835383,.7150413,.007784318,2.820577,.6756784,-2.501583,-1.247404,-15.23462,16.33191,-.01204803,.5896471,-.02002023,1.144647,.06177874,-2.438672,-1.127291,5.731172,-10.2135,.0616561,-.7752641,.4708254,4.176847,1.200881,-.1513427,.09792731,-1.612349,9.814289,.05188921,1.716403,-.07039255,-2.815115,.3291874,-1.318511,-.3650554,.4221268,-9.294529,-.0439752,-.8100625,.3742719,1.834166,.822345,-1.016009,-.1820264,.1278426,11.82696,-4.801528,.4947899,.4660378,1.601254,.6702359,-1.84131,-.9781779,-4.610903,4.824662,-.05100806,.6463776,-6377724e-12,2.216875,.861853,-2.376373,-1.108657,-14.89799,15.46458,.04091025,.0976178,-.01048958,2.165834,-.1609171,-4.710318,-2.261963,6.947327,-10.34828,-.1325542,.7508674,.2247553,2.873142,1.2971,.216375,-.1944345,-2.43786,10.11314,.44505,.3111492,.2751323,-1.627906,.2531213,-1.258794,-.3524641,.8425444,-10.85313,-1.154381,-.4638014,-.002781115,.4344498,.8507091,-1.018938,-.1804153,-.06354054,15.7315,-4.386999,.6211115,.5294648,1.580749,.6586655,-1.116416,-.1917524,-10.68233,12.22221,-.03668978,1.054022,.01592132,3.180583,.562737,-1.132341,-.1671286,5.976499,-4.227366,-.09542489,.8664938,.008351793,4.876068,.4492779,-1.087635,-.3173679,.4314407,1.100555,-.4410057,1.677253,-.03005925,-4.201249,1.070902,-1.083031,-.08847705,1.291773,.4546776,.3091894,.726176,.04203659,5.990615,.3704756,-1.057899,-.2246706,2.329563,-1.219656,-5.33526,.8545378,-.03906209,-.9025499,.7797348,-1.073305,-.1522553,1.767063,1.90428,-3.101673,.3995856,.02905192,2.563977,.5753067,-1.113674,-.1759694,-9.754125,10.87391,-.03841093,.9524272,.05680219,4.227034,.6029571,-1.126496,-.1680281,5.332352,-4.575579,-.06761755,.3295335,.1194896,5.570901,.4536185,-1.103074,-.2681801,.06571479,2.396522,-.455128,2.466331,-.1232022,-3.023201,1.086379,-1.053299,-.02697173,.8379121,-.9681458,.5890692,-.4872027,.2936929,7.510139,.3079122,-1.079553,-.2710448,2.462379,-.3713554,-8.534512,1.828242,-.1686398,-1.96134,.8941077,-1.069741,-.1396394,1.657868,3.236313,-2.706344,-.2948122,.1314816,2.868457,.5413403,-1.131649,-.1954455,-7.751595,8.685861,-.04910871,.8992952,.04710143,4.254818,.6821116,-1.156689,-.1884324,3.163519,-3.091522,-.06613927,-.02575883,.1640065,6.073643,.4453468,-1.079224,-.2621389,.9446437,1.448479,-.3969384,2.626638,-.08101186,-3.016355,1.076295,-1.080832,.01033057,-.3500156,-.03281419,.5655512,-1.156742,.453471,8.774122,.2772869,-1.051202,-.2679975,2.719109,-2.190316,-6.878798,2.250481,-.2030252,-2.026527,.9701096,-1.089849,-.1598589,1.564748,6.869187,-3.05367,-.6110435,.1644472,2.370452,.551177,-1.171419,-.2429746,-8.991334,9.571216,-.02772861,.6688262,.07683478,3.785611,.6347635,-1.228554,-.2917562,2.753986,-2.49178,-.04663434,.3118303,.07546506,4.463096,.5955071,-1.093124,-.2447767,.9097406,.5448296,-.2957824,2.024167,-.0005152333,-1.069081,.9369565,-1.056994,.01569507,-.8217491,1.870818,.706193,-1.483928,.5978206,6.864902,.3673332,-1.054871,-.2758129,2.712807,-5.95011,-6.554039,2.447523,-.1895171,-1.454292,.9131738,-1.100218,-.1746241,1.438505,11.15481,-3.266076,-.8837357,.19701,1.991595,.5907821,-1.207267,-.291361,-11.03767,11.40724,-.014168,.5564047,.08476262,3.371255,.6221335,-1.429698,-.5374218,2.837524,-2.221936,-.02422337,.09313758,.0719025,1.869022,.5609035,-1.002274,-.0697281,.4031308,-.3932997,-.1521923,2.390646,-.0689399,2.999661,1.017843,-1.081168,-.1178666,-.496808,3.919299,.6046866,-2.440615,.7891538,2.140835,.274047,-1.050727,-.2307688,2.276396,-9.454407,-5.505176,2.99262,-.2450942,.6078372,.9606765,-1.103752,-.1810202,1.375044,15.89095,-3.438954,-1.265669,.2475172,1.680768,.5978056,-1.244324,-.3378542,-11.11001,11.37784,-.007896794,.4808023,.09249904,3.025816,.5880239,-1.593165,-.7027621,2.220896,-1.437709,-.01534738,.06286958,.06644555,1.091727,.547008,-.9136506,.01344874,.7772636,-1.209396,-.1408978,2.433718,-.1041938,3.791244,1.037916,-1.134968,-.1803315,-.9267335,4.57667,.6851928,-2.805,.8687208,1.161483,.2571688,-1.017037,-.2053943,2.36164,-9.887818,-5.122889,3.287088,-.2594102,.8578927,.959234,-1.118723,-.1934942,1.226023,16.7414,-3.277335,-1.629809,.2765232,1.637713,.6113963,-1.314779,-.4119915,-12.4115,12.41578,.002344284,.2980837,.1414613,2.781731,.4998556,-1.926199,-1.020038,2.5692,-1.081159,-.02266833,.3588668,.008750078,-.2452171,.4796758,-.7780002,.1850647,.04445456,-2.409297,-.07816346,1.54679,-.02807227,5.998176,1.132396,-1.179326,-.357833,-.2392933,6.467883,.5904596,-1.869975,.8045839,-2.498121,.1610633,-1.009956,-.1311896,1.726577,-12.19356,-3.466239,2.343602,-.2252205,2.573681,1.027109,-1.11246,-.2063093,1.233051,20.58946,-4.578074,-1.145643,.3160192,1.420159,.5860212,-1.371689,-.4914196,-10.7661,11.07405,-.01485077,.5936218,.03685482,2.599968,.6002204,-2.436997,-1.377939,.02130141,1.079593,-.01796232,-.03933248,.1610711,-.6901181,.1206416,-.8743368,.0733137,.8734259,-3.743126,-.03151167,1.297596,-.07634926,6.532873,1.435737,-.9810197,-.3521634,-.2855205,7.134674,.6839748,-1.394841,.6952036,-4.633104,-.02173401,-1.122958,-.1691536,1.38236,-11.02913,-2.608171,1.865111,-.1345154,3.112342,1.094134,-1.075586,-.2077415,1.171477,17.9327,-4.656858,-1.036839,.3338295,1.042793,.5739374,-1.465871,-.6364486,-8.833718,9.34365,-.032236,.7552848,-3121341e-12,2.249164,.8094662,-2.448924,-1.270878,-4.823703,5.853058,-.02149127,.03581132,-.001230276,.4892553,-.1597657,-2.419809,-1.071337,1.575648,-4.98358,.009545185,.5032615,.4186266,4.634147,1.433517,-.1383278,-.02797095,-.1943067,6.679623,.411828,-.2744289,-.02118722,-4.337025,.1505072,-1.341872,-.2518572,1.027009,-6.527103,-1.081271,1.015465,.2845789,2.470371,.927812,-1.04064,-.2367454,1.100744,8.827253,-4.560794,-.7287017,.2842503,.6336593,.6327335,-1.877993,-1.025135,-4.311037,4.715016,-.04711631,.6335844,-7665398e-12,1.788017,.9001409,-2.28154,-1.137668,-10.36869,11.36254,.01961739,-.09836174,-.006734567,1.320918,-.2400807,-4.904054,-2.315781,5.735999,-8.626257,-.1255643,1.545446,.139686,2.972897,1.429934,.4077067,-.1833688,-2.450939,9.119433,.4505361,-1.340828,.397369,-1.78537,.09628711,-1.296052,-.3250526,1.813294,-10.31485,-1.38869,1.239733,-.08989196,-.3389637,.963956,-1.062181,-.2423444,.7577592,15.66938,-4.462264,-.574281,.3262259,.9461672,.6232887],[-1.127942,-.1905548,-12.52356,13.75799,-.03624732,1.055453,.01385036,4.17697,.5928345,-1.15526,-.1778135,6.216056,-5.254116,-.08787445,.8434621,.04025734,6.195322,.3111856,-1.125624,-.3217593,.5043919,1.686284,-.3536071,1.476321,-.07899019,-4.522531,1.271691,-1.081801,-.1033234,.999555,.007482946,-.06776018,1.463141,.09492021,5.612723,.1298846,-1.07532,-.2402711,2.141284,-1.203359,-4.945188,1.437221,-.0809675,-1.028378,1.004164,-1.073337,-.1516517,1.639379,2.304669,-3.214244,1.286245,.05613957,2.480902,.4999363,-1.128399,-.1857793,-10.89863,11.72984,-.03768099,.9439285,.04869335,4.845114,.6119211,-1.114002,-.139928,4.9638,-4.6855,-.07780879,.4049736,.1586297,7.770264,.3449006,-1.185472,-.3403543,.6588322,1.133713,-.4118674,2.061191,-.1882768,-4.372586,1.22353,-1.002272,.02000703,.07073269,1.485075,.5005589,.4301494,.3626541,7.921098,.1574766,-1.121006,-.3007777,2.242051,-4.571561,-7.761071,2.053404,-.1524018,-1.886162,1.018208,-1.058864,-.1358673,1.389667,8.633409,-3.437249,.7295429,.15147,2.842513,.5014325,-1.144464,-.2043799,-10.20188,10.71247,-.03256693,.7860205,.06872719,4.824771,.6259836,-1.170104,-.2118626,4.391405,-4.1989,-.07111559,.3890442,.1024831,6.282535,.5365688,-1.129171,-.255288,.2238298,.7314295,-.356273,1.881931,-.03078716,-1.03912,.9096301,-1.042294,.004450203,-.5116033,2.627589,.6098996,-.1264638,.4325281,7.080503,.4583646,-1.082293,-.2723056,2.065076,-8.143133,-7.892212,2.142231,-.0710624,-1.122398,.8338505,-1.071715,-.1426568,1.095351,17.29783,-3.851931,.4360514,.211444,2.970832,.5944389,-1.195909,-.2590449,-11.91037,12.07947,-.01589842,.6297846,.09054772,4.285959,.5933752,-1.245763,-.3316637,4.29366,-3.694011,-.04699947,.4843684,.02130425,4.097549,.6530809,-1.148742,-.1902509,-.2393233,-.2441254,-.2610918,1.846988,.03532866,2.660106,.8358294,-1.01608,-.0744496,-.5053436,4.388855,.6054987,-1.2083,.5817215,2.54357,.4726568,-1.072027,-.210144,1.518378,-10.60119,-6.016546,2.649475,-.05166992,1.571269,.8344622,-1.072365,-.1511201,.747801,19.00732,-3.950387,-.3473907,.3797211,2.782949,.6296808,-1.239423,-.3136289,-13.511,13.49468,-.007070423,.5012315,.1106008,3.803619,.5577948,-1.452524,-.5676944,2.993153,-2.277288,-.02168954,.305672,.01152338,1.852697,.6427228,-1.061421,-.04590521,.6057022,-1.096835,-.1504952,2.344921,-.05491832,5.268322,.9082253,-1.042373,-.1769498,-1.075388,3.831712,.315414,-2.416458,.7909032,-.01492892,.3854049,-1.064159,-.1892684,1.438685,-8.166362,-3.616364,3.275206,-.1203825,2.039491,.8688057,-1.07012,-.1569508,.412476,13.99683,-3.547085,-1.046326,.4973825,2.791231,.6503286,-1.283579,-.3609518,-13.35397,13.15248,-.0004431938,.3769526,.1429824,3.573613,.4998696,-1.657952,-.7627948,1.958222,-.7949816,-.02882837,.5356149,-.05191946,.8869955,.626332,-.95276,.06494189,.5361303,-2.12959,-.0925863,1.604776,.0506777,6.376055,.9138052,-1.080827,-.252312,-.7154262,4.120085,.1878228,-1.492158,.6881655,-1.446611,.4040631,-1.054075,-.1665498,.9191052,-6.636943,-1.894826,2.10781,-.03680499,2.655452,.841384,-1.061127,-.1448849,.2667493,10.34103,-4.285769,-.3874504,.5998752,3.132426,.6652753,-1.347345,-.4287832,-9.305553,9.133813,-.003173527,.3977564,.115142,3.320564,.4998134,-1.927296,-.9901372,-2.593499,4.087421,-.05833993,.8158929,-.04681279,.2423716,.4938052,-.9470092,.07325237,2.064735,-5.16754,-.01313751,.4832169,.1126295,6.970522,1.035022,-1.022557,-.2762616,-.9375748,6.696739,.2200765,-.1133253,.5492505,-3.109391,.3321914,-1.087444,-.1836263,.6225024,-8.576765,-1.107637,.7859427,.09910909,3.112938,.8596261,-1.051544,-.1546262,.2371731,12.00502,-4.527291,.07268862,.5571478,2.532873,.6662,-1.375576,-.4840019,-8.12129,8.05814,-.01445661,.5123314,.05813321,3.203219,.5442318,-2.325221,-1.241463,-7.06343,8.741369,-.0782995,.8844273,-.03471106,.1740583,.2814079,-1.2287,-.2013412,2.949042,-7.371945,.1071753,-.249197,.2265223,6.391504,1.172389,-.7601786,-.1680631,-.7584444,8.541356,.08222291,.6729633,.3206615,-3.70094,.2710054,-1.191166,-.2672347,.2927498,-9.713613,-.4783721,.2352803,.2161949,2.691481,.8745447,-1.030135,-.1653301,.2263443,12.96157,-4.650644,.007055709,.5091975,2.00037,.6603839,-1.508018,-.6460933,-6.402745,6.545995,-.0375032,.6921803,.003309819,2.797527,.6978446,-2.333308,-1.167837,-17.46787,18.6863,-.008948229,.5621946,-.03402626,1.217943,.01149865,-2.665953,-1.226307,7.169725,-11.59434,.0358342,-.3074378,.3412248,4.422122,1.283791,-.09705116,.08312991,-2.160462,10.28235,.03543357,1.032049,.105831,-2.972898,.2418628,-1.329617,-.3699557,.5560117,-9.730113,.09938865,-.3071488,.2510691,1.777111,.8705142,-1.019387,-.1893247,.1194079,12.39436,-4.799224,.2940213,.4841268,1.529724,.6582615,-1.896737,-1.005442,-6.411032,6.54822,-.03227596,.5717262,-8115192e-12,2.296704,.9000749,-2.411116,-1.225587,-17.53629,18.29393,.01247555,.2364616,-.005114637,1.603778,-.2224156,-4.707121,-2.074977,7.9423,-11.32407,-.05415654,.5446811,.1032493,4.010235,1.369802,.1010482,-.4013305,-2.674579,9.779409,.1782506,.7053045,.4200002,-2.400671,.1953165,-1.243526,-.3391255,.8848882,-9.789025,-.3997324,-.9546227,-.1044017,.6010593,.8714462,-1.014633,-.1730009,-.07738934,13.90903,-4.847307,1.076059,.5685743,1.572992,.6561432,-1.122998,-.1881183,-10.30709,11.58932,-.04079495,.9603774,.03079436,4.009235,.5060745,-1.13479,-.1539688,5.478405,-4.21727,-.1043858,.7165008,.01524765,6.473623,.4207882,-1.134957,-.3513318,.7393837,1.354415,-.4764078,1.690441,-.0549264,-5.563523,1.145743,-1.058344,-.05758503,1.16823,.3269824,.1795193,.7849011,.07441853,6.904804,.281879,-1.075194,-.2355813,2.463685,-1.536505,-7.505771,.9619712,-.06465851,-1.355492,.8489847,-1.07903,-.1465328,1.773838,2.310131,-3.136065,.3507952,.04435014,2.819225,.5689008,-1.125833,-.1870849,-9.555833,10.59713,-.04225402,.9164663,.04338796,4.40098,.6056119,-1.12744,-.1551891,4.755621,-4.408806,-.07851763,.2268284,.146007,7.048003,.3525997,-1.143788,-.3170178,.5480669,2.04183,-.4532139,2.302233,-.1887419,-4.489221,1.250967,-1.032849,.007376031,.5666073,-.2312203,.4862894,-.1748294,.357287,8.380522,.1302333,-1.093728,-.2786977,2.641272,-1.507494,-8.731243,1.684055,-.2023377,-2.176398,1.013249,-1.076578,-.1456205,1.693935,2.945003,-2.822673,-.2520033,.1517034,2.649109,.5179094,-1.146417,-.2119353,-7.187525,8.058599,-.05256438,.8375733,.03887093,4.222111,.6695347,-1.173674,-.2067025,2.899359,-2.804918,-.08473899,.003944225,.1340641,6.160887,.4527141,-1.090098,-.2599633,.9180856,1.09271,-.4215019,2.42766,-.09277667,-2.123523,1.058159,-1.08446,.008056181,-.245351,.6619567,.4668118,-.9526719,.4648454,8.001572,.3054194,-1.053728,-.2765784,2.792388,-3.489517,-8.150535,2.195757,-.2017234,-2.128017,.9326589,-1.099348,-.1593939,1.568292,7.247853,-2.933,-.5890481,.172444,2.433484,.5736558,-1.185983,-.2581184,-7.761056,8.317053,-.03351773,.6676667,.05941733,3.820727,.6324032,-1.268591,-.3398067,2.348503,-2.023779,-.05368458,.1083282,.08402858,3.910254,.5577481,-1.071353,-.1992459,.7878387,.1974702,-.3033058,2.335298,-.08205259,.7954454,.9972312,-1.089513,-.03104364,-.5995746,2.330281,.6581939,-1.821467,.6679973,5.090195,.3125161,-1.040214,-.2570934,2.660489,-6.506045,-7.053586,2.763153,-.2433632,-.7648176,.9452937,-1.116052,-.1831993,1.457694,11.63608,-3.216426,-1.045594,.2285002,1.817407,.5810396,-1.230134,-.3136264,-8.909301,9.145006,-.01055387,.4467317,.1016826,3.342964,.563384,-1.442907,-.5593147,2.156447,-1.241657,-.0351213,.3050274,.01797175,1.742358,.5977153,-1.027627,-.06481539,.4351975,-1.051677,-.2030672,1.942684,-.03615993,4.050266,.9801624,-1.08211,-.1578209,-.3397511,4.163851,.6650368,-1.84173,.7062544,.6789881,.3172623,-1.047447,-.197756,2.183364,-8.805249,-5.483962,2.551309,-.177964,1.519501,.9212536,-1.111853,-.1935736,1.394408,13.92405,-3.46543,-1.068432,.2388671,1.455336,.6233425,-1.262238,-.3546341,-10.08703,10.20084,-.001852187,.353758,.1239199,3.056093,.5132052,-1.61381,-.7355585,2.760123,-1.685253,-.02517552,.2914258,.004743448,.8689596,.5674192,-.9462336,.02950767,-.2613816,-.7398653,-.1315558,1.901042,-.06447844,4.969341,1.027342,-1.111481,-.2194054,-.09004538,3.983442,.4871278,-1.965315,.7956121,-.2363225,.2718037,-1.036397,-.1827106,1.964747,-8.870759,-4.208011,2.461215,-.2158905,1.561676,.9436866,-1.113769,-.1947819,1.30072,15.16476,-4.088732,-1.069384,.2836434,1.671451,.6229612,-1.328069,-.4244047,-8.41704,8.552244,-.006813504,.4127422,.09619897,2.854227,.505988,-1.927552,-1.02529,.9529576,.425595,-.03738779,.2584586,.04911004,-.2640913,.4138626,-.8488094,.1435988,.6356807,-2.895732,-.08473961,1.701305,-.1323908,6.499338,1.210928,-1.128313,-.3397048,-.404314,6.265097,.5482395,-2.057614,.8884087,-2.943879,.09760301,-1.039764,-.1494772,1.781915,-11.53012,-3.379232,2.517231,-.2764393,2.588849,1.05212,-1.108447,-.2012251,1.19864,19.25331,-4.423892,-1.257122,.339569,1.48122,.5880175,-1.374185,-.4967434,-7.401318,7.724021,-.02345723,.5979653,.02436346,2.65897,.6014891,-2.310933,-1.29029,-1.301909,2.557806,-.03744449,.08982861,.1090613,-.4398363,.1184329,-1.12473,-.0992183,1.366902,-4.172489,-.05078016,1.393597,-.09323843,6.452721,1.435913,-.8468477,-.2744819,-.43472,6.713362,.6127133,-1.685634,.7360941,-4.535502,-.02920866,-1.165242,-.2008697,1.438778,-10.08936,-2.214771,2.102909,-.1763085,2.859075,1.09347,-1.074614,-.2066374,1.131891,16.30063,-4.801441,-1.11259,.3595785,1.122227,.579461,-1.521515,-.6835604,-5.571044,6.028774,-.04253715,.6875746,-5279456e-12,2.18015,.8487705,-2.240415,-1.171166,-7.182771,8.417068,-.01932866,.1101887,-.01098862,.6242195,-.2393875,-2.712354,-1.19883,3.1802,-6.76813,-.002563386,.7984607,.2764376,4.695358,1.557045,-.03655172,-.02142321,-.913812,7.932786,.3516542,-.7994343,.1786761,-4.208399,.01820576,-1.36861,-.2656212,1.249397,-8.317818,-.8962772,1.423249,.1478381,2.19166,1.007748,-1.041753,-.2453366,1.061102,11.30172,-4.739312,-.9223334,.2982776,.6162931,.6080302,-1.989159,-1.09516,-2.91555,3.275339,-.05735765,.5742174,-7683288e-12,1.7634,.9001342,-2.07002,-1.086338,-10.95898,12.0696,.03780123,-.01774699,-.0005881348,1.333819,-.2605423,-5.249653,-2.38304,6.160406,-9.097138,-.1955319,1.651785,.0006016463,3.021824,1.493574,.4685432,-.2358662,-2.666433,9.685763,.5804928,-1.521875,.5668989,-1.548136,.01688642,-1.296891,-.3449031,1.928548,-11.6756,-1.627615,1.355603,-.1929074,-.6568952,1.009774,-1.067288,-.2410392,.7147961,17.8384,-4.374399,-.6588777,.3329831,1.012066,.6118645],[-1.310023,-.4407658,-36.4034,36.83292,-.008124762,.5297961,.01188633,3.13832,.5134778,-1.4241,-.5501606,-17.5351,18.22769,-.01539272,.6366826,.002661996,2.659915,.4071138,-1.103436,-.1884105,6.425322,-6.910579,-.02019861,.3553271,-.01589061,5.345985,.8790218,-1.1862,-.4307514,-3.957947,5.979352,-.05348869,1.736117,.03491346,-2.692261,.5610506,-1.006038,-.1305995,4.473513,-3.806719,.1419407,-.02148238,-.05081185,3.735362,.535828,-1.078507,-.1633754,-3.812368,4.3817,.02988122,1.754224,.1472376,3.722798,.4999157,-1.333582,-.4649908,-33.59528,34.04375,-.009384242,.5587511,.00572631,3.073145,.5425529,-1.562624,-.7107068,-14.7817,15.59839,-.01462375,.5050133,.02516017,1.604696,.2902403,-.8930158,.04068077,1.373481,-2.342752,-.02098058,.6248686,-.05258363,7.058214,1.150373,-1.262823,-.4818353,889261e-9,1.92312,-.04979718,1.040693,.1558103,-2.85248,.2420691,-.9968383,-.1200648,1.324342,-.9430889,.1931098,.4436916,-.07320456,4.215931,.7898019,-1.078185,-.1718192,-1.720191,2.358918,.02765637,1.260245,.2021941,3.395483,.5173628,-1.353023,-.4813523,-31.0492,31.40156,-.009510741,.554203,.008135471,3.136646,.5215989,-1.624704,-.7990201,-21.67125,22.46341,-.01163533,.5415746,.02618378,1.139214,.3444357,-.798361,.1417476,9.914841,-10.81503,-.01218845,.3411392,-.06137698,7.445848,1.18008,-1.266679,-.4288977,-5.818701,6.986437,-.08180711,1.397403,.2016916,-1.275731,.2592773,-1.009707,-.1537754,3.496378,-3.013726,.242115,-.2831925,.03003395,3.702862,.774632,-1.075646,-.1768747,-1.347762,1.989004,.01375836,1.76481,.1330018,3.230864,.662621,-1.375269,-.5103569,-34.42661,34.78703,-.008460009,.5408643,.004813323,3.016078,.5062069,-1.821679,-.9766461,-19.26488,19.97912,-.009822567,.3649556,.04316092,.893019,.4166527,-.6633542,.1997841,2.395592,-3.117175,-.01080884,.8983814,-.1375825,6.673463,1.115663,-1.30324,-.3612712,.08292959,.3381364,-.06078648,.3229247,.3680987,.7046755,.3144924,-.9952598,-.2039076,.4026851,.2686684,.1640712,.5186341,-.0120552,2.659613,.8030394,-1.098579,-.2151992,.6558198,-74369e-8,-.001421817,1.073701,.1886875,2.536857,.6673923,-1.457986,-.5906842,-38.12464,38.38539,-.006024357,.4741484,.01209223,2.818432,.5012433,-1.835728,-1.003405,-6.848129,7.601943,-.01277375,.4785598,.03366853,1.097701,.4636635,-.8491348,.009466365,-2.685226,2.00406,-.01168708,.6752316,-.1543371,5.674759,1.039534,-1.083379,-.150679,.7328236,-.5095568,-.08609153,.444882,.4174662,1.481556,.3942551,-1.117089,-.3337605,.2502281,.4036323,.2673899,.2829817,.0224245,2.043207,.7706902,-1.071648,-.21262,.6069466,-.00145629,-.551596,1.046755,.1985021,2.290245,.6876058,-1.483903,-.6309647,-43.80213,44.10537,-.005712161,.5195992,.002028428,2.687114,.5098321,-2.053976,-1.141473,.5109183,.08060391,-.01033983,.4066532,.04869627,1.161722,.4039525,-.6348185,.07651292,-10.31327,10.07598,-.02083688,.7359516,-.2029459,5.013257,1.077649,-1.22863,-.1650496,.04077157,-.7189167,-.0509222,.2959814,.5111496,2.540433,.361533,-1.041883,-.3278413,-.06691911,1.307364,.2166663,.3000595,-.003157136,1.389208,.7999026,-1.103556,-.2443602,.4705347,-.0009296482,-.530992,.9654511,.2142587,2.244723,.6839976,-1.555684,-.6962113,-46.47983,46.7427,-.005034895,.475509,-9.502561e-7,2.626569,.5056194,-1.998288,-1.12472,-1.629586,2.187993,-.008284384,.3845258,.0572624,1.185644,.4255812,-1.03257,-.251385,-3.721112,3.506967,-.02186561,.9436049,-.2451412,4.725724,1.039256,-.8597532,.09073332,-2.553741,1.993237,-.04390891,-.2046928,.5515623,1.909127,.3948212,-1.210482,-.4477622,-.2267805,1.219488,.1336186,.6866897,.02808997,1.600403,.7816409,-1.078168,-.2699261,.2537282,.3820684,-.4425103,.5298235,.2185217,1.728679,.6882743,-1.697968,-.8391488,-57.90105,58.1412,-.00340476,.426514,-1796301e-12,2.368442,.5324429,-2.141552,-1.17223,16.77872,-16.4147,-.005732425,.2002199,.06841834,1.485338,.3215763,-1.442946,-.7264245,-9.503706,9.650462,-.02120995,1.419263,-.2893098,3.860731,1.120857,-.5696752,.3411279,-.2931035,-.6512552,-.1068437,-1.085661,.6107549,1.459503,.3210336,-1.313839,-.5921371,-.2332222,1.648196,.2492787,1.381033,-.01993392,.981256,.8316329,-1.087464,-.3195534,.2902095,.3383709,-.8798482,.01494668,.2529703,1.452644,.669387,-2.068582,-1.118605,-50.81598,50.97486,-.003280669,.4067371,-2544951e-12,2.179497,.5778017,-1.744693,-.8537207,22.34361,-22.08318,-.005932616,.1035049,.05742772,1.97788,.2124846,-3.287515,-2.140268,-12.49566,12.40091,-.02409349,1.397821,-.2371627,2.771192,1.170496,.5502311,1.04663,2.193517,-2.2204,-.1064394,-1.017926,.4795457,1.030644,.3177516,-1.719734,-.9536198,-.6586821,1.386361,-.02513065,1.187011,.06542539,.5296055,.808266,-1.0057,-.3028096,.04470957,1.00776,-.8119016,.03153338,.2311321,1.182208,.6824758,-2.728867,-1.580388,-30.79627,30.92586,-.004197673,.3154759,-3897675e-12,1.920567,.6664791,-1.322495,-.7249275,14.7766,-14.68154,-.009044857,.05624314,.06498392,2.047389,.0636754,-6.102376,-3.473018,-9.926071,9.637797,-.01097909,1.103498,-.2424521,2.520748,1.24026,1.351796,1.018588,2.009081,-1.333394,-.1979125,-.3318292,.4476624,.9095235,.2955611,-1.774467,-1.07988,-.0808468,.2577697,-.1149295,.4975303,.002931611,-.3803171,.8002794,-.9898401,-.2542513,-.07530911,1.870355,-1.521918,.2405164,.2964615,1.3348,.6789053,-1.27973,-.4290674,-42.77972,43.43305,-.006541826,.4945086,.01425338,2.685244,.5011313,-1.449506,-.5766374,-16.88496,17.81118,-.01121649,.354502,.02287338,1.904281,.4936998,-1.02198,-.1897574,2.482462,-2.941725,-.01570448,.7532578,-.042568,5.23966,.4983116,-1.162608,-.3428049,3.974358,-1.527935,-.03919201,.8758593,.07291363,-3.455257,.8007426,-.9929985,-.08712006,-.7397313,1.348372,.09511685,.3233584,-.07549148,5.806452,.4990042,-1.084996,-.1739767,.1580475,.908818,.06871433,.5933079,.1188921,3.074079,.4999327,-1.317009,-.4661946,-42.55347,43.12782,-.005727235,.4285447,.02189854,2.60831,.51907,-1.469236,-.6282139,-12.41404,13.48765,-.0120477,.5070285,-.0007280216,1.491533,.3635064,-.9713808,-.08138038,.3709854,-1.041174,-.01814075,.506086,-.02053756,6.161431,1.093736,-1.159057,-.3698074,2.711209,-.6006479,-.04896926,.9273957,.1137712,-3.496828,.2867109,-1.011601,-.0820189,.2105725,.459752,.1478925,.213894,-.0566067,6.057755,.7859121,-1.07802,-.181158,.1646622,.8348426,.1149064,.4985738,.1376605,2.746607,.4999626,-1.325672,-.4769313,-41.11215,41.68293,-.006274997,.4649469,.01119411,2.631267,.5234546,-1.619391,-.8000253,-15.34098,16.32706,-.01012023,.4242255,.02931597,.8925807,.3314765,-.7356979,.1368406,2.972579,-3.535359,-.01318948,.460762,-.07182778,6.2541,1.236299,-1.316217,-.4194427,.03489902,1.289849,-.0475596,1.138222,.1975992,-.8991542,.2290572,-.9502188,-.1172703,1.405202,-.3061919,.1058772,-.3760592,-.01983179,3.562353,.7895959,-1.100117,-.1900567,.492503,.5250225,.1576804,1.042701,.07330743,2.796064,.6749783,-1.354183,-.5130625,-42.19268,42.71772,-.005365373,.4136743,.01235172,2.520122,.5187269,-1.741434,-.9589761,-8.230339,9.296799,-.009600162,.4994969,.02955452,.3667099,.3526999,-.6917347,.2154887,-.8760264,.2334121,-.01909621,.4748033,-.1138514,6.51536,1.225097,-1.293189,-.42187,1.620952,-.7858597,-.0376941,.6636786,.3364945,-.5341017,.2128347,-.9735521,-.1325495,1.007517,.2598258,.06762169,.001421018,-.06915987,3.185897,.8641956,-1.0948,-.1962062,.5755591,.2906259,.2625748,.7644049,.1347492,2.677126,.646546,-1.393063,-.5578338,-41.85249,42.33504,-.00543564,.4743765,.007422477,2.442801,.5211707,-1.939487,-1.128509,-8.974257,9.978383,-.007965597,.294883,.04436763,.2839868,.3440424,-.6011562,.2354877,-3.07982,2.585094,-.02002701,.7793909,-.1598414,5.834678,1.202856,-1.315676,-.3903446,1.7019,-1.304609,-.01045121,.2747707,.4143967,.3197102,.263758,-.9618628,-.1625841,1.187138,.1497802,-5590954e-12,.03178475,-.04153145,2.496096,.8195082,-1.111554,-.2365546,.7831875,.2018684,.2074369,.7395978,.122573,1.876478,.6821167,-1.427879,-.5994879,-35.31016,35.81581,-.006431497,.4554192,.0007348731,2.334619,.5233377,-1.998177,-1.206633,-21.4651,22.42237,-.005857596,.2755663,.06384795,.1358244,.3328437,-.644063,.2058571,2.155499,-2.587968,-.01840023,.8826555,-.2222452,5.847073,1.228387,-1.229071,-.3360441,-.3429599,.6179469,.00202961,.08899319,.5041624,.1882964,.225204,-1.022905,-.2101621,1.915689,-.6498794,-.03463651,.08954605,-.06797854,2.417705,.8568618,-1.082538,-.2007723,.4731009,.4077267,.1324289,.651488,.1702912,2.309383,.6600895,-1.472139,-.6499815,-34.28465,34.69659,-.005747023,.4174167,.001688597,2.323046,.5395191,-2.161176,-1.353089,-22.26827,23.29138,-.005583808,.2364793,.06096656,.001944666,.2861624,-.6593044,.1393558,4.698373,-5.193883,-.0199839,1.095635,-.2391254,5.598103,1.236193,-1.195717,-.2972715,.04648953,.3024588,.005003313,-.3754741,.5247265,-.1381312,.2493896,-1.020139,-.2253524,.3548437,.7030485,-.02107076,.4581395,-.03243757,2.453259,.8323623,-1.09877,-.243578,.8761614,.1941613,-.1990692,.3761139,.1657412,1.590503,.6741417,-1.648007,-.8205121,-44.35106,44.79801,-.004181353,.385483,-1842385e-12,2.000281,.5518363,-2.140986,-1.282239,-3.979213,4.672459,-.005008582,.242192,.06253602,.6612713,.2555851,-1.300502,-.5137898,.5179821,-.4032341,-.02066785,1.087929,-.2615309,4.225887,1.229237,-.696334,.0924106,.06936356,-.3588571,-.05461843,-.5616643,.5484166,-.04776267,.2414935,-1.233179,-.4325498,.6479813,.8368356,.2458875,.6464752,-.02897097,1.561773,.8518598,-1.051023,-.253369,1.004294,.3028083,-1.520108,.1607013,.1619975,1.131094,.6706655,-1.948249,-1.097383,-44.53697,44.94902,-.003579939,.3491605,-2500253e-12,1.740442,.6188022,-2.154253,-1.209559,4.144894,-3.562411,-.005638843,.1067169,.07594858,1.00528,.1072543,-2.513259,-1.507208,-1.602979,1.404154,-.00556075,1.24049,-.2852117,3.485252,1.349321,-.07832214,.3655626,.3856288,.6867894,-.1609523,-.6704306,.5357301,-.6457935,.1479503,-1.354784,-.5454375,.8797469,-1.466514,.713442,.5934903,-.02911178,.8643737,.9030724,-1.048324,-.2738736,.8783074,3.246188,-4.435369,.1251791,.1783486,1.064657,.6522878,-2.770408,-1.618911,-25.04031,25.31674,-.004239279,.3241013,-3764484e-12,1.586843,.7035906,-1.9135,-1.144014,-10.80587,11.53677,-.01003197,.1577515,.05217789,1.225278,.005172771,-5.293208,-2.876463,2.087053,-3.201552,.003892964,.532393,-.2034512,2.61776,1.273597,.906034,.3773409,-.6399945,3.213979,-.09112172,.6494055,.395328,.5047796,.2998695,-1.482179,-.677831,1.161775,-3.004872,.4774797,-.4969248,-.003512074,-1.30719,.7927378,-.9863181,-.1803364,.5810824,4.58057,-3.863454,.5328174,.2272821,1.771114,.6791814]],Fc=[[1.560219,1.417388,1.206927,10.91949,5.931416,7.304788,1.533049,1.560532,.3685059,13.5504,5.543711,7.792189,1.471043,1.746088,-.9299697,17.20362,5.473384,8.336416,1.355991,2.109348,-3.295855,22.64843,5.454607,9.304656,1.244963,2.547533,-5.841485,27.56879,5.576104,10.43287,1.175532,2.784634,-7.212225,29.75347,6.47298,10.92331,1.082973,3.118094,-8.934293,31.86879,8.473885,11.74019,.96925,3.349574,-10.0381,31.47654,13.38931,12.72547,.8547044,3.151538,-9.095567,25.54995,22.73219,14.10398,.758034,2.311153,-5.170814,12.29669,36.86529,15.98882,1.664273,1.574468,1.422078,9.768247,14.47338,16.44988,1.638295,1.719586,.5786675,12.39846,14.15419,17.28605,1.572623,1.921559,-.7714802,16.09246,14.20954,18.25908,1.468395,2.21197,-2.845869,20.75027,15.24822,19.37622,1.355047,2.556469,-4.96092,24.60237,16.4836,20.65648,1.291642,2.742036,-6.061967,26.02002,18.19144,21.16712,1.194565,2.97212,-7.295779,26.91805,21.2488,22.01819,1.083631,3.047021,-7.766096,24.96261,27.44264,22.91875,.9707994,2.736459,-6.308284,17.6086,37.76291,23.9215,.8574294,1.865155,-2.364707,4.337793,50.92831,25.23432],[1.632341,1.39523,1.375634,12.38193,5.921102,7.766508,1.597115,1.554617,.3932382,15.05284,5.725234,8.158155,1.522034,1.844545,-1.322862,19.18382,5.440769,8.837119,1.403048,2.290852,-4.013792,24.851,5.521888,9.845547,1.286364,2.774498,-6.648221,29.64151,5.923777,10.97075,1.213544,3.040195,-8.092676,31.86082,6.789782,11.58899,1.122622,3.347465,-9.649016,33.43824,9.347715,12.31374,1.007356,3.543858,-10.5352,32.39842,14.83962,13.31718,.8956642,3.2787,-9.254933,25.57923,24.89677,14.76166,.7985143,2.340404,-4.928274,11.41787,39.61501,16.82448,1.745162,1.639467,1.342721,11.66033,14.90124,17.74031,1.708439,1.819144,.2834399,14.48066,14.59214,18.58679,1.63172,2.094799,-1.378825,18.43198,14.63173,19.62881,1.516536,2.438729,-3.624121,22.98621,15.99782,20.70027,1.405863,2.785191,-5.705236,26.45121,17.6833,21.91903,1.344052,2.951807,-6.683851,27.44271,19.85706,22.29452,1.245827,3.182923,-7.82296,27.91395,23.27254,23.1591,1.132305,3.202593,-8.008429,25.21093,30.00014,24.05306,1.02033,2.820556,-6.238704,17.09276,40.77916,25.09949,.903157,1.863917,-1.955738,3.032665,54.3429,26.4178],[1.168084,2.156455,-3.980314,19.89302,13.28335,14.35621,1.135488,2.294701,-4.585886,20.90208,13.4784,14.67658,1.107408,2.382765,-5.112357,21.47823,14.93128,14.60882,1.054193,2.592891,-6.115,22.68967,16.35672,15.18999,1.006946,2.70542,-6.69893,22.9183,18.34324,15.70651,.9794044,2.74244,-6.805283,22.25271,20.50797,15.6313,.9413577,2.722009,-6.760707,20.98242,23.42588,16.05011,.8917923,2.59278,-6.152635,17.74141,28.58324,16.5791,.8288391,2.153434,-4.118327,10.78118,36.8171,17.38139,.7623528,1.418187,-.8845235,.7590129,46.29859,19.21657,1.352858,2.048862,-2.053393,14.05874,30.45344,30.4443,1.330497,2.126497,-2.466296,14.67559,30.90738,30.69707,1.286344,2.200436,-2.877228,14.92701,32.36288,30.77223,1.234428,2.289628,-3.404699,14.99436,34.6839,30.84842,1.17866,2.306071,-3.549159,14.11006,37.54188,30.7973,1.151366,2.333005,-3.728627,13.63374,39.05894,30.92599,1.101593,2.299422,-3.565787,11.96745,41.88472,31.02755,1.038322,2.083539,-2.649585,8.037389,47.00869,30.65948,.9596146,1.67147,-.8751538,1.679772,53.45784,30.5452,.8640731,.9858301,1.854956,-6.798097,59.36468,31.10255]],Bc={getTableValue:function(e,t,n,r,i){return Oc[e][540*t+54*(n-1)+9*r+i]},getTableValueRad:function(e,t,n,r){return Fc[e][60*t+6*(n-1)+r]}};function zc(e,r,i,a,o){return Vc(e).reduce(function(e,t,n){return e+t*Bc.getTableValue(r,i,a,n,o)},0)}function Uc(e,r,i,a){return Vc(e).reduce(function(e,t,n){return e+t*Bc.getTableValueRad(r,i,a,n)},0)}function Vc(e){var t=Math.pow(2*e/Math.PI,1/3);return[Math.pow(1-t,5),5*Math.pow(1-t,4)*t,10*Math.pow(1-t,3)*Math.pow(t,2),10*Math.pow(1-t,2)*Math.pow(t,3),5*(1-t)*Math.pow(t,4),Math.pow(t,5)]}var kc={getDistParams:function(e,t,n,r){for(var i=new Array(9),a=Math.trunc(e),o=e-a,s=0;s<9;s++){var l,c,u=zc(n,r,0,a,s),d=zc(n,r,1,a,s);i[s]=(1-t)*(1-o)*u+t*(1-o)*d,10!=a&&(l=zc(n,r,0,a+1,s),c=zc(n,r,1,a+1,s),i[s]+=(1-t)*o*l+t*o*c)}return i},getRadiance:function(e,t,n,r){var i=Math.trunc(e),a=e-i,o=(1-t)*(1-a)*Uc(n,r,0,i)+t*(1-a)*Uc(n,r,1,i);return 10!=i&&(o+=(1-t)*a*Uc(n,r,0,i+1)+t*a*Uc(n,r,1,i+1)),o}};function Gc(e,t,n,r){Dc.call(this,e,t,n,r)}Gc.prototype=Object.assign(Object.create(Dc.prototype),{constructor:Gc,interpolate_:function(e,t,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=(n-t)/(r-t),u=1-c,d=0;d!==o;++d)i[d]=a[l+d]*u+a[s+d]*c;return i}});var jc=[[.1787,-1.463,-.3554,.4275,-.0227,5.3251,.1206,-2.5771,-.067,.3703],[-.0193,-.2592,-.0665,8e-4,-4e-4,.2125,-.0641,-.8989,-.0033,.0452],[-.0167,-.2608,-.095,.0092,-.0079,.2102,-.0441,-1.6537,-.0109,.0529]],Wc=[[4.0453,-4.971,-.2155,2.4192],[.00166,-.00375,.00209,0,-.02903,.06377,-.03202,.00394,.11693,-.21196,.06052,.25886],[.00275,-.0061,.00317,0,-.04214,.0897,-.04153,.00516,.15346,-.26756,.0667,.26688]],Xc=function(e,t,n){return jc[e][2*t+n]},Hc=function(e){return Wc[e]};function Yc(e,t,n){return(1+e[0]*Math.exp(e[1]/Math.cos(t)))*(1+e[2]*Math.exp(e[3]*n)+e[4]*Math.pow(Math.cos(n),2))}var qc={getDistParams:function(e,t){for(var n=new Array(5),r=0;r<5;r++)n[r]=Xc(t,r,0)*e+Xc(t,r,1);return n},getZenithParams:function(e,t,n){switch(n){case 0:var r=new rn((o=Hc(n))[0],o[1],o[2],o[3]),i=Math.tan((4/9-e/120)*(Math.PI-2*t)),a=new rn(e*i,i,e,1);return.06*r.dot(a)/Yc(this.getDistParams(e,n),0,t);case 1:case 2:var o=Hc(n),s=Math.pow(t,2),l=Math.pow(t,3),r=new un(o[0]*l+o[1]*s+o[2]*t+o[3],o[4]*l+o[5]*s+o[6]*t+o[7],o[8]*l+o[9]*s+o[10]*t+o[11]);return new un(Math.pow(e,2),e,1).dot(r)/Yc(this.getDistParams(e,n),0,t)}},getSunIlluminance:function(e,t){var n=[0,0,0];if(e[1]<0)return n;for(var r,i=[.605,.54,.445],a=[12.25,7.5,.3],o=.04608*t-.04586,s=1/(e[1]+.15*Math.pow(93.885-Math.acos(e[1])*(180/Math.PI),-1.253)),l=[1.05513096,.993359745,.903543472],c=0;c<3;c++){var u=Math.exp(.008735*-s*Math.pow(i[c],-4.08)),d=Math.exp(-s*o*Math.pow(i[c],-1.3)),h=Math.exp(.0035*-a[c]*s);n[c]=128e3*l[c]/(.212671*(r=l[c])+.71516*r+.072169*r),n[c]*=u*d*h}return n},getSunIntegral:function(e,t,n,r){var i=e,a=t,o=n;function s(e){return e*e}var l=1-cos(i),c=((s(Math.PI)-2*s(i-a))*cos(i)-s(Math.PI)*cos(a))/(2*(i-a+Math.PI)*(-i+a+Math.PI)),u=o*((.0892351-.00247875*s(o))*sin(o)+cube(o)+24*o+.029745*o*cos(o))/s(s(o)+36);return 2*Math.PI*(l+c+r*u)}};function Zc(e,t,n){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==n?n:0,this}Object.assign(Zc.prototype,{set:function(e,t,n){return this.radius=e,this.phi=t,this.theta=n,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.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Kt.clamp(t/this.radius,-1,1))),this}});var Qc=12,Kc=20,Jc=0,$c=2,eu=22,tu=5,nu=2,ru=8,iu=21,au=0,ou=9,su=10,lu=1,cu=1,uu=0,du=0,hu=24,pu=5,fu=1,mu=3,vu=3,gu=8,_u=256,yu=512,xu={BEVEL_BL:1,BSDF_DIFFUSE_BL:2,BSDF_GLASS_BL:3,BSDF_GLOSSY_BL:2,BSDF_PRINCIPLED_BL:19,"BSDF_PRINCIPLED_<2.80.64_BL":17,BSDF_REFRACTION_BL:3,BSDF_TRANSLUCENT_BL:1,BUMP_BL:5,"BUMP_<2.81_BL":3,FRESNEL_BL:1,LAYER_WEIGHT_BL:1};function bu(e){Br.call(this);var t,n,me=this;function x(e,t){for(var n=e.node(t),r=(n.originData.type,0);r<n.originData.inputs.length;r++)m(e,t,n.originData,r)}function m(e,t,n,r,i){if(!be(e,t,r)){i=i||"Input "+r;var a=n.inputs[r],o={name:n.name+" "+i,type:"",inputs:[],outputs:[]};switch(Le(a)){case"float":o.type="VALUE"+n.type.slice(-3),o.outputs.push(a);break;case"vec3":o.type="RGB"+n.type.slice(-3);var s=a.slice();s.push(1),o.outputs.push(s);break;case"vec4":o.type="RGB"+n.type.slice(-3),o.outputs.push(a);break;default:throw new Error("Unsupported group input")}e.addNode({originData:o});var l=new Ic.Edge(e.len()-1,t,0);l.connections=[];var c={from:0,to:r};return l.connections.push(c),e.addEdge(l),1}}function M(e,t){for(var n=0;n<e.len();n++){if(e.node(n).originData.type==t)return n}return-1}function ve(e,t){Array.isArray(t)||(t=[t]);for(var n=0,r=0;r<e.len();r++)for(var i=e.node(r),a=0;a<t.length;a++){var o=t[a];i.originData.type==o&&n++}return n}function w(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(i.from()==t&&i.to()==n)return i}return null}function v(e){return!(!g(e)&&"FALLOFF_MX"!=e)}function g(e){return"BITMAP_ENV_MX"==e||"REFLECT_REFRACT_MX"==e}function ge(e,t){switch(e){case"BITMAP_ENV_MX":return t==tu;case"FALLOFF_MX":return t==nu;case"MATERIAL_MX":return t==ru;case"PHYSICAL_MX":return t==iu||t==eu;case"REFLECT_REFRACT_MX":return t==au;default:return!1}}function A(e){return-1<e.type.indexOf("uniform")}function S(e){return-1<e.type.indexOf("varying")}function _e(e,t){return t=Jr(t)?t:"color",me.nodeVCAliases[e]||t}function ye(e,t,n,r){var i=new qi(e,t,1,n,r,nn.DEFAULT_MAPPING,Qe,Qe,tt,tt);return i.needsUpdate=!0,i}function xe(e){switch(e){case Et:return"1";case Pt:return"2";default:return"0"}}function r(e){for(var t,n=0,r=0,i=0,a=0,o=0;o<e.len();o++){var s=(se=(oe=e.node(o)).originData).type;oe.attributes=[],oe.params=[],oe.inputFactors=[],oe.inputs=[],oe.outputs=[],Jr(se.inputFactors)&&(oe.inputFactors=se.inputFactors.slice(0));for(var l,c=0;c<se.outputs.length;c++){var u=se.outputs[c];oe.outputs.push({name:s.toLowerCase()+"_out"+c+"_n"+o,type:Le(u),clamp:!1,normalize:!1})}switch("OUTPUT_MATERIAL_BL"!=s&&"OUTPUT_WORLD_BL"!=s&&"OUTPUT_MX"!=s&&"OUTPUT_MY"!=s&&"SHADING_ENGINE_MY"!=s&&"MATERIAL_GF"!=s||oe.outputs.push({name:"outgoingLight",type:"",clamp:!1,normalize:!1}),s){case"ATTRIBUTE_BL":(ae=_e(se.colorLayer,""))?(_=Ce(ae,3),oe.attributes.push({name:ae,type:"attribute vec3",paramVary:_}),oe.params.push(_)):oe.params.push(Ee("vec3(0.0)"));break;case"BSDF_DIFFUSE_BL":case"BSDF_GLASS_BL":case"BSDF_GLOSSY_BL":oe.params.push(Ee("geometryNormal"));break;case"BSDF_PRINCIPLED_BL":oe.params.push(Ee("geometryNormal")),(0<se.inputs[Qc]||be(e,o,Qc))&&(me.advancedPBR=!0);break;case"BSDF_REFRACTION_BL":oe.params.push(Ee("geometryNormal")),oe.params.push(Ee("BSDF_REFRACTION_"+se.distribution));break;case"BUMP_BL":oe.params.push(Ae(s,o,se.invert,"inv"));break;case"CAMERA_BL":oe.params.push(Ee("vViewPosition")),0<ve(e,"OUTPUT_MATERIAL_BL")||0<ve(e,"OUTPUT_WORLD_BL")?oe.params.push(Ee("1")):oe.params.push(Ee("0"));break;case"CURVE_RGB_BL":case"CURVE_VEC_BL":D=me.useFloatTex?(R=new Float32Array(4*_u),1):(R=new Uint8Array(4*_u),255);for(var d,h,p,f,m=se.curveData.length/_u,c=0;c<_u;c++)f=3<m?(d=D*se.curveData[m*c],h=D*se.curveData[m*c+1],p=D*se.curveData[m*c+2],D*se.curveData[m*c+3]):(d=D*(se.curveData[m*c]/2+.5),h=D*(se.curveData[m*c+1]/2+.5),p=D*(se.curveData[m*c+2]/2+.5),D),R[4*c]=Kt.clamp(d,0,D),R[4*c+1]=Kt.clamp(h,0,D),R[4*c+2]=Kt.clamp(p,0,D),R[4*c+3]=Kt.clamp(f,0,D);var v=ye(R,_u,dt,me.useFloatTex?st:it),g=bu.nodeTexUniName(s,n);me.nodeTextures[g]=v,oe.params.push(Se(s,n)),n++;break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":oe.params.push(Ee("vViewPosition"));break;case"GRADIENT_RAMP_MX":D=me.useFloatTex?(R=new Float32Array(4*yu),1):(R=new Uint8Array(4*yu),255);for(c=0;c<yu;c++)d=D*se.gradientData[3*c],h=D*se.gradientData[3*c+1],p=D*se.gradientData[3*c+2],f=1,R[4*c]=Kt.clamp(d,0,D),R[4*c+1]=Kt.clamp(h,0,D),R[4*c+2]=Kt.clamp(p,0,D),R[4*c+3]=Kt.clamp(f,0,D);v=ye(R,yu,dt,me.useFloatTex?st:it),g=bu.nodeTexUniName(s,n);me.nodeTextures[g]=v,oe.params.push(Se(s,n)),n++,oe.params.push(Ee(De("int",se.gradientType)));var _=Ce(ae=se.uvIndex?"uv"+String(se.uvIndex+1):"uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_),oe.params.push(Ee("geometryNormal")),oe.params.push(Ee("vViewPosition")),-1<["SPHERICAL_ENVIRONMENT","CYLINDRICAL_ENVIRONMENT","SHRINK_WRAP_ENVIRONMENT","SCREEN"].indexOf(se.mapping)?oe.params.push(Ee("MAPPING_EXPLICIT_MAP_CHANNEL")):oe.params.push(Ee("MAPPING_"+se.mapping)),oe.params.push(Ee("AXIS_"+se.axis));var y=De("ivec2",[Pe(se.clampToEdgeNoExtend[0]),Pe(se.clampToEdgeNoExtend[1])]);oe.params.push(Ee(y));break;case"MAPPING_BL":if(se.rotation){var x=new _n,b=new bn;switch(b.set(se.rotation[0],se.rotation[1],se.rotation[2],"ZYX"),x.makeRotationFromEuler(b),x.scale((new un).fromArray(se.scale)),se.vectorType){case"TEXTURE":x.setPosition((new un).fromArray(se.translation)),x.getInverse(x);break;case"POINT":x.setPosition((new un).fromArray(se.translation));break;case"VECTOR":break;case"NORMAL":oe.outputs[0].normalize=!0,x.getInverse(x),x.transpose();break;default:throw new Error("v3d.MeshNodeMaterial: Unknown MAPPING vector type")}oe.params.push(Ae(s,o,x.toArray(),"mat")),oe.params.push(Ae(s,o,se.min,"min")),oe.params.push(Ae(s,o,se.max,"max")),oe.params.push(Ae(s,o,se.useMin,"use_min")),oe.params.push(Ae(s,o,se.useMax,"use_max"))}else oe.params.push(Ee("NODE_MAPPING_"+se.vectorType));break;case"MAP_RANGE_BL":oe.params.push(Ee("NODE_MAP_RANGE_INTERP_LINEAR")),oe.params.push(Ee(se.clamp?"1":"0"));break;case"NEW_GEOMETRY_BL":oe.params.push(Ee("FRONT_FACING_VALUE")),oe.params.push(Ee("vViewPosition")),oe.params.push(Ee("normal")),Me(e,o,$c)&&(me.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":var _=Ce(ae="tangent",4);oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_),oe.params.push(Ee("vNormal"));break;case"TANGENT_BL":"RADIAL"===se.directionType?(oe.params.push(Ee("TANGENT_AXIS_"+se.axis)),oe.params.push(Ee("vViewPosition")),oe.params.push(Ee("normal")),me.needsBoundingBox=!0):"UV_MAP"===se.directionType&&(_=Ce(ae="tangent",4),oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_));break;case"TEX_COORD_BL":oe.params.push(Ee("nodeTexCoordObjectMatrices[".concat(i,"]"))),oe.params.push(Ee("vViewPosition")),oe.params.push(Ee("normal"));var _=Ce(ae="uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_),Me(e,o,Jc)&&(me.needsBoundingBox=!0),me.nodeTexCoordObject.push(null),me.nodeTexCoordObjectMap[se.name]=i,i++;break;case"TEX_ENVIRONMENT_BL":case"TEX_ENVIRONMENT_MX":case"TEX_IMAGE_BL":var M=Se(s,se.texture);oe.params.push(M);var w,A=me.nodeTextures[M.name].encoding;oe.params.push(Ee(xe(A))),"TEX_ENVIRONMENT_BL"==s?(w=se.projection,oe.params.push(Ee("TEX_PROJ_"+w))):"TEX_IMAGE_BL"==s&&(oe.params.push(Ee("normal")),w=se.projection,oe.params.push(Ee("TEX_PROJ_"+w)),oe.params.push(Ae(s,o,se.projectionBlend,"proj_blend")),oe.params.push(Te(se.clampToEdgeNoExtend)));break;case"TEX_GRADIENT_BL":oe.params.push(Ee("TEX_GRAD_"+se.gradientType));break;case"TEX_NOISE_BL":var S=Jr(se.falloffFactor)?se.falloffFactor:0,T=Jr(se.dispersionFactor)?se.dispersionFactor:1;oe.params.push(Ee(De("float",S))),oe.params.push(Ee(De("float",T)));break;case"TEX_SKY_BL":var E,C=(new un).fromArray(se.sunDirection).angleTo(new un(0,0,1));"PREETHAM"==se.skyType?(K=qc.getDistParams(se.turbidity,0).concat([0,0,0,0]),J=qc.getDistParams(se.turbidity,1).concat([0,0,0,0]),$=qc.getDistParams(se.turbidity,2).concat([0,0,0,0]),ee=qc.getZenithParams(se.turbidity,C,0),te=qc.getZenithParams(se.turbidity,C,1),ne=qc.getZenithParams(se.turbidity,C,2)):"HOSEK_WILKIE"==se.skyType&&(E=Math.max(Math.PI/2-C,0),K=kc.getDistParams(se.turbidity,se.groundAlbedo,E,0),J=kc.getDistParams(se.turbidity,se.groundAlbedo,E,1),$=kc.getDistParams(se.turbidity,se.groundAlbedo,E,2),ee=kc.getRadiance(se.turbidity,se.groundAlbedo,E,0),te=kc.getRadiance(se.turbidity,se.groundAlbedo,E,1),ne=kc.getRadiance(se.turbidity,se.groundAlbedo,E,2)),oe.params.push(Ee("TEX_SKY_"+se.skyType)),oe.params.push(Ae(s,o,[K[0],J[0],$[0]],"param0")),oe.params.push(Ae(s,o,[K[1],J[1],$[1]],"param1")),oe.params.push(Ae(s,o,[K[2],J[2],$[2]],"param2")),oe.params.push(Ae(s,o,[K[3],J[3],$[3]],"param3")),oe.params.push(Ae(s,o,[K[4],J[4],$[4]],"param4")),oe.params.push(Ae(s,o,[K[5],J[5],$[5]],"param5")),oe.params.push(Ae(s,o,[K[6],J[6],$[6]],"param6")),oe.params.push(Ae(s,o,[K[7],J[7],$[7]],"param7")),oe.params.push(Ae(s,o,[K[8],J[8],$[8]],"param8")),oe.params.push(Ae(s,o,[ee,te,ne],"radiance")),oe.params.push(Ae(s,o,se.sunDirection,"sun_dir"));break;case"TEX_VORONOI_BL":void 0!==se.coloring&&oe.params.push(Ee("COLORING_"+se.coloring)),oe.params.push(Ee("DISTANCE_"+se.distance)),oe.params.push(Ee("FEATURE_"+se.feature));break;case"TEX_WAVE_BL":oe.params.push(Ee("TEX_WAVE_TYPE_"+se.waveType)),oe.params.push(Ee("TEX_WAVE_PROFILE_"+se.waveProfile)),void 0===se.bandsDirection&&(se.bandsDirection="DIAGONAL"),void 0===se.ringsDirection&&(se.ringsDirection="SPHERICAL"),oe.params.push(Ee("TEX_WAVE_BANDS_DIR_".concat(se.bandsDirection))),oe.params.push(Ee("TEX_WAVE_RINGS_DIR_".concat(se.ringsDirection)));break;case"MATH_BL":oe.outputs[0].clamp=se.useClamp;break;case"MIX_RGB_BL":switch(oe.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":me.defines.HSV_NODES=""}oe.outputs[0].clamp=se.useClamp;break;case"MIX_SHADER_BL":for(var P=-1,c=1;c<3;c++){var L=we(e,o,c);L&&"BSDF_TRANSPARENT_BL"==L.originData.type&&(P=c-1)}oe.params.push(Ee(String(P)));break;case"NORMAL_BL":oe.params.push(Ae(s,o,se.outputs[0],"out"));break;case"RGB_BL":case"RGB_GF":case"RGB_MX":M=(new rn).fromArray(se.outputs[0]);me.nodeRGB.push(M),me.nodeRGBMap[se.name]=r,oe.params.push(Ee("nodeRGB["+r+"]")),r++;break;case"UVMAP_BL":_=Ce(ae=(t=se.uvLayer,me.nodeUVAliases[t]||"uv"),2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_);break;case"VALUE_BL":case"VALUE_GF":case"VALUE_MX":M=se.outputs[0];me.nodeValue[a]=M,me.nodeValueMap[se.name]=a,oe.params.push(Ee("nodeValue["+a+"]")),a++;break;case"VALTORGB_BL":var R,D,N=new("STEP"==(H=se.curve).interpolation?Nc:Gc)(new Float32Array(H.input),new Float32Array(H.output),4);D=me.useFloatTex?(R=new Float32Array(4*_u),1):(R=new Uint8Array(4*_u),255);for(c=0;c<_u;c++){var I=N.evaluate(c/(_u-1));R[4*c]=D*I[0],R[4*c+1]=D*I[1],R[4*c+2]=D*I[2],R[4*c+3]=D*I[3]}v=ye(R,_u,dt,me.useFloatTex?st:it);"STEP"==H.interpolation&&(v.minFilter=Je,v.magFilter=Je);g=bu.nodeTexUniName(s,n);me.nodeTextures[g]=v,oe.params.push(Se(s,n)),n++;break;case"VECTOR_ROTATE_BL":void 0===se.rotationType&&(se.rotationType="AXIS_ANGLE"),void 0===se.invert&&(se.invert=!1),oe.params.push(Ee(De("float",se.invert?-1:1)));break;case"VECT_TRANSFORM_BL":var O=se.vectorType,F=se.convertFrom,B=se.convertTo;"NORMAL"==O&&(oe.outputs[0].normalize=!0);var z="";F==B?z="VEC_TRANS_NONE":(z="VEC_TRANS_"+F[0]+"_"+B[0],"VECTOR"!=O&&"NORMAL"!=O||(z+="_DIR")),oe.params.push(Ee(z)),0<ve(e,"OUTPUT_MATERIAL_BL")||0<ve(e,"OUTPUT_WORLD_BL")?oe.params.push(Ee("1")):oe.params.push(Ee("0"));break;case"VERTEX_COLOR_BL":(ae=_e(se.colorLayer,""))?(_=Ce(ae,4),oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_)):oe.params.push(Ee("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BITMAP_MX":case"BITMAP_ENV_MX":case"REFLECT_REFRACT_MX":var U=Se(s,se.texture);oe.params.push(U),"BITMAP_MX"==s?(_=Ce(ae=se.uvIndex?"uv"+String(se.uvIndex+1):"uv",2),oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_),oe.params.push(Ee("MAPPING_"+se.mapping)),oe.params.push(Ee("AXIS_"+se.axis)),y=De("ivec2",[Pe(se.clampToEdgeNoExtend[0]),Pe(se.clampToEdgeNoExtend[1])]),oe.params.push(Ee(y))):(oe.params.push(Ee(se.reflectMode)),oe.params.push(Ae(s,o,se.IOR,"ior")));A=me.nodeTextures[U.name].encoding;oe.params.push(Ee(xe(A))),"BITMAP_MX"!=s&&"BITMAP_ENV_MX"!=s||(oe.params.push(Ae(s,o,se.alphaAsMono,"as_mono")),oe.params.push(Ae(s,o,se.alphaAsRGB,"as_rgb")),oe.outputs.push({name:s.toLowerCase()+"_out1_n"+o,type:"float",clamp:!1,normalize:!1}));break;case"BLEND_MX":oe.params.push(Ae(s,o,se.useCurve,"use_curve")),oe.params.push(Ae(s,o,se.curveLower,"curve_lower")),oe.params.push(Ae(s,o,se.curveUpper,"curve_upper"));break;case"BUMP_MX":U=Se("BITMAP_MX",se.texture);oe.params.push(U),oe.params.push(Ee("-vViewPosition")),oe.params.push(Ee("normal"));_=Ce(ae=se.uvIndex?"uv"+String(se.uvIndex+1):"uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_);break;case"COLOR_CORRECTION_MX":var V=De("ivec4",[se.rewireR,se.rewireG,se.rewireB,se.rewireA]);oe.params.push(Ee(V));break;case"COMPOSITE_LAYER_MX":oe.params.push(Ee(De("int",se.blendMode)));var k=be(e,o,1)?se.opacity:0;oe.params.push(Ae(s,o,k,"opacity"));break;case"COLOR_MAP_MX":oe.params.push(Ae(s,o,se.reverseGamma,"rev"));break;case"FALLOFF_MX":oe.params.push(Ee("-vViewPosition")),oe.params.push(Ae(s,o,se.IOR,"ior"));break;case"MASK_MX":oe.params.push(Ae(s,o,se.maskInverted,"inv"));break;case"MATERIAL_MX":oe.params.push(Ae(s,o,se.inputFactors[ou],"refl_ratio")),oe.params.push(Ae(s,o,se.inputFactors[su],"refr_ratio")),se.inputFactors[ou]=1,se.inputFactors[su]=1,oe.params.push(Ae(s,o,se.selfIllumColorOn,"self_ill_on"));break;case"NORMAL_BUMP_MX":_=Ce(ae="tangent",4);oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_),oe.params.push(Ee("normal"));var G="ivec2("+Pe(se.flip[0])+","+Pe(se.flip[1])+")";oe.params.push(Ee(G));break;case"OUTPUT_MAP_MX":if(oe.params.push(Te(se.invert)),oe.params.push(Te(se.clamp)),oe.params.push(Te(se.alphaFromRGB)),se.colorMap){D=me.useFloatTex?(l=se.colorMap,R=new Float32Array(4*_u),1):(l=$r(se.colorMap.slice(),0,1),R=new Uint8Array(4*_u),255);for(m=l.length/_u,c=0;c<_u;c++)R[4*c]=D*l[m*c],3==m?(R[4*c+1]=D*l[m*c+1],R[4*c+2]=D*l[m*c+2]):(R[4*c+1]=R[4*c],R[4*c+2]=R[4*c]),R[4*c+3]=D;v=ye(R,_u,dt,me.useFloatTex?st:it),g=bu.nodeTexUniName(s,n);me.nodeTextures[g]=v,oe.params.push(Se(s,n)),n++}break;case"PHYSICAL_MX":oe.params.push(Ee("geometryNormal")),oe.params.push(Ae(s,o,se.emitLuminance,"lum"));var j=void 0===se.brdfMode||se.brdfMode,W=void 0===se.brdfLow?0:se.brdfLow,X=void 0===se.brdfHigh?0:se.brdfHigh,H=void 0===se.brdfCurve?0:se.brdfCurve;oe.params.push(Ee(j?"0":"1")),oe.params.push(Ee(De("float",W))),oe.params.push(Ee(De("float",X))),oe.params.push(Ee(De("float",H))),oe.params.push(Te(Jr(se.roughnessInv)&&se.roughnessInv)),oe.params.push(Te(Jr(se.transRoughnessLock)&&se.transRoughnessLock)),oe.params.push(Te(Jr(se.transRoughnessInv)&&se.transRoughnessInv)),oe.params.push(Te(Jr(se.thinWalled)&&se.thinWalled)),me.advancedPBR=!0;break;case"PHY_SUN_SKY_ENV_MX":var Y=15*se.haze+2,q=new Zc,C=Math.PI/2-se.sunPolarAngle,Z=Math.PI-se.sunAzimuthAngle;q.phi=C,q.theta=Z;var Q=(new un).setFromSpherical(q).toArray(),K=qc.getDistParams(Y,0),J=qc.getDistParams(Y,1),$=qc.getDistParams(Y,2),ee=qc.getZenithParams(Y,C,0),te=qc.getZenithParams(Y,C,1),ne=qc.getZenithParams(Y,C,2);ee/=.06,ee*=1e3,oe.params.push(Ae(s,o,[K[0],J[0],$[0]],"param_a")),oe.params.push(Ae(s,o,[K[1],J[1],$[1]],"param_b")),oe.params.push(Ae(s,o,[K[2],J[2],$[2]],"param_c")),oe.params.push(Ae(s,o,[K[3],J[3],$[3]],"param_d")),oe.params.push(Ae(s,o,[K[4],J[4],$[4]],"param_e")),oe.params.push(Ae(s,o,[ee,te,ne],"radiance"));var re=qc.getSunIlluminance(Q,Y);oe.params.push(Ae(s,o,Q,"sun_dir")),oe.params.push(Ae(s,o,re,"sun_illum")),oe.params.push(Ae(s,o,[0,0,0],"sun_lum"));var ie=1500/Math.PI;oe.params.push(Ae(s,o,se.globalIntensity/ie,"glob_int")),oe.params.push(Ae(s,o,se.groundColor,"gr_col"));break;case"REFLECT_REFRACT_COLOR_MX":M=se.outputs[0];oe.params.push(Ae(s,o,M,"col"));break;case"VERTEX_COLOR_MX":_=Ce(ae="color",3);oe.attributes.push({name:ae,type:"attribute vec3",paramVary:_}),oe.params.push(_);break;case"AI_MIX_SHADER_MY":oe.params.push(Ee(se.mode));break;case"AI_FACING_RATIO_MY":oe.params.push(Ee("normal"));break;case"AI_NORMAL_MAP_MY":_=Ce(ae="tangent",4);oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_);break;case"AI_SKYDOME_LIGHT_MY":U=Se(s,se.texture);oe.params.push(U);A=me.nodeTextures[U.name].encoding;oe.params.push(Ee(xe(A))),oe.params.push(Ee("normal"));break;case"BUMP_2D_MY":oe.params.push(Ee("vNormal")),0<se.bumpInterp&&(_=Ce(ae="tangent",4),oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_));break;case"FILE_MY":M=Se(s,se.texture);oe.params.push(M);A=me.nodeTextures[M.name].encoding;oe.params.push(Ee(xe(A)));break;case"LAMBERT_MY":oe.params.push(Ee("geometryNormal"));break;case"PLACE_2D_TEXTURE_MY":_=Ce(ae=se.uvIndex?"uv"+String(se.uvIndex+1):"uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_);break;case"RAMP_MY":D=me.useFloatTex?(R=new Float32Array(4*yu),1):(R=new Uint8Array(4*yu),255);for(c=0;c<yu;c++)d=D*se.rampData[3*c],h=D*se.rampData[3*c+1],p=D*se.rampData[3*c+2],f=1,R[4*c]=Kt.clamp(d,0,D),R[4*c+1]=Kt.clamp(h,0,D),R[4*c+2]=Kt.clamp(p,0,D),R[4*c+3]=Kt.clamp(f,0,D);v=ye(R,yu,dt,me.useFloatTex?st:it),g=bu.nodeTexUniName(s,n);me.nodeTextures[g]=v,oe.params.push(Se(s,n)),n++,oe.params.push(Ee(De("int",se.rampType)));break;case"SAMPLER_INFO_MY":oe.params.push(Ee("FRONT_FACING_VALUE")),oe.params.push(Ee("normal"));_=Ce(ae="tangent",4);oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_);_=Ce(ae="uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_);break;case"STANDARD_SURFACE_MY":oe.params.push(Ee("geometryNormal")),oe.params.push(Ee("true"));break;case"MATERIAL_GF":oe.params.push(Ee("normal")),oe.params.push(Ee("geometryNormal"));_=Ce(ae="tangent",4);oe.attributes.push({name:ae,type:"attribute vec4",paramVary:_}),oe.params.push(_);break;case"TEXTURE_GF":U=Se(s,se.texture);oe.params.push(U);var ae,_=Ce(ae=se.uvIndex?"uv"+String(se.uvIndex+1):"uv",2);oe.attributes.push({name:ae,type:"attribute vec2",paramVary:_}),oe.params.push(_);v=me.nodeTextures[U.name];oe.params.push(Ae(s,o,v.matrix.toArray(),"trans")),oe.params.push(Ee(xe(v.encoding)));break;case"NORMAL":oe.params.push(Ee("normal"))}}for(o=0;o<e.len();o++)for(var oe,se,s=(se=(oe=e.node(o)).originData).type,c=0;c<se.inputs.length;c++){var le,ce,ue,de,he=se.inputs[c],pe=function(e,t,n,r){for(var i in e.edges){var a=e.edges[i];if(a.to()==t)for(var o=e.node(a.from()),s=0;s<a.connections.length;s++){var l=a.connections[s];if(l.to==n){var c=o.originData.type;return"BITMAP_MX"!=c&&"BITMAP_ENV_MX"!=c||"float"!=Le(r)?o.outputs[l.from]:o.outputs[l.from+1]}}}return null}(e,o,c,he),fe=ge(s,c);pe?(le=oe.inputFactors.length?oe.inputFactors[c]:1,ce=Le(he),ue=fe?"normal":De(ce,he),de=function(e,t,n){for(var r in e.edges){var i=e.edges[r];if(i.to()==t){e.node(i.from());for(var a=0;a<i.connections.length;a++){var o=i.connections[a];if(o.to==n&&o.channelMatrix)return o.channelMatrix}}}return null}(e,o,c),oe.inputs.push({code:function(e,t,n,r,i,a){var o;if(a){for(var s=[],l=Re(t),c=Re(n),u=0;u<c;u++){for(var d=1==c?r:r+"["+u+"]",h=0;h<l;h++)a[h][u]&&(d=1==l?e:e+"["+h+"]");s.push(d)}o=n+"("+s.join(",")+")"}else t==n?o=e:"float"==t&&"vec3"==n?o="vec3("+[e,e,e].join(",")+")":"float"==t&&"vec4"==n?o="vec4("+[e,e,e,e].join(",")+")":"vec3"==t&&"float"==n||"vec4"==t&&"float"==n?o="("+[e+"[0]",e+"[1]",e+"[2]"].join("+")+")/3.0":"vec3"==t&&"vec4"==n?o="vec4("+e+", 1.0)":"vec4"==t&&"vec3"==n&&(o="vec3("+[e+"[0]",e+"[1]",e+"[2]"].join(",")+")"),(i<1||1!=i&&"normal"==r)&&(o="mix("+r+","+o+","+Ne(i)+")","normal"==r&&(o="normalize("+o+")"));return o}(pe.name,pe.type,ce,ue,le,de)})):fe?oe.inputs.push({code:"normal"}):oe.inputs.push({code:De(Le(he),he)})}}function be(e,t,n){for(var r=e.findInEdges(t),i=0;i<r.length;i++)for(var a=r[i],o=0;o<a.connections.length;o++){if(a.connections[o].to==n)return 1}}function Me(e,t,n){for(var r in e.edges){var i=e.edges[r];if(i.from()==t)for(var a=0;a<i.connections.length;a++){if(i.connections[a].from==n)return 1}}}function we(e,t,n){for(var r in e.edges){var i=e.edges[r];if(i.to()==t)for(var a=e.node(i.from()),o=0;o<i.connections.length;o++){if(i.connections[o].to==n)return a}}return null}function Ae(e,t,n,r){return{name:e.toLowerCase()+"_par_"+r+"_n"+t,type:Le(n),value:"boolean"==typeof n?n?1:0:n}}function Se(e,t){var n=bu.nodeTexUniName(e,t);return{name:n,type:me.nodeTextures[n].isCubeTexture?"uniform samplerCube":"uniform sampler2D",value:t}}function Te(e){return Ee(e?"true":"false")}function Ee(e){return{name:e,type:"",value:null}}function Ce(e,t){return{name:"_vary_par_"+e,type:"varying "+i(t),value:null}}function Pe(e){return e?1:0}function Le(e){return"number"==typeof e?"float":"boolean"==typeof e?"maya"==me.profile?"bool":"int":i(e.length)}function i(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";case 9:return"mat3";case 16:return"mat4"}}function Re(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;case"mat3":return 9;case"mat4":return 16}}function De(e,t){switch(e){case"float":return Ne(t);case"bool":case"int":return String(t);default:for(var n=[],r=0;r<t.length;r++)n.push(Ne(t[r]));return e+"("+n.join(",")+")"}}function Ne(e){return e%1?String(e):String(e)+".0"}this.type="MeshNodeMaterial",this.defines={LIGHT_PATH_IS_CAM_RAY:1,WORLD_NODES:0},this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.profile="blender",this.nodeTextures={},this.nodeRGB=[],this.nodeRGBMap={},this.nodeRGBArr=null,this.nodeTexCoordObject=[],this.nodeTexCoordObjectMap={},this.nodeTexCoordObjectArr=null,this.nodeValue=null,this.nodeValueMap={},this.needsBoundingBox=!1,this.useFloatTex=!1,this.nodeGraph=null,this.additionalNodeGraphs={},this.nodeChunks={},this.nodeChunksHash=0,this.nodeVCAliases={},this.nodeUVAliases={},this.color=new Lr(16777215),this.envMap=null,this.envMapIntensity=1,this.advancedPBR=!1,this.reflectivity=.5,Jr(e)&&this.setValues(e),this.nodeGraph||(this.nodeGraph=(t=new Ic.DiGraph(1),n=me.color,t.node(0).originData={name:"ShadelessOutput",type:"OUTPUT_MATERIAL_BL",inputs:[[n.r,n.g,n.b,1],[0,0,0,0],[0,0,0]],outputs:[],is_active_output:!0},t)),this.updateNodeGraph=function(){me.nodeRGB=[],me.nodeRGBMap={},me.nodeTexCoordObject=[],me.nodeTexCoordObjectMap={},me.nodeValueMap={},me.needsBoundingBox=!1,me.nodeChunks={};var e=me.nodeGraph;me.nodeRGBArr=new Float32Array(4*ve(e,["RGB_BL","RGB_GF","RGB_MX"])),me.nodeTexCoordObjectArr=new Float32Array(16*ve(e,"TEX_COORD_BL")),me.nodeValue=new Float32Array(ve(e,["VALUE_BL","VALUE_GF","VALUE_MX"])),r(e),function(e){var t=[],n=[],r=[],i=[],a=new Ic.TopologicalSort(e).order();me.defines.NODE_RGB_NUM=me.nodeRGB.length,me.defines.NODE_VALUE_NUM=me.nodeValue.length,me.defines.NODE_TEX_COORD_NUM=me.nodeTexCoordObject.length;for(var o=0;o<a.length;o++){var s=(m=e.node(a[o])).originData.type;me.defines["NODE_"+s]="","OUTPUT_MATERIAL_BL"!=s&&"PHYSICAL_MX"!=s&&"SHADING_ENGINE_MY"!=s&&"MATERIAL_GF"!=s||(me.defines.STANDARD="",me.defines.PHYSICAL="",me.advancedPBR&&(me.defines.CLEARCOAT=""));var l="node_"+s.toLowerCase()+"_vert";(h=aa[l])&&t.indexOf(h)<0&&t.push(h);var c="node_"+s.toLowerCase()+"_frag",u=aa[c];u&&r.indexOf(u)<0&&r.push(u);for(var d=0;d<m.attributes.length;d++){var h=(v=m.attributes[d]).type+" "+v.name+";";"uv"!=v.name&&t.indexOf(h)<0&&t.push(h)}for(var p,f,d=0;d<m.params.length;d++){A(_=m.params[d])?(u=_.type+" "+_.name+";",r.indexOf(u)<0&&r.push(u)):S(_)&&(p=_.type+" "+_.name+";",t.indexOf(p)<0&&t.push(p),f=_.type+" "+_.name+";",r.indexOf(f)<0&&r.push(f))}}for(var m,o=0;o<a.length;o++){if("ATTRIBUTE_BL"==(s=(m=e.node(a[o])).originData.type)||"NEW_GEOMETRY_BL"==s||"NORMAL_MAP_BL"==s||"TANGENT_BL"==s||"TEX_COORD_BL"==s||"UVMAP_BL"==s||"BITMAP_MX"==s||"NORMAL_BUMP_MX"==s||"BUMP_MX"==s||"VERTEX_COLOR_MX"==s||"GRADIENT_RAMP_MX"==s||"BUMP_2D_MY"==s||"PLACE_2D_TEXTURE_MY"==s||"SAMPLER_INFO_MY"==s||"MATERIAL_GF"==s||"TEXTURE_GF"==s||"VERTEX_COLOR_BL"==s)for(d=0;d<m.attributes.length;d++){var v,g=(v=m.attributes[d]).paramVary.name+"="+v.name+";";n.indexOf(g)<0&&n.push(g)}for(d=0;d<m.outputs.length;d++){(b=m.outputs[d]).type&&i.push(b.type+" "+b.name+";")}for(var _,y=[],d=0;d<m.params.length;d++){!(_=m.params[d]).type||A(_)||S(_)?y.push(_.name):y.push(De(_.type,_.value))}for(d=0;d<m.inputs.length;d++){var x=m.inputs[d];y.push(x.code)}for(d=0;d<m.outputs.length;d++){var b=m.outputs[d];y.push(b.name)}var M="node_"+s.toLowerCase();switch((s.endsWith("_BL")||s.endsWith("_GF")||s.endsWith("_MX")||s.endsWith("_MY"))&&(M=M.slice(0,-3)),s){case"MATH_BL":case"VECT_MATH_BL":M+="_"+m.originData.operation.toLowerCase();break;case"VECTOR_ROTATE_BL":M+="_"+m.originData.rotationType.toLowerCase();break;case"MIX_RGB_BL":M+="_"+m.originData.blendType.toLowerCase()}i.push(M+"("+y.join(",")+");");for(d=0;d<m.outputs.length;d++){var w=(b=m.outputs[d]).name;b.clamp&&(s=b.type,i.push(w+"=clamp("+w+","+s+"(0.0),"+s+"(1.0));")),b.normalize&&i.push(w+"=normalize("+w+");")}}me.nodeChunks.node_pars_vertex=t.join("\n"),me.nodeChunks.node_vertex=n.join("\n"),me.nodeChunks.node_pars_fragment=r.join("\n"),me.nodeChunks.node_fragment=i.join("\n"),me.nodeChunksHash=Kt.hashString(JSON.stringify(me.nodeChunks))}(e)},function(e){for(var t=0;t<e.len();t++){var n=e.node(t),r=n.originData.type;if("GROUP_BL"!=r){if("REROUTE_BL"==r){e.findInEdges(t).length<1&&x(e,t);for(o=e.findInEdges(t),s=e.findOutEdges(t),m=(d=o[0]).connections[0],c=0;c<s.length;c++){h=s[c];(u=new Ic.Edge(d.from(),h.to(),0)).connections=[];for(f=0;f<h.connections.length;f++){v=h.connections[f],g={from:m.from,to:v.to};u.connections.push(g)}e.addEdge(u)}e.disconnect(t,!0),t=-1}}else{var i=n.originData.nodeGraph,a=me.additionalNodeGraphs[i];if(a.len()<=2){for(var o=e.findInEdges(t),s=e.findOutEdges(t),l=Math.min(o.length,s.length),c=0;c<l;c++){var u,d=o[c],h=s[c];(u=new Ic.Edge(d.from(),h.to(),0)).connections=[];for(var p=Math.min(d.connections.length,h.connections.length),f=0;f<p;f++){var m=d.connections[f],v=h.connections[f],g={from:m.from,to:v.to};u.connections.push(g)}e.addEdge(u)}e.disconnect(t,!0),t=-1;continue}x(e,t);var _=function(e,t,n){var r={inputs:[],outputs:[],removedNodes:[]};r.removedNodes.push(n);var i=M(t,"GROUP_INPUT_BL");if(-1<i){r.removedNodes.push(i+e.len());for(var a=e.findInEdges(n),o=t.findOutEdges(i),s=0;s<a.length;s++)for(var l=a[s],c=0;c<o.length;c++)for(var u=o[c],d=0;d<l.connections.length;d++)for(var h=l.connections[d],p=0;p<u.connections.length;p++){var f=u.connections[p];h.to==f.from&&((x=w(r.inputs,l.from(),u.to()))||((x=new Ic.Edge(l.from(),u.to(),0)).connections=[],r.inputs.push(x)),b={from:h.from,to:f.to},x.connections.push(b))}}var m=M(t,"GROUP_OUTPUT_BL");r.removedNodes.push(m+e.len());for(var v=e.findOutEdges(n),g=t.findInEdges(m),s=0;s<v.length;s++)for(var _=v[s],c=0;c<g.length;c++)for(var y=g[c],d=0;d<_.connections.length;d++)for(h=_.connections[d],p=0;p<y.connections.length;p++){var x,b,f=y.connections[p];h.from==f.to&&((x=w(r.outputs,y.from(),_.to()))||((x=new Ic.Edge(y.from(),_.to(),0)).connections=[],r.outputs.push(x)),b={from:f.from,to:h.to},x.connections.push(b))}return r}(e,a,t);e.insert(a,_.inputs,_.outputs);for(var y=_.removedNodes.sort(function(e,t){return t-e}),c=0;c<y.length;c++)e.disconnect(y[c],!0);t=-1}}}(me.nodeGraph),function(e){for(var t,n=0;n<e.len();n++){"TEX_IMAGE_BL"!=(p=(f=e.node(n).originData).type)||be(e,n,0)||(e.addNode({originData:{name:"UVMapGenerated",type:"UVMAP_BL",uvLayer:"",inputs:[],outputs:[[0,0,0]]}}),Mu(e,e.len()-1,0,n,0)),"TEX_CHECKER_BL"!=p&&"TEX_GRADIENT_BL"!=p&&"TEX_NOISE_BL"!=p&&"TEX_WAVE_BL"!=p&&"TEX_VORONOI_BL"!=p&&"TEX_SKY_BL"!=p||be(e,n,0)||(t={originData:{name:"TexCoordGenerated",type:"TEX_COORD_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]}},e.addNode(t),Mu(e,e.len()-1,0,n,0)),"TEX_ENVIRONMENT_BL"!=p&&"TEX_ENVIRONMENT_MX"!=p||be(e,n,0)||(t={originData:{name:"TexCoordObject",type:"TEX_COORD_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]}},e.addNode(t),Mu(e,e.len()-1,3,n,0));var r,i,a=p;if("BSDF_PRINCIPLED_BL"==a&&20==f.inputs.length&&(a="BSDF_PRINCIPLED_<2.80.64_BL"),"BUMP_BL"==a&&4==f.inputs.length&&(a="BUMP_<2.81_BL"),a in xu&&!be(e,n,xu[a])&&(r={originData:{name:"NewGeomNormal",type:"NEW_GEOMETRY_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],0,0,0]}},e.addNode(r),Mu(e,e.len()-1,1,n,xu[a])),"BSDF_PRINCIPLED_BL"==a&&!be(e,n,Kc)&&(0<f.inputs[Qc]||be(e,n,Qc))&&(r={originData:{name:"NewGeomCoatNormal",type:"NEW_GEOMETRY_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],0,0,0]}},e.addNode(r),Mu(e,e.len()-1,1,n,Kc)),"STANDARD_SURFACE_MY"!=a||be(e,n,hu)||(i={originData:{name:"Normal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}},e.addNode(i),Mu(e,e.len()-1,0,n,hu)),"LAMBERT_MY"!=a||be(e,n,pu)||(i={originData:{name:"Normal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}},e.addNode(i),Mu(e,e.len()-1,0,n,pu)),"AI_NORMAL_MAP_MY"!=a||be(e,n,fu)&&be(e,n,mu)||(e.addNode({originData:{name:"SamplerInfo",type:"SAMPLER_INFO_MY",inputs:[],outputs:[0,!1,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0],[0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0]]}}),be(e,n,fu)||Mu(e,e.len()-1,vu,n,fu),be(e,n,mu)||Mu(e,e.len()-1,gu,n,mu)),"FILE_MY"!=a||be(e,n,uu)||(e.addNode({originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}}),Mu(e,e.len()-1,du,n,uu)),"BITMAP_MX"!=p&&"BITMAP_ENV_MX"!=p||Jr(f.mapping)||(f.mapping="EXPLICIT_MAP_CHANNEL",f.axis="XY",f.clampToEdgeNoExtend=[!1,!1],console.warn("v3d.MeshNodeMaterial: adding missing params to bitmap node, please reexport your scene")),"GRADIENT_RAMP_MX"==p&&(Jr(f.mapping)||(f.mapping="EXPLICIT_MAP_CHANNEL",f.axis="XY",f.clampToEdgeNoExtend=[!1,!1],console.warn("v3d.MeshNodeMaterial: adding missing params to gradient ramp node, please reexport your scene"))),Jr(f.output)&&function(e,t,n){var r=n.output,i=e.findInEdges(t),a=e.findOutEdges(t),o={originData:{name:n.name+"Output",type:"OUTPUT_MAP_MX",invert:r.invert,clamp:r.clamp,alphaFromRGB:r.alphaFromRGB,inputs:[[0,0,0,0],r.rgbLevel,r.rgbOffset,r.outputAmount,r.bumpAmount],outputs:[[0,0,0,0]]}};Jr(r.colorMap)&&(o.originData.colorMap=r.colorMap);e.addNode(o);for(var s=0;s<a.length;s++)for(var l=a[s],c=0;c<l.connections.length;c++){var u=l.connections[c];Mu(e,e.len()-1,0,l.to(),u.to)}e.disconnect(t,!1);for(s=0;s<i.length;s++)e.addEdge(i[s]);Mu(e,t,0,e.len()-1,0),delete n.output}(e,n,f),v(p)){if(!Jr(f.inputFactors)){f.inputFactors=[];for(var o=0;o<f.inputs.length;o++)f.inputFactors.push(1)}f.inputs.push([0,0,0]),f.inputFactors.push(0)}if("BUMP_2D_MY"==p&&0<f.bumpInterp){f.inputs[lu]=[0,0,0];for(var s=e.findInEdges(n),o=0;o<s.length;o++)for(var l=s[o],c=e.node(l.from()).originData,u=0;u<l.connections.length;u++){var d=l.connections[u];d.to==lu&&"FILE_MY"==c.type&&(d.from=cu)}}}for(var h=0,n=0;n<e.len();n++){"MATERIAL_MX"!=(p=(f=e.node(n).originData).type)&&"PHYSICAL_MX"!=p||(function(e,t,n){for(var r=n.type,i=e.findInEdges(t),a=0;a<i.length;a++)for(var o=i[a],s=e.node(o.from()).originData,l=0;l<o.connections.length;l++){var c=o.connections[l];if("MATERIAL_MX"==r&&g(s.type)&&(c.to==ou?s.reflectMode="MAX_ENV_COORDS_REFLECT":c.to==su&&(s.reflectMode="MAX_ENV_COORDS_REFRACT")),ge(r,c.to)){if("BITMAP_MX"==s.type||"OUTPUT_MAP_MX"==s.type){e.removeEdge(o.from(),o.to()),"OUTPUT_MAP_MX"==s.type&&(s=we(e,o.from(),0).originData);var u={originData:{name:s.name+"Bump"+a,type:"BUMP_MX",texture:s.texture,uvIndex:s.uvIndex,inputs:[],outputs:[[0,0,0]]}};e.addNode(u),Mu(e,e.len()-1,0,t,c.to),a=-1,i=e.findInEdges(t);break}for(var d=0;d<e.len();d++){var h,p=e.node(d).originData;v(p.type)&&(h=p.inputs.length-1,Mu(e,o.from(),c.from,d,h),p.inputFactors[h]=n.inputFactors[c.to])}}}}(e,n,f),"MATERIAL_MX"==p&&(h=f.IOR))}for(var p,n=0;n<e.len();n++){g(p=(f=e.node(n).originData).type)&&(f.IOR=h),g(p)&&!Jr(f.reflectMode)&&(f.reflectMode="MAX_ENV_COORDS_REFLECT")}for(n=0;n<e.len();n++){"COMPOSITE_MX"==(f=e.node(n).originData).type&&(function(e,t,n){for(var r=n.blendMode.length,i=e.findInEdges(t),a=e.findOutEdges(t),o=0;o<r;o++){var s={originData:{name:n.name+"Layer"+o,type:"COMPOSITE_LAYER_MX",blendMode:0!=o?n.blendMode[o]:0,opacity:n.opacity[o],inputs:[[0,0,0,0]].concat(n.inputs.slice(2*o,2*o+2)),outputs:[n.outputs[o]]}};e.addNode(s);for(var l=0;l<i.length;l++)for(var c=i[l],u=0;u<c.connections.length;u++){(h=c.connections[u]).to==2*o&&n.mapEnabled[o]?Mu(e,c.from(),h.from,e.len()-1,1):h.to==2*o+1&&n.maskEnabled[o]&&Mu(e,c.from(),h.from,e.len()-1,2)}0<o&&Mu(e,e.len()-2,0,e.len()-1,0)}for(o=0;o<a.length;o++)for(var d=a[o],l=0;l<d.connections.length;l++){var h=d.connections[l];Mu(e,e.len()-1,0,d.to(),h.to)}}(e,n,f),e.disconnect(n,!0))}for(n=0;n<e.len();n++){"LAYERED_TEXTURE_MY"==(f=e.node(n).originData).type&&(function(e,t,n){for(var r=n.inputs.length/4,i=e.findInEdges(t),a=e.findOutEdges(t),o=0;o<r;o++){var s={originData:{name:n.name+"Layer"+o,type:"LAYERED_TEXTURE_LAYER_MY",inputs:[0,[0,0,0]].concat(n.inputs.slice(4*o,4*o+4)),outputs:[0,[0,0,0]]}};e.addNode(s);for(var l=0;l<i.length;l++)for(var c=i[l],u=0;u<c.connections.length;u++){(h=c.connections[u]).to==4*o?Mu(e,c.from(),h.from,e.len()-1,2):h.to==4*o+1?Mu(e,c.from(),h.from,e.len()-1,3):h.to==4*o+2?Mu(e,c.from(),h.from,e.len()-1,4):h.to==4*o+3&&Mu(e,c.from(),h.from,e.len()-1,5)}0<o&&(Mu(e,e.len()-1,0,e.len()-2,0),Mu(e,e.len()-1,1,e.len()-2,1))}for(o=0;o<a.length;o++)for(var d=a[o],l=0;l<d.connections.length;l++){var h=d.connections[l];Mu(e,e.len()-r,h.from,d.to(),h.to)}}(e,n,f),e.disconnect(n,!0))}for(var f,n=0;n<e.len();n++){switch((f=e.node(n).originData).type){case"BSDF_DIFFUSE_BL":case"BSDF_GLOSSY_BL":case"BSDF_TRANSLUCENT_BL":case"BSDF_PRINCIPLED_BL":m(e,n,f,0,"Color");break;case"MATERIAL_GF":m(e,n,f,0,"Base Color"),m(e,n,f,2,"Metallic"),m(e,n,f,3,"Rougness"),m(e,n,f,5,"Normal Map Scale"),m(e,n,f,7,"Occlusion"),m(e,n,f,8,"Direct Light Occlusion"),m(e,n,f,10,"Emissive");break;case"MATERIAL_MX":m(e,n,f,0,"Ambient Color")&&(f.inputFactors[0]=1),m(e,n,f,1,"Diffuse Color")&&(f.inputFactors[1]=1);break;case"PHYSICAL_MX":m(e,n,f,1,"Base Color")&&(f.inputFactors[1]=1)}}}(me.nodeGraph),wu(me.nodeGraph),this.updateNodeGraph()}function Mu(e,t,n,r,i){e.edge(t,r)||e.addNewEdge(t,r);var a=e.edge(t,r);a.connections=a.connections||[],a.connections.push({from:n,to:i})}function wu(t){for(var e=-1,n=0;n<t.len();n++)if(t.node(n).originData.is_active_output){e=n;break}if(-1==e)t.removeAll();else{for(var r=new Ic.DepthFirstSearch(t.reverse(),e),i=[],n=0;n<t.len();n++)r.hasPathTo(n)||i.push(t.node(n));i.forEach(function(e){t.disconnect(t.nodeIndex(e),!0)})}}bu.nodeTexUniName=function(e,t){return e.toLowerCase()+"_par_tex_idx"+t},bu.nodeGraphFromGLTFMat=function(e,t){var n=e.pbrMetallicRoughness||{},a=[];Array.isArray(n.baseColorFactor)?a.push(n.baseColorFactor):a.push([1,1,1,1]),a.push([1,1,1,1]),Jr(n.metallicFactor)?a.push(n.metallicFactor):a.push(1),Jr(n.roughnessFactor)?a.push(n.roughnessFactor):a.push(1),a.push([1,1,1]),Jr(e.normalTexture)?Jr(e.normalTexture.scale)?a.push(e.normalTexture.scale):a.push(1):a.push(0),a.push([0,0,0]),Jr(e.occlusionTexture)?(Jr(e.occlusionTexture.strength)?a.push(e.occlusionTexture.strength):a.push(1),t&&Jr(t.directLightOcclusionFactor)?a.push(t.directLightOcclusionFactor):a.push(0)):(a.push(1),a.push(0)),a.push([1,1,1]),Jr(e.emissiveFactor)?a.push(e.emissiveFactor):a.push([0,0,0]),a.push([1,1,1]);var o=new Ic.DiGraph(1);function r(e,t,n){if(!Array.isArray(a[n]))throw new Error("Wrong glTF material input");a[n].length;for(var r=[],i=0;i<a[n].length;i++)r.push(0);o.addNode({originData:{name:bu.nodeTexUniName("TEXTURE_GF",e),type:"TEXTURE_GF",texture:e,uvIndex:t,inputs:[],outputs:[r]}}),Mu(o,o.len()-1,0,0,n)}return o.node(0).originData={name:"Material",type:"MATERIAL_GF",inputs:a,outputs:[],is_active_output:!0},Jr(n.baseColorTexture)&&r(n.baseColorTexture.index,n.baseColorTexture.texCoord||0,1),Jr(n.metallicRoughnessTexture)&&r(n.metallicRoughnessTexture.index,n.metallicRoughnessTexture.texCoord||0,4),Jr(e.normalTexture)&&r(e.normalTexture.index,e.normalTexture.texCoord||0,6),Jr(e.occlusionTexture)&&r(e.occlusionTexture.index,e.occlusionTexture.texCoord||0,9),Jr(e.emissiveTexture)&&r(e.emissiveTexture.index,e.emissiveTexture.texCoord||0,11),o},bu.nodeGraphFromExtGraph=function(e){for(var t=e.nodes,n=e.edges,r=new Ic.DiGraph(t.length),i=0;i<t.length;i++){t[i];r.node(i).originData=t[i];var a,o=r.node(i).originData,s=o.type;a=s.endsWith("_BL")||s.endsWith("_GF")||s.endsWith("_MX")||s.endsWith("_MY")?s:s.endsWith("_MAX")?s.replace("_MAX","_MX"):s+"_BL",s!=(o.type=a)&&console.warn("v3d.MeshNodeMaterial: converting node type: "+s+"->"+a+", please reexport your scene")}for(i=0;i<n.length;i++){var l=n[i];r.edge(l.fromNode,l.toNode)||r.addNewEdge(l.fromNode,l.toNode);var c=r.edge(l.fromNode,l.toNode);if(c.connections=c.connections||[],Jr(l.fromChannel)||Jr(l.toChannel)){for(var u=null,d=0;d<c.connections.length;d++){(f=c.connections[d]).from==l.fromOutput&&f.to==l.toInput&&f.channelMatrix&&(u=f.channelMatrix)}u||(u=[[0,0,0],[0,0,0],[0,0,0]],f={from:l.fromOutput,to:l.toInput,channelMatrix:u},c.connections.push(f));var h=l.fromChannel||0,p=l.toChannel||0;u[h][p]=1}else{var f={from:l.fromOutput,to:l.toInput};c.connections.push(f)}}return wu(r),r},bu.prototype=Object.assign(Object.create(Br.prototype),{constructor:bu,isMeshNodeMaterial:!0,hasNode:function(e){for(var t=0;t<this.nodeGraph.len();t++){if(this.nodeGraph.node(t).originData.type==e)return!0}return!1},traverseNodes:function(e){for(var t=0;t<this.nodeGraph.len();t++){e(this.nodeGraph.node(t))}},findNodeByName:function(e){for(var t=0;t<this.nodeGraph.len();t++){var n=this.nodeGraph.node(t);if(n.originData.name===e)return n}return null},copy:function(e){Br.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Vi.clone(e.uniforms),this.defines=e.defines,this.linewidth=e.linewidth,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.index0AttributeName=this.index0AttributeName,this.color.copy(e.color),this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.reflectivity=e.reflectivity,this.extensions=e.extensions,this.profile=e.profile,this.nodeTextures=e.nodeTextures,this.nodeRGB=e.nodeRGB.slice(),this.nodeRGBMap=Object.assign({},e.nodeRGBMap),this.nodeRGBArr=e.nodeRGBArr.slice(),this.nodeTexCoordObject=e.nodeTexCoordObject.slice(),this.nodeTexCoordObjectMap=Object.assign({},e.nodeTexCoordObjectMap),this.nodeTexCoordObjectArr=e.nodeTexCoordObjectArr.slice(),this.nodeValue=e.nodeValue.slice(),this.nodeValueMap=Object.assign({},e.nodeValueMap),this.needsBoundingBox=e.needsBoundingBox,this.useFloatTex=e.useFloatTex,this.nodeGraph=new Ic.DiGraph(e.nodeGraph.len());for(var t=0;t<this.nodeGraph.len();t++)this.nodeGraph.node(t).originData=e.nodeGraph.node(t).originData;for(var n in e.nodeGraph.edges){var r=e.nodeGraph.edges[n];this.nodeGraph.addNewEdge(r.from(),r.to()).connections=r.connections.slice()}return this.additionalNodeGraphs=Object.assign({},e.additionalNodeGraphs),this.nodeChunks=Object.assign({},e.nodeChunks),this.nodeChunksHash=e.nodeChunksHash,this.nodeVCAliases=Object.assign({},e.nodeVCAliases),this.nodeUVAliases=Object.assign({},e.nodeUVAliases),this},toJSON:function(e){var t=Br.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t}});var Au=Object.freeze({__proto__:null,ShadowMaterial:bc,SpriteMaterial:ys,RawShaderMaterial:Mc,ShaderMaterial:ji,PointsMaterial:il,MeshPhysicalMaterial:Ac,MeshStandardMaterial:wc,MeshPhongMaterial:Sc,MeshToonMaterial:Tc,MeshNormalMaterial:Ec,MeshLambertMaterial:Cc,MeshDepthMaterial:Ho,MeshDistanceMaterial:Yo,MeshBasicMaterial:zr,MeshMatcapMaterial:Pc,LineDashedMaterial:Lc,LineBasicMaterial:Ys,Material:Br,MeshMaskMaterial:Rc,MeshNodeMaterial:bu}),Su={arraySlice:function(e,t,n){return Su.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(n){for(var e=n.length,t=new Array(e),r=0;r!==e;++r)t[r]=r;return t.sort(function(e,t){return n[e]-n[t]}),t},sortedArray:function(e,t,n){for(var r=e.length,i=new e.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*t,l=0;l!==t;++l)i[o++]=e[s+l];return i},flattenJSON:function(e,t,n,r){for(var i=1,a=e[0];void 0!==a&&void 0===a[r];)a=e[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))for(;void 0!==(o=a[r])&&(t.push(a.time),n.push.apply(n,o)),void 0!==(a=e[i++]););else if(void 0!==o.toArray)for(;void 0!==(o=a[r])&&(t.push(a.time),o.toArray(n,n.length)),void 0!==(a=e[i++]););else for(;void 0!==(o=a[r])&&(t.push(a.time),n.push(o)),void 0!==(a=e[i++]););}},subclip:function(e,t,n,r,i){i=i||30;var a=e.clone();a.name=t;for(var o=[],s=0;s<a.tracks.length;++s){for(var l=a.tracks[s],c=l.getValueSize(),u=[],d=[],h=0;h<l.times.length;++h){var p=l.times[h]*i;if(!(p<n||r<=p)){u.push(l.times[h]);for(var f=0;f<c;++f)d.push(l.values[h*c+f])}}0!==u.length&&(l.times=Su.convertArray(u,l.times.constructor),l.values=Su.convertArray(d,l.values.constructor),o.push(l))}a.tracks=o;for(var m=1/0,s=0;s<a.tracks.length;++s)m>a.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s<a.tracks.length;++s)a.tracks[s].shift(-1*m);return a.resetDuration(),a}};function Tu(e,t,n,r){Dc.call(this,e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Eu(e,t,n,r){if(void 0===e)throw new Error("v3d.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("v3d.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Su.convertArray(t,this.TimeBufferType),this.values=Su.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}function Cu(e,t,n){Eu.call(this,e,t,n)}function Pu(e,t,n,r){Eu.call(this,e,t,n,r)}function Lu(e,t,n,r){Eu.call(this,e,t,n,r)}function Ru(e,t,n,r){Dc.call(this,e,t,n,r)}function Du(e,t,n,r){Eu.call(this,e,t,n,r)}function Nu(e,t,n,r){Eu.call(this,e,t,n,r)}function Iu(e,t,n,r){Eu.call(this,e,t,n,r)}function Ou(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=Kt.generateUUID(),this.duration<0&&this.resetDuration()}function Fu(e){if(void 0===e.type)throw new Error("v3d.KeyframeTrack: track type undefined, can not parse");var t,n,r=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Lu;case"vector":case"vector2":case"vector3":case"vector4":return Iu;case"color":return Pu;case"quaternion":return Du;case"bool":case"boolean":return Cu;case"string":return Nu}throw new Error("v3d.KeyframeTrack: Unsupported typeName: "+e)}(e.type);return void 0===e.times&&(t=[],n=[],Su.flattenJSON(e.keys,t,n,"value"),e.times=t,e.values=n),void 0!==r.parse?r.parse(e):new r(e.name,e.times,e.values,e.interpolation)}Tu.prototype=Object.assign(Object.create(Dc.prototype),{constructor:Tu,DefaultSettings_:{endingStart:wt,endingEnd:wt},intervalChanged_:function(e,t,n){var r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(void 0===o)switch(this.getSettings_().endingStart){case At:i=e,o=2*t-n;break;case St:o=t+r[i=r.length-2]-r[i+1];break;default:i=e,o=n}if(void 0===s)switch(this.getSettings_().endingEnd){case At:a=e,s=2*n-t;break;case St:s=n+r[a=1]-r[0];break;default:a=e-1,s=t}var l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(s-n),this._offsetPrev=i*c,this._offsetNext=a*c},interpolate_:function(e,t,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(r-t),f=p*p,m=f*p,v=-d*m+2*d*f-d*p,g=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,_=(-1-h)*m+(1.5+h)*f+.5*p,y=h*m-h*f,x=0;x!==o;++x)i[x]=v*a[c+x]+g*a[l+x]+_*a[s+x]+y*a[u+x];return i}}),Object.assign(Eu,{toJSON:function(e){var t,n,r=e.constructor;return void 0!==r.toJSON?t=r.toJSON(e):(t={name:e.name,times:Su.convertArray(e.times,Array),values:Su.convertArray(e.values,Array)},(n=e.getInterpolation())!==e.DefaultInterpolation&&(t.interpolation=n)),t.type=e.ValueTypeName,t}}),Object.assign(Eu.prototype,{constructor:Eu,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:bt,InterpolantFactoryMethodDiscrete:function(e){return new Nc(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new Gc(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new Tu(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t;switch(e){case r:t=this.InterpolantFactoryMethodDiscrete;break;case bt:t=this.InterpolantFactoryMethodLinear;break;case Mt:t=this.InterpolantFactoryMethodSmooth}if(void 0!==t)return this.createInterpolant=t,this;var n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(n);this.setInterpolation(this.DefaultInterpolation)}return console.warn("v3d.KeyframeTrack:",n),this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return r;case this.InterpolantFactoryMethodLinear:return bt;case this.InterpolantFactoryMethodSmooth:return Mt}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,n=0,r=t.length;n!==r;++n)t[n]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,n=0,r=t.length;n!==r;++n)t[n]*=e;return this},trim:function(e,t){for(var n,r=this.times,i=r.length,a=0,o=i-1;a!==i&&r[a]<e;)++a;for(;-1!==o&&r[o]>t;)--o;return++o,0===a&&o===i||(o<=a&&(a=(o=Math.max(o,1))-1),n=this.getValueSize(),this.times=Su.arraySlice(r,a,o),this.values=Su.arraySlice(this.values,a*n,o*n)),this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("v3d.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&s<a){console.error("v3d.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==r&&Su.isTypedArray(r))for(var o=0,l=r.length;o!==l;++o){var c=r[o];if(isNaN(c)){console.error("v3d.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e},optimize:function(){for(var e=Su.arraySlice(this.times),t=Su.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===Mt,i=1,a=e.length-1,o=1;o<a;++o){var s=!1,l=e[o];if(l!==e[o+1]&&(1!==o||l!==l[0]))if(r)s=!0;else for(var c=o*n,u=c-n,d=c+n,h=0;h!==n;++h){var p=t[c+h];if(p!==t[u+h]||p!==t[d+h]){s=!0;break}}if(s){if(o!==i){e[i]=e[o];for(var f=o*n,m=i*n,h=0;h!==n;++h)t[m+h]=t[f+h]}++i}}if(0<a){e[i]=e[a];for(f=a*n,m=i*n,h=0;h!==n;++h)t[m+h]=t[f+h];++i}return i!==e.length?(this.times=Su.arraySlice(e,0,i),this.values=Su.arraySlice(t,0,i*n)):(this.times=e,this.values=t),this},clone:function(){var e=Su.arraySlice(this.times,0),t=Su.arraySlice(this.values,0),n=new this.constructor(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}),Cu.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Cu,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:r,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Pu.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Pu,ValueTypeName:"color"}),Lu.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Lu,ValueTypeName:"number"}),Ru.prototype=Object.assign(Object.create(Dc.prototype),{constructor:Ru,interpolate_:function(e,t,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=(n-t)/(r-t),c=s+o;s!==c;s+=4)sn.slerpFlat(i,0,a,s-o,a,s,l);return i}}),Du.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Du,ValueTypeName:"quaternion",DefaultInterpolation:bt,InterpolantFactoryMethodLinear:function(e){return new Ru(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),Nu.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Nu,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:r,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Iu.prototype=Object.assign(Object.create(Eu.prototype),{constructor:Iu,ValueTypeName:"vector"}),Object.assign(Ou,{parse:function(e){for(var t=[],n=e.tracks,r=1/(e.fps||1),i=0,a=n.length;i!==a;++i)t.push(Fu(n[i]).scale(r));return new Ou(e.name,e.duration,t)},toJSON:function(e){for(var t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},i=0,a=n.length;i!==a;++i)t.push(Eu.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(e,t,n,r){for(var i=t.length,a=[],o=0;o<i;o++){var s=[];(c=[]).push((o+i-1)%i,o,(o+1)%i),s.push(0,1,0);var l=Su.getKeyframeOrder(c),c=Su.sortedArray(c,1,l),s=Su.sortedArray(s,1,l);r||0!==c[0]||(c.push(i),s.push(s[0])),a.push(new Lu(".morphTargetInfluences["+t[o].name+"]",c,s).scale(1/n))}return new Ou(e,-1,a)},findByName:function(e,t){var n=e;Array.isArray(e)||(n=e.geometry&&e.geometry.animations||e.animations);for(var r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null},CreateClipsFromMorphTargetSequences:function(e,t,n){for(var r={},i=/^([\w-]*?)([\d]+)$/,a=0,o=e.length;a<o;a++){var s,l=e[a],c=l.name.match(i);c&&1<c.length&&((s=r[d=c[1]])||(r[d]=s=[]),s.push(l))}var u=[];for(var d in r)u.push(Ou.CreateFromMorphTargetSequence(d,r[d],t,n));return u},parseAnimation:function(e,t){if(!e)return console.error("v3d.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,r,i){var a,o;0!==n.length&&(a=[],o=[],Su.flattenJSON(n,a,o,r),0!==a.length&&i.push(new e(t,a,o)))},r=[],i=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],l=0;l<s.length;l++){var c=s[l].keys;if(c&&0!==c.length)if(c[0].morphTargets){for(var u={},d=0;d<c.length;d++)if(c[d].morphTargets)for(var h=0;h<c[d].morphTargets.length;h++)u[c[d].morphTargets[h]]=-1;for(var p in u){for(var f=[],m=[],h=0;h!==c[d].morphTargets.length;++h){var v=c[d];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new Lu(".morphTargetInfluence["+p+"]",f,m))}a=u.length*(o||1)}else{var g=".bones["+t[l].name+"]";n(Iu,g+".position",c,"pos",r),n(Du,g+".quaternion",c,"rot",r),n(Iu,g+".scale",c,"scl",r)}}return 0===r.length?null:new Ou(i,a,r)}}),Object.assign(Ou.prototype,{resetDuration:function(){for(var e=0,t=0,n=this.tracks.length;t!==n;++t)var r=this.tracks[t],e=Math.max(e,r.times[r.times.length-1]);return this.duration=e,this},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){for(var e=!0,t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){for(var e=[],t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new Ou(this.name,this.duration,e)}});var Bu={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function zu(e,t,n){var r=this,i=!1,a=0,o=0,s=void 0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===i&&void 0!==r.onStart&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(i=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){var t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(var t=0,n=l.length;t<n;t+=2){var r=l[t],i=l[t+1];if(r.global&&(r.lastIndex=0),r.test(e))return i}return null}}var Uu=new zu;function Vu(e){this.manager=void 0!==e?e:Uu,this.crossOrigin="anonymous",this.path="",this.resourcePath=""}Object.assign(Vu.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this}});var ku={};function Gu(e){Vu.call(this,e)}function ju(e){Vu.call(this,e)}function Wu(e){Vu.call(this,e)}function Xu(e){Vu.call(this,e)}function Hu(e){Vu.call(this,e)}function Yu(e){Vu.call(this,e)}function qu(e){Vu.call(this,e)}function Zu(){this.type="Curve",this.arcLengthDivisions=200}function Qu(e,t,n,r,i,a,o,s){Zu.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=r||1,this.aStartAngle=i||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function Ku(e,t,n,r,i,a){Qu.call(this,e,t,n,n,r,i,a),this.type="ArcCurve"}function Ju(){var i=0,a=0,o=0,s=0;function c(e,t,n,r){o=-3*(i=e)+3*t-2*(a=n)-r,s=2*e-2*t+n+r}return{initCatmullRom:function(e,t,n,r,i){c(t,n,i*(n-e),i*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,i,a,o){var s=(t-e)/i-(n-e)/(i+a)+(n-t)/a,l=(n-t)/a-(r-t)/(a+o)+(r-n)/o;c(t,n,s*=a,l*=a)},calc:function(e){var t=e*e;return i+a*e+o*t+s*(t*e)}}}Gu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Gu,load:function(o,e,t,n){void 0===o&&(o=""),void 0!==this.path&&(o=this.path+o),o=this.manager.resolveURL(o);var s=this,r=Bu.get(o);if(void 0!==r)return s.manager.itemStart(o),setTimeout(function(){e&&e(r),s.manager.itemEnd(o)},0),r;if(void 0===ku[o]){var i=o.match(/^data:(.*?)(;base64)?,(.*)$/);if(i){var a=i[1],l=!!i[2],c=i[3],c=decodeURIComponent(c);l&&(c=atob(c));try{var u=(this.responseType||"").toLowerCase();switch(u){case"arraybuffer":case"blob":for(var d=new Uint8Array(c.length),h=0;h<c.length;h++)d[h]=c.charCodeAt(h);p="blob"===u?new Blob([d.buffer],{type:a}):d.buffer;break;case"document":var p=(new DOMParser).parseFromString(c,a);break;case"json":p=JSON.parse(c);break;default:p=c}setTimeout(function(){e&&e(p),s.manager.itemEnd(o)},0)}catch(e){setTimeout(function(){n&&n(e),s.manager.itemError(o),s.manager.itemEnd(o)},0)}}else{ku[o]=[],ku[o].push({onLoad:e,onProgress:t,onError:n});var f=new XMLHttpRequest;for(var m in f.open("GET",o,!0),f.addEventListener("load",function(e){var t=this.response,n=ku[o];if(delete ku[o],200===this.status||0===this.status){0===this.status&&console.warn("v3d.FileLoader: HTTP Status 0 received."),Bu.add(o,t);for(var r=0,i=n.length;r<i;r++){(a=n[r]).onLoad&&a.onLoad(t)}s.manager.itemEnd(o)}else{for(var a,r=0,i=n.length;r<i;r++){(a=n[r]).onError&&a.onError(e)}s.manager.itemError(o),s.manager.itemEnd(o)}},!1),f.addEventListener("progress",function(e){for(var t=ku[o],n=0,r=t.length;n<r;n++){var i=t[n];i.onProgress&&i.onProgress(e)}},!1),f.addEventListener("error",function(e){var t=ku[o];delete ku[o];for(var n=0,r=t.length;n<r;n++){var i=t[n];i.onError&&i.onError(e)}s.manager.itemError(o),s.manager.itemEnd(o)},!1),f.addEventListener("abort",function(e){var t=ku[o];delete ku[o];for(var n=0,r=t.length;n<r;n++){var i=t[n];i.onError&&i.onError(e)}s.manager.itemError(o),s.manager.itemEnd(o)},!1),void 0!==this.responseType&&(f.responseType=this.responseType),void 0!==this.withCredentials&&(f.withCredentials=this.withCredentials),f.overrideMimeType&&f.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)f.setRequestHeader(m,this.requestHeader[m]);f.send(null)}return s.manager.itemStart(o),f}ku[o].push({onLoad:e,onProgress:t,onError:n})},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}}),ju.prototype=Object.assign(Object.create(Vu.prototype),{constructor:ju,load:function(e,t,n,r){var i=this,a=new Gu(i.manager);a.setPath(i.path),a.load(e,function(e){t(i.parse(JSON.parse(e)))},n,r)},parse:function(e){for(var t=[],n=0;n<e.length;n++){var r=Ou.parse(e[n]);t.push(r)}return t}}),Wu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Wu,load:function(e,a,t,r){var o=this,s=[],l=new hl;l.image=s;var i=new Gu(this.manager);if(i.setPath(this.path),i.setResponseType("arraybuffer"),Array.isArray(e))for(var c=0,n=0,u=e.length;n<u;++n)!function(n){i.load(e[n],function(e){var t=o.parse(e,!0);s[n]={width:t.width,height:t.height,format:t.format,mipmaps:t.mipmaps},6===(c+=1)&&(1===t.mipmapCount&&(l.minFilter=tt),l.format=t.format,l.needsUpdate=!0,a&&a(l))},t,r)}(n);else i.load(e,function(e){var t=o.parse(e,!0);if(t.isCubemap)for(var n=t.mipmaps.length/t.mipmapCount,r=0;r<n;r++){s[r]={mipmaps:[]};for(var i=0;i<t.mipmapCount;i++)s[r].mipmaps.push(t.mipmaps[r*t.mipmapCount+i]),s[r].format=t.format,s[r].width=t.width,s[r].height=t.height}else l.image.width=t.width,l.image.height=t.height,l.mipmaps=t.mipmaps;1===t.mipmapCount&&(l.minFilter=tt),l.format=t.format,l.needsUpdate=!0,a&&a(l)},t,r);return l}}),Xu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Xu,load:function(e,n,t,r){var i=this,a=new qi,o=new Gu(this.manager);return o.setResponseType("arraybuffer"),o.setPath(this.path),o.load(e,function(e){var t=i.parse(e);t&&(void 0!==t.image?a.image=t.image:void 0!==t.data&&(a.image.width=t.width,a.image.height=t.height,a.image.data=t.data),a.wrapS=void 0!==t.wrapS?t.wrapS:Qe,a.wrapT=void 0!==t.wrapT?t.wrapT:Qe,a.magFilter=void 0!==t.magFilter?t.magFilter:tt,a.minFilter=void 0!==t.minFilter?t.minFilter:tt,a.anisotropy=void 0!==t.anisotropy?t.anisotropy:1,void 0!==t.format&&(a.format=t.format),void 0!==t.type&&(a.type=t.type),void 0!==t.mipmaps&&(a.mipmaps=t.mipmaps,a.minFilter=rt),1===t.mipmapCount&&(a.minFilter=tt),a.needsUpdate=!0,n&&n(a,t))},t,r),a}}),Hu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Hu,load:function(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=Bu.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){e&&e(a),i.manager.itemEnd(t)},0),a;var o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1),Bu.add(t,this),e&&e(this),i.manager.itemEnd(t)}function l(e){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1),r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}return o.addEventListener("load",s,!1),o.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(t),o.src=t,o}}),Yu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Yu,load:function(e,n,t,r){var i=new _a,a=new Hu(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);var o=0;for(var s=0;s<e.length;++s)!function(t){a.load(e[t],function(e){i.images[t]=e,6===++o&&(i.needsUpdate=!0,n&&n(i))},void 0,r)}(s);return i}}),qu.prototype=Object.assign(Object.create(Vu.prototype),{constructor:qu,load:function(n,r,e,t){var i=new nn,a=new Hu(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(n,function(e){i.image=e;var t=0<n.search(/\.jpe?g($|\?)/i)||0===n.search(/^data\:image\/jpeg/);i.format=t?ut:dt,i.needsUpdate=!0,void 0!==r&&r(i)},e,t),i}}),Object.assign(Zu.prototype,{getPoint:function(){return console.warn("v3d.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=e;n++)a+=(t=this.getPoint(n/e)).distanceTo(i),r.push(a),i=t;return this.cacheArcLengths=r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){for(var n,r=this.getLengths(),i=0,a=r.length,o=t||e*r[a-1],s=0,l=a-1;s<=l;)if((n=r[i=Math.floor(s+(l-s)/2)]-o)<0)s=i+1;else{if(!(0<n)){l=i;break}l=i-1}if(r[i=l]===o)return i/(a-1);var c=r[i];return(i+(o-c)/(r[i+1]-c))/(a-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),1<n&&(n=1);var r=this.getPoint(t);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){for(var n,r,i=new un,a=[],o=[],s=[],l=new un,c=new _n,u=0;u<=e;u++)n=u/e,a[u]=this.getTangentAt(n),a[u].normalize();o[0]=new un,s[0]=new un;var d=Number.MAX_VALUE,h=Math.abs(a[0].x),p=Math.abs(a[0].y),f=Math.abs(a[0].z);for(h<=d&&(d=h,i.set(1,0,0)),p<=d&&(d=p,i.set(0,1,0)),f<=d&&i.set(0,0,1),l.crossVectors(a[0],i).normalize(),o[0].crossVectors(a[0],l),s[0].crossVectors(a[0],o[0]),u=1;u<=e;u++)o[u]=o[u-1].clone(),s[u]=s[u-1].clone(),l.crossVectors(a[u-1],a[u]),l.length()>Number.EPSILON&&(l.normalize(),r=Math.acos(Kt.clamp(a[u-1].dot(a[u]),-1,1)),o[u].applyMatrix4(c.makeRotationAxis(l,r))),s[u].crossVectors(a[u],o[u]);if(!0===t)for(r=Math.acos(Kt.clamp(o[0].dot(o[e]),-1,1)),r/=e,0<a[0].dot(l.crossVectors(o[0],o[e]))&&(r=-r),u=1;u<=e;u++)o[u].applyMatrix4(c.makeRotationAxis(a[u],r*u)),s[u].crossVectors(a[u],o[u]);return{tangents:a,normals:o,binormals:s}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),((Qu.prototype=Object.create(Zu.prototype)).constructor=Qu).prototype.isEllipseCurve=!0,Qu.prototype.getPoint=function(e,t){for(var n=t||new Jt,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<Number.EPSILON;i<0;)i+=r;for(;r<i;)i-=r;i<Number.EPSILON&&(i=a?0:r),!0!==this.aClockwise||a||(i===r?i=-r:i-=r);var o,s,l,c,u=this.aStartAngle+e*i,d=this.aX+this.xRadius*Math.cos(u),h=this.aY+this.yRadius*Math.sin(u);return 0!==this.aRotation&&(o=Math.cos(this.aRotation),s=Math.sin(this.aRotation),d=(l=d-this.aX)*o-(c=h-this.aY)*s+this.aX,h=l*s+c*o+this.aY),n.set(d,h)},Qu.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Qu.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},Qu.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},((Ku.prototype=Object.create(Qu.prototype)).constructor=Ku).prototype.isArcCurve=!0;var $u=new un,ed=new Ju,td=new Ju,nd=new Ju;function rd(e,t,n,r){Zu.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=n||"centripetal",this.tension=r||.5}function id(e,t,n,r,i){var a=.5*(r-t),o=.5*(i-n),s=e*e;return(2*n-2*r+a+o)*(e*s)+(-3*n+3*r-2*a-o)*s+a*e+n}function ad(e,t,n,r){return(o=1-e)*o*t+2*(1-(a=e))*a*n+(i=e)*i*r;var i,a,o}function od(e,t,n,r,i){return(c=1-e)*c*c*t+3*(l=1-(s=e))*l*s*n+3*(1-(o=e))*o*o*r+(a=e)*a*a*i;var a,o,s,l,c}function sd(e,t,n,r){Zu.call(this),this.type="CubicBezierCurve",this.v0=e||new Jt,this.v1=t||new Jt,this.v2=n||new Jt,this.v3=r||new Jt}function ld(e,t,n,r){Zu.call(this),this.type="CubicBezierCurve3",this.v0=e||new un,this.v1=t||new un,this.v2=n||new un,this.v3=r||new un}function cd(e,t){Zu.call(this),this.type="LineCurve",this.v1=e||new Jt,this.v2=t||new Jt}function ud(e,t){Zu.call(this),this.type="LineCurve3",this.v1=e||new un,this.v2=t||new un}function dd(e,t,n){Zu.call(this),this.type="QuadraticBezierCurve",this.v0=e||new Jt,this.v1=t||new Jt,this.v2=n||new Jt}function hd(e,t,n){Zu.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new un,this.v1=t||new un,this.v2=n||new un}function pd(e){Zu.call(this),this.type="SplineCurve",this.points=e||[]}((rd.prototype=Object.create(Zu.prototype)).constructor=rd).prototype.isCatmullRomCurve3=!0,rd.prototype.getPoint=function(e,t){var n,r,i,a,o,s,l,c,u=t||new un,d=this.points,h=d.length,p=(h-(this.closed?0:1))*e,f=Math.floor(p),m=p-f;return this.closed?f+=0<f?0:(Math.floor(Math.abs(f)/h)+1)*h:0===m&&f===h-1&&(f=h-2,m=1),n=this.closed||0<f?d[(f-1)%h]:($u.subVectors(d[0],d[1]).add(d[0]),$u),r=d[f%h],i=d[(f+1)%h],a=this.closed||f+2<h?d[(f+2)%h]:($u.subVectors(d[h-1],d[h-2]).add(d[h-1]),$u),"centripetal"===this.curveType||"chordal"===this.curveType?(o="chordal"===this.curveType?.5:.25,s=Math.pow(n.distanceToSquared(r),o),(l=Math.pow(r.distanceToSquared(i),o))<1e-4&&(l=1),s<1e-4&&(s=l),(c=Math.pow(i.distanceToSquared(a),o))<1e-4&&(c=l),ed.initNonuniformCatmullRom(n.x,r.x,i.x,a.x,s,l,c),td.initNonuniformCatmullRom(n.y,r.y,i.y,a.y,s,l,c),nd.initNonuniformCatmullRom(n.z,r.z,i.z,a.z,s,l,c)):"catmullrom"===this.curveType&&(ed.initCatmullRom(n.x,r.x,i.x,a.x,this.tension),td.initCatmullRom(n.y,r.y,i.y,a.y,this.tension),nd.initCatmullRom(n.z,r.z,i.z,a.z,this.tension)),u.set(ed.calc(m),td.calc(m),nd.calc(m)),u},rd.prototype.copy=function(e){Zu.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t<n;t++){var r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},rd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);e.points=[];for(var t=0,n=this.points.length;t<n;t++){var r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},rd.prototype.fromJSON=function(e){Zu.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,n=e.points.length;t<n;t++){var r=e.points[t];this.points.push((new un).fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},((sd.prototype=Object.create(Zu.prototype)).constructor=sd).prototype.isCubicBezierCurve=!0,sd.prototype.getPoint=function(e,t){var n=t||new Jt,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(od(e,r.x,i.x,a.x,o.x),od(e,r.y,i.y,a.y,o.y)),n},sd.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},sd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},sd.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},((ld.prototype=Object.create(Zu.prototype)).constructor=ld).prototype.isCubicBezierCurve3=!0,ld.prototype.getPoint=function(e,t){var n=t||new un,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(od(e,r.x,i.x,a.x,o.x),od(e,r.y,i.y,a.y,o.y),od(e,r.z,i.z,a.z,o.z)),n},ld.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},ld.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},ld.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},((cd.prototype=Object.create(Zu.prototype)).constructor=cd).prototype.isLineCurve=!0,cd.prototype.getPoint=function(e,t){var n=t||new Jt;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},cd.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},cd.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},cd.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},cd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},cd.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},((ud.prototype=Object.create(Zu.prototype)).constructor=ud).prototype.isLineCurve3=!0,ud.prototype.getPoint=function(e,t){var n=t||new un;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},ud.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},ud.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},ud.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},ud.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},((dd.prototype=Object.create(Zu.prototype)).constructor=dd).prototype.isQuadraticBezierCurve=!0,dd.prototype.getPoint=function(e,t){var n=t||new Jt,r=this.v0,i=this.v1,a=this.v2;return n.set(ad(e,r.x,i.x,a.x),ad(e,r.y,i.y,a.y)),n},dd.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},dd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},dd.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},((hd.prototype=Object.create(Zu.prototype)).constructor=hd).prototype.isQuadraticBezierCurve3=!0,hd.prototype.getPoint=function(e,t){var n=t||new un,r=this.v0,i=this.v1,a=this.v2;return n.set(ad(e,r.x,i.x,a.x),ad(e,r.y,i.y,a.y),ad(e,r.z,i.z,a.z)),n},hd.prototype.copy=function(e){return Zu.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},hd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},hd.prototype.fromJSON=function(e){return Zu.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},((pd.prototype=Object.create(Zu.prototype)).constructor=pd).prototype.isSplineCurve=!0,pd.prototype.getPoint=function(e,t){var n=t||new Jt,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[0===a?a:a-1],l=r[a],c=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(id(o,s.x,l.x,c.x,u.x),id(o,s.y,l.y,c.y,u.y)),n},pd.prototype.copy=function(e){Zu.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t<n;t++){var r=e.points[t];this.points.push(r.clone())}return this},pd.prototype.toJSON=function(){var e=Zu.prototype.toJSON.call(this);e.points=[];for(var t=0,n=this.points.length;t<n;t++){var r=this.points[t];e.points.push(r.toArray())}return e},pd.prototype.fromJSON=function(e){Zu.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,n=e.points.length;t<n;t++){var r=e.points[t];this.points.push((new Jt).fromArray(r))}return this};var fd,md,vd,gd=Object.freeze({__proto__:null,ArcCurve:Ku,CatmullRomCurve3:rd,CubicBezierCurve:sd,CubicBezierCurve3:ld,EllipseCurve:Qu,LineCurve:cd,LineCurve3:ud,QuadraticBezierCurve:dd,QuadraticBezierCurve3:hd,SplineCurve:pd});function _d(){Zu.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function yd(e){_d.call(this),this.type="Path",this.currentPoint=new Jt,e&&this.setFromPoints(e)}function xd(e){yd.call(this,e),this.uuid=Kt.generateUUID(),this.type="Shape",this.holes=[]}function bd(e,t){Bn.call(this),this.type="Light",this.color=new Lr(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0,this.isFreeLight=void 0}function Md(e,t,n){bd.call(this,e,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Bn.DefaultUp),this.updateMatrix(),this.groundColor=new Lr(t),this.target=new Bn}function wd(e,t,n,r,i,a){bd.call(this,e,t),this.type="SpotLight",this.position.copy(Bn.DefaultUp),this.updateMatrix(),this.target=new Bn,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==a?a:1,this.shadow=new Uo}function Ad(){zo.call(this,new Xi(90,1,.5,500)),this._frameExtents=new Jt(4,2),this._viewportCount=6,this._viewports=[new rn(2,1,1,1),new rn(0,1,1,1),new rn(3,1,1,1),new rn(1,1,1,1),new rn(3,0,1,1),new rn(1,0,1,1)],this._cubeDirections=[new un(1,0,0),new un(-1,0,0),new un(0,0,1),new un(0,0,-1),new un(0,1,0),new un(0,-1,0)],this._cubeUps=[new un(0,1,0),new un(0,1,0),new un(0,1,0),new un(0,1,0),new un(0,0,1),new un(0,0,-1)]}function Sd(e,t,n,r){bd.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==r?r:1,this.shadow=new Ad}function Td(){zo.call(this,new na(-5,5,5,-5,.5,500))}function Ed(){zo.call(this,new na(-5,5,5,-5,.5,500)),this.maxDistance=10}function Cd(e,t){bd.call(this,e,t),this.type="DirectionalLight",this.position.copy(Bn.DefaultUp),this.updateMatrix(),this.target=new Bn,this.shadow=new Td}function Pd(e,t){bd.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function Ld(e,t,n,r){bd.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==r?r:10}function Rd(e){Vu.call(this,e),this.textures={}}_d.prototype=Object.assign(Object.create(Zu.prototype),{constructor:_d,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new cd(t,e))},getPoint:function(e){for(var t=e*this.getLength(),n=this.getCurveLengths(),r=0;r<n.length;){if(n[r]>=t){var i=n[r]-t,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e},getSpacedPoints:function(e){void 0===e&&(e=40);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e){e=e||12;for(var t,n=[],r=0,i=this.curves;r<i.length;r++)for(var a=i[r],o=a&&a.isEllipseCurve?2*e:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o),l=0;l<s.length;l++){var c=s[l];t&&t.equals(c)||(n.push(c),t=c)}return this.autoClose&&1<n.length&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){Zu.prototype.copy.call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t<n;t++){var r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){var e=Zu.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(var t=0,n=this.curves.length;t<n;t++){var r=this.curves[t];e.curves.push(r.toJSON())}return e},fromJSON:function(e){Zu.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var t=0,n=e.curves.length;t<n;t++){var r=e.curves[t];this.curves.push((new gd[r.type]).fromJSON(r))}return this}}),yd.prototype=Object.assign(Object.create(_d.prototype),{constructor:yd,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){var n=new cd(this.currentPoint.clone(),new Jt(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,n,r){var i=new dd(this.currentPoint.clone(),new Jt(e,t),new Jt(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this},bezierCurveTo:function(e,t,n,r,i,a){var o=new sd(this.currentPoint.clone(),new Jt(e,t),new Jt(n,r),new Jt(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this},splineThru:function(e){var t=new pd([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,n,r,i,a){var o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this},absarc:function(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this},ellipse:function(e,t,n,r,i,a,o,s){var l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,a,o,s),this},absellipse:function(e,t,n,r,i,a,o,s){var l,c=new Qu(e,t,n,r,i,a,o,s);0<this.curves.length&&((l=c.getPoint(0)).equals(this.currentPoint)||this.lineTo(l.x,l.y)),this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(e){return _d.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=_d.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return _d.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),xd.prototype=Object.assign(Object.create(yd.prototype),{constructor:xd,getPointsHoles:function(e){for(var t=[],n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){yd.prototype.copy.call(this,e),this.holes=[];for(var t=0,n=e.holes.length;t<n;t++){var r=e.holes[t];this.holes.push(r.clone())}return this},toJSON:function(){var e=yd.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(var t=0,n=this.holes.length;t<n;t++){var r=this.holes[t];e.holes.push(r.toJSON())}return e},fromJSON:function(e){yd.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var t=0,n=e.holes.length;t<n;t++){var r=e.holes[t];this.holes.push((new yd).fromJSON(r))}return this}}),bd.prototype=Object.assign(Object.create(Bn.prototype),{constructor:bd,isLight:!0,copy:function(e){return Bn.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this.receiveShadow=e.receiveShadow,this.isFreeLight=e.isFreeLight,this},getWorldDirection:function(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},toJSON:function(e){var t=Bn.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Md.prototype=Object.assign(Object.create(bd.prototype),{constructor:Md,isHemisphereLight:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this.target=e.target.clone(),this},updateMatrixWorld:function(e){Bn.prototype.updateMatrixWorld.call(this,e),this.isFreeLight&&this.updateFreeLightTarget()},updateFreeLightTarget:(fd=new un,function(){fd.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,fd),this.target.updateMatrix()})}),wd.prototype=Object.assign(Object.create(bd.prototype),{constructor:wd,isSpotLight:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this},updateMatrixWorld:function(e){Bn.prototype.updateMatrixWorld.call(this,e),this.isFreeLight&&this.updateFreeLightTarget()},updateFreeLightTarget:(md=new un,function(){md.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,md),this.target.updateMatrix()})}),Ad.prototype=Object.assign(Object.create(zo.prototype),{constructor:Ad,isPointLightShadow:!0,updateMatrices:function(e,t){void 0===t&&(t=0);var n=this.camera,r=this.matrix,i=this._lightPositionWorld,a=this._lookTarget,o=this._projScreenMatrix;i.setFromMatrixPosition(e.matrixWorld),n.position.copy(i),a.copy(n.position),a.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(a),n.updateMatrixWorld(),r.makeTranslation(-i.x,-i.y,-i.z),o.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}}),Sd.prototype=Object.assign(Object.create(bd.prototype),{constructor:Sd,isPointLight:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Td.prototype=Object.assign(Object.create(zo.prototype),{constructor:Td,isDirectionalLightShadow:!0,updateMatrices:function(e){zo.prototype.updateMatrices.call(this,e)}}),Ed.prototype=Object.assign(Object.create(zo.prototype),{constructor:Ed,isDirectionalLightShadowCSM:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.maxDistance=e.maxDistance,this}}),Cd.prototype=Object.assign(Object.create(bd.prototype),{constructor:Cd,isDirectionalLight:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this},updateMatrixWorld:function(e){Bn.prototype.updateMatrixWorld.call(this,e),this.isFreeLight&&this.updateFreeLightTarget()},updateFreeLightTarget:(vd=new un,function(){vd.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,vd),this.target.updateMatrix()})}),Pd.prototype=Object.assign(Object.create(bd.prototype),{constructor:Pd,isAmbientLight:!0}),Ld.prototype=Object.assign(Object.create(bd.prototype),{constructor:Ld,isRectAreaLight:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=bd.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}}),Rd.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Rd,load:function(e,t,n,r){var i=this,a=new Gu(i.manager);a.setPath(i.path),a.load(e,function(e){t(i.parse(JSON.parse(e)))},n,r)},parse:function(e){var t=this.textures;function n(e){return void 0===t[e]&&console.warn("v3d.MaterialLoader: Undefined texture",e),t[e]}var r,i=new Au[e.type];if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=(new Lr).setHex(e.sheen)),void 0!==e.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&i.specular.setHex(e.specular),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.vertexColors&&(i.vertexColors=e.vertexColors),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.skinning&&(i.skinning=e.skinning),void 0!==e.morphTargets&&(i.morphTargets=e.morphTargets),void 0!==e.morphNormals&&(i.morphNormals=e.morphNormals),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.uniforms)for(var a in e.uniforms){var o=e.uniforms[a];switch(i.uniforms[a]={},o.type){case"t":i.uniforms[a].value=n(o.value);break;case"c":i.uniforms[a].value=(new Lr).setHex(o.value);break;case"v2":i.uniforms[a].value=(new Jt).fromArray(o.value);break;case"v3":i.uniforms[a].value=(new un).fromArray(o.value);break;case"v4":i.uniforms[a].value=(new rn).fromArray(o.value);break;case"m3":i.uniforms[a].value=(new $t).fromArray(o.value);case"m4":i.uniforms[a].value=(new _n).fromArray(o.value);break;default:i.uniforms[a].value=o.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(var s in e.extensions)i.extensions[s]=e.extensions[s];return void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap),i.transparent=!0),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale&&(r=e.normalScale,!1===Array.isArray(r)&&(r=[r,r]),i.normalScale=(new Jt).fromArray(r)),void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Jt).fromArray(e.clearcoatNormalScale)),i},setTextures:function(e){return this.textures=e,this}});var Dd={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}},extractUrlBase:function(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}};function Nd(){ui.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Id(e,t,n,r){"number"==typeof n&&(r=n,n=!1,console.error("v3d.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Vr.call(this,e,t,n),this.meshPerAttribute=r||1}function Od(e){Vu.call(this,e)}Nd.prototype=Object.assign(Object.create(ui.prototype),{constructor:Nd,isInstancedBufferGeometry:!0,copy:function(e){return ui.prototype.copy.call(this,e),this.maxInstancedCount=e.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e=ui.prototype.toJSON.call(this);return e.maxInstancedCount=this.maxInstancedCount,e.isInstancedBufferGeometry=!0,e}}),Id.prototype=Object.assign(Object.create(Vr.prototype),{constructor:Id,isInstancedBufferAttribute:!0,copy:function(e){return Vr.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){var e=Vr.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}),Od.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Od,load:function(e,t,n,r){var i=this,a=new Gu(i.manager);a.setPath(i.path),a.load(e,function(e){t(i.parse(JSON.parse(e)))},n,r)},parse:function(e){var t=new(e.isInstancedBufferGeometry?Nd:ui),n=e.data.index;void 0!==n&&(o=new Fd[n.type](n.array),t.setIndex(new Vr(o,1)));var r=e.data.attributes;for(var i in r){var a=r[i],o=new Fd[a.type](a.array),s=new(a.isInstancedBufferAttribute?Id:Vr)(o,a.itemSize,a.normalized);void 0!==a.name&&(s.name=a.name),t.setAttribute(i,s)}var l=e.data.morphAttributes;if(l)for(var i in l){for(var c=l[i],u=[],d=0,h=c.length;d<h;d++){a=c[d],s=new Vr(o=new Fd[a.type](a.array),a.itemSize,a.normalized);void 0!==a.name&&(s.name=a.name),u.push(s)}t.morphAttributes[i]=u}e.data.morphTargetsRelative&&(t.morphTargetsRelative=!0);var p=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==p)for(var d=0,f=p.length;d!==f;++d){var m=p[d];t.addGroup(m.start,m.count,m.materialIndex)}var v,g=e.data.boundingSphere;return void 0!==g&&(v=new un,void 0!==g.center&&v.fromArray(g.center),t.boundingSphere=new rr(v,g.radius)),e.name&&(t.name=e.name),e.userData&&(t.userData=e.userData),t}});var Fd={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Bd(e){Vu.call(this,e)}Bd.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Bd,load:function(r,i,e,a){var o=this,t=""===this.path?Dd.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||t;var n=new Gu(o.manager);n.setPath(this.path),n.load(r,function(e){var t=null;try{t=JSON.parse(e)}catch(e){return void 0!==a&&a(e),void console.error("v3d:ObjectLoader: Can't parse "+r+".",e.message)}var n=t.metadata;void 0!==n&&void 0!==n.type&&"geometry"!==n.type.toLowerCase()?o.parse(t,i):console.error("v3d.ObjectLoader: Can't load "+r)},e,a)},parse:function(e,t){var n=this.parseShape(e.shapes),r=this.parseGeometries(e.geometries,n),i=this.parseImages(e.images,function(){void 0!==t&&t(s)}),a=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,r,o);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var n=0,r=e.length;n<r;n++){var i=(new xd).fromJSON(e[n]);t[i.uuid]=i}return t},parseGeometries:function(e,t){var n={};if(void 0!==e)for(var r=new Od,i=0,a=e.length;i<a;i++){var o=e[i];switch(o.type){case"PlaneGeometry":case"PlaneBufferGeometry":h=new xc[o.type](o.width,o.height,o.widthSegments,o.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":h=new xc[o.type](o.width,o.height,o.depth,o.widthSegments,o.heightSegments,o.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":h=new xc[o.type](o.radius,o.segments,o.thetaStart,o.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":h=new xc[o.type](o.radiusTop,o.radiusBottom,o.height,o.radialSegments,o.heightSegments,o.openEnded,o.thetaStart,o.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":h=new xc[o.type](o.radius,o.height,o.radialSegments,o.heightSegments,o.openEnded,o.thetaStart,o.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":h=new xc[o.type](o.radius,o.widthSegments,o.heightSegments,o.phiStart,o.phiLength,o.thetaStart,o.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":h=new xc[o.type](o.radius,o.detail);break;case"RingGeometry":case"RingBufferGeometry":h=new xc[o.type](o.innerRadius,o.outerRadius,o.thetaSegments,o.phiSegments,o.thetaStart,o.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":h=new xc[o.type](o.radius,o.tube,o.radialSegments,o.tubularSegments,o.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":h=new xc[o.type](o.radius,o.tube,o.tubularSegments,o.radialSegments,o.p,o.q);break;case"TubeGeometry":case"TubeBufferGeometry":h=new xc[o.type]((new gd[o.path.type]).fromJSON(o.path),o.tubularSegments,o.radius,o.radialSegments,o.closed);break;case"LatheGeometry":case"LatheBufferGeometry":h=new xc[o.type](o.points,o.segments,o.phiStart,o.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":h=new xc[o.type](o.vertices,o.indices,o.radius,o.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var s=[],l=0,c=o.shapes.length;l<c;l++){var u=t[o.shapes[l]];s.push(u)}h=new xc[o.type](s,o.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(s=[],l=0,c=o.shapes.length;l<c;l++){u=t[o.shapes[l]];s.push(u)}var d=o.options.extrudePath;void 0!==d&&(o.options.extrudePath=(new gd[d.type]).fromJSON(d)),h=new xc[o.type](s,o.options);break;case"BufferGeometry":case"InstancedBufferGeometry":h=r.parse(o);break;case"Geometry":var h,p=ni();"v3d"in p&&"LegacyJSONLoader"in p.v3d?h=(new p.v3d.LegacyJSONLoader).parse(o,this.resourcePath).geometry:console.error('v3d.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:console.warn('v3d.ObjectLoader: Unsupported geometry type "'+o.type+'"');continue}h.uuid=o.uuid,void 0!==o.name&&(h.name=o.name),!0===h.isBufferGeometry&&void 0!==o.userData&&(h.userData=o.userData),n[o.uuid]=h}return n},parseMaterials:function(e,t){var n={},r={};if(void 0!==e){var i=new Rd;i.setTextures(t);for(var a=0,o=e.length;a<o;a++){var s=e[a];if("MultiMaterial"===s.type){for(var l=[],c=0;c<s.materials.length;c++){var u=s.materials[c];void 0===n[u.uuid]&&(n[u.uuid]=i.parse(u)),l.push(n[u.uuid])}r[s.uuid]=l}else void 0===n[s.uuid]&&(n[s.uuid]=i.parse(s)),r[s.uuid]=n[s.uuid]}}return r},parseAnimations:function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=Ou.parse(r);void 0!==r.uuid&&(i.uuid=r.uuid),t.push(i)}return t},parseImages:function(e,t){var n=this,r={};function i(e){return n.manager.itemStart(e),a.load(e,function(){n.manager.itemEnd(e)},void 0,function(){n.manager.itemError(e),n.manager.itemEnd(e)})}if(void 0!==e&&0<e.length){var a=new Hu(new zu(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o<s;o++){var l=e[o],c=l.url;if(Array.isArray(c)){r[l.uuid]=[];for(var u=0,d=c.length;u<d;u++){var h=c[u],p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:n.resourcePath+h;r[l.uuid].push(i(p))}}else{p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l.url)?l.url:n.resourcePath+l.url;r[l.uuid]=i(p)}}}return r},parseTextures:function(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("v3d.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var r={};if(void 0!==e)for(var i=0,a=e.length;i<a;i++){var o,s=e[i];void 0===s.image&&console.warn('v3d.ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&console.warn("v3d.ObjectLoader: Undefined image",s.image),(o=new(Array.isArray(t[s.image])?_a:nn)(t[s.image])).needsUpdate=!0,o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),void 0!==s.mapping&&(o.mapping=n(s.mapping,Ud)),void 0!==s.offset&&o.offset.fromArray(s.offset),void 0!==s.repeat&&o.repeat.fromArray(s.repeat),void 0!==s.center&&o.center.fromArray(s.center),void 0!==s.rotation&&(o.rotation=s.rotation),void 0!==s.wrap&&(o.wrapS=n(s.wrap[0],Vd),o.wrapT=n(s.wrap[1],Vd)),void 0!==s.format&&(o.format=s.format),void 0!==s.type&&(o.type=s.type),void 0!==s.encoding&&(o.encoding=s.encoding),void 0!==s.minFilter&&(o.minFilter=n(s.minFilter,kd)),void 0!==s.magFilter&&(o.magFilter=n(s.magFilter,kd)),void 0!==s.anisotropy&&(o.anisotropy=s.anisotropy),void 0!==s.flipY&&(o.flipY=s.flipY),void 0!==s.premultiplyAlpha&&(o.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(o.unpackAlignment=s.unpackAlignment),r[s.uuid]=o}return r},parseObject:function(e,t,a){function n(e){return void 0===t[e]&&console.warn("v3d.ObjectLoader: Undefined geometry",e),t[e]}function r(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n];void 0===a[i]&&console.warn("v3d.ObjectLoader: Undefined material",i),t.push(a[i])}return t}return void 0===a[e]&&console.warn("v3d.ObjectLoader: Undefined material",e),a[e]}}switch(e.type){case"Scene":s=new zn,void 0!==e.background&&Number.isInteger(e.background)&&(s.background=new Lr(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?s.fog=new fs(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(s.fog=new ps(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":s=new Xi(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(s.focus=e.focus),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.filmGauge&&(s.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(s.filmOffset=e.filmOffset),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new na(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new Pd(e.color,e.intensity);break;case"DirectionalLight":s=new Cd(e.color,e.intensity);break;case"PointLight":s=new Sd(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new Ld(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new wd(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":s=new Md(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("v3d.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var i=n(e.geometry),o=r(e.material),s=new(i.bones&&0<i.bones.length?Bs:Ci)(i,o);break;case"InstancedMesh":var i=n(e.geometry),o=r(e.material),l=e.count,c=e.instanceMatrix;(s=new Hs(i,o,l)).instanceMatrix=new Vr(new Float32Array(c.array),16);break;case"LOD":s=new Fs;break;case"Line":s=new $s(n(e.geometry),r(e.material),e.mode);break;case"LineLoop":s=new rl(n(e.geometry),r(e.material));break;case"LineSegments":s=new nl(n(e.geometry),r(e.material));break;case"PointCloud":case"Points":s=new cl(n(e.geometry),r(e.material));break;case"Sprite":s=new Ds(r(e.material));break;case"Group":s=new as;break;default:s=new Bn}if(s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.userData&&(s.userData=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),void 0!==e.children)for(var u=e.children,d=0;d<u.length;d++)s.add(this.parseObject(u[d],t,a));if("LOD"===e.type){void 0!==e.autoUpdate&&(s.autoUpdate=e.autoUpdate);for(var h=e.levels,p=0;p<h.length;p++){var f=h[p],m=s.getObjectByProperty("uuid",f.object);void 0!==m&&s.addLevel(m,f.distance)}}return s}});var zd,Ud={UVMapping:300,CubeReflectionMapping:Ge,CubeRefractionMapping:je,EquirectangularReflectionMapping:We,EquirectangularRefractionMapping:Xe,SphericalReflectionMapping:He,CubeUVReflectionMapping:Ye,CubeUVRefractionMapping:qe},Vd={RepeatWrapping:Ze,ClampToEdgeWrapping:Qe,MirroredRepeatWrapping:Ke},kd={NearestFilter:Je,NearestMipmapNearestFilter:$e,NearestMipmapLinearFilter:et,LinearFilter:tt,LinearMipmapNearestFilter:nt,LinearMipmapLinearFilter:rt};function Gd(e){"undefined"==typeof createImageBitmap&&console.warn("v3d.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("v3d.ImageBitmapLoader: fetch() not supported."),Vu.call(this,e),this.options=void 0}function jd(){this.type="ShapePath",this.color=new Lr,this.subPaths=[],this.currentPath=null}function Wd(e){this.type="Font",this.data=e}function Xd(e){Vu.call(this,e)}Gd.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Gd,setOptions:function(e){return this.options=e,this},load:function(t,n,e,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=Bu.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){n&&n(a),i.manager.itemEnd(t)},0),a;fetch(t).then(function(e){return e.blob()}).then(function(e){return void 0===i.options?createImageBitmap(e):createImageBitmap(e,i.options)}).then(function(e){Bu.add(t,e),n&&n(e),i.manager.itemEnd(t)}).catch(function(e){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}),i.manager.itemStart(t)}}),Object.assign(jd.prototype,{moveTo:function(e,t){return this.currentPath=new yd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this},bezierCurveTo:function(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function n(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n],a=new xd;a.curves=i.curves,t.push(a)}return t}var r=Zl.isClockWise,i=this.subPaths;if(0===i.length)return[];if(!0===t)return n(i);var a,o,s,l=[];if(1===i.length)return o=i[0],(s=new xd).curves=o.curves,l.push(s),l;var c,u=!r(i[0].getPoints()),u=e?!u:u,d=[],h=[],p=[],f=0;h[f]=void 0,p[f]=[];for(var m,v=0,g=i.length;v<g;v++)a=r(c=(o=i[v]).getPoints()),(a=e?!a:a)?(!u&&h[f]&&f++,h[f]={s:new xd,p:c},h[f].s.curves=o.curves,u&&f++,p[f]=[]):p[f].push({h:o,p:c[0]});if(!h[0])return n(i);if(1<h.length){for(var _=!1,y=[],x=0,b=h.length;x<b;x++)d[x]=[];for(x=0,b=h.length;x<b;x++)for(var M=p[x],w=0;w<M.length;w++){for(var A=M[w],S=!0,T=0;T<h.length;T++)!function(e,t){for(var n=t.length,r=!1,i=n-1,a=0;a<n;i=a++){var o=t[i],s=t[a],l=s.x-o.x,c=s.y-o.y;if(Math.abs(c)>Number.EPSILON){if(c<0&&(o=t[a],l=-l,s=t[i],c=-c),e.y<o.y||e.y>s.y)continue;if(e.y===o.y){if(e.x===o.x)return 1}else{var u=c*(e.x-o.x)-l*(e.y-o.y);if(0==u)return 1;if(u<0)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return 1}}return r}(A.p,h[T].p)||(x!==T&&y.push({froms:x,tos:T,hole:w}),S?(S=!1,d[T].push(A)):_=!0);S&&d[x].push(A)}0<y.length&&(_||(p=d))}for(var v=0,E=h.length;v<E;v++){s=h[v].s,l.push(s);for(var C=0,P=(m=p[v]).length;C<P;C++)s.holes.push(m[C].h)}return l}}),Object.assign(Wd.prototype,{isFont:!0,generateShapes:function(e,t){void 0===t&&(t=100);for(var n=[],r=function(e,t,n){for(var r=Array.from?Array.from(e):String(e).split(""),i=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,o=[],s=0,l=0,c=0;c<r.length;c++){var u,d=r[c];"\n"===d?(s=0,l-=a):(u=function(e,t,n,r,i){var a=i.glyphs[e]||i.glyphs["?"];if(!a)return void console.error('v3d.Font: character "'+e+'" does not exists in font family '+i.familyName+".");var o,s,l,c,u,d,h,p,f=new jd;if(a.o)for(var m=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),v=0,g=m.length;v<g;){switch(m[v++]){case"m":o=m[v++]*t+n,s=m[v++]*t+r,f.moveTo(o,s);break;case"l":o=m[v++]*t+n,s=m[v++]*t+r,f.lineTo(o,s);break;case"q":l=m[v++]*t+n,c=m[v++]*t+r,u=m[v++]*t+n,d=m[v++]*t+r,f.quadraticCurveTo(u,d,l,c);break;case"b":l=m[v++]*t+n,c=m[v++]*t+r,u=m[v++]*t+n,d=m[v++]*t+r,h=m[v++]*t+n,p=m[v++]*t+r,f.bezierCurveTo(u,d,h,p,l,c)}}return{offsetX:a.ha*t,path:f}}(d,i,s,l,n),s+=u.offsetX,o.push(u.path))}return o}(e,t,this.data),i=0,a=r.length;i<a;i++)Array.prototype.push.apply(n,r[i].toShapes());return n}}),Xd.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Xd,load:function(e,r,t,n){var i=this,a=new Gu(this.manager);a.setPath(this.path),a.load(e,function(t){var n;try{n=JSON.parse(t)}catch(e){console.warn("v3d.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}var e=i.parse(n);r&&r(e)},t,n)},parse:function(e){return new Wd(e)}});var Hd={getContext:function(){return void 0===zd&&(zd=new(window.AudioContext||window.webkitAudioContext)),zd},setContext:function(e){zd=e}};function Yd(e){Vu.call(this,e)}function qd(){this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new un)}function Zd(e,t){bd.call(this,void 0,t),this.sh=void 0!==e?e:new qd}function Qd(e,t,n){Zd.call(this,void 0,n);var r=(new Lr).set(e),i=(new Lr).set(t),a=new un(r.r,r.g,r.b),o=new un(i.r,i.g,i.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(s),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(l)}function Kd(e,t){Zd.call(this,void 0,t);var n=(new Lr).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}Yd.prototype=Object.assign(Object.create(Vu.prototype),{constructor:Yd,load:function(e,n,t,r){var i=new Gu(this.manager);i.setResponseType("arraybuffer"),i.setPath(this.path),i.load(e,function(e){var t=e.slice(0);Hd.getContext().decodeAudioData(t,function(e){n(e)})},t,r)}}),Object.assign(qd.prototype,{isSphericalHarmonics3:!0,set:function(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this},zero:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this},getAt:function(e,t){var n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScale(a[1],.488603*r),t.addScale(a[2],.488603*i),t.addScale(a[3],.488603*n),t.addScale(a[4],n*r*1.092548),t.addScale(a[5],r*i*1.092548),t.addScale(a[6],.315392*(3*i*i-1)),t.addScale(a[7],n*i*1.092548),t.addScale(a[8],.546274*(n*n-r*r)),t},getIrradianceAt:function(e,t){var n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScale(a[1],1.023328*r),t.addScale(a[2],1.023328*i),t.addScale(a[3],1.023328*n),t.addScale(a[4],.858086*n*r),t.addScale(a[5],.858086*r*i),t.addScale(a[6],.743125*i*i-.247708),t.addScale(a[7],.858086*n*i),t.addScale(a[8],.429043*(n*n-r*r)),t},add:function(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this},scale:function(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this},lerp:function(e,t){for(var n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this},equals:function(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0},copy:function(e){return this.set(e.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(e,t){void 0===t&&(t=0);for(var n=this.coefficients,r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);for(var n=this.coefficients,r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}}),Object.assign(qd,{getBasisAt:function(e,t){var n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}),Zd.prototype=Object.assign(Object.create(bd.prototype),{constructor:Zd,isLightProbe:!0,copy:function(e){return bd.prototype.copy.call(this,e),this.sh.copy(e.sh),this.intensity=e.intensity,this},toJSON:function(e){return bd.prototype.toJSON.call(this,e)}}),Qd.prototype=Object.assign(Object.create(Zd.prototype),{constructor:Qd,isHemisphereLightProbe:!0,copy:function(e){return Zd.prototype.copy.call(this,e),this},toJSON:function(e){return Zd.prototype.toJSON.call(this,e)}}),Kd.prototype=Object.assign(Object.create(Zd.prototype),{constructor:Kd,isAmbientLightProbe:!0,copy:function(e){return Zd.prototype.copy.call(this,e),this},toJSON:function(e){return Zd.prototype.toJSON.call(this,e)}});var Jd,$d={fromCubeTexture:function(e){for(var t,n,r,i=0,a=new un,o=new un,s=new rn,l=[0,0,0,0,0,0,0,0,0],c=new qd,u=c.coefficients,d=0;d<6;d++){var h=e.image[d],p=h.width,f=h.height,m=document.createElement("canvas");m.width=p,m.height=f;var v=m.getContext("2d");v.drawImage(h,0,0,p,f);for(var g=v.getImageData(0,0,p,f),_=g.data,y=g.width,x=2/y,b=0,M=_.length;b<M;b+=4){s.set(_[b]/255,_[b+1]/255,_[b+2]/255,_[b+3]/255),eh(s,e.encoding);var w=b/4,A=(w%y+.5)*x-1,S=1-(Math.floor(w/y)+.5)*x;switch(d){case 0:a.set(-1,S,-A);break;case 1:a.set(1,S,A);break;case 2:a.set(-A,1,-S);break;case 3:a.set(-A,-1,S);break;case 4:a.set(-A,S,1);break;case 5:a.set(A,S,-1)}n=a.lengthSq(),i+=r=4/(Math.sqrt(n)*n),o.copy(a).normalize(),qd.getBasisAt(o,l);for(var T=0;T<9;T++)u[T].x+=l[T]*s.x*r,u[T].y+=l[T]*s.y*r,u[T].z+=l[T]*s.z*r}}t=4*Math.PI/i;for(T=0;T<9;T++)u[T].x*=t,u[T].y*=t,u[T].z*=t;return new Zd(c)},fromCubeRenderTarget:function(e,t){for(var n,r,i,a=0,o=new un,s=new un,l=new rn,c=[0,0,0,0,0,0,0,0,0],u=new qd,d=u.coefficients,h=0;h<6;h++){var p=t.width,f=new Uint8Array(p*p*4);e.readRenderTargetPixels(t,0,0,p,p,f,h);for(var m=2/p,v=0,g=f.length;v<g;v+=4){l.set(f[v]/255,f[v+1]/255,f[v+2]/255,f[v+3]/255),eh(l,t.texture.encoding);var _=v/4,y=(_%p+.5)*m-1,x=1-(Math.floor(_/p)+.5)*m;switch(h){case 0:o.set(1,x,-y);break;case 1:o.set(-1,x,y);break;case 2:o.set(y,1,-x);break;case 3:o.set(y,-1,x);break;case 4:o.set(y,x,1);break;case 5:o.set(-y,x,-1)}r=o.lengthSq(),a+=i=4/(Math.sqrt(r)*r),s.copy(o).normalize(),qd.getBasisAt(s,c);for(var b=0;b<9;b++)d[b].x+=c[b]*l.x*i,d[b].y+=c[b]*l.y*i,d[b].z+=c[b]*l.z*i}}n=4*Math.PI/a;for(b=0;b<9;b++)d[b].x*=n,d[b].y*=n,d[b].z*=n;return new Zd(u)}},eh=(Jd=new Lr,function(e,t){switch(t){case Et:th(e,Jd),Jd.convertSRGBToLinear(),nh(Jd,e);break;case Pt:th(e,Jd),Jd.convertRGBEToLinear(e.w),nh(Jd,e),e.w=1;break;case Tt:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported encoding.")}return e});function th(e,t){t.setRGB(e.x,e.y,e.z)}function nh(e,t){t.setX(e.r).setY(e.g).setZ(e.b)}var rh=new _n,ih=new _n;function ah(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Xi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Xi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(ah.prototype,{update:function(e){var t,n,r,i,a,o,s=this._cache;s.focus===e.focus&&s.fov===e.fov&&s.aspect===e.aspect*this.aspect&&s.near===e.near&&s.far===e.far&&s.zoom===e.zoom&&s.eyeSep===this.eyeSep||(s.focus=e.focus,s.fov=e.fov,s.aspect=e.aspect*this.aspect,s.near=e.near,s.far=e.far,s.zoom=e.zoom,s.eyeSep=this.eyeSep,t=e.projectionMatrix.clone(),r=(n=s.eyeSep/2)*s.near/s.focus,i=s.near*Math.tan(Kt.DEG2RAD*s.fov*.5)/s.zoom,ih.elements[12]=-n,rh.elements[12]=n,a=-i*s.aspect+r,o=i*s.aspect+r,t.elements[0]=2*s.near/(o-a),t.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(t),a=-i*s.aspect-r,o=i*s.aspect-r,t.elements[0]=2*s.near/(o-a),t.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(t)),this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ih),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(rh)}});var oh,sh,lh,ch={calcCameraZoomToObjectsParams:(sh=new Jn,lh=new rr,function(e,t,n,r){var i=sh.makeEmpty();t.forEach(function(e){i.expandByObject(e)});var a=i.getBoundingSphere(lh);ch.calcCameraZoomToSphereParams(e,a,n,r)}),calcCameraZoomToSphereParams:(oh=new un,function(e,t,n,r){var i=Kt.degToRad(e.fov/2);e.aspect<1&&(i=Math.atan(e.aspect*Math.tan(i)));var a=t.radius/Math.sin(i),o=e.getWorldDirection(oh);n.copy(t.center).addScaledVector(o,-a),r.copy(t.center)})};function uh(e){this.autoStart=void 0===e||e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}Object.assign(uh.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e,t=0;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(t=((e=("undefined"==typeof performance?Date:performance).now())-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t),t)}});var dh=new un,hh=new sn,ph=new un,fh=new un;function mh(){Bn.call(this),this.type="AudioListener",this.context=Hd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new uh}function vh(e){Bn.call(this),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this._startedAt=0,this._pausedAt=0,this.filters=[]}mh.prototype=Object.assign(Object.create(Bn.prototype),{constructor:mh,getInput:function(){return this.gain},removeFilter:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this},updateMatrixWorld:function(e){Bn.prototype.updateMatrixWorld.call(this,e);var t,n=this.context.listener,r=this.up;this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(dh,hh,ph),fh.set(0,0,-1).applyQuaternion(hh),n.positionX?(t=this.context.currentTime+this.timeDelta,n.positionX.linearRampToValueAtTime(dh.x,t),n.positionY.linearRampToValueAtTime(dh.y,t),n.positionZ.linearRampToValueAtTime(dh.z,t),n.forwardX.linearRampToValueAtTime(fh.x,t),n.forwardY.linearRampToValueAtTime(fh.y,t),n.forwardZ.linearRampToValueAtTime(fh.z,t),n.upX.linearRampToValueAtTime(r.x,t),n.upY.linearRampToValueAtTime(r.y,t),n.upZ.linearRampToValueAtTime(r.z,t)):(n.setPosition(dh.x,dh.y,dh.z),n.setOrientation(fh.x,fh.y,fh.z,r.x,r.y,r.z))}}),vh.prototype=Object.assign(Object.create(Bn.prototype),{constructor:vh,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setMediaElementSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this},setMediaStreamSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(e){if(void 0===e&&(e=0),!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+e;var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._pausedAt+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("v3d.Audio: this Audio has no playback control.")}else console.warn("v3d.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._pausedAt=(this.context.currentTime-this._startedAt)*this.playbackRate,this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("v3d.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this._pausedAt=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("v3d.Audio: this Audio has no playback control.")},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e=e||[],!0===this.isPlaying?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},setDetune:function(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("v3d.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("v3d.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("v3d.Audio: this Audio has no playback control.")},setLoopStart:function(e){return this.loopStart=e,this},setLoopEnd:function(e){return this.loopEnd=e,this},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}});var gh=new un,_h=new sn,yh=new un,xh=new un;function bh(e){vh.call(this,e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}function Mh(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}function wh(e,t,n){this.binding=e,this.valueSize=n;var r,i=Float64Array;switch(t){case"quaternion":r=this._slerp;break;case"string":case"bool":i=Array,r=this._select;break;default:r=this._lerp}this.buffer=new i(4*n),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}bh.prototype=Object.assign(Object.create(vh.prototype),{constructor:bh,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){return this.panner.refDistance=e,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){return this.panner.rolloffFactor=e,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){return this.panner.distanceModel=e,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){return this.panner.maxDistance=e,this},setDirectionalCone:function(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this},updateMatrixWorld:function(e){var t,n;Bn.prototype.updateMatrixWorld.call(this,e),!0===this.hasPlaybackControl&&!1===this.isPlaying||(this.matrixWorld.decompose(gh,_h,yh),xh.set(0,0,1).applyQuaternion(_h),(t=this.panner).positionX?(n=this.context.currentTime+this.listener.timeDelta,t.positionX.linearRampToValueAtTime(gh.x,n),t.positionY.linearRampToValueAtTime(gh.y,n),t.positionZ.linearRampToValueAtTime(gh.z,n),t.orientationX.linearRampToValueAtTime(xh.x,n),t.orientationY.linearRampToValueAtTime(xh.y,n),t.orientationZ.linearRampToValueAtTime(xh.z,n)):(t.setPosition(gh.x,gh.y,gh.z),t.setOrientation(xh.x,xh.y,xh.z)))}}),Object.assign(Mh.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,t=this.getFrequencyData(),n=0;n<t.length;n++)e+=t[n];return e/t.length}}),Object.assign(wh.prototype,{accumulate:function(e,t){var n=this.buffer,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==r;++o)n[i+o]=n[o];a=t}else{var s=t/(a+=t);this._mixBufferRegion(n,i,0,s,r)}this.cumulativeWeight=a},apply:function(e){var t,n=this.valueSize,r=this.buffer,i=e*n+n,a=this.cumulativeWeight,o=this.binding;this.cumulativeWeight=0,a<1&&(t=3*n,this._mixBufferRegion(r,i,t,1-a,n));for(var s=n,l=n+n;s!==l;++s)if(r[s]!==r[s+n]){o.setValue(r,i);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,n=this.valueSize,r=3*n;e.getValue(t,r);for(var i=n,a=r;i!==a;++i)t[i]=t[r+i%n];this.cumulativeWeight=0},restoreOriginalState:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)},_select:function(e,t,n,r,i){if(.5<=r)for(var a=0;a!==i;++a)e[t+a]=e[n+a]},_slerp:function(e,t,n,r){sn.slerpFlat(e,t,e,t,e,n,r)},_lerp:function(e,t,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*r}}});var Ah="\\[\\]\\.",Sh=new RegExp("["+Ah+"]","g"),Th="[^"+Ah+"]",Eh="[^"+Ah.replace("\\.","")+"]",Ch=(/((?:WC+[\/:])*)/.source.replace("WC",Th),/(WCOD+)?/.source.replace("WCOD",Eh)),Ph=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Th),Lh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Th),Rh=new RegExp("^"+Ch+Ph+Lh+"$"),Dh=["material","materials","bones"];function Nh(e,t,n){var r=n||Ih.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}function Ih(e,t,n){this.path=t,this.parsedPath=n||Ih.parseTrackName(t),this.node=Ih.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Oh(){this.uuid=Kt.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function Fh(e,t,n){this._mixer=e,this._clip=t,this._localRoot=n||null;for(var r=t.tracks,i=r.length,a=new Array(i),o={endingStart:wt,endingEnd:wt},s=0;s!==i;++s){var l=r[s].createInterpolant(null);(a[s]=l).settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._pingIsEven=!0,this._startTime=null,this.time=0,this.timeStart=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Bh(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function zh(e){"string"==typeof e&&(console.warn("v3d.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function Uh(e,t,n){ms.call(this,e,t),this.meshPerAttribute=n||1}function Vh(e,t,n){return this.radius=void 0!==e?e:1,this.theta=void 0!==t?t:0,this.y=void 0!==n?n:0,this}Object.assign(Nh.prototype,{getValue:function(e,t){this.bind();var n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)},setValue:function(e,t){for(var n=this._bindings,r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(Ih,{Composite:Nh,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new Ih.Composite(e,t,n):new Ih(e,t,n)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(Sh,"")},parseTrackName:function(e){var t=Rh.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var n,r={nodeName:t[1],objectName:t[2],objectIndex:t[3],propertyName:t[4],propertyIndex:t[5]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i&&(n=r.nodeName.substring(i+1),-1!==Dh.indexOf(n)&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=n)),null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r},findNode:function(e,i){if(!i||""===i||"."===i||-1===i||i===e.name||i===e.uuid)return e;if(e.skeleton){var t=e.skeleton.getBoneByName(i);if(void 0!==t)return t}if(e.children){var a=function(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.name===i||n.uuid===i)return n;var r=a(n.children);if(r)return r}return null},n=a(e.children);if(n)return n}return null}}),Object.assign(Ih.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)e[t++]=n[r]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++]},function(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,i=t.propertyIndex;if(e||(e=Ih.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(n){var a=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("v3d.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("v3d.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("v3d.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(var o=0;o<e.length;o++)if(e[o].name===a){a=o;break}break;default:if(void 0===e[n])return void console.error("v3d.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==a){if(void 0===e[a])return void console.error("v3d.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[a]}}var s=e[r];if(void 0!==s){var l=this.Versioning.None;void 0!==(this.targetObject=e).needsUpdate?l=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(l=this.Versioning.MatrixWorldNeedsUpdate);var c=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(o=0;o<this.node.geometry.morphAttributes.position.length;o++)if(e.geometry.morphAttributes.position[o].name===i){i=o;break}}else{if(!e.geometry.morphTargets)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(o=0;o<this.node.geometry.morphTargets.length;o++)if(e.geometry.morphTargets[o].name===i){i=o;break}}}else if("nodeValue"==r){if(i=i.replace(/"/g,""),!e.nodeValueMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(void 0===(i=e.nodeValueMap[i]))return void console.error("v3d.PropertyBinding: Animated node not found ",this)}if(c=this.BindingType.ArrayElement,"nodeRGB"==r){if(i=i.replace(/"/g,""),!e.nodeRGBMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(void 0===(i=e.nodeRGBMap[i]))return void console.error("v3d.PropertyBinding: Animated node not found ",this);c=this.BindingType.HasFromToArray,s=e.nodeRGB[i]}this.resolvedProperty=s,this.propertyIndex=i}else void 0!==s.fromArray&&void 0!==s.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(c=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][l]}else{var u=t.nodeName;console.error("v3d.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",e)}}else console.error("v3d.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Ih.prototype,{_getValue_unbound:Ih.prototype.getValue,_setValue_unbound:Ih.prototype.setValue}),Object.assign(Oh.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._paths,a=this._parsedPaths,o=this._bindings,s=o.length,l=void 0,c=0,u=arguments.length;c!==u;++c){var d=arguments[c],h=d.uuid,p=r[h];if(void 0===p){p=t++,r[h]=p,e.push(d);for(var f=0,m=s;f!==m;++f)o[f].push(new Ih(d,i[f],a[f]))}else if(p<n){l=e[p];var v=--n,g=e[v];e[r[g.uuid]=p]=g,e[r[h]=v]=d;for(f=0,m=s;f!==m;++f){var _=o[f],y=_[v],x=_[p];_[p]=y,void 0===x&&(x=new Ih(d,i[f],a[f])),_[v]=x}}else e[p]!==l&&console.error("v3d.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=n},remove:function(){for(var e=this._objects,t=this.nCachedObjects_,n=this._indicesByUUID,r=this._bindings,i=r.length,a=0,o=arguments.length;a!==o;++a){var s=arguments[a],l=s.uuid,c=n[l];if(void 0!==c&&t<=c){var u=t++,d=e[u];e[n[d.uuid]=c]=d,e[n[l]=u]=s;for(var h=0,p=i;h!==p;++h){var f=r[h],m=f[u],v=f[c];f[c]=m,f[u]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var l=arguments[o].uuid,c=r[l];if(void 0!==c)if(delete r[l],c<n){var u,d=--n,h=e[d],p=e[u=--t];e[r[h.uuid]=c]=h,e[r[p.uuid]=d]=p,e.pop();for(var f=0,m=a;f!==m;++f){var v=(_=i[f])[d],g=_[u];_[c]=v,_[d]=g,_.pop()}}else{e[r[(p=e[u=--t]).uuid]=c]=p,e.pop();for(var _,f=0,m=a;f!==m;++f){(_=i[f])[c]=_[u],_.pop()}}}this.nCachedObjects_=n},subscribe_:function(e,t){var n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(void 0!==r)return i[r];var a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l),r=i.length;n[e]=r,a.push(e),o.push(t),i.push(u);for(var d=c,h=s.length;d!==h;++d){var p=s[d];u[d]=new Ih(p,e,t)}return u},unsubscribe_:function(e){var t,n,r,i,a,o=this._bindingsIndicesByPath,s=o[e];void 0!==s&&(t=this._paths,n=this._parsedPaths,a=(r=this._bindings)[i=r.length-1],r[o[e[i]]=s]=a,r.pop(),n[s]=n[i],n.pop(),t[s]=t[i],t.pop())}}),Object.assign(Fh.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this._pingIsEven=!0,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,n){var r,i,a,o;return e.fadeOut(t),this.fadeIn(t),n&&(r=this._clip.duration,a=(i=e._clip.duration)/r,o=r/i,e.warp(1,a,t),this.warp(o,1,t)),this},crossFadeTo:function(e,t,n){return e.crossFadeFrom(this,t,n)},stopFading:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,t,n){var r=this._mixer,i=r.time,a=this._timeScaleInterpolant,o=this.timeScale;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);var s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=e/o,l[1]=t/o,this},stopWarping:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,n,r){if(this.enabled){var i=this._startTime;if(null!==i){var a=(e-i)*n;if(a<0||0===n)return;this._startTime=null,t=n*a}t*=this._updateTimeScale(e);var o=this._updateTime(t),s=this._updateWeight(e);if(0<s)for(var l=this._interpolants,c=this._propertyBindings,u=0,d=l.length;u!==d;++u)l[u].evaluate(o),c[u].accumulate(r,s)}else this._updateWeight(e)},_updateWeight:function(e){var t,n,r=0;return this.enabled&&(r=this.weight,null!==(t=this._weightInterpolant)&&(r*=n=t.evaluate(e)[0],e>t.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1)))),this._effectiveWeight=r},_updateTimeScale:function(e){var t,n=0;return this.paused||(n=this.timeScale,null!==(t=this._timeScaleInterpolant)&&(n*=t.evaluate(e)[0],e>t.parameterPositions[1]&&(this.stopWarping(),0===n?this.paused=!0:this.timeScale=n))),this._effectiveTimeScale=n},_loopIsPing:function(e){return 2202!==this.loop||(-1==e||0==(1&e)===this._pingIsEven)},_updateTime:function(e){if(0===e)return this.time;if(2200!==this.loop&&this.repetitions<=0)return this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1}),this.time;var t=this.timeStart,n=Math.max(t,this._clip.duration),r=n-t;if(2200===this.loop)return this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.time<t||this.time>n)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Kt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var i=2202===this.loop,a=this._loopIsPing(this._loopCount)?1:-1;this.time+=a*e;var o,s,l,c,u=this.time<t||this.time>n,d=!1;return-1===this._loopCount&&(d=u,this._loopCount=d?-1:0,this._pingIsEven=!d,0<=e?this._setEndings(!0,0===this.repetitions,i):this._setEndings(0===this.repetitions,!0,i)),u&&(o=Math.floor((this.time-t)/r),this._loopCount+=Math.abs(o),(s=this.repetitions-this._loopCount)<=0?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Kt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})):(1==s?(l=e<0,this._setEndings(l,!l,i)):this._setEndings(!1,!1,i),(c=(this.time-t)%r)<0&&(c+=r),this.time=i?n-c:c+t,d||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o}))),this.time},_setEndings:function(e,t,n){var r=this._interpolantSettings;n?(r.endingStart=At,r.endingEnd=At):(r.endingStart=e?this.zeroSlopeAtStart?At:wt:St,r.endingEnd=t?this.zeroSlopeAtEnd?At:wt:St)},_scheduleFading:function(e,t,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}),Bh.prototype=Object.assign(Object.create(o.prototype),{constructor:Bh,_bindAction:function(e,t){var n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==i;++u){var d=r[u],h=d.name;if(void 0!==(p=c[h]))a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,h));continue}var p,f=t&&t._propertyBindings[u].binding.parsedPath;++(p=new wh(Ih.create(n,h,f),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(p,s,h),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){var t,n,r;null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n],this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t));for(var i=e._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t<this._nActiveActions},_addInactiveAction:function(e,t,n){var r,i=this._actions,a=this._actionsByClip,o=a[t];void 0===o?(o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=o):(r=o.knownActions,e._byClipCacheIndex=r.length,r.push(e)),e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e},_removeInactiveAction:function(e){var t=this._actions,n=t[t.length-1],r=e._cacheIndex;t[n._cacheIndex=r]=n,t.pop(),e._cacheIndex=null;var i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;s[l._byClipCacheIndex=c]=l,s.pop(),e._byClipCacheIndex=null,delete o.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete a[i],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0==--i.referenceCount&&this._removeInactiveBinding(i)}},_lendAction:function(e){var t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];t[e._cacheIndex=r]=e,t[i._cacheIndex=n]=i},_takeBackAction:function(e){var t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];t[e._cacheIndex=r]=e,t[i._cacheIndex=n]=i},_addInactiveBinding:function(e,t,n){var r=this._bindingsByRootAndName,i=r[t],a=this._bindings;void 0===i&&(i={},r[t]=i),(i[n]=e)._cacheIndex=a.length,a.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],l=e._cacheIndex;t[s._cacheIndex=l]=s,t.pop(),delete o[i],0===Object.keys(o).length&&delete a[r]},_lendBinding:function(e){var t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];t[e._cacheIndex=r]=e,t[i._cacheIndex=n]=i},_takeBackBinding:function(e){var t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];t[e._cacheIndex=r]=e,t[i._cacheIndex=n]=i},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return void 0===n&&(e[(n=new Gc(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t]=n),n},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];t[e.__cacheIndex=r]=e,t[i.__cacheIndex=n]=i},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t){var n=t||this._root,r=n.uuid,i="string"==typeof e?Ou.findByName(n,e):e,a=null!==i?i.uuid:e,o=this._actionsByClip[a],s=null;if(void 0!==o){var l=o.actionByRoot[r];if(void 0!==l)return l;s=o.knownActions[0],null===i&&(i=s._clip)}if(null===i)return null;var c=new Fh(this,i,t);return this._bindAction(c,s),this._addInactiveAction(c,a,r),c},existingAction:function(e,t){var n=t||this._root,r=n.uuid,i="string"==typeof e?Ou.findByName(n,e):e,a=i?i.uuid:e,o=this._actionsByClip[a];return void 0!==o&&o.actionByRoot[r]||null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,n=this._bindings,r=this._nActiveBindings;this._nActiveActions=0;for(var i=this._nActiveBindings=0;i!==t;++i)e[i].reset();for(i=0;i!==r;++i)n[i].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1,o=0;o!==n;++o){t[o]._update(r,e,i,a)}for(var s=this._bindings,l=this._nActiveBindings,o=0;o!==l;++o)s[o].apply(a);return this},setTime:function(e){for(var t=this.time=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){for(var a=i.knownActions,o=0,s=a.length;o!==s;++o){var l=a[o];this._deactivateAction(l);var c=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,t[u._cacheIndex=c]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[n]}},uncacheRoot:function(e){var t=e.uuid,n=this._actionsByClip;for(var r in n){var i=n[r].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}var a=this._bindingsByRootAndName[t];if(void 0!==a)for(var o in a){var s=a[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(e,t){var n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}),zh.prototype.clone=function(){return new zh(void 0===this.value.clone?this.value:this.value.clone())},Uh.prototype=Object.assign(Object.create(ms.prototype),{constructor:Uh,isInstancedInterleavedBuffer:!0,copy:function(e){return ms.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Object.assign(Vh.prototype,{set:function(e,t,n){return this.radius=e,this.theta=t,this.y=n,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}});var kh=new Jt;function Gh(e,t){this.min=void 0!==e?e:new Jt(1/0,1/0),this.max=void 0!==t?t:new Jt(-1/0,-1/0)}Object.assign(Gh.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var n=kh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return void 0===e&&(console.warn("v3d.Box2: .getCenter() target is now required"),e=new Jt),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("v3d.Box2: .getSize() target is now required"),e=new Jt),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},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},getParameter:function(e,t){return void 0===t&&(console.warn("v3d.Box2: .getParameter() target is now required"),t=new Jt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box2: .clampPoint() target is now required"),t=new Jt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return kh.copy(e).clamp(this.min,this.max).sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),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)}});var jh=new un,Wh=new un;function Xh(e,t){this.start=void 0!==e?e:new un,this.end=void 0!==t?t:new un}function Hh(e){Bn.call(this),this.material=e,this.render=function(){}}Object.assign(Xh.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("v3d.Line3: .getCenter() target is now required"),e=new un),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("v3d.Line3: .delta() target is now required"),e=new un),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("v3d.Line3: .at() target is now required"),t=new un),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){jh.subVectors(e,this.start),Wh.subVectors(this.end,this.start);var n=Wh.dot(Wh),r=Wh.dot(jh)/n;return t&&(r=Kt.clamp(r,0,1)),r},closestPointToPoint:function(e,t,n){var r=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("v3d.Line3: .closestPointToPoint() target is now required"),n=new un),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),((Hh.prototype=Object.create(Bn.prototype)).constructor=Hh).prototype.isImmediateRenderObject=!0;var Yh=new un;function qh(e,t){Bn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var n=new ui,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],i=0,a=1;i<32;i++,a++){var o=i/32*Math.PI*2,s=a/32*Math.PI*2;r.push(Math.cos(o),Math.sin(o),1,Math.cos(s),Math.sin(s),1)}n.setAttribute("position",new qr(r,3));var l=new Ys({fog:!1});this.cone=new nl(n,l),this.add(this.cone),this.update()}((qh.prototype=Object.create(Bn.prototype)).constructor=qh).prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},qh.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Yh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Yh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Zh=new un,Qh=new _n,Kh=new _n;function Jh(e){for(var t=function e(t){var n=[];t&&t.isBone&&n.push(t);for(var r=0;r<t.children.length;r++)n.push.apply(n,e(t.children[r]));return n}(e),n=new ui,r=[],i=[],a=new Lr(0,0,1),o=new Lr(0,1,0),s=0;s<t.length;s++){var l=t[s];l.parent&&l.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}n.setAttribute("position",new qr(r,3)),n.setAttribute("color",new qr(i,3));var c=new Ys({vertexColors:_,depthTest:!1,depthWrite:!1,transparent:!0});nl.call(this,n,c),this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}function $h(e,t,n){this.light=e,this.light.updateMatrixWorld(),this.color=n;var r=new ac(t,4,2),i=new zr({wireframe:!0,fog:!1});Ci.call(this,r,i),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}((Jh.prototype=Object.create(nl.prototype)).constructor=Jh).prototype.updateMatrixWorld=function(e){var t=this.bones,n=this.geometry,r=n.getAttribute("position");Kh.getInverse(this.root.matrixWorld);for(var i=0,a=0;i<t.length;i++){var o=t[i];o.parent&&o.parent.isBone&&(Qh.multiplyMatrices(Kh,o.matrixWorld),Zh.setFromMatrixPosition(Qh),r.setXYZ(a,Zh.x,Zh.y,Zh.z),Qh.multiplyMatrices(Kh,o.parent.matrixWorld),Zh.setFromMatrixPosition(Qh),r.setXYZ(a+1,Zh.x,Zh.y,Zh.z),a+=2)}n.getAttribute("position").needsUpdate=!0,Bn.prototype.updateMatrixWorld.call(this,e)},(($h.prototype=Object.create(Ci.prototype)).constructor=$h).prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},$h.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};var ep=new un,tp=new Lr,np=new Lr;function rp(e,t,n){Bn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new wl(t);r.rotateY(.5*Math.PI),this.material=new zr({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=_);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new Vr(a,3)),this.add(new Ci(r,this.material)),this.update()}function ip(e,t,n,r){e=e||10,t=t||10,n=new Lr(void 0!==n?n:4473924),r=new Lr(void 0!==r?r:8947848);for(var i=t/2,a=e/t,o=e/2,s=[],l=[],c=0,u=0,d=-o;c<=t;c++,d+=a){s.push(-o,0,d,o,0,d),s.push(d,0,-o,d,0,o);var h=c===i?n:r;h.toArray(l,u),u+=3,h.toArray(l,u),u+=3,h.toArray(l,u),u+=3,h.toArray(l,u),u+=3}var p=new ui;p.setAttribute("position",new qr(s,3)),p.setAttribute("color",new qr(l,3));var f=new Ys({vertexColors:_});nl.call(this,p,f)}function ap(e,t,n,r,i,a){e=e||10,t=t||16,n=n||8,r=r||64,i=new Lr(void 0!==i?i:4473924),a=new Lr(void 0!==a?a:8947848);for(var o,s,l,c,u,d,h=[],p=[],f=0;f<=t;f++)l=f/t*(2*Math.PI),o=Math.sin(l)*e,s=Math.cos(l)*e,h.push(0,0,0),h.push(o,0,s),d=1&f?i:a,p.push(d.r,d.g,d.b),p.push(d.r,d.g,d.b);for(f=0;f<=n;f++)for(d=1&f?i:a,u=e-e/n*f,c=0;c<r;c++)l=c/r*(2*Math.PI),o=Math.sin(l)*u,s=Math.cos(l)*u,h.push(o,0,s),p.push(d.r,d.g,d.b),l=(c+1)/r*(2*Math.PI),o=Math.sin(l)*u,s=Math.cos(l)*u,h.push(o,0,s),p.push(d.r,d.g,d.b);var m=new ui;m.setAttribute("position",new qr(h,3)),m.setAttribute("color",new qr(p,3));var v=new Ys({vertexColors:_});nl.call(this,m,v)}((rp.prototype=Object.create(Bn.prototype)).constructor=rp).prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},rp.prototype.update=function(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var t=e.geometry.getAttribute("color");tp.copy(this.light.color),np.copy(this.light.groundColor);for(var n=0,r=t.count;n<r;n++){var i=n<r/2?tp:np;t.setXYZ(n,i.r,i.g,i.b)}t.needsUpdate=!0}e.lookAt(ep.setFromMatrixPosition(this.light.matrixWorld).negate())},ip.prototype=Object.assign(Object.create(nl.prototype),{constructor:ip,copy:function(e){return nl.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return(new this.constructor).copy(this)}}),(ap.prototype=Object.create(nl.prototype)).constructor=ap;var op=new un,sp=new un,lp=new un;function cp(e,t,n){Bn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);var r=new ui;r.setAttribute("position",new qr([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));var i=new Ys({fog:!1});this.lightPlane=new $s(r,i),this.add(this.lightPlane),(r=new ui).setAttribute("position",new qr([0,0,0,0,0,1],3)),this.targetLine=new $s(r,i),this.add(this.targetLine),this.update()}((cp.prototype=Object.create(Bn.prototype)).constructor=cp).prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},cp.prototype.update=function(){op.setFromMatrixPosition(this.light.matrixWorld),sp.setFromMatrixPosition(this.light.target.matrixWorld),lp.subVectors(sp,op),this.lightPlane.lookAt(sp),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(sp),this.targetLine.scale.z=lp.length()};var up=new un,dp=new Wi;function hp(e){var t=new ui,n=new Ys({color:16777215,vertexColors:1}),r=[],i=[],a={},o=new Lr(16755200),s=new Lr(16711680),l=new Lr(43775),c=new Lr(16777215),u=new Lr(3355443);function d(e,t,n){h(e,n),h(t,n)}function h(e,t){r.push(0,0,0),i.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(r.length/3-1)}d("n1","n2",o),d("n2","n4",o),d("n4","n3",o),d("n3","n1",o),d("f1","f2",o),d("f2","f4",o),d("f4","f3",o),d("f3","f1",o),d("n1","f1",o),d("n2","f2",o),d("n3","f3",o),d("n4","f4",o),d("p","n1",s),d("p","n2",s),d("p","n3",s),d("p","n4",s),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l),d("c","t",c),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u),t.setAttribute("position",new qr(r,3)),t.setAttribute("color",new qr(i,3)),nl.call(this,t,n),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}function pp(e,t,n,r,i,a,o){up.set(i,a,o).unproject(r);var s=t[e];if(void 0!==s)for(var l=n.getAttribute("position"),c=0,u=s.length;c<u;c++)l.setXYZ(s[c],up.x,up.y,up.z)}((hp.prototype=Object.create(nl.prototype)).constructor=hp).prototype.update=function(){var e=this.geometry,t=this.pointMap;dp.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),pp("c",t,e,dp,0,0,-1),pp("t",t,e,dp,0,0,1),pp("n1",t,e,dp,-1,-1,-1),pp("n2",t,e,dp,1,-1,-1),pp("n3",t,e,dp,-1,1,-1),pp("n4",t,e,dp,1,1,-1),pp("f1",t,e,dp,-1,-1,1),pp("f2",t,e,dp,1,-1,1),pp("f3",t,e,dp,-1,1,1),pp("f4",t,e,dp,1,1,1),pp("u1",t,e,dp,.7,1.1,-1),pp("u2",t,e,dp,-.7,1.1,-1),pp("u3",t,e,dp,0,2,-1),pp("cf1",t,e,dp,-1,0,1),pp("cf2",t,e,dp,1,0,1),pp("cf3",t,e,dp,0,-1,1),pp("cf4",t,e,dp,0,1,1),pp("cn1",t,e,dp,-1,0,-1),pp("cn2",t,e,dp,1,0,-1),pp("cn3",t,e,dp,0,-1,-1),pp("cn4",t,e,dp,0,1,-1),e.getAttribute("position").needsUpdate=!0};var fp=new Jn;function mp(e,t){this.object=e,void 0===t&&(t=16776960);var n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new ui;i.setIndex(new Vr(n,1)),i.setAttribute("position",new Vr(r,3)),nl.call(this,i,new Ys({color:t})),this.matrixAutoUpdate=!1,this.update()}function vp(e,t){this.type="Box3Helper",this.box=e,t=t||16776960;var n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new ui;r.setIndex(new Vr(n,1)),r.setAttribute("position",new qr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),nl.call(this,r,new Ys({color:t})),this.geometry.computeBoundingSphere()}function gp(e,t,n){this.type="PlaneHelper",this.plane=e,this.size=void 0===t?1:t;var r=void 0!==n?n:16776960,i=new ui;i.setAttribute("position",new qr([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),i.computeBoundingSphere(),$s.call(this,i,new Ys({color:r}));var a=new ui;a.setAttribute("position",new qr([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),a.computeBoundingSphere(),this.add(new Ci(a,new zr({color:r,opacity:.2,transparent:!0,depthWrite:!1})))}((mp.prototype=Object.create(nl.prototype)).constructor=mp).prototype.update=function(e){var t,n,r,i;void 0!==e&&console.warn("v3d.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&fp.setFromObject(this.object),fp.isEmpty()||(t=fp.min,n=fp.max,(i=(r=this.geometry.attributes.position).array)[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere())},mp.prototype.setFromObject=function(e){return this.object=e,this.update(),this},mp.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.object=e.object,this},mp.prototype.clone=function(){return(new this.constructor).copy(this)},((vp.prototype=Object.create(nl.prototype)).constructor=vp).prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),Bn.prototype.updateMatrixWorld.call(this,e))},((gp.prototype=Object.create($s.prototype)).constructor=gp).prototype.updateMatrixWorld=function(e){var t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?Le:re,this.lookAt(this.plane.normal),Bn.prototype.updateMatrixWorld.call(this,e)};var _p,yp,xp=new un;function bp(e,t,n,r,i,a){Bn.call(this),void 0===e&&(e=new un(0,0,1)),void 0===t&&(t=new un(0,0,0)),void 0===n&&(n=1),void 0===r&&(r=16776960),void 0===i&&(i=.2*n),void 0===a&&(a=.2*i),void 0===_p&&((_p=new ui).setAttribute("position",new qr([0,0,0,0,1,0],3)),(yp=new mc(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new $s(_p,new Ys({color:r})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ci(yp,new zr({color:r})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,a)}function Mp(e){var t=[0,0,0,e=e||1,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new ui;n.setAttribute("position",new qr(t,3)),n.setAttribute("color",new qr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var r=new Ys({vertexColors:_});nl.call(this,n,r)}((bp.prototype=Object.create(Bn.prototype)).constructor=bp).prototype.setDirection=function(e){var t;.99999<e.y?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(xp.set(e.z,0,-e.x).normalize(),t=Math.acos(e.y),this.quaternion.setFromAxisAngle(xp,t))},bp.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},bp.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},bp.prototype.copy=function(e){return Bn.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},bp.prototype.clone=function(){return(new this.constructor).copy(this)},(Mp.prototype=Object.create(nl.prototype)).constructor=Mp;function wp(e){console.warn("v3d.ClosedSplineCurve3 has been deprecated. Use v3d.CatmullRomCurve3 instead."),rd.call(this,e),this.type="catmullrom",this.closed=!0}function Ap(e){console.warn("v3d.SplineCurve3 has been deprecated. Use v3d.CatmullRomCurve3 instead."),rd.call(this,e),this.type="catmullrom"}function Sp(e){console.warn("v3d.Spline has been removed. Use v3d.CatmullRomCurve3 instead."),rd.call(this,e),this.type="catmullrom"}Zu.create=function(e,t){return console.log("v3d.Curve.create() has been deprecated"),e.prototype=Object.create(Zu.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},Object.assign(_d.prototype,{createPointsGeometry:function(e){console.warn("v3d.CurvePath: .createPointsGeometry() has been removed. Use new v3d.Geometry().setFromPoints(points) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("v3d.CurvePath: .createSpacedPointsGeometry() has been removed. Use new v3d.Geometry().setFromPoints(points) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("v3d.CurvePath: .createGeometry() has been removed. Use new v3d.Geometry().setFromPoints(points) instead.");for(var t=new Oi,n=0,r=e.length;n<r;n++){var i=e[n];t.vertices.push(new un(i.x,i.y,i.z||0))}return t}}),Object.assign(yd.prototype,{fromPoints:function(e){return console.warn("v3d.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),wp.prototype=Object.create(rd.prototype),Ap.prototype=Object.create(rd.prototype),Sp.prototype=Object.create(rd.prototype),Object.assign(Sp.prototype,{initFromArray:function(){console.error("v3d.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("v3d.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("v3d.Spline: .reparametrizeByArcLength() has been removed.")}}),ip.prototype.setColors=function(){console.error("v3d.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},Jh.prototype.update=function(){console.error("v3d.SkeletonHelper: update() no longer needs to be called.")},Object.assign(Vu.prototype,{extractUrlBase:function(e){return console.warn("v3d.Loader: .extractUrlBase() has been deprecated. Use v3d.LoaderUtils.extractUrlBase() instead."),Dd.extractUrlBase(e)}}),Vu.Handlers={add:function(){console.error("v3d.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("v3d.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(Bd.prototype,{setTexturePath:function(e){return console.warn("v3d.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}),Object.assign(Gh.prototype,{center:function(e){return console.warn("v3d.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("v3d.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("v3d.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("v3d.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Jn.prototype,{center:function(e){return console.warn("v3d.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("v3d.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("v3d.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("v3d.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("v3d.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Ki.prototype.setFromMatrix=function(e){return console.warn("v3d.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Xh.prototype.center=function(e){return console.warn("v3d.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Object.assign(Kt,{random16:function(){return console.warn("v3d.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("v3d.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Kt.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("v3d.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Kt.ceilPowerOfTwo(e)}}),Object.assign($t.prototype,{flattenToArrayOffset:function(e,t){return console.warn("v3d.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("v3d.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("v3d.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("v3d.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("v3d.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(_n.prototype,{extractPosition:function(e){return console.warn("v3d.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("v3d.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){return console.warn("v3d.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition(matrix) instead."),(new un).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("v3d.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("v3d.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("v3d.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("v3d.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("v3d.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("v3d.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection(matrix) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("v3d.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},translate:function(){console.error("v3d.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("v3d.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("v3d.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("v3d.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("v3d.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("v3d.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("v3d.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,n,r,i,a){return console.warn("v3d.Matrix4: .makeFrustum() has been removed. Use .makePerspective(left, right, top, bottom, near, far) instead."),this.makePerspective(e,t,r,n,i,a)}}),mr.prototype.isIntersectionLine=function(e){return console.warn("v3d.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},sn.prototype.multiplyVector3=function(e){return console.warn("v3d.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion(quaternion) instead."),e.applyQuaternion(this)},Object.assign(dr.prototype,{isIntersectionBox:function(e){return console.warn("v3d.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("v3d.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("v3d.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(Tr.prototype,{area:function(){return console.warn("v3d.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("v3d.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("v3d.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("v3d.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("v3d.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(Tr,{barycoordFromPoint:function(e,t,n,r,i){return console.warn("v3d.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Tr.getBarycoord(e,t,n,r,i)},normal:function(e,t,n,r){return console.warn("v3d.Triangle: .normal() has been renamed to .getNormal()."),Tr.getNormal(e,t,n,r)}}),Object.assign(xd.prototype,{extractAllPoints:function(e){return console.warn("v3d.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("v3d.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Jl(this,e)},makeGeometry:function(e){return console.warn("v3d.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new uc(this,e)}}),Object.assign(Jt.prototype,{fromAttribute:function(e,t,n){return console.warn("v3d.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn("v3d.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("v3d.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(un.prototype,{setEulerFromRotationMatrix:function(){console.error("v3d.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("v3d.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("v3d.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("v3d.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("v3d.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("v3d.Vector3: .applyProjection() has been removed. Use .applyMatrix4(m) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,n){return console.warn("v3d.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn("v3d.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("v3d.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(rn.prototype,{fromAttribute:function(e,t,n){return console.warn("v3d.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},lengthManhattan:function(){return console.warn("v3d.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Oi.prototype,{computeTangents:function(){console.error("v3d.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("v3d.Geometry: .computeLineDistances() has been removed. Use v3d.Line.computeLineDistances() instead.")},applyMatrix:function(e){return console.warn("v3d.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.assign(Bn.prototype,{getChildByName:function(e){return console.warn("v3d.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("v3d.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("v3d.Object3D: .translate() has been removed. Use .translateOnAxis(axis, distance) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("v3d.Object3D: .getWorldRotation() has been removed. Use v3d.Object3D.getWorldQuaternion(target) instead.")},applyMatrix:function(e){return console.warn("v3d.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(Bn.prototype,{eulerOrder:{get:function(){return console.warn("v3d.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("v3d.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("v3d.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("v3d.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Ci.prototype,{setDrawMode:function(){console.error("v3d.Mesh: .setDrawMode() has been removed. The renderer now always assumes v3d.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Ci.prototype,{drawMode:{get:function(){return console.error("v3d.Mesh: .drawMode has been removed. The renderer now always assumes v3d.TrianglesDrawMode."),0},set:function(){console.error("v3d.Mesh: .drawMode has been removed. The renderer now always assumes v3d.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(Fs.prototype,{objects:{get:function(){return console.warn("v3d.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Vs.prototype,"useVertexTexture",{get:function(){console.warn("v3d.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("v3d.Skeleton: useVertexTexture has been removed.")}}),Bs.prototype.initBones=function(){console.error("v3d.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Zu.prototype,"__arcLengthDivisions",{get:function(){return console.warn("v3d.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("v3d.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Xi.prototype.setLens=function(e,t){console.warn("v3d.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(bd.prototype,{onlyShadow:{set:function(){console.warn("v3d.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("v3d.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("v3d.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("v3d.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("v3d.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("v3d.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("v3d.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("v3d.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("v3d.Light: .shadowCameraVisible has been removed. Use new v3d.CameraHelper(light.shadow.camera) instead.")}},shadowBias:{set:function(e){console.warn("v3d.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("v3d.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("v3d.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("v3d.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Vr.prototype,{length:{get:function(){return console.warn("v3d.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("v3d.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===jt},set:function(){console.warn("v3d.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(jt)}}}),Object.assign(Vr.prototype,{setDynamic:function(e){return console.warn("v3d.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?jt:Gt),this},copyIndicesArray:function(){console.error("v3d.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("v3d.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(ui.prototype,{addIndex:function(e){console.warn("v3d.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,t){return console.warn("v3d.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("v3d.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("v3d.BufferGeometry: .addAttribute() now expects (name, attribute)."),this.setAttribute(e,new Vr(t,arguments[2])))},addDrawCall:function(e,t,n){void 0!==n&&console.warn("v3d.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("v3d.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("v3d.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("v3d.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("v3d.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("v3d.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("v3d.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(ui.prototype,{drawcalls:{get:function(){return console.error("v3d.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("v3d.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(ms.prototype,{dynamic:{get:function(){return console.warn("v3d.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===jt},set:function(e){console.warn("v3d.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(ms.prototype,{setDynamic:function(e){return console.warn("v3d.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?jt:Gt),this},setArray:function(){console.error("v3d.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign($l.prototype,{getArrays:function(){console.error("v3d.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("v3d.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("v3d.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(zh.prototype,{dynamic:{set:function(){console.warn("v3d.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("v3d.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Br.prototype,{wrapAround:{get:function(){console.warn("v3d.Material: .wrapAround has been removed.")},set:function(){console.warn("v3d.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("v3d.Material: .overdraw has been removed.")},set:function(){console.warn("v3d.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("v3d.Material: .wrapRGB has been removed."),new Lr}},shading:{get:function(){console.error("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("v3d."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("v3d."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(Sc.prototype,{metal:{get:function(){return console.warn("v3d.MeshPhongMaterial: .metal has been removed. Use v3d.MeshStandardMaterial instead."),!1},set:function(){console.warn("v3d.MeshPhongMaterial: .metal has been removed. Use v3d.MeshStandardMaterial instead")}}}),Object.defineProperties(ji.prototype,{derivatives:{get:function(){return console.warn("v3d.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("v3d. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(hs.prototype,{clearTarget:function(e,t,n,r){console.warn("v3d.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,r)},animate:function(e){console.warn("v3d.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("v3d.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("v3d.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("v3d.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("v3d.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("v3d.WebGLRenderer: .supportsFloatTextures() is now .extensions.get('OES_texture_float')."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("v3d.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get('OES_texture_half_float')."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("v3d.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get('OES_standard_derivatives')."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("v3d.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get('WEBGL_compressed_texture_s3tc')."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("v3d.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get('WEBGL_compressed_texture_pvrtc')."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("v3d.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get('EXT_blend_minmax')."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("v3d.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("v3d.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get('ANGLE_instanced_arrays')."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("v3d.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("v3d.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("v3d.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("v3d.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("v3d.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("v3d.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("v3d.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("v3d.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("v3d.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("v3d.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("v3d.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(hs.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("v3d.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("v3d.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("v3d.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("v3d.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("v3d.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("v3d.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("v3d.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("v3d.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?Et:Tt}}}),Object.defineProperties(Jo.prototype,{cullFace:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(an.prototype,{wrapS:{get:function(){return console.warn("v3d.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("v3d.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("v3d.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("v3d.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("v3d.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("v3d.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("v3d.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("v3d.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("v3d.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("v3d.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("v3d.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("v3d.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("v3d.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("v3d.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("v3d.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("v3d.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("v3d.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("v3d.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("v3d.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("v3d.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(vh.prototype,{load:{value:function(e){console.warn("v3d.Audio: .load has been deprecated. Use v3d.AudioLoader instead.");var t=this;return(new Yd).load(e,function(e){t.setBuffer(e)}),this}},startTime:{set:function(){console.warn("v3d.Audio: .startTime is now .play(delay).")}}}),Mh.prototype.getData=function(){return console.warn("v3d.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Hi.prototype.updateCubeMap=function(e,t){return console.warn("v3d.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)};var Tp={merge:function(e,t,n){var r;console.warn("v3d.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge(geometry2, matrix, materialIndexOffset) instead."),t.isMesh&&(t.matrixAutoUpdate&&t.updateMatrix(),r=t.matrix,t=t.geometry),e.merge(t,r,n)},center:function(e){return console.warn("v3d.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}};en.crossOrigin=void 0,en.loadTexture=function(e,t,n,r){console.warn("v3d.ImageUtils.loadTexture has been deprecated. Use v3d.TextureLoader() instead.");var i=new qu;i.setCrossOrigin(this.crossOrigin);var a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},en.loadTextureCube=function(e,t,n,r){console.warn("v3d.ImageUtils.loadTextureCube has been deprecated. Use v3d.CubeTextureLoader() instead.");var i=new Yu;i.setCrossOrigin(this.crossOrigin);var a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},en.loadCompressedTexture=function(){console.error("v3d.ImageUtils.loadCompressedTexture has been removed. Use v3d.DDSLoader instead.")},en.loadCompressedTextureCube=function(){console.error("v3d.ImageUtils.loadCompressedTextureCube has been removed. Use v3d.DDSLoader instead.")};var Ep=new un,Cp=new un,Pp=new un,Lp=new Jt,Rp=new Jt,Dp=new Jt,Np=new un,Ip=new un;function Op(e,t,n,r,i,a,o,s){Ep.fromBufferAttribute(r,a),Cp.fromBufferAttribute(r,o),Pp.fromBufferAttribute(r,s);var l,c=function(e,t,n,r,i,a,o,s){var l=t.side===Le?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side!==ie,s);if(null===l)return null;Ip.copy(s),Ip.applyMatrix4(e.matrixWorld);var c=n.ray.origin.distanceTo(Ip);return c<n.near||c>n.far?null:{distance:c,point:Ip.clone(),object:e}}(e,e.material,t,n,Ep,Cp,Pp,Np);return c&&(i&&(Lp.fromBufferAttribute(i,a),Rp.fromBufferAttribute(i,o),Dp.fromBufferAttribute(i,s),c.uv=Tr.getUV(Np,Ep,Cp,Pp,Lp,Rp,Dp,new Jt)),l=new un,c.face=new Or(a,o,s,Tr.getNormal(Ep,Cp,Pp,l)),c.faceIndex=a),c}function Fp(e,t,n,r,i,a){var o=3*i,s=t.index.getX(o),l=t.index.getX(1+o),c=t.index.getX(2+o),u=Op(e,n,r,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=i,a&&a.push(u),u):null}function Bp(e,t){return t.min.x=e[0],t.min.y=e[1],t.min.z=e[2],t.max.x=e[3],t.max.y=e[4],t.max.z=e[5],t}function zp(e){for(var t=-1,n=-1/0,r=0;r<3;r++){var i=e[r+3]-e[r];n<i&&(n=i,t=r)}return t}var Up,Vp=function(){function e(){_classCallCheck(this,e),this.min=1/0,this.max=-1/0}return _createClass(e,[{key:"setFromPointsField",value:function(e,t){for(var n=1/0,r=-1/0,i=0,a=e.length;i<a;i++)var o=e[i][t],n=Math.min(o,n),r=Math.max(o,r);this.min=n,this.max=r}},{key:"setFromPoints",value:function(e,t){for(var n=1/0,r=-1/0,i=0,a=t.length;i<a;i++)var o=t[i],s=e.dot(o),n=Math.min(s,n),r=Math.max(s,r);this.min=n,this.max=r}},{key:"isSeparated",value:function(e){return this.min>e.max||e.min>this.max}}]),e}();Vp.prototype.setFromBox=(Up=new un,function(e,t){for(var n=t.min,r=t.max,i=1/0,a=-1/0,o=0;o<=1;o++)for(var s=0;s<=1;s++)for(var l=0;l<=1;l++){Up.x=n.x*o+r.x*(1-o),Up.y=n.y*s+r.y*(1-s),Up.z=n.z*l+r.z*(1-l);var c=e.dot(Up),i=Math.min(c,i),a=Math.max(c,a)}this.min=i,this.max=a});var kp,Gp,jp,Wp,Xp,Hp,Yp,qp,Zp,Qp,Kp,Jp,$p,ef,tf,nf,rf,af,of,sf,lf,cf,uf,df=(kp=new un,Gp=new un,jp=new un,function(e,t,n){var r=e.start,i=kp,a=t.start,o=Gp;jp.subVectors(r,a),kp.subVectors(e.end,t.start),Gp.subVectors(t.end,t.start);var s=jp.dot(o),l=o.dot(i),c=o.dot(o),u=jp.dot(i),d=i.dot(i)*c-l*l,h=0!=d?(s*l-u*c)/d:0,p=(s+h*l)/c;n.x=h,n.y=p}),hf=(Wp=new Jt,Xp=new un,Hp=new un,function(e,t,n,r){df(e,t,Wp);var i=Wp.x,a=Wp.y;if(0<=i&&i<=1&&0<=a&&a<=1)return e.at(i,n),void t.at(a,r);if(0<=i&&i<=1)return a<0?t.at(0,r):t.at(1,r),void e.closestPointToPoint(r,!0,n);if(0<=a&&a<=1)return i<0?e.at(0,n):e.at(1,n),void t.closestPointToPoint(n,!0,r);var o=i<0?e.start:e.end,s=a<0?t.start:t.end,l=Xp,c=Hp;return e.closestPointToPoint(s,!0,Xp),t.closestPointToPoint(o,!0,Hp),l.distanceToSquared(s)<=c.distanceToSquared(o)?(n.copy(l),void r.copy(s)):(n.copy(o),void r.copy(c))}),pf=(Yp=new un,qp=new un,Zp=new mr,Qp=new Xh,function(e,t){var n=e.radius,r=e.center,i=t.a,a=t.b,o=t.c;if(Qp.start=i,Qp.end=a,Qp.closestPointToPoint(r,!0,Yp).distanceTo(r)<=n)return!0;if(Qp.start=i,Qp.end=o,Qp.closestPointToPoint(r,!0,Yp).distanceTo(r)<=n)return!0;if(Qp.start=a,Qp.end=o,Qp.closestPointToPoint(r,!0,Yp).distanceTo(r)<=n)return!0;var s=t.getPlane(Zp);if(Math.abs(s.distanceToPoint(r))<=n){var l=s.projectPoint(r,qp);if(t.containsPoint(l))return!0}return!1}),ff=function(){_inherits(a,Tr);var i=_createSuper(a);function a(){var e;_classCallCheck(this,a);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=i.call.apply(i,[this].concat(n))).isSeparatingAxisTriangle=!0,e.satAxes=new Array(4).fill().map(function(){return new un}),e.satBounds=new Array(4).fill().map(function(){return new Vp}),e.points=[e.a,e.b,e.c],e.sphere=new rr,e}return a}();ff.prototype.update=(Kp=new Array(3),function(){var e=this.a,t=this.b,n=this.c;Kp[0]=this.a,Kp[1]=this.b,Kp[2]=this.c;var r=this.satAxes,i=this.satBounds,a=r[0],o=i[0];this.getNormal(a),o.setFromPoints(a,Kp);var s=r[1],l=i[1];s.subVectors(e,t),l.setFromPoints(s,Kp);var c=r[2],u=i[2];c.subVectors(t,n),u.setFromPoints(c,Kp);var d=r[3],h=i[3];d.subVectors(n,e),h.setFromPoints(d,Kp),this.sphere.setFromPoints(this.points)}),ff.prototype.intersectsTriangle=(Jp=new ff,$p=new Array(3),ef=new Array(3),tf=new Vp,nf=new Vp,rf=new un,function(e){e.isSeparatingAxisTriangle||(Jp.copy(e),Jp.update(),e=Jp);var t=this.satBounds,n=this.satAxes;ef[0]=e.a,ef[1]=e.b,ef[2]=e.c;for(var r=0;r<4;r++){var i=t[r],a=n[r];if(tf.setFromPoints(a,ef),i.isSeparated(tf))return!1}var o=e.satBounds,s=e.satAxes;$p[0]=this.a,$p[1]=this.b,$p[2]=this.c;for(var l=0;l<4;l++){var c=o[l],u=s[l];if(tf.setFromPoints(u,$p),c.isSeparated(tf))return!1}for(var d=0;d<4;d++)for(var h=n[d],p=0;p<4;p++){var f=s[p];if(rf.crossVectors(h,f),tf.setFromPoints(rf,$p),nf.setFromPoints(rf,ef),tf.isSeparated(nf))return!1}return!0}),ff.prototype.distanceToPoint=(af=new un,function(e){return this.closestPointToPoint(e,af),e.distanceTo(af)}),ff.prototype.distanceToTriangle=(of=new un,sf=new un,lf=["a","b","c"],cf=new Xh,uf=new Xh,function(e,t,n){var r=1<arguments.length&&void 0!==t?t:null,i=2<arguments.length&&void 0!==n?n:null;if(this.intersectsTriangle(e))return(r||i)&&(this.getMidpoint(of),e.closestPointToPoint(of,sf),this.closestPointToPoint(sf,of),r&&r.copy(of),i&&i.copy(sf)),0;for(var a=1/0,o=0;o<3;o++){var s=void 0,l=lf[o],c=e[l];this.closestPointToPoint(c,of),(s=c.distanceToSquared(of))<a&&(a=s,r&&r.copy(of),i&&i.copy(c));var u=this[l];e.closestPointToPoint(u,of),(s=u.distanceToSquared(of))<a&&(a=s,r&&r.copy(u),i&&i.copy(of))}for(var d=0;d<3;d++){var h=lf[d],p=lf[(d+1)%3];cf.set(this[h],this[p]);for(var f=0;f<3;f++){var m=lf[f],v=lf[(f+1)%3];uf.set(e[m],e[v]),hf(cf,uf,of,sf);var g=of.distanceToSquared(sf);g<a&&(a=g,r&&r.copy(of),i&&i.copy(sf))}}return Math.sqrt(a)});var mf,vf,gf,_f,yf,xf,bf,Mf,wf,Af,Sf,Tf,Ef=function(){_inherits(a,Jn);var i=_createSuper(a);function a(){var e;_classCallCheck(this,a);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=i.call.apply(i,[this].concat(n))).isOrientedBox=!0,e.matrix=new _n,e.invMatrix=new _n,e.points=new Array(8).fill().map(function(){return new un}),e.satAxes=new Array(3).fill().map(function(){return new un}),e.satBounds=new Array(3).fill().map(function(){return new Vp}),e.alignedSatBounds=new Array(3).fill().map(function(){return new Vp}),e.sphere=new rr,e}return _createClass(a,[{key:"set",value:function(e,t,n){_get(_getPrototypeOf(a.prototype),"set",this).call(this,e,t),this.matrix=n}},{key:"copy",value:function(e){_get(_getPrototypeOf(a.prototype),"copy",this).call(this,e),this.matrix.copy(e.matrix)}}]),a}();Ef.prototype.update=function(){for(var e=this.matrix,t=this.min,n=this.max,r=this.points,i=0;i<=1;i++)for(var a=0;a<=1;a++)for(var o=0;o<=1;o++){var s=r[+i|2*a|4*o];s.x=i?n.x:t.x,s.y=a?n.y:t.y,s.z=o?n.z:t.z,s.applyMatrix4(e)}this.sphere.setFromPoints(this.points);for(var l=this.satBounds,c=this.satAxes,u=r[0],d=0;d<3;d++){var h=c[d],p=l[d],f=r[1<<d];h.subVectors(u,f),p.setFromPoints(h,r)}var m=this.alignedSatBounds;m[0].setFromPointsField(r,"x"),m[1].setFromPointsField(r,"y"),m[2].setFromPointsField(r,"z"),this.invMatrix.getInverse(this.matrix)},Ef.prototype.intersectsBox=(mf=new Vp,function(e){if(!e.intersectsSphere(this.sphere))return!1;var t=e.min,n=e.max,r=this.satBounds,i=this.satAxes,a=this.alignedSatBounds;if(mf.min=t.x,mf.max=n.x,a[0].isSeparated(mf))return!1;if(mf.min=t.y,mf.max=n.y,a[1].isSeparated(mf))return!1;if(mf.min=t.z,mf.max=n.z,a[2].isSeparated(mf))return!1;for(var o=0;o<3;o++){var s=i[o],l=r[o];if(mf.setFromBox(s,e),l.isSeparated(mf))return!1}return!0}),Ef.prototype.intersectsTriangle=(vf=new ff,gf=new Array(3),_f=new Vp,yf=new Vp,xf=new un,function(e){e.isSeparatingAxisTriangle||(vf.copy(e),vf.update(),e=vf);var t=this.satBounds,n=this.satAxes;gf[0]=e.a,gf[1]=e.b,gf[2]=e.c;for(var r=0;r<3;r++){var i=t[r],a=n[r];if(_f.setFromPoints(a,gf),i.isSeparated(_f))return!1}for(var o=e.satBounds,s=e.satAxes,l=this.points,c=0;c<3;c++){var u=o[c],d=s[c];if(_f.setFromPoints(d,l),u.isSeparated(_f))return!1}for(var h=0;h<3;h++)for(var p=n[h],f=0;f<4;f++){var m=s[f];if(xf.crossVectors(p,m),_f.setFromPoints(xf,gf),yf.setFromPoints(xf,l),_f.isSeparated(yf))return!1}return!0}),Ef.prototype.closestPointToPoint=function(e,t){return t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Ef.prototype.distanceToPoint=(bf=new un,function(e){return this.closestPointToPoint(e,bf),e.distanceTo(bf)}),Ef.prototype.distanceToBox=(Mf=["x","y","z"],wf=new Array(12).fill().map(function(){return new Xh}),Af=new Array(12).fill().map(function(){return new Xh}),Sf=new un,Tf=new un,function(e,t,n,r){var i=1<arguments.length&&void 0!==t?t:0,a=2<arguments.length&&void 0!==n?n:null,o=3<arguments.length&&void 0!==r?r:null;if(this.intersectsBox(e))return(a||o)&&(e.getCenter(Tf),this.closestPointToPoint(Tf,Sf),e.closestPointToPoint(Sf,Tf),a&&a.copy(Sf),o&&o.copy(Tf)),0;for(var s=i*i,l=e.min,c=e.max,u=this.points,d=1/0,h=0;h<8;h++){var p=u[h];Tf.copy(p).clamp(l,c);var f=p.distanceToSquared(Tf);if(f<d&&(d=f,a&&a.copy(p),o&&o.copy(Tf),f<s))return Math.sqrt(f)}for(var m=0,v=0;v<3;v++)for(var g=0;g<=1;g++)for(var _=0;_<=1;_++){var y=(v+1)%3,x=(v+2)%3,b=1<<v|g<<y|_<<x,M=u[g<<y|_<<x],w=u[b];wf[m].set(M,w);var A=Mf[v],S=Mf[y],T=Mf[x],E=Af[m],C=E.start,P=E.end;C[A]=l[A],C[S]=g?l[S]:c[S],C[T]=_?l[T]:c[S],P[A]=c[A],P[S]=g?l[S]:c[S],P[T]=_?l[T]:c[S],m++}for(var L=0;L<=1;L++)for(var R=0;R<=1;R++)for(var D=0;D<=1;D++){Tf.x=L?c.x:l.x,Tf.y=R?c.y:l.y,Tf.z=D?c.z:l.z,this.closestPointToPoint(Tf,Sf);var N=Tf.distanceToSquared(Sf);if(N<d&&(d=N,a&&a.copy(Sf),o&&o.copy(Tf),N<s))return Math.sqrt(N)}for(var I=0;I<12;I++)for(var O=wf[I],F=0;F<12;F++){var B=Af[F];hf(O,B,Sf,Tf);var z=Sf.distanceToSquared(Tf);if(z<d&&(d=z,a&&a.copy(Sf),o&&o.copy(Tf),z<s))return Math.sqrt(z)}return Math.sqrt(d)});var Cf=new Jn,Pf=new un,Lf=["x","y","z"];function Rf(e,t,n,r){var i=e.a,a=e.b,o=e.c,s=n.getX(t);i.x=r.getX(s),i.y=r.getY(s),i.z=r.getZ(s),s=n.getX(t+1),a.x=r.getX(s),a.y=r.getY(s),a.z=r.getZ(s),s=n.getX(t+2),o.x=r.getX(s),o.y=r.getY(s),o.z=r.getZ(s)}var Df,Nf,If,Of,Ff,Bf,zf,Uf,Vf,kf,Gf,jf,Wf,Xf,Hf,Yf=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"intersectRay",value:function(e,t){return Bp(this.boundingData,Cf),e.intersectBox(Cf,t)}},{key:"raycast",value:function(e,t,n,r){this.count?function(e,t,n,r,i,a,o){for(var s=i,l=i+a;s<l;s++)Fp(e,t,n,r,s,o)}(e,e.geometry,t,n,this.offset,this.count,r):(this.left.intersectRay(n,Pf)&&this.left.raycast(e,t,n,r),this.right.intersectRay(n,Pf)&&this.right.raycast(e,t,n,r))}},{key:"raycastFirst",value:function(e,t,n){if(this.count)return function(e,t,n,r,i,a){for(var o=1/0,s=null,l=i,c=i+a;l<c;l++){var u=Fp(e,t,n,r,l);u&&u.distance<o&&(o=(s=u).distance)}return s}(e,e.geometry,t,n,this.offset,this.count);var r,i=this.splitAxis,a=Lf[i],o=0<=n.direction[a]?(r=this.left,this.right):(r=this.right,this.left),s=r.intersectRay(n,Pf)?r.raycastFirst(e,t,n):null;if(s){var l=n.origin[a],c=l-s.point[a],u=l-o.boundingData[i],d=l-o.boundingData[i+3],h=c*c;if(h<=u*u&&h<=d*d)return s}var p=o.intersectRay(n,Pf)?o.raycastFirst(e,t,n):null;return s&&p?s.distance<=p.distance?s:p:s||p||null}}]),e}();Yf.prototype.shapecast=(Df=new ff,Nf=new Jn,If=new Jn,function(e,t,n,r){var i=2<arguments.length&&void 0!==n?n:null,a=3<arguments.length&&void 0!==r?r:null;if(this.count&&i){for(var o=e.geometry,s=o.index,l=o.attributes.position,c=this.offset,u=3*c,d=3*(this.count+c);u<d;u+=3)if(Rf(Df,u,s,l),Df.update(),i(Df,u,u+1,u+2))return!0;return!1}var h,p,f,m,v,g,_=this.left,y=this.right,x=_,b=y;return a&&(v=Nf,g=If,Bp(x.boundingData,v),Bp(b.boundingData,g),p=a(v),(f=a(g))<p&&(x=y,b=_,h=p,p=f,f=h,m=v,v=g,g=m)),v||(v=Nf,Bp(x.boundingData,v)),!!(t(v,!!x.count,p,x)&&x.shapecast(e,t,i,a)||(g||(g=If,Bp(b.boundingData,g)),t(g,!!b.count,f,b)&&b.shapecast(e,t,i,a)))}),Yf.prototype.intersectsGeometry=(Of=new ff,Ff=new ff,Bf=new Ci,zf=new _n,Uf=new Ef,Vf=new Ef,function(e,t,r,n){var i=3<arguments.length&&void 0!==n?n:null;if(null===i&&(t.boundingBox||t.computeBoundingBox(),Uf.set(t.boundingBox.min,t.boundingBox.max,r),Uf.update(),i=Uf),!this.count){var a=this.left,o=this.right;return Bp(a.boundingData,Cf),!(!i.intersectsBox(Cf)||!a.intersectsGeometry(e,t,r,i))||(Bp(o.boundingData,Cf),!(!i.intersectsBox(Cf)||!o.intersectsGeometry(e,t,r,i)))}var s=e.geometry,l=s.index,c=s.attributes.position,u=t.index,d=t.attributes.position,h=this.offset,p=this.count;if(zf.getInverse(r),t.boundsTree){Bp(this.boundingData,Vf),Vf.matrix.copy(zf),Vf.update();var f=(Bf.geometry=t).boundsTree.shapecast(Bf,function(e){return Vf.intersectsBox(e)},function(e){e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.update();for(var t=3*h,n=3*(p+h);t<n;t+=3)if(Rf(Ff,t,l,c),Ff.update(),e.intersectsTriangle(Ff))return!0;return!1});return Bf.geometry=null,f}for(var m=3*h,v=p+3*h;m<v;m+=3){Rf(Of,m,l,c),Of.a.applyMatrix4(zf),Of.b.applyMatrix4(zf),Of.c.applyMatrix4(zf),Of.update();for(var g=0,_=u.count;g<_;g+=3)if(Rf(Ff,g,u,d),Ff.update(),Of.intersectsTriangle(Ff))return!0}}),Yf.prototype.intersectsBox=(kf=new Ef,function(e,t,n){return kf.set(t.min,t.max,n),kf.update(),this.shapecast(e,function(e){return kf.intersectsBox(e)},function(e){return kf.intersectsTriangle(e)})}),Yf.prototype.intersectsSphere=function(e,t){return this.shapecast(e,function(e){return t.intersectsBox(e)},function(e){return pf(t,e)})},Yf.prototype.closestPointToPoint=(Gf=new un,function(e,n,t,r,i){var a=2<arguments.length&&void 0!==t?t:null,o=3<arguments.length&&void 0!==r?r:0,s=4<arguments.length&&void 0!==i?i:1/0,l=1/0;return this.shapecast(e,function(e,t,n){return n<l&&n<s},function(e){e.closestPointToPoint(n,Gf);var t=n.distanceTo(Gf);return t<l&&(a&&a.copy(Gf),l=t),t<o},function(e){return e.distanceToPoint(n)}),l}),Yf.prototype.closestPointToGeometry=(jf=new ff,Wf=new Ef,Xf=new un,Hf=new un,function(e,t,s,n,r,i,a){var l=3<arguments.length&&void 0!==n?n:null,c=4<arguments.length&&void 0!==r?r:null,u=5<arguments.length&&void 0!==i?i:0,o=6<arguments.length&&void 0!==a?a:1/0;t.boundingBox||t.computeBoundingBox(),Wf.set(t.boundingBox.min,t.boundingBox.max,s),Wf.update();var d,h,p=t.attributes.position,f=t.index;l&&(d=Xf),c&&(h=Hf);var m=1/0;return this.shapecast(e,function(e,t,n){return n<m&&n<o},function(e){for(var t=e.sphere,n=0,r=f.count;n<r;n+=3){Rf(jf,n,f,p),jf.a.applyMatrix4(s),jf.b.applyMatrix4(s),jf.c.applyMatrix4(s),jf.sphere.setFromPoints(jf.points);var i=jf.sphere,a=i.center.distanceTo(t.center)-i.radius-t.radius;if(!(m<a)){jf.update();var o=e.distanceToTriangle(jf,d,h);if(o<m&&(l&&l.copy(d),c&&c.copy(h),m=o),o<u)return!0}}return!1},function(e){return Wf.distanceToBox(e,Math.min(m,o))}),m});var qf=0,Zf=2,Qf=["x","y","z"];var Kf=new Jn,Jf=function(){function a(e,t){if(_classCallCheck(this,a),this.geo=e,this.options=t,this.bounds=function(e){for(var t=e.attributes.position.array,n=e.index.array,r=n.length/3,i=new Float32Array(6*r),a=0;a<r;a++)for(var o=3*n[3*a+0],s=3*n[3*a+1],l=3*n[3*a+2],c=0;c<3;c++){var u=t[o+c],d=t[s+c],h=t[l+c],p=Math.min(u,d,h),f=(Math.max(u,d,h)-p)/2;i[6*a+2*c]=p+f,i[6*a+2*c+1]=f}return i}(e),this.sahplanes=null,t.strategy===Zf){var n=e.index.count/3;this.sahplanes=[new Array(n),new Array(n),new Array(n)];for(var r=0;r<n;r++)for(var i=0;i<3;i++)this.sahplanes[i][r]={p:this.bounds[6*r+2*i],tri:r}}}return _createClass(a,[{key:"getAverage",value:function(e,t,n){for(var r=0,i=this.bounds,a=e,o=e+t;a<o;a++)r+=i[6*a+2*n];return r/t}},{key:"getBounds",value:function(e,t,n){for(var r=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,l=-1/0,c=this.bounds,u=e,d=e+t;u<d;u++)var h=c[6*u+0],p=c[6*u+1],r=Math.min(r,h-p),o=Math.max(o,h+p),f=c[6*u+2],m=c[6*u+3],i=Math.min(i,f-m),s=Math.max(s,f+m),v=c[6*u+4],g=c[6*u+5],a=Math.min(a,v-g),l=Math.max(l,v+g);return n[0]=r,n[1]=i,n[2]=a,n[3]=o,n[4]=s,n[5]=l,n}},{key:"partition",value:function(e,t,n){for(var r=e,i=e+t-1,a=n.pos,o=2*n.axis,s=this.geo.index.array,l=this.bounds,c=this.sahplanes;;){for(;r<=i&&l[6*r+o]<a;)r++;for(;r<=i&&l[6*i+o]>=a;)i--;if(!(r<i))return r;for(var u=0;u<3;u++){var d=s[3*r+u];s[3*r+u]=s[3*i+u],s[3*i+u]=d;var h=l[6*r+2*u];l[6*r+2*u]=l[6*i+2*u],l[6*i+2*u]=h;var p=l[6*r+2*u+1];l[6*r+2*u+1]=l[6*i+2*u+1],l[6*i+2*u+1]=p}if(c)for(var f=0;f<3;f++){var m=c[f][r];c[f][r]=c[f][i],c[f][i]=m}r++,i--}}},{key:"getOptimalSplit",value:function(e,t,n,r){var i,a=-1,o=0;if(r===qf)-1!==(a=zp(e))&&(o=(e[a+3]+e[a])/2);else if(1===r)-1!==(a=zp(e))&&(o=this.getAverage(t,n,a));else if(r===Zf){for(var s=Bp(e,Kf),l=[s.max.x-s.min.x,s.max.y-s.min.y,s.max.z-s.min.z],c=2*(l[0]*l[1]+l[0]*l[2]+l[1]*l[2]),u=[[],[],[]],d=t,h=t+n;d<h;d++)for(var p=0;p<3;p++)u[p].push(this.sahplanes[p][d]);u.forEach(function(e){return e.sort(function(e,t){return e.p-t.p})});for(var a=-1,f=+n,m=0;m<3;m++)for(var v=(m+1)%3,g=(m+2)%3,_=s.min[Qf[m]],y=s.max[Qf[m]],x=u[m],b=0,M=n,w=0;w<x.length;w++){var A=x[w];b++,M--;var S=A.p-_,T=y-A.p,E=l[v],C=l[v],P=l[g],L=l[g],R=2*(E*P+E*S+P*S)/(i=c)*b+2*(C*L+C*T+L*T)/i*M+3;R<f&&(a=m,o=A.p,f=R)}}return{axis:a,pos:o}}}]),a}(),$f=function(){function n(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(_classCallCheck(this,n),!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.attributes.position.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the position attribute.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");(t=Object.assign({strategy:qf,maxDepth:40,maxLeafTris:10,verbose:!0},t)).strategy=Math.max(0,Math.min(2,t.strategy)),this._roots=this._buildTree(e,t)}return _createClass(n,[{key:"_ensureIndex",value:function(e){if(!e.index){var t=e.attributes.position.count,n=new(65535<t?Uint32Array:Uint16Array)(t);e.setIndex(new Vr(n,1));for(var r=0;r<t;r++)n[r]=r}}},{key:"_getRootIndexRanges",value:function(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];for(var t=[],n=new Set,r=0,i=e.groups;r<i.length;r++){var a=i[r];n.add(a.start),n.add(a.start+a.count)}for(var o=Array.from(n.values()).sort(function(e,t){return e-t}),s=0;s<o.length-1;s++){var l=o[s],c=o[s+1];t.push({offset:l/3,count:(c-l)/3})}return t}},{key:"_buildTree",value:function(e,h){this._ensureIndex(e);var t,n,p=new Jf(e,h),f=!1,m=function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;if(r>=h.maxDepth&&(f=!0),n<=h.maxLeafTris||r>=h.maxDepth)return e.offset=t,e.count=n,e;var i=p.getOptimalSplit(e.boundingData,t,n,h.strategy);if(-1===i.axis)return e.offset=t,e.count=n,e;var a,o,s,l,c,u,d=p.partition(t,n,i);return d===t||d===t+n?(e.offset=t,e.count=n):(e.splitAxis=i.axis,s=d-(o=t),(a=e.left=new Yf).boundingData=p.getBounds(o,s,new Float32Array(6)),m(a,o,s,r+1),c=d,u=n-s,(l=e.right=new Yf).boundingData=p.getBounds(c,u,new Float32Array(6)),m(l,c,u,r+1)),e},r=[],i=this._getRootIndexRanges(e);if(1===i.length){var a=new Yf,o=i[0];null!=e.boundingBox?a.boundingData=(t=e.boundingBox,(n=new Float32Array(6))[0]=t.min.x,n[1]=t.min.y,n[2]=t.min.z,n[3]=t.max.x,n[4]=t.max.y,n[5]=t.max.z,n):a.boundingData=p.getBounds(o.offset,o.count,new Float32Array(6)),m(a,o.offset,o.count),r.push(a)}else for(var s=0;s<i.length;s++){var l=i[s],c=new Yf;c.boundingData=p.getBounds(l.offset,l.count,new Float32Array(6)),m(c,l.offset,l.count),r.push(c)}if(f&&h.verbose&&(console.warn("MeshBVH: Max depth of ".concat(h.maxDepth," reached when generating BVH. Consider increasing maxDepth.")),console.warn(this,e)),null==e.boundingBox){var u=new Jn;e.boundingBox=new Jn;for(var d=0;d<r.length;d++){var v=r[d];e.boundingBox.union(Bp(v.boundingData,u))}}return r}},{key:"raycast",value:function(e,t,n,r){for(var i=0,a=this._roots;i<a.length;i++){a[i].raycast(e,t,n,r)}}},{key:"raycastFirst",value:function(e,t,n){for(var r=null,i=0,a=this._roots;i<a.length;i++){var o=a[i].raycastFirst(e,t,n);null!=o&&(null==r||o.distance<r.distance)&&(r=o)}return r}},{key:"intersectsGeometry",value:function(e,t,n){for(var r=0,i=this._roots;r<i.length;r++){if(i[r].intersectsGeometry(e,t,n))return!0}return!1}},{key:"shapecast",value:function(e,t,n,r){for(var i=2<arguments.length&&void 0!==n?n:null,a=3<arguments.length&&void 0!==r?r:null,o=0,s=this._roots;o<s.length;o++){if(s[o].shapecast(e,t,i,a))return!0}return!1}},{key:"intersectsBox",value:function(e,t,n){for(var r=0,i=this._roots;r<i.length;r++){if(i[r].intersectsBox(e,t,n))return!0}return!1}},{key:"intersectsSphere",value:function(e,t){for(var n=0,r=this._roots;n<r.length;n++){if(r[n].intersectsSphere(e,t))return!0}return!1}},{key:"closestPointToGeometry",value:function(e,t,n,r,i,a,o){for(var s=1/0,l=0,c=this._roots;l<c.length;l++){var u=c[l].closestPointToGeometry(e,t,n,r,i,a,o);if(u<s&&(s=u),u<a)return u}return s}},{key:"distanceToGeometry",value:function(e,t,n,r,i){return this.closestPointToGeometry(e,t,n,null,null,r,i)}},{key:"closestPointToPoint",value:function(e,t,n,r,i){for(var a=1/0,o=0,s=this._roots;o<s.length;o++){var l=s[o].closestPointToPoint(e,t,n,r,i);if(l<a&&(a=l),l<r)return l}return a}},{key:"distanceToPoint",value:function(e,t,n,r){return this.closestPointToPoint(e,t,null,n,r)}}]),n}(),em=new Ys({color:65416,transparent:!0,opacity:.3}),tm=(new vp).geometry,nm=new Jn,rm=function(){_inherits(a,Bn);var i=_createSuper(a);function a(e){var t,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:10,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return _classCallCheck(this,a),(t=i.call(this,"MeshBVHRootVisualizer")).depth=n,t._oldDepth=-1,t._mesh=e,t._boundsTree=null,t._group=r,t.update(),t}return _createClass(a,[{key:"update",value:function(){var i=this;if(this._mesh.geometry.boundsTree!==this._boundsTree||this._oldDepth!==this.depth){this._oldDepth=this.depth,this._boundsTree=this._mesh.geometry.boundsTree;var a,o=0;for(this._boundsTree&&(a=function(e,t){var n,r="count"in e;t!==i.depth&&(t!==i.depth-1&&!r||((n=o<i.children.length?i.children[o]:null)||((n=new nl(tm,em)).raycast=function(){return[]},i.add(n)),o++,Bp(e.boundingData,nm),nm.getCenter(n.position),n.scale.subVectors(nm.max,nm.min).multiplyScalar(.5),0===n.scale.x&&(n.scale.x=Number.EPSILON),0===n.scale.y&&(n.scale.y=Number.EPSILON),0===n.scale.z&&(n.scale.z=Number.EPSILON)),r||(a(e.left,t+1),a(e.right,t+1)))})(this._boundsTree._roots[this._group],0);this.children.length>o;)this.remove(this.children.pop())}}}]),a}(),im=function(){_inherits(i,Bn);var r=_createSuper(i);function i(e){var t,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:10;return _classCallCheck(this,i),(t=r.call(this,"MeshBVHVisualizer")).depth=n,t._mesh=e,t._roots=[],t.update(),t}return _createClass(i,[{key:"update",value:function(){for(var e=this._mesh.geometry.boundsTree,t=e?e._roots.length:0;this._roots.length>t;)this._roots.pop();for(var n,r,i=0;i<t;i++){i>=this._roots.length?(n=new rm(this._mesh,this.depth,i),this.add(n),this._roots.push(n)):((r=this._roots[i]).depth=this.depth,r.update())}this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}}]),i}(),am=new dr,om=new _n,sm=Ci.prototype.raycast;function lm(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;try{om.getInverse(this.matrixWorld,!0)}catch(e){return}var n;am.copy(e.ray).applyMatrix4(om),!0===e.firstHitOnly?(n=this.geometry.boundsTree.raycastFirst(this,e,am))&&t.push(n):this.geometry.boundsTree.raycast(this,e,am,t)}else sm.call(this,e,t)}function cm(e){return this.boundsTree=new $f(this,e),this.boundsTree}function um(){this.boundsTree=null}var dm,hm,pm,fm,mm,vm,gm,_m,ym,xm,bm,Mm,wm,Am,Sm,Tm,Em,Cm,Pm,Lm,Rm,Dm,Nm,Im,Om,Fm,Bm,zm,Um,Vm,km=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],Gm={disposeTextures:function(t){if(km.forEach(function(e){t[e]&&t[e].isTexture&&t[e].dispose()}),"MeshNodeMaterial"==t.type)for(var e in t.nodeTextures)t.nodeTextures[e]&&t.nodeTextures[e].dispose()}};function jm(){this.name="",this.type="Constraint",this.mute=!1}function Wm(e){jm.call(this),this.type="TargetConstraint",this.target=e}function Xm(e){Wm.call(this,e),this.type="ChildOfConstraint",this.offsetMatrix=new _n}function Hm(e){Wm.call(this,e),this.type="CopyLocationConstraint"}function Ym(e){Wm.call(this,e),this.type="CopyRotationConstraint"}function qm(e){Wm.call(this,e),this.type="CopyScaleConstraint"}function Zm(e){Wm.call(this,e),this.type="FloorConstraint",this.floorLocation="Y",this.offset=0}function Qm(){jm.call(this),this.type="LimitLocationConstraint",this.min=(new un).setScalar(-1/0),this.max=(new un).setScalar(1/0)}function Km(){jm.call(this),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}function Jm(){jm.call(this),this.type="LimitScaleConstraint",this.min=(new un).setScalar(-1/0),this.max=(new un).setScalar(1/0)}function $m(e){Wm.call(this,e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y"}function ev(e){Wm.call(this,e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y"}Object.assign(jm.prototype,{isConstraint:!0,update:function(e){this.mute},copy:function(e){return this.name=e.name,this.mute=e.mute,this},clone:function(){return(new this.constructor).copy(this)}}),Wm.prototype=Object.assign(Object.create(jm.prototype),{constructor:Wm,isTargetConstraint:!0,copy:function(e){jm.prototype.copy.call(this,e),this.target=e.target}}),Xm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Xm,isChildOfConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.offsetMatrix.copy(e.offsetMatrix)},update:(dm=new _n,hm=(new sn).setFromAxisAngle(new un(1,0,0),-Math.PI/2),function(e){Wm.prototype.update.call(this,e),this.mute||(dm.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),dm.decompose(e.position,e.quaternion,e.scale),e.isCamera&&e.quaternion.multiply(hm))})}),Hm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Hm,isCopyLocationConstraint:!0,update:(pm=new sn,fm=new un,function(e){Wm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(e.position,pm,fm),e.parent&&e.parent.worldToLocal(e.position))})}),Ym.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Ym,isCopyRotationConstraint:!0,update:(mm=new un,vm=new sn,gm=new un,_m=(new sn).setFromAxisAngle(new un(1,0,0),-Math.PI/2),function(e){Wm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(mm,e.quaternion,gm),e.parent&&(e.parent.matrixWorld.decompose(mm,vm,gm),e.quaternion.premultiply(vm.inverse())),e.isCamera&&e.quaternion.multiply(_m))})}),qm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:qm,isCopyScaleConstraint:!0,update:function(e){Wm.prototype.update.call(this,e),this.mute||e.scale.copy(this.target.scale)}}),Zm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Zm,isFloorConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.floorLocation=e.floorLocation,this.offset=e.offset},update:function(e){if(Wm.prototype.update.call(this,e),!this.mute){var t=e.position,n=this.target.position,r=this.offset;switch(this.floorLocation){case"X":t.x=Math.max(t.x,n.x+r);break;case"Y":t.y=Math.max(t.y,n.y+r);break;case"Z":t.z=Math.max(t.z,n.z+r);break;case"-X":t.x=Math.min(t.x,n.x+r);break;case"-Y":t.y=Math.min(t.y,n.y+r);break;case"-Z":t.z=Math.min(t.z,n.z+r)}}}}),Qm.prototype=Object.assign(Object.create(jm.prototype),{constructor:Qm,isLimitLocationConstraint:!0,copy:function(e){jm.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){jm.prototype.update.call(this,e),this.mute||e.position.clamp(this.min,this.max)}}),Km.prototype=Object.assign(Object.create(jm.prototype),{constructor:Km,isLimitRotationConstraint:!0,copy:function(e){jm.prototype.copy.call(this,e),this.axis=e.axis,this.min=e.min,this.max=e.max},update:(ym=new bn,function(e){jm.prototype.update.call(this,e),this.mute||("X"==this.axis?(ym.setFromQuaternion(e.quaternion,"XYZ"),ym.x=this._clampAngle(ym.x,this.min,this.max)):"Y"==this.axis?(ym.setFromQuaternion(e.quaternion,"YZX"),ym.y=this._clampAngle(ym.y,this.min,this.max)):"Z"==this.axis&&(ym.setFromQuaternion(e.quaternion,"ZXY"),ym.z=this._clampAngle(ym.z,this.min,this.max)),e.quaternion.setFromEuler(ym))}),_clampAngle:function(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=Kt.clampAngle(e,t,n)),e}}),Jm.prototype=Object.assign(Object.create(jm.prototype),{constructor:Jm,isLimitScaleConstraint:!0,copy:function(e){jm.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){jm.prototype.update.call(this,e),this.mute||e.scale.clamp(this.min,this.max)}}),$m.prototype=Object.assign(Object.create(Wm.prototype),{constructor:$m,isLockedTrackConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis},update:(xm=new un,bm=new un,Mm=new un,wm=new un,Am=new un,Sm=new mr,Tm=new un,Em=new un,Cm=new sn,Pm=(new sn).setFromAxisAngle(new un(1,0,0),-Math.PI/2),function(e){var t;Wm.prototype.update.call(this,e),this.mute||(Mm.set("X"==this.trackAxis?1:"-X"==this.trackAxis?-1:0,"Y"==this.trackAxis?1:"-Y"==this.trackAxis?-1:0,"Z"==this.trackAxis?1:"-Z"==this.trackAxis?-1:0),wm.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1!=Math.abs(Mm.dot(wm))&&(xm.setFromMatrixPosition(e.matrixWorld),bm.setFromMatrixPosition(this.target.matrixWorld),Sm.setFromNormalAndCoplanarPoint(wm,xm),Sm.projectPoint(bm,Am).sub(xm),t=0<Tm.crossVectors(Mm,Am).dot(wm)?1:-1,e.setRotationFromAxisAngle(Sm.normal,t*Mm.angleTo(Am)),e.parent&&(e.parent.matrixWorld.decompose(Em,Cm,Em),e.quaternion.premultiply(Cm.inverse())),e.isCamera&&e.quaternion.multiply(Pm)))})}),ev.prototype=Object.assign(Object.create(Wm.prototype),{constructor:ev,isTrackToConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.trackAxis=e.trackAxis,this.upAxis=e.upAxis},update:(Lm=new mr,Rm=new un,Dm=new un,Nm=new un,Im=new un,Om=new un,Fm=new _n,Bm=new un,zm=new sn,Um=new un(0,1,0),Vm=(new sn).setFromAxisAngle(new un(1,0,0),-Math.PI/2),function(e){var t,n,r,i,a,o,s;Wm.prototype.update.call(this,e),this.mute||(t=this.trackAxis[this.trackAxis.length-1],n=this.upAxis[this.upAxis.length-1],r="-"==this.trackAxis[0],i="-"==this.upAxis[0],t!=n&&(Rm.setFromMatrixPosition(e.matrixWorld),Dm.setFromMatrixPosition(this.target.matrixWorld),Nm.subVectors(Dm,Rm),Nm.lengthSq()?Nm.normalize():Nm.set(0,-1,0),Lm.set(Nm,0),1!=Math.abs(Nm.dot(Um))?Lm.projectPoint(Um,Im).normalize():Im.set(0,0,-1),r&&Nm.negate(),i&&Im.negate(),o="Y"==t?Nm:"Y"==n?Im:null,s="Z"==t?Nm:"Z"==n?Im:null,(a="X"==t?Nm:"X"==n?Im:null)?o?s=s||Om.crossVectors(a,o):o=Om.crossVectors(s,a):a=Om.crossVectors(o,s),Fm.makeBasis(a,o,s),e.setRotationFromMatrix(Fm),e.parent&&(e.parent.matrixWorld.decompose(Bm,zm,Bm),e.quaternion.premultiply(zm.inverse())),e.isCamera&&e.quaternion.multiply(Vm)))})});var tv={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE_BREAK:19,CAPS_LOCK:20,ESCAPE:27,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,INSERT:45,DELETE:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LEFT_WINDOW_KEY:91,RIGHT_WINDOW_KEY:92,SELECT_KEY:93,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,MULTIPLY:106,ADD:107,SUBTRACT:109,DECIMAL_POINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUM_LOCK:144,SCROLL_LOCK:145,SEMI_COLON:186,EQUAL_SIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARD_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRAKET:221,SINGLE_QUOTE:222};function nv(e){for(var t in this.isKeyDown={},tv)this.isKeyDown[tv[t]]=!1;this.onKeyDown=null,this.onKeyUp=null,this._domElement=e,this._keydownCb=function(e){this.isKeyDown[e.keyCode]=!0,this.onKeyDown&&this.onKeyDown(e)}.bind(this),this._keyupCb=function(e){this.isKeyDown[e.keyCode]=!1,this.onKeyUp&&this.onKeyUp(e)}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1),this._domElement.addEventListener("keyup",this._keyupCb,!1)}Object.assign(nv.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._domElement.removeEventListener("keyup",this._keyupCb,!1)}});function rv(e,t){var c=this;this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=!0,this.enableRotate=!0,this.rotateSpeed=.9,this.rotateSpeedTouch=.75,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enableZoom=!0,this.zoomSpeed=30,this.zoomSpeedKey=.2,this.zoomInertia=.05,this.enablePan=!0,this.panSpeedKey=.15,this.panInertia=.05,this.gazeLevel=1.8,this.storyHeight=3,this.collisionMeshes=[];var l=new uh,a=new un,o=new un,s=new un,u=new un,d=new sn,h=new un,p={};p[tv.W]=p[tv.S]=p[tv.A]=p[tv.D]=p[tv.UP_ARROW]=p[tv.DOWN_ARROW]=p[tv.LEFT_ARROW]=p[tv.RIGHT_ARROW]=0;var f=new nv(window),n=!(f.onKeyDown=function(e){e.keyCode in p&&(p[e.keyCode]=1)}),m=new Zc,v=new Zc,g=new Jt,_=1,y=1,r=new Jt,i=new Jt,x=0,b=0,M=1,w=1,A=new Jt,S=new Jt,T=1,E=1,C=new ss(new un,new un(0,-1,0)),P=C.params.checkVisibility=!1,L=!1,R=function(){},D=new un,N=new un,I=new un,O=new un,F=0,B=new uh,z={type:"change"},U={type:"start"},V={type:"end"};this.handleResize=function(){var e,t;this.domElement===document?(this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight):(e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement,this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var k,G,j,W,X,H=(k=new Jt,function(e,t){return k.set((e-.5*c.screen.width-c.screen.left)/(.5*c.screen.width),(c.screen.height+2*(c.screen.top-t))/c.screen.width),k});function Y(e){!1!==c.enabled&&(e.preventDefault(),!1!==c.enableRotate&&(i.copy(H(e.pageX,e.pageY).negate()),r.copy(i),n=!0,document.addEventListener("mousemove",q,!1),document.addEventListener("mouseup",Z,!1),document.addEventListener("mouseleave",Z,!1),c.dispatchEvent(U)))}function q(e){if(!1!==c.enabled&&(e.preventDefault(),n)){if(!1===c.enableRotate)return;i.copy(H(e.pageX,e.pageY).negate()),g.add(i).sub(r),r.copy(i),_=c.rotateSpeed,y=c.rotateInertia}}function Z(e){!1!==c.enabled&&(e.preventDefault(),n=!1,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z),document.removeEventListener("mouseleave",Z),c.dispatchEvent(V))}function Q(e){if(!1!==c.enabled&&!1!==c.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:b-=.025*e.deltaY,M=c.zoomSpeed,w=c.zoomInertia;break;case 1:b-=.01*e.deltaY,M=c.zoomSpeed,w=c.zoomInertia;break;default:b-=25e-5*e.deltaY,M=c.zoomSpeed,w=c.zoomInertia}c.dispatchEvent(U),c.dispatchEvent(V)}}function K(e){var t;!1!==c.enabled&&(t=e.touches[0],n=!0,i.copy(H(t.pageX,t.pageY).negate()),r.copy(i),c.dispatchEvent(U))}function J(e){var t;!1!==c.enabled&&(e.preventDefault(),t=e.touches[0],!1!==c.enableRotate&&(i.copy(H(t.pageX,t.pageY).negate()),g.add(i).sub(r),r.copy(i),_=c.rotateSpeedTouch,y=c.rotateInertiaTouch))}function $(e){if(!1!==c.enabled){switch(e.touches.length){case 0:n=!1;break;default:if(!1===c.enableRotate)return;n=!0,i.copy(H(e.touches[0].pageX,e.touches[0].pageY).negate()),r.copy(i)}c.dispatchEvent(V)}}function ee(e){!1!==c.enabled&&e.preventDefault()}this.update=(G=new un,function(){if(L){var e=B.getElapsedTime()/F,e=Kt.smootherstep(e,0,1);if(c.object.position.lerpVectors(D,I,e),c.object.lookAt(G.lerpVectors(N,O,e)),1<=e){for(var t in L=!1,R(),v.set(0,0,0),g.set(0,0),b=x=0,A.set(0,0),S.set(0,0),p)p[t]=0;l.getDelta()}}else c.object.getLocalDirection(h),m.setFromVector3(h),m.theta+=v.theta*_,m.phi+=v.phi*_,m.makeSafe(),h.setFromSpherical(m),a.copy(h).add(c.object.position),c.object.lookAtLocal(a),c.object.isPerspectiveCamera?c.object.position.addScaledVector(h,x):c.object.isOrthographicCamera&&(c.object.zoom*=1+.15*x,c.object.updateProjectionMatrix()),o.copy(h).cross(c.object.up).setLength(-A.x),o.add(s.copy(c.object.up).setLength(A.y)),c.object.position.add(o),function(){var e=l.getDelta();for(var t in v.set(v.radius,g.y,g.x),g.x=c.enableDamping?Kt.expAverageClamp(g.x,0,e,y,.001):0,g.y=c.enableDamping?Kt.expAverageClamp(g.y,0,e,y,.001):0,v.set(v.radius,v.phi-g.y,v.theta-g.x),A.copy(S),S.x=c.enableDamping?Kt.expAverageClamp(S.x,0,e,E,.001):0,S.y=c.enableDamping?Kt.expAverageClamp(S.y,0,e,E,.001):0,A.sub(S),A.multiplyScalar(T),x=b,b=c.enableDamping?Kt.expAverageClamp(b,0,e,w,.001):0,x-=b,x*=M,p){var n,r,i=t==tv.A||t==tv.LEFT_ARROW||t==tv.D||t==tv.RIGHT_ARROW,a=t==tv.W||t==tv.UP_ARROW||t==tv.S||t==tv.DOWN_ARROW,o=i?c.panInertia:c.zoomInertia,s=i?c.panSpeedKey:c.zoomSpeedKey;r=f.isKeyDown[t]?p[t]=1:(n=p[t],p[t]=Kt.expAverageClamp(p[t],0,e,o,.001),n-p[t]),c.enabled&&(i&&!c.enablePan||a&&!c.enableZoom||(r*=60*e*s,t==tv.A||t==tv.LEFT_ARROW?A.x+=r:t==tv.D||t==tv.RIGHT_ARROW?A.x-=r:t==tv.W||t==tv.UP_ARROW?x+=r:t!=tv.S&&t!=tv.DOWN_ARROW||(x-=r)))}}();var n,r;c.collisionMeshes.length&&(C.ray.origin.copy(c.object.position),C.far=c.storyHeight,0<(n=C.intersectObjects(c.collisionMeshes)).length?(r=n[0],c.object.position.y=r.point.y+c.gazeLevel,P=!0):P&&c.object.position.copy(u));var i=!1;1e-6<u.distanceToSquared(c.object.position)&&(u.copy(c.object.position),i=!0),d.dot(c.object.quaternion)<1-1e-6&&(d.copy(c.object.quaternion),i=!0),i&&c.dispatchEvent(z)}),this.dispose=function(){this.domElement.removeEventListener("contextmenu",ee,!1),this.domElement.removeEventListener("mousedown",Y,!1),this.domElement.removeEventListener("wheel",Q,!1),this.domElement.removeEventListener("touchstart",K,!1),this.domElement.removeEventListener("touchend",$,!1),this.domElement.removeEventListener("touchmove",J,!1),document.removeEventListener("mousemove",q,!1),document.removeEventListener("mouseup",Z,!1),document.removeEventListener("mouseleave",Z,!1),f.dispose()},this.releaseFromCollision=function(){P=!1},this.tween=(j=new un,W=new un,X=new un,function(e,t,n,r){c.object.parent&&(e=j.copy(e),c.object.parent.worldToLocal(e));var i=c.object.getWorldPosition(W),a=X.subVectors(t,i).length(),o=c.object.getWorldDirection(X).multiplyScalar(a).add(i),s=e.manhattanDistanceTo(c.object.position),l=t.manhattanDistanceTo(o);s<1e-5&&l<1e-5||(L=!0,R="function"==typeof r?r:function(){},D.copy(c.object.position),N.copy(o),I.copy(e),O.copy(t),F=n,B.start())}),this.domElement.addEventListener("contextmenu",ee,!1),this.domElement.addEventListener("mousedown",Y,!1),this.domElement.addEventListener("wheel",Q,!1),this.domElement.addEventListener("touchstart",K,!1),this.domElement.addEventListener("touchend",$,!1),this.domElement.addEventListener("touchmove",J,!1),this.handleResize(),this.update()}Object.assign(rv.prototype,o.prototype);function iv(e,t){var c=this,a={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=!0,this.enableRotate=!0,this.rotateSpeed=.9,this.rotateSpeedTouch=.75,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enableZoom=!0,this.zoomSpeed=150,this.zoomSpeedKey=.5,this.zoomSpeedTouch=20,this.zoomInertia=.05,this.zoomInertiaTouch=.05,this.enablePan=!0,this.panSpeed=20,this.panSpeedKey=.15,this.panSpeedTouch=15,this.panInertia=.05,this.panInertiaTouch=.05,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.mouseButtons={ROTATE:me.LEFT,ZOOM:me.MIDDLE,PAN:me.RIGHT};var l=new uh,r=new un,i=new un,o=new un,u=new Jt,s=new un,d=new sn,h=a.NONE,p=new un,f={};f[tv.W]=f[tv.S]=f[tv.A]=f[tv.D]=f[tv.UP_ARROW]=f[tv.DOWN_ARROW]=f[tv.LEFT_ARROW]=f[tv.RIGHT_ARROW]=0;var m=new nv(window);m.onKeyDown=function(e){e.keyCode in f&&(f[e.keyCode]=1)};var v=new Zc,g=new Zc,_=new Jt,y=1,x=1,b=new Jt,M=new Jt,w=0,A=0,S=1,T=1,E=0,C=0,P=new Jt,L=new Jt,R=1,D=1,N=new Jt,I=new Jt,O=!1,F=function(){},B=new un,z=new un,U=new un,V=new un,k=0,G=new uh,j={type:"change"},W={type:"start"},n={type:"end"};this.handleResize=function(){var e,t;this.domElement===document?(this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight):(e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement,this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var X,H,Y,q,Z,Q,K=(X=new Jt,function(e,t){return X.set((e-c.screen.left)/c.screen.width,(t-c.screen.top)/c.screen.height),X}),J=(H=new Jt,function(e,t){return H.set((e-.5*c.screen.width-c.screen.left)/(.5*c.screen.width),(c.screen.height+2*(c.screen.top-t))/c.screen.width),H});function $(e){if(!1!==c.enabled){switch(e.preventDefault(),e.button){case c.mouseButtons.ROTATE:if(!1===c.enableRotate)return;M.copy(J(e.pageX,e.pageY).negate()),b.copy(M),h=a.ROTATE;break;case c.mouseButtons.ZOOM:case c.mouseButtons.PAN:if(!1===c.enablePan)return;N.copy(K(e.pageX,e.pageY)),I.copy(N),h=e.button==c.mouseButtons.PAN?a.PAN:a.ZOOM}document.addEventListener("mousemove",ee,!1),document.addEventListener("mouseup",te,!1),document.addEventListener("mouseleave",te,!1),c.dispatchEvent(W)}}function ee(e){if(!1!==c.enabled)if(e.preventDefault(),h===a.ROTATE){if(!1===c.enableRotate)return;M.copy(J(e.pageX,e.pageY).negate()),_.add(M).sub(b),b.copy(M),y=c.rotateSpeed,x=c.rotateInertia}else if(h===a.PAN||h===a.ZOOM){if(!1===c.enablePan)return;I.copy(K(e.pageX,e.pageY)),L.add(I).sub(N),N.copy(I),R=c.panSpeed,D=c.panInertia}}function te(e){!1!==c.enabled&&(e.preventDefault(),h=a.NONE,document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",te),document.removeEventListener("mouseleave",te),c.dispatchEvent(n))}function ne(e){if(!1!==c.enabled&&!1!==c.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:A-=.025*e.deltaY,S=c.zoomSpeed,T=c.zoomInertia;break;case 1:A-=.01*e.deltaY,S=c.zoomSpeed,T=c.zoomInertia;break;default:A-=25e-5*e.deltaY,S=c.zoomSpeed,T=c.zoomInertia}c.dispatchEvent(W),c.dispatchEvent(n)}}function re(e){if(!1!==c.enabled){var t,n,r=e.touches[0],i=e.touches[1];switch(e.touches.length){case 1:if(!1===c.enableRotate)return;h=a.TOUCH_ROTATE,M.copy(J(r.pageX,r.pageY).negate()),b.copy(M);break;default:if(!1===c.enableZoom&&!1===c.enablePan)return;h=a.TOUCH_ZOOM_PAN,c.enableZoom&&(t=K(r.pageX-i.pageX,r.pageY-i.pageY),E=C=t.length()),c.enablePan&&(n=K((r.pageX+i.pageX)/2,(r.pageY+i.pageY)/2),N.copy(n),I.copy(N))}c.dispatchEvent(W)}}function ie(e){if(!1!==c.enabled){e.preventDefault();var t=e.touches[0],n=e.touches[1];switch(e.touches.length){case 1:if(!1===c.enableRotate)return;M.copy(J(t.pageX,t.pageY).negate()),_.add(M).sub(b),b.copy(M),y=c.rotateSpeedTouch,x=c.rotateInertiaTouch;break;default:if(!1===c.enableZoom&&!1===c.enablePan)return;var r=K(t.pageX-n.pageX,t.pageY-n.pageY),i=(C=r.length())-E;E=C;var a=K((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2);I.copy(a);var o=u.subVectors(I,N),s=o.length();N.copy(I),c.enableZoom&&Math.abs(i)>Math.abs(s)&&(A+=i,S=c.zoomSpeedTouch,T=c.zoomInertiaTouch),c.enablePan&&Math.abs(i)<=Math.abs(s)&&(L.add(o),R=c.panSpeedTouch,D=c.panInertiaTouch)}}}function ae(e){if(!1!==c.enabled){switch(e.touches.length){case 0:h=a.NONE;break;case 1:if(!1===c.enableRotate)return;h=a.TOUCH_ROTATE,M.copy(J(e.touches[0].pageX,e.touches[0].pageY).negate()),b.copy(M)}c.dispatchEvent(n)}}function oe(e){!1!==c.enabled&&e.preventDefault()}this.update=(Y=new un,function(){if(O){var e=G.getElapsedTime()/k,e=Kt.smootherstep(e,0,1);if(c.object.position.lerpVectors(B,U,e),c.object.lookAt(Y.lerpVectors(z,V,e)),1<=e){for(var t in O=!1,F(),g.set(0,0,0),_.set(0,0),A=w=0,P.set(0,0),L.set(0,0),f)f[t]=0;l.getDelta()}}else c.object.getLocalDirection(p),v.setFromVector3(p),v.theta+=g.theta*y,v.phi+=g.phi*y,v.theta=Math.max(c.minAzimuthAngle,Math.min(c.maxAzimuthAngle,v.theta)),v.phi=Math.max(c.minPolarAngle,Math.min(c.maxPolarAngle,v.phi)),v.makeSafe(),p.setFromSpherical(v),r.copy(p).add(c.object.position),c.object.lookAtLocal(r),c.object.isPerspectiveCamera?c.object.position.addScaledVector(p,w):c.object.isOrthographicCamera&&(c.object.zoom*=1+.15*w,c.object.updateProjectionMatrix()),i.copy(p).cross(c.object.up).setLength(-P.x),i.add(o.copy(c.object.up).setLength(P.y)),c.object.position.add(i),function(){var e=l.getDelta();for(var t in g.set(g.radius,_.y,_.x),_.x=c.enableDamping?Kt.expAverageClamp(_.x,0,e,x,.001):0,_.y=c.enableDamping?Kt.expAverageClamp(_.y,0,e,x,.001):0,g.set(g.radius,g.phi-_.y,g.theta-_.x),P.copy(L),L.x=c.enableDamping?Kt.expAverageClamp(L.x,0,e,D,.001):0,L.y=c.enableDamping?Kt.expAverageClamp(L.y,0,e,D,.001):0,P.sub(L),P.multiplyScalar(R),w=A,A=c.enableDamping?Kt.expAverageClamp(A,0,e,T,.001):0,w-=A,w*=S,f){var n,r,i=t==tv.A||t==tv.LEFT_ARROW||t==tv.D||t==tv.RIGHT_ARROW,a=t==tv.W||t==tv.UP_ARROW||t==tv.S||t==tv.DOWN_ARROW,o=i?c.panInertia:c.zoomInertia,s=i?c.panSpeedKey:c.zoomSpeedKey;r=m.isKeyDown[t]?f[t]=1:(n=f[t],f[t]=Kt.expAverageClamp(f[t],0,e,o,.001),n-f[t]),c.enabled&&(i&&!c.enablePan||a&&!c.enableZoom||(r*=60*e*s,t==tv.A||t==tv.LEFT_ARROW?P.x+=r:t==tv.D||t==tv.RIGHT_ARROW?P.x-=r:t==tv.W||t==tv.UP_ARROW?w+=r:t!=tv.S&&t!=tv.DOWN_ARROW||(w-=r)))}}();var n=!1;1e-6<s.distanceToSquared(c.object.position)&&(s.copy(c.object.position),n=!0),d.dot(c.object.quaternion)<1-1e-6&&(d.copy(c.object.quaternion),n=!0),n&&c.dispatchEvent(j)}),this.dispose=function(){this.domElement.removeEventListener("contextmenu",oe,!1),this.domElement.removeEventListener("mousedown",$,!1),this.domElement.removeEventListener("wheel",ne,!1),this.domElement.removeEventListener("touchstart",re,!1),this.domElement.removeEventListener("touchend",ae,!1),this.domElement.removeEventListener("touchmove",ie,!1),document.removeEventListener("mousemove",ee,!1),document.removeEventListener("mouseup",te,!1),document.removeEventListener("mouseleave",te,!1),m.dispose()},this.tween=(q=new un,Z=new un,Q=new un,function(e,t,n,r){c.object.parent&&(e=q.copy(e),c.object.parent.worldToLocal(e));var i=c.object.getWorldPosition(Z),a=Q.subVectors(t,i).length(),o=c.object.getWorldDirection(Q).multiplyScalar(a).add(i),s=e.manhattanDistanceTo(c.object.position),l=t.manhattanDistanceTo(o);s<1e-5&&l<1e-5||(O=!0,F="function"==typeof r?r:function(){},B.copy(c.object.position),z.copy(o),U.copy(e),V.copy(t),k=n,G.start())}),this.domElement.addEventListener("contextmenu",oe,!1),this.domElement.addEventListener("mousedown",$,!1),this.domElement.addEventListener("wheel",ne,!1),this.domElement.addEventListener("touchstart",re,!1),this.domElement.addEventListener("touchend",ae,!1),this.domElement.addEventListener("touchmove",ie,!1),this.handleResize(),this.update()}Object.assign(iv.prototype,o.prototype);var av,ov;function sv(e,t){var n,r,i,a,o,s,l,c,u;this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.targetObj=new Bn,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=!0,this.enableZoom=!0,this.zoomSpeed=5,this.zoomSpeedTouch=1,this.zoomInertia=.05,this.zoomInertiaTouch=.05,this.enableRotate=!0,this.rotateSpeed=1.2,this.rotateSpeedTouch=.7,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enablePan=!0,this.panSpeed=1.3,this.panSpeedKey=15,this.panInertia=.05,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.mouseButtons={ROTATE:me.LEFT,ZOOM:me.MIDDLE,PAN:me.RIGHT},this.target0=this.targetObj.position.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return _.phi},this.getAzimuthalAngle=function(){return _.theta},this.saveState=function(){d.targetObj.updateWorldMatrix(!0,!1),d.target0.setFromMatrixPosition(d.targetObj.matrixWorld),d.position0.copy(d.object.position),d.zoom0=d.object.zoom},this.reset=(n=new un,function(){d.targetObj.updateWorldMatrix(!0,!1);var e=n.copy(d.target0);d.targetObj.worldToLocal(e),d.targetObj.position.add(e),d.object.position.copy(d.position0),d.object.zoom=d.zoom0,d.object.updateProjectionMatrix(),d.dispatchEvent(h),d.update(),v=m.NONE}),this.update=(r=new un,i=new un,a=(new sn).setFromUnitVectors(e.up,new un(0,1,0)),o=a.clone().inverse(),s=new un,l=new sn,function(){var e=d.object.position;if(d.targetObj.updateWorldMatrix(!0,!1),this.inTween){var t=Y.getElapsedTime()/H,t=Kt.smootherstep(t,0,1);if(e.lerpVectors(G,W,t),i.lerpVectors(j,X,t),d.object.lookAt(i),1<=t){for(var n in this.inTween=!1,this.tweenCallback(),y.set(0,0,0),b.set(0,0,0),x=1,I.set(0,0),w)w[n]=0;C.set(0,0),k.getDelta()}}else i.setFromMatrixPosition(d.targetObj.matrixWorld),r.copy(e).sub(i),r.applyQuaternion(a),_.setFromVector3(r),d.autoRotate&&v===m.NONE&&Z(2*Math.PI/60/60*d.autoRotateSpeed),_.theta+=y.theta,_.phi+=y.phi,isFinite(d.minAzimuthAngle)&&isFinite(d.maxAzimuthAngle)&&(_.theta=Kt.clampAngle(_.theta,d.minAzimuthAngle,d.maxAzimuthAngle)),_.phi=Math.max(d.minPolarAngle,Math.min(d.maxPolarAngle,_.phi)),_.makeSafe(),d.object.isPerspectiveCamera?(_.radius*=x,_.radius=Math.max(d.minDistance,Math.min(d.maxDistance,_.radius))):d.object.isOrthographicCamera&&(d.object.zoom/=x,d.object.zoom=Math.max(d.minZoom,Math.min(d.maxZoom,d.object.zoom)),d.object.updateProjectionMatrix()),i.add(b),r.setFromSpherical(_),r.applyQuaternion(o),e.copy(i).add(r),d.object.lookAt(i),y.set(0,0,0),b.set(0,0,0),function(){var e,t,n=k.getDelta();for(var r in E.copy(C),C.x=d.enableDamping?Kt.expAverageClamp(C.x,0,n,L,1):0,C.y=d.enableDamping?Kt.expAverageClamp(C.y,0,n,L,1):0,E.sub(C),function(){var e=d.domElement===document?d.domElement.body:d.domElement,t=e.clientWidth,n=e.clientHeight;t&&n&&(Z(2*Math.PI*E.x/t*P),function(e){y.phi-=e}(2*Math.PI*E.y/n*P))}(),N.copy(I),I.x=d.enableDamping?Kt.expAverageClamp(I.x,0,n,d.panInertia,.1):0,I.y=d.enableDamping?Kt.expAverageClamp(I.y,0,n,d.panInertia,.1):0,N.sub(I),N.multiplyScalar(d.panSpeed),w){t=A.isKeyDown[r]?w[r]=1:(e=w[r],w[r]=Kt.expAverageClamp(w[r],0,n,d.panInertia,.1),e-w[r]),d.enabled&&d.enableKeys&&d.enablePan&&(t*=60*n*d.panSpeedKey,r==tv.A||r==tv.LEFT_ARROW?N.x+=t:r==tv.D||r==tv.RIGHT_ARROW?N.x-=t:r==tv.W||r==tv.UP_ARROW?N.y+=t:r!=tv.S&&r!=tv.DOWN_ARROW||(N.y-=t))}re(N.x,N.y),x=z,z=d.enableDamping?Kt.expAverageClamp(z,1,n,V,.01):1,x/=z}();return d.targetObj.position.copy(i),!(!(M||s.distanceToSquared(d.object.position)>g||8*(1-l.dot(d.object.quaternion))>g)||(d.dispatchEvent(h),s.copy(d.object.position),l.copy(d.object.quaternion),M=!1))}),this.dispose=function(){d.domElement.removeEventListener("contextmenu",fe,!1),d.domElement.removeEventListener("mousedown",se,!1),d.domElement.removeEventListener("wheel",ue,!1),d.domElement.removeEventListener("touchstart",de,!1),d.domElement.removeEventListener("touchend",pe,!1),d.domElement.removeEventListener("touchmove",he,!1),document.removeEventListener("mousemove",le,!1),document.removeEventListener("mouseup",ce,!1),document.removeEventListener("mouseleave",ce,!1),A.dispose()},this.tween=(c=new un,u=new un,function(e,t,n,r){d.targetObj.updateWorldMatrix(!0,!1),u.setFromMatrixPosition(d.targetObj.matrixWorld),d.object.parent&&(e=c.copy(e),d.object.parent.worldToLocal(e)),e.manhattanDistanceTo(d.object.position)<1e-5&&t.manhattanDistanceTo(u)<1e-5||(d.inTween=!0,d.tweenCallback="function"==typeof r?r:function(){},G.copy(d.object.position),j.copy(u),W.copy(e),X.copy(t),H=n,Y.start())});var d=this,h={type:"change"},p={type:"start"},f={type:"end"},m={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},v=m.NONE,g=1e-6,_=new Zc,y=new Zc,x=1,b=new un,M=!1,w={};w[tv.W]=w[tv.S]=w[tv.A]=w[tv.D]=w[tv.UP_ARROW]=w[tv.DOWN_ARROW]=w[tv.LEFT_ARROW]=w[tv.RIGHT_ARROW]=0;var A=new nv(window);A.onKeyDown=function(e){e.keyCode in w&&(w[e.keyCode]=1)};var S=new Jt,T=new Jt,E=new Jt,C=new Jt,P=1,L=1,R=new Jt,D=new Jt,N=new Jt,I=new Jt,O=new Jt,F=new Jt,B=new Jt,z=1,U=1,V=1,k=new uh,G=new un,j=new un,W=new un,X=new un,H=0,Y=new uh;function q(){return Math.pow(.95,U)}function Z(e){y.theta-=e}function Q(e,t){T.set(e,t),C.add(T).sub(S),S.copy(T)}var K,J,$,ee,te=(K=new un,function(e,t){K.setFromMatrixColumn(t,0),K.multiplyScalar(-e),b.add(K)}),ne=(J=new un,function(e,t){J.setFromMatrixColumn(t,1),J.multiplyScalar(e),b.add(J)}),re=($=new un,ee=new un,function(e,t){var n,r,i=d.domElement===document?d.domElement.body:d.domElement,a=i.clientWidth,o=i.clientHeight;a&&o&&(d.object.isPerspectiveCamera?(d.targetObj.updateWorldMatrix(!0,!1),ee.setFromMatrixPosition(d.targetObj.matrixWorld),n=d.object.position,$.copy(n).sub(ee),r=$.length(),r*=Math.tan(d.object.fov/2*Kt.DEG2RAD),te(2*e*r/o,d.object.matrix),ne(2*t*r/o,d.object.matrix)):d.object.isOrthographicCamera?(te(e*(d.object.right-d.object.left)/d.object.zoom/a,d.object.matrix),ne(t*(d.object.top-d.object.bottom)/d.object.zoom/o,d.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),d.enablePan=!1))});function ie(e){d.object.isPerspectiveCamera?z/=e:d.object.isOrthographicCamera?(z/=e,M=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),d.enableZoom=!1)}function ae(e){d.object.isPerspectiveCamera?z*=e:d.object.isOrthographicCamera?(z*=e,M=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),d.enableZoom=!1)}function oe(e){var t,n;t=e.clientX,n=e.clientY,D.set(t,n),I.add(D).sub(R),R.copy(D)}function se(e){if(!1!==d.enabled){switch(e.preventDefault(),e.button){case d.mouseButtons.ROTATE:if(!1===d.enableRotate)return;n=e,S.set(n.clientX,n.clientY),v=m.ROTATE;break;case d.mouseButtons.ZOOM:case d.mouseButtons.PAN:if(!1===d.enablePan)return;t=e,R.set(t.clientX,t.clientY),v=m.PAN}var t,n;v!==m.NONE&&(document.addEventListener("mousemove",le,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mouseleave",ce,!1),d.dispatchEvent(p))}}function le(e){var t,n;if(!1!==d.enabled)switch(e.preventDefault(),v){case m.ROTATE:if(!1===d.enableRotate)return;Q((n=e).clientX,n.clientY),P=d.rotateSpeed,L=d.rotateInertia;break;case m.DOLLY:if(!1===d.enableZoom)return;t=e,F.set(t.clientX,t.clientY),B.subVectors(F,O),0<B.y?ie(q()):B.y<0&&ae(q()),O.copy(F),d.update();break;case m.PAN:if(!1===d.enablePan)return;oe(e)}}function ce(e){!1!==d.enabled&&(document.removeEventListener("mousemove",le,!1),document.removeEventListener("mouseup",ce,!1),document.removeEventListener("mouseleave",ce,!1),d.dispatchEvent(f),v=m.NONE)}function ue(e){var t;!1===d.enabled||!1===d.enableZoom||v!==m.NONE&&v!==m.ROTATE||(e.preventDefault(),e.stopPropagation(),d.dispatchEvent(p),t=e,U=d.zoomSpeed,V=d.zoomInertia,t.deltaY<0?ae(q()):0<t.deltaY&&ie(q()),d.update(),d.dispatchEvent(f))}function de(e){if(!1!==d.enabled){switch(e.touches.length){case 1:if(!1===d.enableRotate)return;s=e,S.set(s.touches[0].pageX,s.touches[0].pageY),v=m.TOUCH_ROTATE;break;case 2:if(!1===d.enableZoom&&!1===d.enablePan)return;t=e,d.enableZoom&&(U=d.zoomSpeedTouch,V=d.zoomInertiaTouch,n=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY,i=Math.sqrt(n*n+r*r),O.set(0,i)),d.enablePan&&(a=.5*(t.touches[0].pageX+t.touches[1].pageX),o=.5*(t.touches[0].pageY+t.touches[1].pageY),R.set(a,o)),d.update(),v=m.TOUCH_DOLLY_PAN;break;default:v=m.NONE}var t,n,r,i,a,o,s;v!==m.NONE&&d.dispatchEvent(p)}}function he(e){var t;if(!1!==d.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===d.enableRotate)return;if(v!==m.TOUCH_ROTATE)return;Q((t=e).touches[0].pageX,t.touches[0].pageY),P=d.rotateSpeedTouch,L=d.rotateInertiaTouch;break;case 2:if(!1===d.enableZoom&&!1===d.enablePan)return;if(v!==m.TOUCH_DOLLY_PAN)return;!function(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+n*n);F.set(0,r),B.subVectors(F,O),O.copy(F);var i=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);D.set(i,a),N.subVectors(D,R),R.copy(D),d.enableZoom&&Math.abs(B.length())>Math.abs(N.length())&&(0<B.y?ae(q()):B.y<0&&ie(q())),d.enablePan&&Math.abs(B.length())<Math.abs(N.length())&&I.add(N),d.update()}(e);break;default:v=m.NONE}}function pe(e){!1!==d.enabled&&(d.dispatchEvent(f),v=m.NONE)}function fe(e){!1!==d.enabled&&e.preventDefault()}d.domElement.addEventListener("contextmenu",fe,!1),d.domElement.addEventListener("mousedown",se,!1),d.domElement.addEventListener("wheel",ue,!1),d.domElement.addEventListener("touchstart",de,!1),d.domElement.addEventListener("touchend",pe,!1),d.domElement.addEventListener("touchmove",he,!1),this.update()}function lv(e,t,n){this.sourceTexture=e;var r=Object.assign({mapping:e.mapping,wrapS:e.wrapS,wrapT:e.wrapT,magFilter:e.magFilter,minFilter:e.minFilter,format:e.format,type:e.type,anisotropy:e.anisotropy,encoding:e.encoding,generateMipmaps:e.generateMipmaps},n);this.renderTarget=new Yi(t,r),this.renderTarget.texture.name=e.name,this.renderTarget.texture.flipY=e.flipY,this.camera=new na(-1,1,1,-1,0,1),this.shader=new ji({type:"CubeCopy",uniforms:{faceIdx:{value:0},cubemap:{value:null}},vertexShader:"\n uniform int faceIdx;\n\n varying vec3 vCubeDirection;\n\n vec3 uvToCubeDirection(vec2 uv, int face) {\n vec3 dir;\n uv = 2.0 * uv - 1.0;\n\n if (face == 0) {\n dir = vec3(1.0, -uv.y, -uv.x);\n } else if (face == 1) {\n dir = vec3(-1.0, -uv.y, uv.x);\n } else if (face == 2) {\n dir = vec3(uv.x, 1.0, uv.y);\n } else if (face == 3) {\n dir = vec3(uv.x, -1.0, -uv.y);\n } else if (face == 4) {\n dir = vec3(uv.x, -uv.y, 1.0);\n } else if (face == 5) {\n dir = vec3(-uv.x, -uv.y, -1.0);\n }\n return dir;\n }\n\n void main() {\n vCubeDirection = uvToCubeDirection(uv, faceIdx);\n gl_Position = vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform samplerCube cubemap;\n\n varying vec3 vCubeDirection;\n\n void main() {\n gl_FragColor = linearToOutputTexel(mapTexelToLinear(textureCube(\n cubemap, vCubeDirection)));\n }\n "}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new Ci(new ia(2,2,0),this.shader),this.scene=new zn,this.scene.add(this.camera),this.scene.add(this.planeMesh)}function cv(e,t){this.sourceTexture=e,this.resolution=void 0!==t?t:256;var n=this.resolution,r={format:this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.renderTarget=new Yi(n,n,r),this.renderTarget.texture.name="EquiCube.cube",this.camera=new na(-1,1,1,-1,0,1e3),this.shader=new ji(oa.equicube),this.planeMesh=new Ci(new ia(2,2,0),this.shader),this.planeMesh.material.side=ie,this.scene=new zn,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.invertU=!1,this.offsetU=0,this.shader.uniforms.tEquirect.value=this.sourceTexture}function uv(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}function dv(e){this._mesh=new Ci(ov,e)}function hv(e,t,n,r,i){uv.call(this),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=r,this.resolution=void 0!==e?new Jt(e.x,e.y):new Jt(256,256),i=i||{minFilter:tt,magFilter:tt,format:dt},this.clearColor=new Lr(0,0,0),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 an(a,o,i),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s<this.nMips;s++){var l=new an(a,o,i);l.texture.name="BloomPass.h"+s,l.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(l),(l=new an(a,o,i)).texture.name="BloomPass.v"+s,l.texture.generateMipmaps=!1,this.renderTargetsVertical.push(l),a=Math.round(a/2),o=Math.round(o/2)}var c=oa.bloomLumHighPass;this.highPassUniforms=Vi.clone(c.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new ji({type:"BloomHighPass",uniforms:this.highPassUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,defines:{}}),this.separableBlurMaterials=[];for(var u=[3,5,7,9,11],a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2),s=0;s<this.nMips;s++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(u[s])),this.separableBlurMaterials[s].uniforms.texSize.value=new Jt(a,o),a=Math.round(a/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new un(1,1,1),new un(1,1,1),new un(1,1,1),new un(1,1,1),new un(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;var d=oa.copy;this.copyUniforms=Vi.clone(d.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ji({type:"BloomCopy",defines:d.defines,uniforms:this.copyUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:ue,blendEquation:de,blendEquationAlpha:de,blendSrc:be,blendDst:_e,blendSrcAlpha:ge,blendDstAlpha:_e,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Lr,this.oldClearAlpha=1,this.basic=new zr,this.fsQuad=new uv.FullScreenQuad(null)}function pv(e,t,n){uv.call(this),this.scene=e,this.camera=t;var r=new an(n.width||window.innerWidth||1,n.height||window.innerHeight||1,{minFilter:tt,magFilter:tt,format:dt});this.renderTargetDepth=r.clone(),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new Ho,this.materialDepth.depthPacking=Ot,this.materialDepth.blending=ae;var i=oa.bokeh,a=Vi.clone(i.uniforms);a.tDepth.value=this.renderTargetDepth.texture,a.focus.value=Jr(n.focus)?n.focus:1,a.aperture.value=Jr(n.aperture)?n.aperture:1,a.maxblur.value=Jr(n.maxblur)?n.maxblur:1,a.depthLeakThreshold.value=Jr(n.depthLeakThreshold)?n.depthLeakThreshold:.2,a.nearClip.value=t.near,a.farClip.value=t.far,a.aspect.value=t.aspect,Object.defineProperties(this,{focus:{get:function(){return this.uniforms.focus.value},set:function(e){this.uniforms.focus.value=e}},aperture:{get:function(){return this.uniforms.aperture.value},set:function(e){this.uniforms.aperture.value=e}},maxblur:{get:function(){return this.uniforms.maxblur.value},set:function(e){this.uniforms.maxblur.value=e}},depthLeakThreshold:{get:function(){return this.uniforms.depthLeakThreshold.value},set:function(e){this.uniforms.depthLeakThreshold.value=e}}}),this.materialBokeh=new ji({type:"Bokeh",defines:i.defines,uniforms:a,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader}),this.uniforms=a,this.camera2=new na(-1,1,1,-1,0,1),this.scene2=new zn,this.quad2=new Ci(new ia(2,2),null),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2),this.oldClearColor=new Lr,this.oldClearAlpha=1}function fv(e,t){uv.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof ji?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Vi.clone(e.uniforms),this.material=new ji({type:"ShaderPass",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new uv.FullScreenQuad(this.material)}function mv(){fv.call(this,oa.brightness_contrast),this.material.type="Grayscale",Object.defineProperties(this,{brightness:{get:function(){return this.uniforms.brightness.value},set:function(e){this.uniforms.brightness.value=e}},contrast:{get:function(){return this.uniforms.contrast.value},set:function(e){this.uniforms.contrast.value=e}}})}function vv(e,t,n,r){fv.call(this,oa.fxaa),this.material.type="FXAA",this.width=void 0!==n?n:512,this.height=void 0!==r?r:256,this.needsSwap=!1}function gv(){fv.call(this,oa.grayscale),this.material.type="Grayscale"}function _v(e,t){uv.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}function yv(){uv.call(this),this.needsSwap=!1}function xv(){this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.geometry=new ui,this.widthCallback=null}function bv(e,t,n,r,i){var a;if(e=e.subarray||e.slice?e:e.buffer,n=n.subarray||n.slice?n:n.buffer,e=t?e.subarray?e.subarray(t,i&&t+i):e.slice(t,i&&t+i):e,n.set)n.set(e,r);else for(a=0;a<e.length;a++)n[a+r]=e[a];return n}function Mv(e){this.headEdge=this.tailEdge=e,this.headIndex=e.index0,this.tailIndex=e.index1,this.indexCount=2}function wv(e,t){this.index0=e,this.index1=t,this.edge0=null,this.edge1=null}function Av(){this.geometry=new ui}function Sv(e,t,n){var r=e.headIndex,i=e.tailIndex;return t[r][0]||t[i][0]||n[r][0]||n[i][0]||null}function Tv(e){Mc.call(this),this.type="MeshLineMaterial",this.lineWidth=1,this.sizeAttenuation=1,this.color=new Lr(16777215),this.opacity=1,this.useMap=0,this.map=null,this.useAlphaMap=0,this.alphaMap=null,this.resolution=new Jt(1,1),this.visibility=1,this.alphaTest=0,this.repeat=new Jt(1,1),this.uniforms={lineWidth:{value:1},sizeAttenuation:{value:1},color:{value:new Lr(16777215)},opacity:{value:1},useMap:{value:0},map:{value:null},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Jt(1,1)},visibility:{value:1},alphaTest:{value:0},repeat:{value:new Jt(1,1)}},this.vertexShader=aa.raw_meshline_vert,this.fragmentShader=aa.raw_meshline_frag,this.setValues(e)}function Ev(e,t,n,r){this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new rn(1,1,1,1),this.hiddenEdgeColor=new rn(.1,.04,.02,1),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this.renderToScreen=!1,uv.call(this),this.resolution=void 0!==e?new Jt(e.x,e.y):new Jt(256,256);var i={minFilter:tt,magFilter:tt,format:dt},a=Math.round(this.resolution.x/this.downSampleRatio),o=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new an(this.resolution.x,this.resolution.y,i),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.renderTargetDepthBuffer=new an(this.resolution.x,this.resolution.y,i),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new an(a,o,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new an(a,o,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new an(Math.round(a/2),Math.round(o/2),i),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new an(a,o,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new an(Math.round(a/2),Math.round(o/2),i),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeparableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new Jt(a,o),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new Jt(Math.round(a/2),Math.round(o/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial();var s=oa.copy;this.copyUniforms=Vi.clone(s.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ji({defines:s.defines,uniforms:this.copyUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,blending:ae,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Lr,this.oldClearAlpha=1,this.basic=new zr,this.fsQuad=new uv.FullScreenQuad(null),this.camera=new na(-1,1,1,-1,0,1),this.scene=new zn,this.tempPulseColor1=new rn,this.tempPulseColor2=new rn,this.textureMatrix=new _n,this._MorphingFlag=1,this._SkinningFlag=2,this._NumberOfMaterialVariants=1+(this._MorphingFlag|this._SkinningFlag),this._depthMaterials=new Array(this._NumberOfMaterialVariants),this._maskMaterials=new Array(this._NumberOfMaterialVariants);for(var l=0;l!==this._NumberOfMaterialVariants;++l){var c=0!=(l&this._MorphingFlag),u=0!=(l&this._SkinningFlag),d=new Ho({blending:ae,depthPacking:Ot,side:ie,morphTargets:c,skinning:u});this._depthMaterials[l]=d;var h=new Rc({side:ie,morphTargets:c,skinning:u});this._maskMaterials[l]=h}}function Cv(e,t,n,r,i){uv.call(this),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1}(sv.prototype=Object.create(o.prototype)).constructor=sv,Object.defineProperties(sv.prototype,{center:{get:function(){return console.warn("v3d.OrbitControls: .center has been deprecated, use .targetObj instead"),new un}},target:{get:function(){return console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead"),new un},set:function(){console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead")}},noZoom:{get:function(){return console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}}}),lv.prototype={constructor:lv,update:function(e){var t=e.toneMapping,n=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=ze,e.toneMappingExposure=1;for(var i=0;i<6;i++)e.setRenderTarget(this.renderTarget,i),this.shader.uniforms.faceIdx.value=i,e.render(this.scene,this.camera);e.toneMapping=t,e.toneMappingExposure=n,e.setRenderTarget(r)},dispose:function(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}},cv.prototype={constructor:cv,update:function(e){var t=e.gammaInput,n=e.gammaOutput,r=e.toneMapping,i=e.toneMappingExposure,a=e.getRenderTarget();e.toneMapping=ze,e.toneMappingExposure=1,e.gammaInput=!1,e.gammaOutput=!1,this.renderToCubeMapTarget(e,this.renderTarget),e.setRenderTarget(a),e.toneMapping=r,e.toneMappingExposure=i,e.gammaInput=t,e.gammaOutput=n},renderToCubeMapTarget:function(e,t){this.shader.uniforms.invertU.value=this.invertU,this.shader.uniforms.offsetU.value=this.offsetU;for(var n=0;n<6;n++)this.renderToCubeMapTargetFace(e,t,n)},renderToCubeMapTargetFace:function(e,t,n){this.shader.uniforms.faceIndex.value=n,e.setRenderTarget(t,n),e.render(this.scene,this.camera)},dispose:function(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}},uv.prototype=Object.assign(Object.create(o.prototype),{constructor:uv,setCamera:function(e){},setSize:function(e,t){},dispose:function(){},render:function(e,t,n,r,i){console.error("v3d.Pass: .render() must be implemented in derived pass.")}}),uv.FullScreenQuad=(av=new na(-1,1,1,-1,0,1),ov=new ia(2,2),Object.defineProperty(dv.prototype,"material",{get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}),Object.assign(dv.prototype,{render:function(e){e.render(this._mesh,av)},dispose:function(){}}),dv),hv.prototype=Object.assign(Object.create(uv.prototype),{constructor:hv,dispose:function(){for(var e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()},setSize:function(e,t){var n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(var i=0;i<this.nMips;i++)this.renderTargetsHorizontal[i].setSize(n,r),this.renderTargetsVertical[i].setSize(n,r),this.separableBlurMaterials[i].uniforms.texSize.value=new Jt(n,r),n=Math.round(n/2),r=Math.round(r/2)},render:function(e,t,n,r,i){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),i&&e.context.disable(e.context.STENCIL_TEST),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);for(var o=this.renderTargetBright,s=0;s<this.nMips;s++)this.fsQuad.material=this.separableBlurMaterials[s],this.separableBlurMaterials[s].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[s].uniforms.direction.value=hv.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[s]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[s].uniforms.colorTexture.value=this.renderTargetsHorizontal[s].texture,this.separableBlurMaterials[s].uniforms.direction.value=hv.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[s]),e.clear(),this.fsQuad.render(e),o=this.renderTargetsVertical[s];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,i&&e.context.enable(e.context.STENCIL_TEST),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a},getSeperableBlurMaterial:function(e){return new ji({type:"BloomSeparableBlur",defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new Jt(.5,.5)},direction:{value:new Jt(.5,.5)}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_bloom_separable_blur_frag})},getCompositeMaterial:function(e){return new ji({type:"BloomComposite",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:aa.pp_plane_vert,fragmentShader:aa.pp_bloom_composite_frag})}}),hv.BlurDirectionX=new Jt(1,0),hv.BlurDirectionY=new Jt(0,1),pv.prototype=Object.assign(Object.create(uv.prototype),{constructor:pv,render:function(e,t,n,r,i){this.quad2.material=this.materialBokeh,this.scene.overrideMaterial=this.materialDepth,this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.tColor.value=n.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.uniforms.aspect.value=this.camera.aspect,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),e.clear()),e.render(this.scene2,this.camera2),this.scene.overrideMaterial=null,e.setClearColor(this.oldClearColor),e.setClearAlpha(this.oldClearAlpha),e.autoClear=this.oldAutoClear},setCamera:function(e){this.camera=e},setSize:function(e,t){this.renderTargetDepth.setSize(e,t)},dispose:function(){this.renderTargetDepth.dispose()}}),fv.prototype=Object.assign(Object.create(uv.prototype),{constructor:fv,render:function(e,t,n,r,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)},dispose:function(){this.material.dispose()}}),mv.prototype=Object.assign(Object.create(fv.prototype),{constructor:mv}),(vv.prototype=Object.create(fv.prototype)).setSize=function(e,t){this.width=e,this.height=t,this.uniforms.resolution.value.set(1/e,1/t)},gv.prototype=Object.assign(Object.create(fv.prototype),{constructor:gv}),_v.prototype=Object.assign(Object.create(uv.prototype),{constructor:_v,render:function(e,t,n,r,i){var a,o,s=e.context,l=e.state;l.buffers.color.setMask(!1),l.buffers.depth.setMask(!1),l.buffers.color.setLocked(!0),l.buffers.depth.setLocked(!0),o=this.inverse?(a=0,1):(a=1,0),l.buffers.stencil.setTest(!0),l.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),l.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),l.buffers.stencil.setClear(o),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),l.buffers.color.setLocked(!1),l.buffers.depth.setLocked(!1),l.buffers.stencil.setFunc(s.EQUAL,1,4294967295),l.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP)},setCamera:function(e){this.camera=e}}),yv.prototype=Object.create(uv.prototype),Object.assign(yv.prototype,{render:function(e,t,n,r,i){e.state.buffers.stencil.setTest(!1)}}),xv.prototype.setGeometry=function(e,t){if(this.widthCallback=t,this.positions=[],this.counters=[],e instanceof Oi)for(var n=0;n<e.vertices.length;n++){var r=e.vertices[n],t=n/e.vertices.length;this.positions.push(r.x,r.y,r.z),this.positions.push(r.x,r.y,r.z),this.counters.push(t),this.counters.push(t)}if(e instanceof Float32Array||e instanceof Array)for(n=0;n<e.length;n+=3){t=n/e.length;this.positions.push(e[n],e[n+1],e[n+2]),this.positions.push(e[n],e[n+1],e[n+2]),this.counters.push(t),this.counters.push(t)}this.process()},xv.prototype.compareV3=function(e,t){var n=6*e,r=6*t;return this.positions[n]===this.positions[r]&&this.positions[1+n]===this.positions[1+r]&&this.positions[2+n]===this.positions[2+r]},xv.prototype.copyV3=function(e){var t=6*e;return[this.positions[t],this.positions[1+t],this.positions[2+t]]},xv.prototype.process=function(){var e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];for(var t,n=0;n<e;n++)this.side.push(1),this.side.push(-1);for(n=0;n<e;n++)t=this.widthCallback?this.widthCallback(n/(e-1)):1,this.width.push(t),this.width.push(t);for(var r,n=0;n<e;n++)this.uvs.push(n/(e-1),0),this.uvs.push(n/(e-1),1);r=this.compareV3(0,e-1)?this.copyV3(e-2):this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(n=0;n<e-1;n++)r=this.copyV3(n),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(n=1;n<e;n++)r=this.copyV3(n),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]);r=this.compareV3(e-1,0)?this.copyV3(1):this.copyV3(e-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]);for(n=0;n<e-1;n++){var i=2*n;this.indices_array.push(i,1+i,2+i),this.indices_array.push(2+i,1+i,3+i)}this.attributes?(this.attributes.position.copyArray(new Float32Array(this.positions)),this.attributes.position.needsUpdate=!0,this.attributes.previous.copyArray(new Float32Array(this.previous)),this.attributes.previous.needsUpdate=!0,this.attributes.next.copyArray(new Float32Array(this.next)),this.attributes.next.needsUpdate=!0,this.attributes.side.copyArray(new Float32Array(this.side)),this.attributes.side.needsUpdate=!0,this.attributes.width.copyArray(new Float32Array(this.width)),this.attributes.width.needsUpdate=!0,this.attributes.uv.copyArray(new Float32Array(this.uvs)),this.attributes.uv.needsUpdate=!0,this.attributes.counters.copyArray(new Float32Array(this.counters)),this.attributes.counters.needsUpdate=!0,this.attributes.index.copyArray(new Uint16Array(this.indices_array)),this.attributes.index.needsUpdate=!0):this.attributes={position:new Vr(new Float32Array(this.positions),3),previous:new Vr(new Float32Array(this.previous),3),next:new Vr(new Float32Array(this.next),3),side:new Vr(new Float32Array(this.side),1),width:new Vr(new Float32Array(this.width),1),uv:new Vr(new Float32Array(this.uvs),2),counters:new Vr(new Float32Array(this.counters),1),index:new Vr(new Uint16Array(this.indices_array),1)},this.geometry.setAttribute("position",this.attributes.position),this.geometry.setAttribute("previous",this.attributes.previous),this.geometry.setAttribute("next",this.attributes.next),this.geometry.setAttribute("side",this.attributes.side),this.geometry.setAttribute("width",this.attributes.width),this.geometry.setAttribute("uv",this.attributes.uv),this.geometry.setAttribute("counters",this.attributes.counters),this.geometry.setIndex(this.attributes.index)},xv.prototype.advance=function(e){var t=this.attributes.position.array,n=this.attributes.previous.array,r=this.attributes.next.array,i=t.length;bv(t,0,n,0,i),bv(t,6,t,0,i-6),t[i-6]=e.x,t[i-5]=e.y,t[i-4]=e.z,t[i-3]=e.x,t[i-2]=e.y,t[i-1]=e.z,bv(t,6,r,0,i-6),r[i-6]=e.x,r[i-5]=e.y,r[i-4]=e.z,r[i-3]=e.x,r[i-2]=e.y,r[i-1]=e.z,this.attributes.position.needsUpdate=!0,this.attributes.previous.needsUpdate=!0,this.attributes.next.needsUpdate=!0},Object.assign(Mv.prototype,{mergeStrip:function(e){var t=this.headIndex,n=e.headIndex,r=this.tailIndex,i=e.tailIndex;t==n?(this.headEdge.linkToEdge(e.headEdge),e.headEdge.linkToEdge(this.headEdge),this.headEdge=e.tailEdge,this.headIndex=e.tailIndex,this.indexCount+=e.indexCount-1):t==i?(this.headEdge.linkToEdge(e.tailEdge),e.tailEdge.linkToEdge(this.headEdge),this.headEdge=e.headEdge,this.headIndex=e.headIndex,this.indexCount+=e.indexCount-1):r==n?(this.tailEdge.linkToEdge(e.headEdge),e.headEdge.linkToEdge(this.tailEdge),this.tailEdge=e.tailEdge,this.tailIndex=e.tailIndex,this.indexCount+=e.indexCount-1):r==i&&(this.tailEdge.linkToEdge(e.tailEdge),e.tailEdge.linkToEdge(this.tailEdge),this.tailEdge=e.headEdge,this.tailIndex=e.headIndex,this.indexCount+=e.indexCount-1)},getIndicesFlat:function(){for(var e=new Float32Array(this.indexCount),t=0,n=null,r=this.headEdge,i=e[t++]=this.headIndex;null!==r;){i=r.index0==i?r.index1:r.index0;e[t++]=i;var a=r.edge0;a!=n&&null!==a||(a=r.edge1),a==n&&(a=null),n=r,r=a}return e}}),Object.assign(wv.prototype,{linkToEdge:function(e){null===this.edge0?this.edge0=e:null===this.edge1&&(this.edge1=e)}}),Object.assign(Av.prototype,{fromBufferGeometry:function(e){var r,t,n,i,a,o,s,l,c,u,d,h,p=e.getAttribute("position"),f=e.getIndex();void 0!==p&&(r=[],null!==f?function(e){for(var t=e.length%2?e.length-1:e.length,n={},r={},i=0;i<t;i+=2){var a=(u=new Mv(new wv(e[i],e[i+1]))).headIndex,o=u.tailIndex;n[a]=n[a]||[],n[o]=n[o]||[],r[a]=r[a]||[],r[o]=r[o]||[],n[a].push(u),r[o].push(u)}var s=new Ic.LinkMap;for(var l in n)n[l].length&&s.push(new Ic.LinkMapNode(n[l]),l);for(var c=[],u=s.first&&s.first.value[0];u;){n[a=u.headIndex].splice(n[a].indexOf(u),1),r[o=u.tailIndex].splice(r[o].indexOf(u),1),0==n[a].length&&s.removeNodeByKey(a);for(var d=Sv(u,n,r);null!==d;)n[a=d.headIndex].splice(n[a].indexOf(d),1),r[o=d.tailIndex].splice(r[o].indexOf(d),1),0==n[a].length&&s.removeNodeByKey(a),u.mergeStrip(d),d=Sv(u,n,r);c.push(u),u=s.first&&s.first.value[0]}return c}(f.array).forEach(function(e){var t=new xv,n=new Float32Array(3*e.indexCount);e.getIndicesFlat().forEach(function(e,t){n.set(p.array.subarray(3*e,3*e+3),3*t)}),t.setGeometry(n),r.push(t)}):((t=new xv).setGeometry(p.array),r.push(t)),n=[],i=[],a=[],o=[],s=[],l=[],c=[],u=[],d=0,r.forEach(function(e){n=n.concat(e.positions),i=i.concat(e.previous),a=a.concat(e.next),o=o.concat(e.side),s=s.concat(e.width),l=l.concat(e.uvs),c=c.concat(e.counters);var t=e.indices_array.map(function(e){return e+d});u=u.concat(t),d+=e.positions.length/3}),this.geometry.setAttribute("position",new Vr(new Float32Array(n),3)),this.geometry.setAttribute("previous",new Vr(new Float32Array(i),3)),this.geometry.setAttribute("next",new Vr(new Float32Array(a),3)),this.geometry.setAttribute("side",new Vr(new Float32Array(o),1)),this.geometry.setAttribute("width",new Vr(new Float32Array(s),1)),this.geometry.setAttribute("uv",new Vr(new Float32Array(l),2)),this.geometry.setAttribute("counters",new Vr(new Float32Array(c),1)),h=65535<Kr(u)?Uint32Array:Uint16Array,this.geometry.setIndex(new Vr(new h(u),1)))}}),Tv.prototype=Object.assign(Object.create(Mc.prototype),{constructor:Tv,isMeshLineMaterial:!0,copy:function(e){return Mc.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this.sizeAttenuation=e.sizeAttenuation,this.color.copy(e.color),this.opacity=e.opacity,this.useMap=e.useMap,this.map=e.map,this.useAlphaMap=e.useAlphaMap,this.alphaMap=e.alphaMap,this.resolution.copy(e.resolution),this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}),Ev.prototype=Object.assign(Object.create(uv.prototype),{constructor:Ev,dispose:function(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()},setSize:function(e,t){this.renderTargetMaskBuffer.setSize(e,t);var n=Math.round(e/this.downSampleRatio),r=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,r),this.renderTargetBlurBuffer1.setSize(n,r),this.renderTargetEdgeBuffer1.setSize(n,r),this.separableBlurMaterial1.uniforms.texSize.value=new Jt(n,r),n=Math.round(n/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(n,r),this.renderTargetEdgeBuffer2.setSize(n,r),this.separableBlurMaterial2.uniforms.texSize.value=new Jt(n,r)},changeVisibilityOfSelectedObjects:function(t){function e(e){e instanceof Ci&&(e.outlineVisible=t)}for(var n=0;n<this.selectedObjects.length;n++){var r=this.selectedObjects[n];e(r);for(var i=r.children,a=0;a<i.length;a++){var o=i[a];o.isMesh&&o.isMaterialGeneratedMesh&&e(o)}}},changeVisibilityOfNonSelectedObjects:function(r){var i=[];function e(e){e instanceof Ci&&i.push(e)}for(var t=0;t<this.selectedObjects.length;t++){var n=this.selectedObjects[t];e(n);for(var a=n.children,o=0;o<a.length;o++){var s=a[o];s.isMesh&&s.isMaterialGeneratedMesh&&e(s)}}this.renderScene.traverse(function(e){if(e instanceof Ci){for(var t=!1,n=0;n<i.length;n++){if(i[n].id===e.id){t=!0;break}}t||(e.outlineVisible=r)}})},updateTextureMatrix:function(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)},getDepthMaterial:function(e,t,n){var r,i,a,o=e.geometry,s=null,l=this._depthMaterials,c=e.customDepthMaterial;n&&(l=this._maskMaterials),(s=c||(r=!1,t.morphTargets&&(o&&o.isBufferGeometry?r=o.morphAttributes&&o.morphAttributes.position&&0<o.morphAttributes.position.length:o&&o.isGeometry&&(r=o.morphTargets&&0<o.morphTargets.length)),e.isSkinnedMesh&&!1===t.skinning&&console.warn("v3d.OutlinePass: v3d.SkinnedMesh with material.skinning set to false:",e),i=e.isSkinnedMesh&&t.skinning,a=0,r&&(a|=this._MorphingFlag),i&&(a|=this._SkinningFlag),l[a])).visible=t.visible,s.wireframe=t.wireframe;var u=t.side;return s.side=u,s.clipShadows=t.clipShadows,s.clippingPlanes=t.clippingPlanes,s.clipIntersection=t.clipIntersection,s.wireframeLinewidth=t.wireframeLinewidth,s.linewidth=t.linewidth,n&&(s.cameraNearFar=new Jt(this.renderCamera.near,this.renderCamera.far),s.depthTexture=this.renderTargetDepthBuffer.texture,s.textureMatrix=this.textureMatrix),s},renderObject:function(e,t,n,r){var i,a,o;t.outlineVisible&&t.isVisible()&&t.layers.test(n.layers)&&(i=e.updateGeometry(t),(a=t.material).visible&&(o=this.getDepthMaterial(t,a,r),e.renderObject(t,this.scene,n,i,o,null)));for(var s=t.children,l=0,c=s.length;l<c;l++)this.renderObject(e,s[l],n,r)},render:function(e,t,n,r,i){var a,o,s;this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),0!==this.selectedObjects.length&&(this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha(),a=e.autoClear,e.autoClear=!1,i&&e.context.disable(e.context.STENCIL_TEST),e.setClearColor(16777215,1),o=this.renderScene.background,this.renderScene.background=null,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),this.changeVisibilityOfSelectedObjects(!1),this.changeVisibilityOfNonSelectedObjects(!0),this.renderObject(e,this.renderScene,this.renderCamera,!1),this.updateTextureMatrix(),e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),this.changeVisibilityOfSelectedObjects(!0),this.changeVisibilityOfNonSelectedObjects(!1),this.renderObject(e,this.renderScene,this.renderCamera,!0),this.renderScene.background=o,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),0<this.pulsePeriod&&(s=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2,this.tempPulseColor1.multiplyScalar(s),this.tempPulseColor2.multiplyScalar(s)),this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new Jt(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ev.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ev.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Ev.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Ev.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.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),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a)},getEdgeDetectionMaterial:function(){return new ji({type:"OutlineEdgeDetection",defines:{HIDDEN_EDGE_ALPHA:1},uniforms:{maskTexture:{value:null},texSize:{value:new Jt(.5,.5)},visibleEdgeColor:{value:new rn(1,1,1,1)},hiddenEdgeColor:{value:new rn(1,1,1,1)}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_outline_edge_frag})},getSeparableBlurMaterial:function(e){return new ji({type:"OutlineSeparableBlur",defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Jt(.5,.5)},direction:{value:new Jt(.5,.5)},kernelRadius:{value:1}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_outline_blur_frag})},getOverlayMaterial:function(){return new ji({type:"OutlineOverlay",uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_outline_overlay_frag,blending:ue,blendEquation:de,blendEquationAlpha:de,blendSrc:be,blendDst:Me,blendSrcAlpha:_e,blendDstAlpha:_e,depthTest:!1,depthWrite:!1,transparent:!0})},setCamera:function(e){this.renderCamera=e}}),Ev.BlurDirectionX=new Jt(1,0),Ev.BlurDirectionY=new Jt(0,1),Cv.prototype=Object.assign(Object.create(uv.prototype),{constructor:Cv,render:function(e,t,n,r,i){var a,o,s=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(a=e.getClearColor().getHex(),o=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(a,o),this.scene.overrideMaterial=null,e.autoClear=s},setCamera:function(e){this.camera=e}});function Pv(e,t,n,r){uv.call(this),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==r?r:0;var i=oa.copy;this.copyUniformsAccum=Vi.clone(i.uniforms),this.copyMaterialAccum=new ji({type:"SSAACopyAccum",defines:i.defines,uniforms:this.copyUniformsAccum,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:se,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new uv.FullScreenQuad(this.copyMaterialAccum),this.copyUniformsFinal=Vi.clone(i.uniforms),this.copyMaterialFinal=new ji({type:"SSAACopyFinal",defines:i.defines,uniforms:this.copyUniformsFinal,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:ae,depthTest:!1,depthWrite:!1}),this.fsQuadFinal=new uv.FullScreenQuad(this.copyMaterialFinal),this.iterative=!1,this.iterativeFrame=0}function Lv(e,t){var n=(this.sourceTexture=e).image.width,r=e.image.height,i={format:dt,magFilter:tt,minFilter:1008,type:t,generateMipmaps:!0,anisotropy:e.anisotropy,encoding:Tt,wrapS:e.wrapS,wrapT:e.wrapT};this.renderTarget=new an(n,r,i),this.renderTarget.texture.name=e.name,this.renderTarget.texture.flipY=e.flipY,this.camera=new na(-1,1,1,-1,0,1),this.shader=new ji({type:"RGBEToFloat",uniforms:Vi.clone(oa.copy.uniforms),vertexShader:oa.copy.vertexShader,fragmentShader:oa.copy.fragmentShader,defines:{MAP_TEXELS:1}}),this.planeMesh=new Ci(new ia(2,2,0),this.shader),this.planeMesh.material.map=e,this.scene=new zn,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.shader.uniforms.tDiffuse.value=e,this.shader.uniforms.opacity.value=1}Pv.prototype=Object.assign(Object.create(uv.prototype),{constructor:Pv,_getJitterOffsets:function(){return Pv.JitterVectors[Math.max(0,Math.min(this.sampleLevel,5))]},_isLastIterativeFrame:function(){var e=this._getJitterOffsets();return this.iterativeFrame==e.length-1},dispose:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null,this.accumRenderTarget.dispose(),this.accumRenderTarget=null)},setSize:function(e,t){this.sampleRenderTarget&&(this.sampleRenderTarget.setSize(e,t),this.accumRenderTarget.setSize(e,t))},render:function(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=n.clone(),this.sampleRenderTarget.texture.name="SSAARenderPass.sample",this.accumRenderTarget=n.clone(),this.accumRenderTarget.texture.name="SSAARenderPass.accum");var r=this._getJitterOffsets(),i=e.autoClear;e.autoClear=!1;var a=e.getClearColor().getHex(),o=e.getClearAlpha(),s=1/r.length;this.copyUniformsAccum.tDiffuse.value=this.sampleRenderTarget.texture;var l,c,u=n.width,d=n.height;this.iterative?(c=this.iterativeFrame,l=performance.now()):c=0;for(var h=r.length,p=c;p<h;p++){this.dispatchEvent({type:"iteration",frame:p});var f=r[p];this.camera.setViewOffset&&this.camera.setViewOffset(u,d,.0625*f[0],.0625*f[1],u,d);var m=s;if(this.unbiased&&(m+=1/32*((p+.5)/r.length-.5)),this.copyUniformsAccum.opacity.value=m,e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(this.scene,this.camera),this.iterative?e.setRenderTarget(this.accumRenderTarget):e.setRenderTarget(this.renderToScreen?null:t),0===p&&(e.setClearColor(0,0),e.clear()),this.fsQuadAccum.render(e),this.iterativeFrame=p,this.iterative&&4<performance.now()-l)break}this.iterative&&(this._isLastIterativeFrame()?(this.copyUniformsFinal.tDiffuse.value=this.accumRenderTarget.texture,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuadFinal.render(e),this.iterativeFrame=0):this.iterativeFrame++),this.camera.clearViewOffset&&this.camera.clearViewOffset(),e.autoClear=i,e.setClearColor(a,o)},isLastIterativeFrame:function(){console.error("isLastIterativeFrame() deprectated, use pass event listener instead")},setCamera:function(e){this.camera=e}}),Pv.JitterVectors=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Lv.prototype={constructor:Lv,update:function(e){var t=e.toneMapping,n=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=ze,e.toneMappingExposure=1,e.setRenderTarget(this.renderTarget),e.render(this.scene,this.camera),e.setRenderTarget(r),e.toneMapping=t,e.toneMappingExposure=n},dispose:function(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};function Rv(e){null==e&&(e=Math),this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(var t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());for(this.perm=[],t=0;t<512;t++)this.perm[t]=this.p[255&t];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}var Dv={renderWorldNodeMatToCubemap:function(e,t,n,r){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");var i=new zn,a=new Hi(.1,10,n,r);i.add(a);var o=/Firefox/.test(navigator.userAgent)&&/Android/.test(navigator.userAgent);e.getContext();if(!o&&os.checkHalfFloatTex(e,!0)){a.renderTarget.texture.type=lt;var s=window.navigator.platform,l=!!window.chrome&&!/Edge/.test(navigator.userAgent),c=-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(s);for(var u in t.nodeTextures){var d,h=t.nodeTextures[u];h.encoding!=Pt||l&&c||((d=new Lv(h,lt)).update(e),t.nodeTextures[u]=d.renderTarget.texture,t.updateNodeGraph())}}var p=t.clone();p.defines.WORLD_NODES=1,p.side=Le;var f=new Ci(new Bi(1,1,1),p);for(var u in i.add(f),a.update(e,i),f.material.dispose(),f.material.nodeTextures)f.material.nodeTextures[u].dispose();return f.geometry.dispose(),a.renderTarget},assignAllLayersMask:function(e){var t=e.layers.mask;return e.layers.set(0),e.isArrayCamera&&(e.layers.enable(1),e.layers.enable(2)),e.layers.enable(3),e.layers.enable(4),e.layers.enable(5),e.layers.enable(6),t}};Rv.prototype.dot=function(e,t,n){return e[0]*t+e[1]*n},Rv.prototype.dot3=function(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r},Rv.prototype.dot4=function(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i},Rv.prototype.noise=function(e,t){var n,r=(e+t)*(.5*(Math.sqrt(3)-1)),i=Math.floor(e+r),a=Math.floor(t+r),o=(3-Math.sqrt(3))/6,s=(i+a)*o,l=e-(i-s),c=t-(a-s),u=c<l?(n=1,0):(n=0,1),d=l-n+o,h=c-u+o,p=l-1+2*o,f=c-1+2*o,m=255&i,v=255&a,g=this.perm[m+this.perm[v]]%12,_=this.perm[m+n+this.perm[v+u]]%12,y=this.perm[1+m+this.perm[1+v]]%12,x=.5-l*l-c*c,b=x<0?0:(x*=x)*x*this.dot(this.grad3[g],l,c),M=.5-d*d-h*h,w=M<0?0:(M*=M)*M*this.dot(this.grad3[_],d,h),A=.5-p*p-f*f,S=A<0?0:(A*=A)*A*this.dot(this.grad3[y],p,f);return 70*(b+w+S)},Rv.prototype.noise3d=function(e,t,n){var r,i,a,o,s,l=(e+t+n)*(1/3),c=Math.floor(e+l),u=Math.floor(t+l),d=Math.floor(n+l),h=(c+u+d)*(1/6),p=e-(c-h),f=t-(u-h),m=n-(d-h),v=f<=p?m<=f?(s=o=r=1,a=i=0):o=m<=p?(s=a=i=0,r=1):(s=i=r=0,a=1):f<m?(o=i=r=0,s=a=1):p<m?(o=a=r=0,s=i=1):(s=o=i=1,a=r=0),g=p-r+1/6,_=f-i+1/6,y=m-a+1/6,x=p-o+1/6*2,b=f-s+1/6*2,M=m-v+1/6*2,w=p-1+.5,A=f-1+.5,S=m-1+.5,T=255&c,E=255&u,C=255&d,P=this.perm[T+this.perm[E+this.perm[C]]]%12,L=this.perm[T+r+this.perm[E+i+this.perm[C+a]]]%12,R=this.perm[T+o+this.perm[E+s+this.perm[C+v]]]%12,D=this.perm[1+T+this.perm[1+E+this.perm[1+C]]]%12,N=.6-p*p-f*f-m*m,I=N<0?0:(N*=N)*N*this.dot3(this.grad3[P],p,f,m),O=.6-g*g-_*_-y*y,F=O<0?0:(O*=O)*O*this.dot3(this.grad3[L],g,_,y),B=.6-x*x-b*b-M*M,z=B<0?0:(B*=B)*B*this.dot3(this.grad3[R],x,b,M),U=.6-w*w-A*A-S*S,V=U<0?0:(U*=U)*U*this.dot3(this.grad3[D],w,A,S);return 32*(I+F+z+V)},Rv.prototype.noise4d=function(e,t,n,r){var i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20,c=(e+t+n+r)*s,u=Math.floor(e+c),d=Math.floor(t+c),h=Math.floor(n+c),p=Math.floor(r+c),f=(u+d+h+p)*l,m=e-(u-f),v=t-(d-f),g=n-(h-f),_=r-(p-f),y=(v<m?32:0)+(g<m?16:0)+(g<v?8:0)+(_<m?4:0)+(_<v?2:0)+(_<g?1:0),x=3<=a[y][0]?1:0,b=3<=a[y][1]?1:0,M=3<=a[y][2]?1:0,w=3<=a[y][3]?1:0,A=2<=a[y][0]?1:0,S=2<=a[y][1]?1:0,T=2<=a[y][2]?1:0,E=2<=a[y][3]?1:0,C=1<=a[y][0]?1:0,P=1<=a[y][1]?1:0,L=1<=a[y][2]?1:0,R=1<=a[y][3]?1:0,D=m-x+l,N=v-b+l,I=g-M+l,O=_-w+l,F=m-A+2*l,B=v-S+2*l,z=g-T+2*l,U=_-E+2*l,V=m-C+3*l,k=v-P+3*l,G=g-L+3*l,j=_-R+3*l,W=m-1+4*l,X=v-1+4*l,H=g-1+4*l,Y=_-1+4*l,q=255&u,Z=255&d,Q=255&h,K=255&p,J=o[q+o[Z+o[Q+o[K]]]]%32,$=o[q+x+o[Z+b+o[Q+M+o[K+w]]]]%32,ee=o[q+A+o[Z+S+o[Q+T+o[K+E]]]]%32,te=o[q+C+o[Z+P+o[Q+L+o[K+R]]]]%32,ne=o[1+q+o[1+Z+o[1+Q+o[1+K]]]]%32,re=.6-m*m-v*v-g*g-_*_,ie=re<0?0:(re*=re)*re*this.dot4(i[J],m,v,g,_),ae=.6-D*D-N*N-I*I-O*O,oe=ae<0?0:(ae*=ae)*ae*this.dot4(i[$],D,N,I,O),se=.6-F*F-B*B-z*z-U*U,le=se<0?0:(se*=se)*se*this.dot4(i[ee],F,B,z,U),ce=.6-V*V-k*k-G*G-j*j,ue=ce<0?0:(ce*=ce)*ce*this.dot4(i[te],V,k,G,j),de=.6-W*W-X*X-H*H-Y*Y,he=de<0?0:(de*=de)*de*this.dot4(i[ne],W,X,H,Y);return 27*(ie+oe+le+ue+he)};function Nv(e,t,n,r){uv.call(this),this.width=void 0!==n?n:512,this.height=void 0!==r?r:512,this.clear=!0,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this.generateSampleKernel(),this.generateRandomKernelRotations();var i=new fl;i.type=at,i.minFilter=Je,i.maxFilter=Je,this.beautyRenderTarget=new an(this.width,this.height,{minFilter:tt,magFilter:tt,format:dt,depthTexture:i,depthBuffer:!0}),this.normalRenderTarget=new an(this.width,this.height,{minFilter:Je,magFilter:Je,format:dt}),this.ssaoRenderTarget=new an(this.width,this.height,{minFilter:tt,magFilter:tt,format:dt}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=this.getSSAOMaterial(),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.normalMaterial=new Ec,this.normalMaterial.blending=ae,this.blurMaterial=this.getSSAOBlurMaterial(),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=this.getSSAODepthMaterial(),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far;var a=oa.copy;this.copyMaterial=new ji({type:"SSAOCopy",uniforms:Vi.clone(a.uniforms),defines:Object.assign({},a.defines),vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Se,blendDst:ge,blendEquation:de,blendSrcAlpha:we,blendDstAlpha:ge,blendEquationAlpha:de}),this.fsQuad=new uv.FullScreenQuad(null),this.originalClearColor=new Lr}Nv.prototype=Object.assign(Object.create(uv.prototype),{constructor:Nv,dispose:function(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose()},getSSAOMaterial:function(){return new ji({type:"SSAO",defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new Jt},cameraProjectionMatrix:{value:new _n},cameraInverseProjectionMatrix:{value:new _n},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_ssao_frag,blending:ae})},getSSAODepthMaterial:function(){return new ji({type:"SSAODepth",defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_ssao_depth_frag,blending:ae})},getSSAOBlurMaterial:function(){return new ji({type:"SSAOBlur",uniforms:{tDiffuse:{value:null},resolution:{value:new Jt}},vertexShader:aa.pp_plane_vert,fragmentShader:aa.pp_ssao_blur_frag})},render:function(e,t,n,r,i){var a=Dv.assignAllLayersMask(this.camera);switch(e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case Nv.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=ae,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nv.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=ae,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nv.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=ae,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nv.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Nv.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=ae,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nv.OUTPUT.Default:t.disableBlit=!0,this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=ae,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),t.disableBlit=!1,this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=ue,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("v3d.SSAOPass: Unknown output type.")}this.camera.layers.mask=a},renderPass:function(e,t,n,r,i){this.originalClearColor.copy(e.getClearColor());var a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=r&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=o,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)},renderOverride:function(e,t,n,r,i){this.originalClearColor.copy(e.getClearColor());var a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,null!=r&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)},setSize:function(e,t){this.width=e,this.height=t,this.beautyRenderTarget.setSize(e,t),this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.blurMaterial.uniforms.resolution.value.set(e,t)},generateSampleKernel:function(){for(var e=this.kernelSize,t=this.kernel,n=0;n<e;n++){var r=new un;r.x=2*Math.random()-1,r.y=2*Math.random()-1,r.z=Math.random(),r.normalize();var i=n/e,i=Kt.lerp(.1,1,i*i);r.multiplyScalar(i),t.push(r)}},generateRandomKernelRotations:function(){for(var e=new Rv,t=new Float32Array(64),n=0;n<16;n++){var r=4*n,i=2*Math.random()-1,a=2*Math.random()-1,o=e.noise3d(i,a,0);t[r]=o,t[1+r]=o,t[2+r]=o,t[3+r]=1}this.noiseTexture=new qi(t,4,4,dt,st),this.noiseTexture.wrapS=Ze,this.noiseTexture.wrapT=Ze,this.noiseTexture.needsUpdate=!0}}),Nv.OUTPUT={Default:0,SSAO:1,Blur:2,Beauty:3,Depth:4,Normal:5};function Iv(e,t,n){uv.call(this),this.enabled=!0,this.needsSwap=!1,n=n||{},this.objects=n.objects||[],this.steps=Jr(n.steps)||10,this.stride=Jr(n.stride)||30,this.binarySearchSteps=Jr(n.binarySearchSteps)||4,this.renderTargetScale=Jr(n.renderTargetScale)||.5,this.thickness=Jr(n.thickness)||.01,this.maxDistance=Jr(n.maxDistance)||100,this.jitter=Jr(n.jitter)||1,this.useRefract=Jr(n.useRefract)||!1,this.renderAfter=Jr(n.renderAfter)||[],this.simpleRefraction=Jr(n.simpleRefraction)||!1,this.scene=e,this.camera=t,this._prevClearColor=new Lr,this._depthBuffer=new an(256,256,{minFilter:Je,magFilter:Je,format:dt,type:lt}),this._depthBuffer.texture.name="SSRPass.Depth",this._depthBuffer.texture.generateMipmaps=!1,this._depthMaterial=new Ho,this._depthMaterial.depthPacking=3202,this._backfaceDepthBuffer=this._depthBuffer.clone(),this._backfaceDepthBuffer.texture.name="SSRPass.Depth",this._backfaceDepthMaterial=new Ho,this._backfaceDepthMaterial.depthPacking=3202,this._backfaceDepthMaterial.side=Le,this.basic=new zr,this.fsQuad=new uv.FullScreenQuad(null)}function Ov(){fv.call(this,oa.tonemap),this.material.type="ToneMap"}Iv.prototype=Object.assign(Object.create(uv.prototype),{constructor:Iv,_setLayer:function(e,t){e.layers.set(t),e.isMesh&&e.isMaterialGeneratedMesh&&e.parent.layers.enable(t)},dispose:function(){this._depthBuffer.dispose(),this._backfaceDepthBuffer.dispose();for(var e=0;e<this.objects.length;e++){var t=(n=this.objects[e]).material;t&&(this._setLayer(n,0),delete t.defines.USE_SSR,delete t.defines.USE_SSR_REFRACT,t.needsUpdate=!0)}this.objects.splice(0);for(e=0;e<this.renderAfter.length;e++){var n=this.renderAfter[e];this._setLayer(n,0)}this.renderAfter.splice(0)},setCamera:function(e){this.camera=e},setSize:function(e,t){e*=this.renderTargetScale,t*=this.renderTargetScale,this._depthBuffer.setSize(e,t),this._backfaceDepthBuffer.setSize(e,t)},render:function(e,t,n,r,i){var a=this;this._prevClearColor.copy(e.getClearColor());var o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!0,e.setClearColor(new Lr(0,0,0),0);var l=this.scene.background;this.scene.background=null;var c=this.camera.layers.mask,u=this.scene.overrideMaterial;this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e),this.useRefract||(this._depthMaterial.side=ie),this.camera.layers.enable(this.useRefract?3:5),this.useRefract&&this.simpleRefraction||(this.scene.overrideMaterial=this._depthMaterial,e.setRenderTarget(this._depthBuffer),e.clear(),e.render(this.scene,this.camera)),this.useRefract||(this.scene.overrideMaterial=this._backfaceDepthMaterial,e.setRenderTarget(this._backfaceDepthBuffer),e.clear(),e.render(this.scene,this.camera)),this.scene.overrideMaterial=u,this.scene.traverse(function(e){e.isLight&&(e.userData.v3d.oldLayersMask=e.layers.mask,e.layers.enable(a.useRefract?5:3),a.renderAfter.length&&e.layers.enable(a.useRefract?6:4))});for(var d=0;d<this.objects.length;d++){var h=(p=this.objects[d]).material;h&&h.isMeshNodeMaterial&&(this._setLayer(p,this.useRefract?5:3),h.defines.USE_SSR="",this.useRefract&&(h.defines.USE_SSR_REFRACT="",this.simpleRefraction&&(h.defines.SSR_SIMPLE_REFRACT="")),h.ssrParams={invProjectionMatrix:(new _n).getInverse(this.camera.projectionMatrix),sourceBuffer:t,depthBuffer:this._depthBuffer,backfaceDepthBuffer:this._backfaceDepthBuffer,stride:this.stride,thickness:this.thickness,maxDistance:this.maxDistance,jitter:this.jitter},h.needsUpdate=!0,h.defines.MAX_STEPS!==this.steps&&(h.defines.MAX_STEPS=Math.floor(this.steps),h.needsUpdate=!0),h.defines.BINARY_SEARCH_ITERATIONS!==this.binarySearchSteps&&(h.defines.BINARY_SEARCH_ITERATIONS=Math.floor(this.binarySearchSteps),h.needsUpdate=!0))}for(d=0;d<this.renderAfter.length;d++){var p=this.renderAfter[d];this._setLayer(p,this.useRefract?6:4)}this.camera.layers.set(this.useRefract?5:3),e.autoClear=!1,e.setRenderTarget(n),this.renderAfter.length&&(n.disableBlit=!0),e.render(this.scene,this.camera),this.renderAfter.length&&(this.camera.layers.set(this.useRefract?6:4),n.disableBlit=!1,e.render(this.scene,this.camera)),this.scene.background=l,this.camera.layers.mask=c,this.scene.traverse(function(e){e.isLight&&"oldLayersMask"in e.userData.v3d&&(e.layers.mask=e.userData.v3d.oldLayersMask,delete e.userData.v3d.oldLayersMask)}),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),e.setClearColor(this._prevClearColor,o),e.autoClear=s}}),Ov.prototype=Object.assign(Object.create(fv.prototype),{constructor:Ov});var Fv={Bloom:hv,Bokeh:pv,"Brightness/Contrast":mv,FXAA:vv,Grayscale:gv,Mask:_v,Outline:Ev,Render:Cv,SSAA:Pv,SSAO:Nv,SSR:Iv,ToneMapping:Ov},Bv={getPageParams:function(e){e=e||window;var t=decodeURIComponent(e.location.href.toString()),n={};if(-1==t.indexOf("?"))return n;for(var r=t.split("#")[0].split("?")[1].split("&"),i=0;i<r.length;i++){var a=r[i].split("="),o=a[0];1==a.length?n[o]="":n[o]=a[1]}return n},updatePageParam:function(e,t,n){var r=null,i="",a=e.split("?"),o=a[0],s=a[1],l="";if(s){var c=(d=s.split("#"))[0];(r=d[1])&&(s=c),a=s.split("&");for(var u=0;u<a.length;u++)a[u].split("=")[0]!=t&&(i+=l+a[u],l="&")}else{var d,c=(d=o.split("#"))[0],r=d[1];c&&(o=c)}return r&&(n+="#"+r),o+"?"+i+(l+""+t+"="+n)},loadScript:function(e,t,n,r){var i=document.createElement("script");i.addEventListener("load",n,!1),i.addEventListener("error",r,!1),t.appendChild(i),i.src=e},drawWatermark:function(e){var t,n,r=e.container;3483952072==Kt.hashString(Xt)&&(t=["color: #fff;","opacity: 0.5;","font-size: 18px;","font-family: sans-serif;","text-align: center;","text-decoration: none;","position: absolute;","bottom: 1%;","right: 1%;","user-select: none;","z-index: 9999;","text-shadow: 1px 1px #000;"].join("\n"),(n=document.createElement("div")).innerHTML='<a href="https://www.soft8soft.com/verge3d-trial/" target="_blank" style="'.concat(t,'">').concat("MADE WITH VERGE3D TRIAL","</a>"),r.appendChild(n),setTimeout(function(){r.contains(n)&&890310108==Kt.hashString(n.textContent)||e.dispose()},1e3))},isXML:function(e){return null!==e.match(/.*\.xml$/)},isJS:function(e){return null!==e.match(/.*\.js$/)},createLineObjectHTML:function(m,v,g,e,t,_){console.warn("v3d.AppUtils.createLineObjectHTML has been deprecated. Use v3d.LineHTML instead."),e=e||2,t=t?t.convertSRGBToLinear():new Lr(1,0,.2),_=_||5;var y=new un(1,0,0),n=new xv;n.setGeometry([0,0,0,y.x,y.y,y.z]);var r=new Tv({color:t,lineWidth:e,sizeAttenuation:0}),x=new Ci(n.geometry,r);x.name=v.name+"_LINE",v.add(x);var b=new un,M=new un,w=new sn;m.renderCallbacks.push(function(){m.camera.updateMatrixWorld(),v.traverseAncestors(function(e){e.updateMatrixWorld()});var e=g.getBoundingClientRect(),t=(e.left+e.right)/2,n=(e.top+e.bottom)/2,r=v.getWorldPosition(b);r.project(m.camera);var i,a,o=(r.x+1)/2*m.getWidth(),s=(1-r.y)/2*m.getHeight(),l=(n-s)/(t-o),c=(e.height+2*_)/(e.width+2*_);Math.abs(l)>c?i=((a=n<s?Math.min(e.bottom+_,s):Math.max(e.top-_,s))-s)/l+o:a=((i=o<t?Math.max(e.left-_,o):Math.min(e.right+_,o))-o)*l+s;var u=2*i/m.getWidth()-1,d=1-2*a/m.getHeight(),h=M.set(u,d,0);h.unproject(m.camera),v.worldToLocal(h);var p=h.length();x.scale.set(p,p,p),h.normalize();var f=w.setFromUnitVectors(y,h);x.setRotationFromQuaternion(f)})},addToAppList:function(e){var t=ni();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))},removeFromAppList:function(e){var t,n=ni();n.v3d&&n.v3d.apps&&(-1<(t=n.v3d.apps.indexOf(e))&&n.v3d.apps.splice(t,1))},requestDeviceMotionPermissions:function(){var t;window.DeviceMotionEvent&&window.DeviceMotionEvent.requestPermission&&((t=document.createElement("div")).innerHTML='<div class="v3d-device-motion-permissions-dialog">Click here to enable iOS VR mode</div>',t.onclick=function(){window.DeviceMotionEvent.requestPermission().then(function(e){"granted"==e?console.log("DeviceMotion permissions granted"):console.log("DeviceMotion permissions not granted"),document.querySelector("body").removeChild(t)}).catch(function(){console.error(e)})},document.querySelector("body").appendChild(t))},printPerformanceInfo:function(m,v){v=v||1;var g=m.renderer.info,_=g.autoReset;g.autoReset=!1,g.reset();for(var y=m.frame,e=0;e<g.programs.length;e++)g.programs[e].profile.calcRenderTime=!0;setTimeout(function(){if(console.log("--- Verge3D Performance Profile ("+v+"s) ---"),m.scene){var e=m.frame-y;console.log("Scene Loading Time:",String(Math.round(m._loadingTime))+"ms"),console.log("FPS:",e/v),console.log("Render Calls:",g.render.calls/e),console.log("Triangles Rendered:",g.render.triangles/e),console.log("Geometry Buffers:",g.memory.geometries),console.log("HDR Rendering:",m.useHDR?"yes":"no"),console.log("Pixel Ratio:",m.renderer.getPixelRatio(),"(current) /",window.devicePixelRatio,"(device)");var t="N/A";switch(m._envIBLMode){case Yt:t="PMREM";break;case 1:t="Light Probe + Cubemap";break;case 2:t="Light Probe"}console.log("Image-Based Lighting:",t,m._pmremMaxTileSize+"px");var n=0,r=0,i="";m.scene.traverse(function(e){e.isLight&&(n++,e.castShadow&&e.shadow&&(r++,i=e.shadow.mapSize.width+"x"+e.shadow.mapSize.height))}),console.log("Lights:",n);var a=[];m.postprocessing&&m.postprocessing.composer.passes.forEach(function(e){for(var t in Fv)if(e instanceof Fv[t])return void a.push(t);a.push("Undefined")}),console.log("Post-Processing:",a.length?a.join(","):"N/A");var o="N/A";if(r&&m.renderer.shadowMap&&m.renderer.shadowMap.enabled){switch(m.renderer.shadowMap.type){case Y:o="Basic";break;case ne:o="Bilinear";break;case q:o="PCF";break;case Z:o="PCF (Bilinear)";break;case te:o="PCF (Poisson Disk)";break;case ee:o="ESM";break;case $:o="VSM";break;default:o="Unknown"}o+=" "+r+"x "+i}console.log("Shadow Map:",o),console.log("Materials and Shaders:");var s=g.programs.slice(0);s.sort(function(e,t){return t.profile.renderTime-e.profile.renderTime});for(var l=0,c=0;c<s.length;c++){var u=s[c];u.profile.calcRenderTime=!1;var d=u.profile.materials,h=u.profile.renderTime/e;console.log(" ",0==d.length?"System Material":d.join(","),"-",u.name,"-",String(Math.round(10*h)/10)+"ms"),l+=h,u.profile.renderTime=0}console.log("Total Render Time:",String(Math.round(10*l)/10)+"ms"),console.log("Textures & Render Buffers:",g.memory.textures);var p=Array.from(g.memory.textureSpecs.values());p.sort(function(e,t){return e.type<t.type?-1:e.type>t.type?1:e.width!=t.width?t.width-e.width:t.height-e.height});for(c=0;c<p.length;c++){var f=p[c];console.log(" ",f.name||"N/A","-",f.type,"-",f.width+"x"+f.height)}g.autoReset=_}else console.log("Scene not loaded")},1e3*v)}},zv={prepareRenderer:function(e){os.checkAndroid()&&"ARM"===os.getGPUVendor(e)&&"Mali-T760"===os.getGPUModel(e)&&(e.compatSettings.saturateSpecEnvBlenderApprox=!0)}};function Uv(e,t){var n,r;this.renderer=e,void 0===t&&(n={minFilter:tt,magFilter:tt,format:dt,stencilBuffer:!1},(t=new an((r=e.getDrawingBufferSize()).width,r.height,n)).texture.name="EffectComposer.rt1",t.texture.encoding=Et),this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new fv(oa.copy),this._previousFrameTime=Date.now()}Object.assign(Uv.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var t=this.renderer.getDrawingBufferSize(new Jt);e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},isLastEnabledPass:function(e){for(var t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0},render:function(e){void 0===e&&(e=.001*(Date.now()-this._previousFrameTime)),this._previousFrameTime=Date.now();for(var t,n,r=this.renderer.getRenderTarget(),i=!1,a=this.passes.length,o=0;o<a;o++){!1!==(t=this.passes[o]).enabled&&(t.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(o),t.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),t.needsSwap&&(i&&((n=this.renderer.context).stencilFunc(n.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.stencilFunc(n.EQUAL,1,4294967295)),this.swapBuffers()),t instanceof _v?i=!0:t instanceof yv&&(i=!1))}this.renderer.setRenderTarget(r)},reset:function(e){var t;void 0===e&&(t=this.renderer.getDrawingBufferSize(new Jt),(e=this.renderTarget1.clone()).setSize(t.width,t.height)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,t){this.renderTarget1.setSize(e,t),this.renderTarget2.setSize(e,t);for(var n=0;n<this.passes.length;n++)this.passes[n].setSize(e,t)},dispose:function(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()},getActiveSSAAPass:function(){return this.passes[0]instanceof Pv?this.passes[0]:null},insertPassAfter:function(e,t){for(var n=0,r=0;r<this.passes.length;r++)-1<t.indexOf(this.passes[r])&&(n=r+1);this.insertPass(e,n)},enableAllPasses:function(){for(var e=0;e<this.passes.length;e++)this.passes[e].enabled=!0},disableAllPasses:function(){for(var e=0;e<this.passes.length;e++)this.passes[e].enabled=!1}});var Vv=[[0,0,!1,!1],[2,0,!1,!1],[1,1,!0,!0],[0,1,!0,!0],[1,0,!1,!1],[2,1,!1,!1]];function kv(e){this.manager=void 0!==e?e:Uu}Object.assign(kv.prototype,{crossOrigin:"Anonymous",load:function(e,s,t,n){var l=new _a,r=new Hu(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);var c=0;return r.load(e,function(e){for(var t=0;t<Vv.length;t++){var n=Vv[t],r=document.createElement("canvas"),i=e.width/3,a=e.height/2;r.width=i,r.height=a;var o=r.getContext("2d");n[2]&&(o.translate(i,0),o.scale(-1,1)),n[3]&&(o.translate(0,a),o.scale(1,-1)),o.drawImage(e,n[0]*i,n[1]*a,i,a,0,0,i,a),l.images[t]=r,6===++c&&(l.needsUpdate=!0,s&&s(l))}},void 0,n),l},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}});var Gv,jv=void 0!==jv?jv:{},Wv={};for(Gv in jv)jv.hasOwnProperty(Gv)&&(Wv[Gv]=jv[Gv]);var Xv,Hv,Yv,qv,Zv=!1,Qv=!1,Kv=!1,Zv="object"==typeof window,Qv="function"==typeof importScripts,Kv="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&!Zv&&!Qv,Jv=!Zv&&!Kv&&!Qv,$v="";Kv?($v=__dirname+"/",Xv=function(e,t){var n=Ig(e);return n?t?n:n.toString():(Yv=Yv||require("fs"),e=(qv=qv||require("path")).normalize(e),Yv.readFileSync(e,t?null:"utf8"))},Hv=function(e){var t=Xv(e,!0);return t.buffer||(t=new Uint8Array(t)),sg(t.buffer),t},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),"undefined"!=typeof module&&(module.exports=jv),process.on("uncaughtException",function(e){if(!(e instanceof function(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}))throw e}),process.on("unhandledRejection",Tg),jv.inspect=function(){return"[Emscripten Module object]"}):Jv?("undefined"!=typeof read&&(Xv=function(e){var t=Ig(e);return t?Dg(t):read(e)}),Hv=function(e){var t=Ig(e);return t||("function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(sg("object"==typeof(t=read(e,"binary"))),t))},"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(Zv||Qv)&&(Qv?$v=self.location.href:document.currentScript&&($v=document.currentScript.src),$v=0!==$v.indexOf("blob:")?$v.substr(0,$v.lastIndexOf("/")+1):"",Xv=function(t){try{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText}catch(e){var n=Ig(t);if(n)return Dg(n);throw e}},Qv&&(Hv=function(t){try{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}catch(e){var n=Ig(t);if(n)return n;throw e}}));var eg=jv.print||console.log.bind(console),tg=jv.printErr||console.warn.bind(console);for(Gv in Wv)Wv.hasOwnProperty(Gv)&&(jv[Gv]=Wv[Gv]);Wv=null,jv.arguments&&jv.arguments,jv.thisProgram&&jv.thisProgram,jv.wasmBinary&&(ig=jv.wasmBinary);var ng,rg={Memory:function(e){return{buffer:new ArrayBuffer(65536*e.initial),grow:function(e){return Gg(e)}}},Table:function(e){var n=new Array(e.initial);return n.grow=function(e){1<=n.length&&Tg("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."),n.push(null)},n.set=function(e,t){n[e]=t},n.get=function(e){return n[e]},n},Module:function(e){return{}},Instance:function(e,t){var n,r,i,a,o,s="function"==typeof s?s:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");t=s.indexOf(e.charAt(c++))<<2|(i=s.indexOf(e.charAt(c++)))>>4,n=(15&i)<<4|(a=s.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(o=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==a&&(l+=String.fromCharCode(n)),64!==o&&(l+=String.fromCharCode(r)),c<e.length;);return l};return{exports:(n=Og,i=(r=ng).buffer,a=new Uint8Array(i),(o=function(e,t){var n,r;if("undefined"==typeof Buffer)for(n=s(t),r=0;r<n.length;r++)a[e+r]=n.charCodeAt(r);else for(n=Buffer.from(t,"base64"),r=0;r<n.length;r++)a[e+r]=n[r]})(1024,"/Td6WFo="),o(1041,"BAQECAgIEBAQICAgQEBA"),function(e,t,n){t.memory;var x=new e.Int8Array(n),g=new e.Int16Array(n),b=new e.Int32Array(n),M=new e.Uint8Array(n),_=new e.Uint16Array(n),w=new e.Uint32Array(n),y=(new e.Float32Array(n),new e.Float64Array(n),e.Math.imul),r=(e.Math.fround,e.Math.abs,e.Math.clz32,e.Math.min,e.Math.max,e.Math.floor,e.Math.ceil,e.Math.sqrt,t.abort),a=(e.NaN,e.Infinity,t.emscripten_memcpy_big),i=t.emscripten_resize_heap,h=6296128,A=0;function S(e,t,n){var r,i=0;if(8192<=n>>>0)a(0|e,0|t,0|n);else{r=e+n|0;e:if(3&(e^t))if(r>>>0<4)n=e;else if((i=r-4|0)>>>0<e>>>0)n=e;else for(n=e;x[0|n]=M[0|t],x[n+1|0]=M[t+1|0],x[n+2|0]=M[t+2|0],x[n+3|0]=M[t+3|0],t=t+4|0,(n=n+4|0)>>>0<=i>>>0;);else{t:if((0|n)<1)n=e;else if(3&e)for(n=e;;){if(x[0|n]=M[0|t],t=t+1|0,r>>>0<=(n=n+1|0)>>>0)break t;if(!(3&n))break}else n=e;if(!((e=-4&r)>>>0<64||(i=e+-64|0)>>>0<n>>>0))for(;b[n>>2]=b[t>>2],b[n+4>>2]=b[t+4>>2],b[n+8>>2]=b[t+8>>2],b[n+12>>2]=b[t+12>>2],b[n+16>>2]=b[t+16>>2],b[n+20>>2]=b[t+20>>2],b[n+24>>2]=b[t+24>>2],b[n+28>>2]=b[t+28>>2],b[n+32>>2]=b[t+32>>2],b[n+36>>2]=b[t+36>>2],b[n+40>>2]=b[t+40>>2],b[n+44>>2]=b[t+44>>2],b[n+48>>2]=b[t+48>>2],b[n+52>>2]=b[t+52>>2],b[n+56>>2]=b[t+56>>2],b[n+60>>2]=b[t+60>>2],t=t- -64|0,(n=n- -64|0)>>>0<=i>>>0;);if(e>>>0<=n>>>0)break e;for(;b[n>>2]=b[t>>2],t=t+4|0,(n=n+4|0)>>>0<e>>>0;);}if(n>>>0<r>>>0)for(;x[0|n]=M[0|t],t=t+1|0,(0|r)!=(0|(n=n+1|0)););}}function T(e,t,n){if(n^=-1,t)for(;n=b[1056+((M[0|e]^255&n)<<2)>>2]^n>>>8,e=e+1|0,t=t+-1|0;);return-1^n}function o(e){var t=0;e&&(t=b[e+1200>>2],b[t+60>>2]&&E(b[t+24>>2]),E(t),E(e))}function p(e){var t;return(0|(e=(t=b[263312])+(e+3&-4)|0))<=-1||!(e>>>0<=(n.byteLength/65536|0)<<16>>>0||i(0|e))?(b[263185]=48,-1):(b[263312]=e,t)}function E(e){var t=0,n=0,r=0,i=0,a=0,o=0,s=0;e:if(e){a=(r=e+-8|0)+(e=-8&(n=b[e+-4>>2]))|0;t:if(!(1&n)){if(!(3&n))break e;if((r=r-(n=b[r>>2])|0)>>>0<w[263190])break e;if(e=e+n|0,b[263191]==(0|r)){if(3==(3&(n=b[a+4>>2])))return b[263188]=e,b[a+4>>2]=-2&n,b[r+4>>2]=1|e,b[e+r>>2]=e,0}else{if(n>>>0<=255){if(i=b[r+8>>2],n=n>>>3|0,(0|(t=b[r+12>>2]))==(0|i)){b[263186]=b[263186]&m(n);break t}b[i+12>>2]=t,b[t+8>>2]=i;break t}if(s=b[r+24>>2],(0|r)==(0|(n=b[r+12>>2])))if((t=b[(i=r+20|0)>>2])||(t=b[(i=r+16|0)>>2])){for(;o=i,(t=b[(i=(n=t)+20|0)>>2])||(i=n+16|0,t=b[n+16>>2]););b[o>>2]=0}else n=0;else t=b[r+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(!s)break t;i=b[r+28>>2];n:{if(b[(t=1053048+(i<<2)|0)>>2]==(0|r)){if(b[t>>2]=n)break n;b[263187]=b[263187]&m(i);break t}if(!(b[s+(b[s+16>>2]==(0|r)?16:20)>>2]=n))break t}if(b[n+24>>2]=s,(t=b[r+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),!(t=b[r+20>>2]))break t;b[n+20>>2]=t,b[t+24>>2]=n}}if(!(a>>>0<=r>>>0)&&1&(n=b[a+4>>2])){t:{if(!(2&n)){if(b[263192]==(0|a)){if(b[263192]=r,e=b[263189]+e|0,b[263189]=e,b[r+4>>2]=1|e,b[263191]!=(0|r))break e;return b[263188]=0,b[263191]=0}if(b[263191]==(0|a))return b[263191]=r,e=b[263188]+e|0,b[263188]=e,b[r+4>>2]=1|e,b[e+r>>2]=e,0;e=(-8&n)+e|0;n:if(n>>>0<=255){if(n=n>>>3|0,(0|(t=b[a+8>>2]))==(0|(i=b[a+12>>2]))){b[263186]=b[263186]&m(n);break n}b[t+12>>2]=i,b[i+8>>2]=t}else{if(s=b[a+24>>2],(0|a)==(0|(n=b[a+12>>2])))if((t=b[(i=a+20|0)>>2])||(t=b[(i=a+16|0)>>2])){for(;o=i,(t=b[(i=(n=t)+20|0)>>2])||(i=n+16|0,t=b[n+16>>2]););b[o>>2]=0}else n=0;else t=b[a+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(s){i=b[a+28>>2];r:{if(b[(t=1053048+(i<<2)|0)>>2]==(0|a)){if(b[t>>2]=n)break r;b[263187]=b[263187]&m(i);break n}if(!(b[s+(b[s+16>>2]==(0|a)?16:20)>>2]=n))break n}b[n+24>>2]=s,(t=b[a+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),(t=b[a+20>>2])&&(b[n+20>>2]=t,b[t+24>>2]=n)}}if(b[r+4>>2]=1|e,b[e+r>>2]=e,b[263191]!=(0|r))break t;return b[263188]=e,0}b[a+4>>2]=-2&n,b[r+4>>2]=1|e,b[e+r>>2]=e}if(e>>>0<=255)return n=1052784+((e=e>>>3|0)<<3)|0,e=(t=b[263186])&(e=1<<e)?b[n+8>>2]:(b[263186]=e|t,n),b[n+8>>2]=r,b[e+12>>2]=r,b[r+12>>2]=n,b[r+8>>2]=e,0;b[r+16>>2]=0,t=b[r+20>>2]=0,(i=e>>>8|0)&&(t=31,16777215<e>>>0||(t=i,t<<=i=i+1048320>>>16&8,t=28+((t=((t<<=s=t+520192>>>16&4)<<(o=t+245760>>>16&2)>>>15|0)-(o|i|s)|0)<<1|e>>>t+21&1)|0)),o=1053048+((b[(n=r)+28>>2]=t)<<2)|0;t:{n:{if((i=b[263187])&(n=1<<t)){for(i=e<<(31==(0|t)?0:25-(t>>>1|0)|0),n=b[o>>2];;){if((-8&b[(t=n)+4>>2])==(0|e))break n;if(n=i>>>29|0,i<<=1,!(n=b[16+(o=t+(4&n)|0)>>2]))break}b[o+16>>2]=r,b[r+24>>2]=t}else b[263187]=n|i,b[o>>2]=r,b[r+24>>2]=o;b[r+12>>2]=r,b[r+8>>2]=r;break t}e=b[t+8>>2],b[e+12>>2]=r,b[t+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=t,b[r+8>>2]=e}if(e=b[263194]+-1|0,!(b[263194]=e)){for(r=1053200;r=(e=b[r>>2])+8|0,e;);b[263194]=-1}}}}function C(e,t){var n=0;if(t&&(x[(n=e+t|0)-1|0]=0,!(t>>>(x[0|e]=0)<3||(x[n+-2|0]=0,x[e+1|0]=0,x[n+-3|0]=0,t>>>(x[e+2|0]=0)<7||(x[n+-4|0]=0,t>>>(x[e+3|0]=0)<9||(b[(e=(n=0-e&3)+e|0)>>2]=0,(n=t-n&-4)>>>(b[(t=n+e|0)-4>>2]=0)<9||(b[e+8>>2]=0,b[e+4>>2]=0,b[t+-8>>2]=0,n>>>(b[t+-12>>2]=0)<25||(b[e+24>>2]=0,b[e+20>>2]=0,b[e+16>>2]=0,b[e+12>>2]=0,b[t+-16>>2]=0,b[t+-20>>2]=0,b[t+-24>>2]=0,b[t+-28>>2]=0,(t=(t=n)-(n=4&e|24)|0)>>>0<32))))))))for(e=e+n|0;b[e+24>>2]=0,b[e+28>>2]=0,b[e+16>>2]=0,b[e+20>>2]=0,b[e+8>>2]=0,b[e+12>>2]=0,b[e>>2]=0,e=e+32|(b[e+4>>2]=0),31<(t=t+-32|0)>>>0;);}function P(e){var t,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0;h=t=h-16|0;e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{if(e>>>0<=244){if(3&(n=(o=b[263186])>>>(e=(s=e>>>0<11?16:e+11&-8)>>>3|0)|0)){e=(n=b[1052792+(a=(r=e+(1&(-1^n))|0)<<3)>>2])+8|0,(0|(i=b[n+8>>2]))!=(0|(a=a+1052784|0))?(b[i+12>>2]=a,b[a+8>>2]=i):b[263186]=m(r)&o,r<<=3,b[n+4>>2]=3|r,b[4+(n=n+r|0)>>2]=1|b[n+4>>2];break e}if(s>>>0<=(c=b[263188])>>>0)break u;if(n){r=n=(e=(0-(e=(0-(r=2<<e)|r)&n<<e)&e)-1|0)>>>12&16,r|=n=(e=e>>>n|0)>>>5&8,r|=n=(e=e>>>n|0)>>>2&4,n=b[1052792+(i=(r=((r|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)|0)<<3)>>2],(0|(e=b[n+8>>2]))!=(0|(i=i+1052784|0))?(b[e+12>>2]=i,b[i+8>>2]=e):(o=m(r)&o,b[263186]=o),e=n+8|0,b[n+4>>2]=3|s,a=(r<<=3)-s|0,b[4+(l=n+s|0)>>2]=1|a,b[n+r>>2]=a,c&&(n=1052784+((r=c>>>3|0)<<3)|0,i=b[263191],r=(r=1<<r)&o?b[n+8>>2]:(b[263186]=r|o,n),b[n+8>>2]=i,b[r+12>>2]=i,b[i+12>>2]=n,b[i+8>>2]=r),b[263191]=l,b[263188]=a;break e}if(!(d=b[263187]))break u;for(r=n=(e=(d&0-d)-1|0)>>>12&16,r|=n=(e=e>>>n|0)>>>5&8,r|=n=(e=e>>>n|0)>>>2&4,n=b[1053048+(((r|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2],i=(-8&b[n+4>>2])-s|0,r=n;e=(e=b[r+16>>2])||b[r+20>>2];)i=(r=(a=(-8&b[e+4>>2])-s|0)>>>0<i>>>0)?a:i,n=r?e:n,r=e;if(u=b[n+24>>2],(0|(a=b[n+12>>2]))!=(0|n)){e=b[n+8>>2],b[e+12>>2]=a,b[a+8>>2]=e;break t}if(!(e=b[(r=n+20|0)>>2])){if(!(e=b[n+16>>2]))break c;r=n+16|0}for(;l=r,(e=b[(r=(a=e)+20|0)>>2])||(r=a+16|0,e=b[a+16>>2]););b[l>>2]=0;break t}if(s=-1,!(4294967231<e>>>0)&&(s=-8&(n=e+11|0),c=b[263187])){r=0-s|0,(n=n>>>8|(o=0))&&(o=31,16777215<s>>>0||(o=28+((e=((o=(n<<=i=n+1048320>>>16&8)<<(e=n+520192>>>16&4))<<(n=o+245760>>>16&2)>>>15|0)-(n|e|i)|0)<<1|s>>>e+21&1)|0));d:{h:{if(i=b[1053048+(o<<2)>>2])for(n=s<<(31==(0|o)?0:25-(o>>>1|0)|0),e=0;;){if(!(r>>>0<=(l=(-8&b[i+4>>2])-s|0)>>>0||(a=i,r=l))){r=0,e=i;break h}if(l=b[i+20>>2],i=b[16+((n>>>29&4)+i|0)>>2],e=l&&(0|l)!=(0|i)?l:e,n<<=0!=(0|i),!i)break}else e=0;if(!(e|a)){if(!(e=(0-(e=2<<o)|e)&c))break u;i=n=(e=(e&0-e)-1|0)>>>12&16,i|=n=(e=e>>>n|0)>>>5&8,i|=n=(e=e>>>n|0)>>>2&4,e=b[1053048+(((i|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2]}if(!e)break d}for(;r=(n=(i=(-8&b[e+4>>2])-s|0)>>>0<r>>>0)?i:r,a=n?e:a,e=(n=b[e+16>>2])||b[e+20>>2];);}if(!(!a|r>>>0>=b[263188]-s>>>0)){if(l=b[a+24>>2],(0|a)!=(0|(n=b[a+12>>2]))){e=b[a+8>>2],b[e+12>>2]=n,b[n+8>>2]=e;break n}if(!(e=b[(i=a+20|0)>>2])){if(!(e=b[a+16>>2]))break l;i=a+16|0}for(;o=i,(e=b[(i=(n=e)+20|0)>>2])||(i=n+16|0,e=b[n+16>>2]););b[o>>2]=0;break n}}}if(s>>>0<=(n=b[263188])>>>0){e=b[263191],16<=(r=n-s|0)>>>0?(b[263188]=r,i=e+s|0,b[263191]=i,b[i+4>>2]=1|r,b[e+n>>2]=r,b[e+4>>2]=3|s):(b[263191]=0,b[263188]=0,b[e+4>>2]=3|n,b[4+(n=e+n|0)>>2]=1|b[n+4>>2]),e=e+8|0;break e}if(s>>>0<(i=b[263189])>>>0){n=i-s|0,b[263189]=n,r=(e=b[263192])+s|0,b[263192]=r,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}if((r=(o=(r=a=s+47|(e=0))+(n=b[263304]?b[263306]:(b[263307]=-1,b[263308]=-1,b[263305]=4096,b[263306]=4096,b[263304]=12+t&-16^1431655768,b[263309]=0,b[263297]=0,4096))|0)&(l=0-n|0))>>>0<=s>>>0)break e;if((n=b[263296])&&(u=(c=b[263294])+r|0)>>>0<=c>>>0|n>>>0<u>>>0)break e;if(4&M[1053188])break a;u:{d:{if(n=b[263192])for(e=1053192;;){if((c=b[e>>2])+b[e+4>>2]>>>0>n>>>0&&c>>>0<=n>>>0)break d;if(!(e=b[e+8>>2]))break}if(-1==(0|(n=p(0))))break o;if(o=r,(i=(e=b[263305])+-1|0)&n&&(o=(r-n|0)+(n+i&0-e)|0),o>>>0<=s>>>0|2147483646<o>>>0)break o;if((e=b[263296])&&(l=(i=b[263294])+o|0)>>>0<=i>>>0|e>>>0<l>>>0)break o;if((0|n)!=(0|(e=p(o))))break u;break i}if(2147483646<(o=l&o-i)>>>0)break o;if((0|(n=p(o)))==(b[e>>2]+b[e+4>>2]|0))break s;e=n}if(!(s+48>>>0<=o>>>0|2147483646<o>>>0|-1==(0|(n=e)))){if(2147483646<(e=(e=b[263306])+(a-o|0)&0-e)>>>0)break i;if(-1!=(0|p(e))){o=e+o|0;break i}p(0-o|0);break o}if(-1!=(0|n))break i;break o}a=0;break t}n=0;break n}if(-1!=(0|n))break i}b[263297]=4|b[263297]}if(2147483646<r>>>0)break r;if(n=p(r),(e=p(0))>>>0<=n>>>0|-1==(0|n)|-1==(0|e))break r;if((o=e-n|0)>>>0<=s+40>>>0)break r}e=b[263294]+o|0,(b[263294]=e)>>>0>w[263295]&&(b[263295]=e);i:{a:{o:{if(r=b[263192]){for(e=1053192;;){if(((i=b[e>>2])+(a=b[e+4>>2])|0)==(0|n))break o;if(!(e=b[e+8>>2]))break}break a}for((e=b[263190])>>>0<=n>>>0&&e||(b[263190]=n),e=0,b[263299]=o,b[263298]=n,b[263194]=-1,b[263195]=b[263304],b[263301]=0;i=1052784+(r=e<<3)|0,b[r+1052792>>2]=i,b[r+1052796>>2]=i,32!=(0|(e=e+1|0)););i=(e=o+-40|0)-(r=n+8&7?-8-n&7:0)|0,b[263189]=i,r=n+r|0,b[263192]=r,b[r+4>>2]=1|i,b[4+(e+n|0)>>2]=40,b[263193]=b[263308];break i}if(!(8&M[e+12|0]|n>>>0<=r>>>0|r>>>0<i>>>0)){b[e+4>>2]=a+o,n=(e=r+8&7?-8-r&7:0)+r|0,b[263192]=n,e=(i=b[263189]+o|0)-e|0,b[263189]=e,b[n+4>>2]=1|e,b[4+(r+i|0)>>2]=40,b[263193]=b[263308];break i}}n>>>0<(a=b[263190])>>>0&&(b[263190]=n,a=0),i=n+o|0,e=1053192;a:{o:{s:{l:{c:{u:{for(;(0|i)!=b[e>>2];)if(!(e=b[e+8>>2]))break u;if(!(8&M[e+12|0]))break c}for(e=1053192;;){if((i=b[e>>2])>>>0<=r>>>0&&r>>>0<(a=i+b[e+4>>2]|0)>>>0)break l;e=b[e+8>>2]}}if(b[e>>2]=n,b[e+4>>2]=b[e+4>>2]+o,b[4+(u=(n+8&7?-8-n&7:0)+n|0)>>2]=3|s,e=((n=i+(i+8&7?-8-i&7:0)|0)-u|0)-s|0,l=s+u|0,(0|n)==(0|r)){b[263192]=l,e=b[263189]+e|0,b[263189]=e,b[l+4>>2]=1|e;break o}if(b[263191]==(0|n)){b[263191]=l,e=b[263188]+e|0,b[263188]=e,b[l+4>>2]=1|e,b[e+l>>2]=e;break o}if(1==(3&(r=b[n+4>>2]))){d=-8&r;c:if(r>>>0<=255){if(a=r>>>3|0,r=b[n+8>>2],(0|(i=b[n+12>>2]))==(0|r)){b[263186]=b[263186]&m(a);break c}b[r+12>>2]=i,b[i+8>>2]=r}else{if(c=b[n+24>>2],(0|(o=b[n+12>>2]))==(0|n))if((s=b[(i=n+20|0)>>2])||(s=b[(i=n+16|0)>>2])){for(;r=i,(s=b[(i=(o=s)+20|0)>>2])||(i=o+16|0,s=b[o+16>>2]););b[r>>2]=0}else o=0;else r=b[n+8>>2],b[r+12>>2]=o,b[o+8>>2]=r;if(c){r=b[n+28>>2];u:{if(b[(i=1053048+(r<<2)|0)>>2]==(0|n)){if(b[i>>2]=o)break u;b[263187]=b[263187]&m(r);break c}if(!(b[c+(b[c+16>>2]==(0|n)?16:20)>>2]=o))break c}b[o+24>>2]=c,(r=b[n+16>>2])&&(b[o+16>>2]=r,b[r+24>>2]=o),(r=b[n+20>>2])&&(b[o+20>>2]=r,b[r+24>>2]=o)}}n=n+d|0,e=e+d|0}if(b[n+4>>2]=-2&b[n+4>>2],b[l+4>>2]=1|e,(b[e+l>>2]=e)>>>0<=255){e=1052784+((n=e>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|r,e),b[e+8>>2]=l,b[n+12>>2]=l,b[l+12>>2]=e,b[l+8>>2]=n;break o}if((i=e>>>8|(n=0))&&(n=31,16777215<e>>>0||(n=28+((n=((s=(i<<=a=i+1048320>>>16&8)<<(n=i+520192>>>16&4))<<(i=s+245760>>>16&2)>>>15|0)-(i|n|a)|0)<<1|e>>>n+21&1)|0)),b[(r=l)+28>>2]=n,b[l+16>>2]=0,r=1053048+(n<<2)|(b[l+20>>2]=0),(i=b[263187])&(a=1<<n)){for(i=e<<(31==(0|n)?0:25-(n>>>1|0)|0),n=b[r>>2];;){if((-8&b[(r=n)+4>>2])==(0|e))break s;if(n=i>>>29|0,i<<=1,!(n=b[16+(a=(4&n)+r|0)>>2]))break}b[a+16>>2]=l}else b[263187]=i|a,b[r>>2]=l;b[l+24>>2]=r,b[l+12>>2]=l,b[l+8>>2]=l;break o}for(l=(e=o+-40|0)-(i=n+8&7?-8-n&7:0)|0,b[263189]=l,i=n+i|0,b[263192]=i,b[i+4>>2]=1|l,b[4+(e+n|0)>>2]=40,b[263193]=b[263308],b[(i=(e=(a+(a+-39&7?39-a&7:0)|0)-47|0)>>>0<r+16>>>0?r:e)+4>>2]=27,e=b[263301],b[i+16>>2]=b[263300],b[i+20>>2]=e,e=b[263299],b[i+8>>2]=b[263298],b[i+12>>2]=e,b[263300]=i+8,b[263299]=o,b[263298]=n,e=i+24|(b[263301]=0);b[e+4>>2]=7,n=e+8|0,e=e+4|0,n>>>0<a>>>0;);if((0|r)==(0|i))break i;if(b[i+4>>2]=-2&b[i+4>>2],a=i-r|0,b[r+4>>2]=1|a,(b[i>>2]=a)>>>0<=255){e=1052784+((n=a>>>3|0)<<3)|0,n=(i=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|i,e),b[e+8>>2]=r,b[n+12>>2]=r,b[r+12>>2]=e,b[r+8>>2]=n;break i}if(b[r+16>>2]=0,e=b[r+20>>2]=0,(i=a>>>8|0)&&(e=31,16777215<a>>>0||(e=28+((e=((l=(i<<=o=i+1048320>>>16&8)<<(e=i+520192>>>16&4))<<(i=l+245760>>>16&2)>>>15|0)-(i|e|o)|0)<<1|a>>>e+21&1)|0)),n=1053048+((b[(n=r)+28>>2]=e)<<2)|0,(i=b[263187])&(o=1<<e)){for(e=a<<(31==(0|e)?0:25-(e>>>1|0)|0),n=b[n>>2];;){if((0|a)==(-8&b[(i=n)+4>>2]))break a;if(n=e>>>29|0,e<<=1,!(n=b[16+(o=i+(4&n)|0)>>2]))break}b[o+16>>2]=r,b[r+24>>2]=i}else b[263187]=i|o,b[n>>2]=r,b[r+24>>2]=n;b[r+12>>2]=r,b[r+8>>2]=r;break i}e=b[r+8>>2],b[e+12>>2]=l,b[r+8>>2]=l,b[l+24>>2]=0,b[l+12>>2]=r,b[l+8>>2]=e}e=u+8|0;break e}e=b[i+8>>2],b[e+12>>2]=r,b[i+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=i,b[r+8>>2]=e}if(!((e=b[263189])>>>0<=s>>>0)){n=e-s|0,b[263189]=n,r=(e=b[263192])+s|0,b[263192]=r,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}}b[263185]=48,e=0;break e}n:if(l){e=b[a+28>>2];r:{if(b[(i=1053048+(e<<2)|0)>>2]==(0|a)){if(b[i>>2]=n)break r;c=m(e)&c,b[263187]=c;break n}if(!(b[l+(b[l+16>>2]==(0|a)?16:20)>>2]=n))break n}b[n+24>>2]=l,(e=b[a+16>>2])&&(b[n+16>>2]=e,b[e+24>>2]=n),(e=b[a+20>>2])&&(b[n+20>>2]=e,b[e+24>>2]=n)}n:if(r>>>0<=15)e=r+s|0,b[a+4>>2]=3|e,b[4+(e=e+a|0)>>2]=1|b[e+4>>2];else if(b[a+4>>2]=3|s,b[4+(i=a+s|0)>>2]=1|r,(b[r+i>>2]=r)>>>0<=255)e=1052784+((n=r>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|r,e),b[e+8>>2]=i,b[n+12>>2]=i,b[i+12>>2]=e,b[i+8>>2]=n;else{(s=r>>>8|(e=0))&&(e=31,16777215<r>>>0||(e=28+((e=((l=(s<<=o=s+1048320>>>16&8)<<(e=s+520192>>>16&4))<<(s=l+245760>>>16&2)>>>15|0)-(s|e|o)|0)<<1|r>>>e+21&1)|0)),b[(n=i)+28>>2]=e,b[i+16>>2]=0,n=1053048+(e<<2)|(b[i+20>>2]=0);r:{if((s=1<<e)&c){for(e=r<<(31==(0|e)?0:25-(e>>>1|0)|0),s=b[n>>2];;){if((-8&b[(n=s)+4>>2])==(0|r))break r;if(s=e>>>29|0,e<<=1,!(s=b[16+(o=(4&s)+n|0)>>2]))break}b[o+16>>2]=i}else b[263187]=s|c,b[n>>2]=i;b[i+24>>2]=n,b[i+12>>2]=i,b[i+8>>2]=i;break n}e=b[n+8>>2],b[e+12>>2]=i,b[n+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=n,b[i+8>>2]=e}e=a+8|0;break e}t:if(u){e=b[n+28>>2];n:{if(b[(r=1053048+(e<<2)|0)>>2]==(0|n)){if(b[r>>2]=a)break n;b[263187]=m(e)&d;break t}if(!(b[u+(b[u+16>>2]==(0|n)?16:20)>>2]=a))break t}b[a+24>>2]=u,(e=b[n+16>>2])&&(b[a+16>>2]=e,b[e+24>>2]=a),(e=b[n+20>>2])&&(b[a+20>>2]=e,b[e+24>>2]=a)}i>>>0<=15?(e=i+s|0,b[n+4>>2]=3|e,b[4+(e=e+n|0)>>2]=1|b[e+4>>2]):(b[n+4>>2]=3|s,b[4+(s=n+s|0)>>2]=1|i,b[i+s>>2]=i,c&&(e=1052784+((r=c>>>3|0)<<3)|0,a=b[263191],r=(r=1<<r)&o?b[e+8>>2]:(b[263186]=r|o,e),b[e+8>>2]=a,b[r+12>>2]=a,b[a+12>>2]=e,b[a+8>>2]=r),b[263191]=s,b[263188]=i),e=n+8|0}return h=16+t|0,e}function f(e){var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0;if(!((n=b[e+40>>2])>>>0<=(c=b[e+32>>2])>>>0)&&(t=b[e+104>>2])&&(a=b[e+84>>2],!(w[e+36>>2]<=a>>>0|w[e+48>>2]<=a>>>0))){if(o=(n=n-c|0)>>>0<t>>>0?n:t,b[e+104>>2]=t-o,t=(-1^a)+c|0,t=c>>>0<=a>>>0?b[e+44>>2]+t|0:t,a=b[e+24>>2],n=M[t+a|0],b[e+32>>2]=c+1,x[a+c|0]=n,r=o+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,o=b[e+24>>2],a=M[t+o|0],n=b[e+32>>2],b[e+32>>2]=n+1,x[n+o|0]=a,r=r+-1|0;);c=b[e+32>>2],w[e+36>>2]>=c>>>0||(b[e+36>>2]=c)}e:{t:if(!(c>>>0>=w[e+40>>2]))for(p=e+1756|0,f=e+2784|0,m=e+84|0;;){if((a=b[e+16>>2])>>>0>w[e+20>>2])break t;o=u=(((d=b[e+100>>2])<<5)+e|0)+((s=b[e+116>>2]&c)<<1)|0,16777216<=(i=b[e>>2])>>>0?r=b[e+4>>2]:(i<<=8,b[e>>2]=i,n=a+1|0,b[e+16>>2]=n,r=M[b[e+12>>2]+a|0]|b[e+4>>2]<<8,b[e+4>>2]=r,a=n),n=_[o+120>>1];n:if(r>>>0<(t=y(n,i>>>11|0))>>>0){b[e>>2]=t,g[o+120>>1]=n+(2048-n>>>5|0),i=c+-1|0,i=c?i:b[e+44>>2]+i|0,s=b[e+108>>2],n=(b[e+112>>2]&c)<<s,u=0,(o=b[e+36>>2])&&(u=M[b[e+24>>2]+i|0]),h=n+(u>>>8-s|0)|0,i=1;r:{if(d>>>0<=6)for(;;)if(o=3812+((i<<=1)+(y(h,1536)+e|0)|0)|0,16777215<t>>>0?n=t:(n=t<<8,b[e>>2]=n,t=a+1|0,b[e+16>>2]=t,r=M[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r,a=t),s=_[o>>1],(t=y(s,n>>>11|0))>>>0<=r>>>0?(r=r-t|0,b[e+4>>2]=r,t=n-t|0,b[e>>2]=t,g[o>>1]=s-(s>>>5|0),i|=1):(b[e>>2]=t,g[o>>1]=s+(2048-s>>>5|0)),!(i>>>0<256))break r;for(i=(-1^(n=b[e+84>>2]))+c|0,i=c>>>0<=n>>>0?b[e+44>>2]+i|0:i,o=o?M[b[e+24>>2]+i|0]:0,i=1,l=256;d=l&(o<<=1),s=3812+((y(h,1536)+e|0)+((d+l|0)+i<<1)|0)|0,16777215<t>>>0?u=t:(u=t<<8,b[e>>2]=u,n=a+1|0,b[e+16>>2]=n,r=M[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r,a=n),s=_[(v=n=s)>>1],n=(t=y(s,u>>>11|0))>>>0<=r>>>0?(r=r-t|0,b[e+4>>2]=r,t=u-t|0,b[e>>2]=t,u=1,s-(s>>>5|(l=0))|0):(b[e>>2]=t,s+(2048-s>>>5|(u=0))|0),g[v>>1]=n,l^=d,(i=i<<1|u)>>>0<256;);}if(b[e+32>>2]=c+1,x[b[e+24>>2]+c|0]=i,c=b[e+32>>2],w[e+36>>2]<c>>>0&&(b[e+36>>2]=c),(n=b[e+100>>2])>>>0<=3){b[e+100>>2]=0;break n}if(n>>>0<=9){b[e+100>>2]=n+-3;break n}b[e+100>>2]=n+-6}else{r=r-t|0,b[e+4>>2]=r,t=i-t|0,b[e>>2]=t,g[o+120>>1]=n-(n>>>5|0),o=h=(d<<1)+e|0,16777215<t>>>0?n=a:(t<<=8,b[e>>2]=t,n=a+1|0,b[e+16>>2]=n,r=M[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r),d=_[o+504>>1];r:if((a=y(d,t>>>11|0))>>>0<=r>>>0){r=r-a|0,b[e+4>>2]=r,t=t-a|0,b[e>>2]=t,g[o+504>>1]=d-(d>>>5|0),16777215<t>>>0?o=n:(t<<=8,b[e>>2]=t,o=n+1|0,b[e+16>>2]=o,r=M[b[e+12>>2]+n|0]|r<<8,b[e+4>>2]=r),n=_[h+528>>1];i:{if(r>>>0<(i=y(n,t>>>11|0))>>>0){if(b[e>>2]=i,g[h+528>>1]=n+(2048-n>>>5|0),i>>>0<=16777215&&(i<<=8,b[e>>2]=i,b[e+16>>2]=o+1,r=M[b[e+12>>2]+o|0]|r<<8,b[e+4>>2]=r),t=_[u+600>>1],(n=y(t,i>>>11|0))>>>0<=r>>>0){b[e+4>>2]=r-n,b[e>>2]=i-n,g[u+600>>1]=t-(t>>>5|0);break i}b[e>>2]=n,g[u+600>>1]=t+(2048-t>>>5|0),b[e+104>>2]=1,b[e+100>>2]=w[e+100>>2]<7?9:11;break r}r=r-i|0,b[e+4>>2]=r,t=t-i|0,b[e>>2]=t,g[h+528>>1]=n-(n>>>5|0),16777215<t>>>0?n=o:(t<<=8,b[e>>2]=t,n=o+1|0,b[e+16>>2]=n,r=M[b[e+12>>2]+o|0]|r<<8,b[e+4>>2]=r),o=_[h+552>>1],r>>>0<(a=y(o,t>>>11|0))>>>0?(b[e>>2]=a,g[h+552>>1]=o+(2048-o>>>5|0),t=b[e+88>>2]):(r=r-a|0,b[e+4>>2]=r,t=t-a|0,b[e>>2]=t,g[h+552>>1]=o-(o>>>5|0),t>>>0<=16777215&&(t<<=8,b[e>>2]=t,b[e+16>>2]=n+1,r=M[b[e+12>>2]+n|0]|r<<8,b[e+4>>2]=r),a=_[h+576>>1],r>>>0<(n=y(a,t>>>11|0))>>>0?(b[e>>2]=n,g[h+576>>1]=a+(2048-a>>>5|0),t=b[e+92>>2]):(b[e+4>>2]=r-n,b[e>>2]=t-n,g[h+576>>1]=a-(a>>>5|0),t=b[e+96>>2],b[e+96>>2]=b[e+92>>2]),b[e+92>>2]=b[e+88>>2]),b[e+88>>2]=b[e+84>>2],b[e+84>>2]=t}b[e+100>>2]=w[e+100>>2]<7?8:11,R(e,f,s)}else{for(b[e>>2]=a,g[o+504>>1]=d+(2048-d>>>5|0),b[e+96>>2]=b[e+92>>2],n=b[e+88>>2],b[e+88>>2]=b[e+84>>2],b[e+92>>2]=n,b[e+100>>2]=w[e+100>>2]<7?7:10,R(e,p,s),a=(n=b[e+104>>2])>>>0<6?n+-2|0:3,t=b[e>>2],r=1;o=(r<<=1)+((a<<7)+e|0)|0,16777216<=t>>>0?i=b[e+4>>2]:(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=i),s=_[o+984>>1],(n=y(s,t>>>11|0))>>>0<=i>>>0?(i=i-n|0,b[e+4>>2]=i,t=t-n|0,b[e>>2]=t,g[o+984>>1]=s-(s>>>5|0),r|=1):(b[e>>2]=n,g[o+984>>1]=s+(2048-s>>>5|0),t=n),r>>>0<64;);if((a=r+-64|0)>>>0<=3)b[e+84>>2]=a;else if(l=1&a|2,b[e+84>>2]=l,n=a>>>1|0,a>>>0<=13)for(u=l<<(o=n+-1|0),a=1538+((((b[e+84>>2]=u)<<(l=1))+m|0)+(0-r<<1)|0)|0,r=0;s=a+(l<<=1)|0,16777215<t>>>0?n=t:(n=t<<8,b[e>>2]=n,t=b[e+16>>2],b[e+16>>2]=t+1,i=M[t+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),d=_[s>>1],i>>>0<(t=y(d,n>>>11|0))>>>0?(b[e>>2]=t,g[s>>1]=d+(2048-d>>>5|0)):(i=i-t|0,b[e+4>>2]=i,t=n-t|0,b[e>>2]=t,g[s>>1]=d-(d>>>5|0),u=(1<<r)+u|0,b[e+84>>2]=u,l|=1),(r=r+1|0)>>>0<o>>>0;);else{for(a=n+-5|0;16777215<t>>>0?r=t:(r=t<<8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),t=r>>>1|0,l=(n=(o=i-(b[e>>2]=t)|0)>>31)+(l<<1|1)|0,b[e+84>>2]=l,i=o+(t&n)|0,b[e+4>>2]=i,a=a+-1|0;);l<<=4,b[e+84>>2]=l,r>>>0<=33554431&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),a=_[(n=e)+1726>>1],o=1724+(n+(a=(t=i>>>0<(r=y(a,t>>>11|0))>>>0?(b[e>>2]=r,g[e+1726>>1]=a+(2048-a>>>5|0),2):(i=i-r|0,b[e+4>>2]=i,r=t-r|0,b[e>>2]=r,l|=1,b[e+84>>2]=l,g[e+1726>>1]=a-(a>>>5|0),3))<<1)|0)|0,r>>>0<=16777215&&(r<<=8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),n=_[o>>1],(t=y(n,r>>>11|0))>>>0<=i>>>0?(i=i-t|0,b[e+4>>2]=i,t=r-t|0,b[e>>2]=t,g[o>>1]=n-(n>>>5|0),l=l+2|0,b[e+84>>2]=l,a|=1):(b[e>>2]=t,g[o>>1]=n+(2048-n>>>5|0)),o=1724+((a<<=1)+e|0)|0,t>>>0<=16777215&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),n=_[o>>1],(r=y(n,t>>>11|0))>>>0<=i>>>0?(i=i-r|0,b[e+4>>2]=i,r=t-r|0,b[e>>2]=r,g[o>>1]=n-(n>>>5|0),l=l+4|0,b[e+84>>2]=l,a|=1):(b[e>>2]=r,g[o>>1]=n+(2048-n>>>5|0)),r>>>0<=16777215&&(r<<=8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=M[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),a=_[(n=1724+((a<<1)+e|0)|0)>>1],(t=y(a,r>>>11|0))>>>0<=i>>>0?(b[e+4>>2]=i-t,b[e>>2]=r-t,g[n>>1]=a-(a>>>5|0),b[e+84>>2]=l+8):(b[e>>2]=t,g[n>>1]=a+(2048-a>>>5|0))}}if(t=0,a=b[e+84>>2],w[e+36>>2]<=a>>>0|w[e+48>>2]<=a>>>0)break e;if(s=b[e+32>>2],o=(n=b[e+40>>2]-s|0)>>>0<(t=b[e+104>>2])>>>0?n:t,b[e+104>>2]=t-o,t=s+(-1^a)|0,t=s>>>0<=a>>>0?b[e+44>>2]+t|0:t,a=b[e+24>>2],n=M[t+a|0],b[e+32>>2]=s+1,x[a+s|0]=n,i=o+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,o=b[e+24>>2],a=M[t+o|0],n=b[e+32>>2],b[e+32>>2]=n+1,x[n+o|0]=a,i=i+-1|0;);c=b[e+32>>2],w[e+36>>2]>=c>>>0||(b[e+36>>2]=c)}if(!(c>>>0<w[e+40>>2]))break}t=1,16777215<(n=b[e>>2])>>>0||(b[e>>2]=n<<8,n=b[e+16>>2],b[e+16>>2]=n+1,b[e+4>>2]=M[n+b[e+12>>2]|0]|b[e+4>>2]<<8)}return t}function L(e,t,n){var r=0,i=0,a=0;e:if(n){for(;(0|(r=M[0|e]))==(0|(i=M[0|t]));)if(t=t+1|0,e=e+1|0,!(n=n+-1|0))break e;a=r-i|0}return a}function R(e,t,n){var r=0,i=0,a=0,o=0,s=0,l=0,c=0;for(16777216<=(o=b[e>>2])>>>0?a=b[e+4>>2]:(o<<=8,b[e>>2]=o,i=b[e+16>>2],b[e+16>>2]=i+1,a=M[i+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=a),i=_[t>>1],i=a>>>0<(r=y(i,o>>>11|0))>>>0?(b[e>>2]=r,g[t>>1]=i+(2048-i>>>5|0),c=4+((n<<4)+t|0)|0,l=2,8):(a=a-r|0,b[e+4>>2]=a,o=o-r|0,b[e>>2]=o,g[t>>1]=i-(i>>>5|0),o>>>0<=16777215&&(o<<=8,b[e>>2]=o,i=b[e+16>>2],b[e+16>>2]=i+1,a=M[i+b[e+12>>2]|0]|a<<8,b[e+4>>2]=a),i=_[t+2>>1],a>>>0<(r=y(i,o>>>11|0))>>>0?(b[e>>2]=r,g[t+2>>1]=i+(2048-i>>>5|0),c=260+((n<<4)+t|0)|0,l=10,8):(a=a-r|0,b[e+4>>2]=a,r=o-r|0,b[e>>2]=r,g[t+2>>1]=i-(i>>>5|0),c=t+516|0,l=18,256)),b[e+104>>2]=l,t=1;o=c+(t<<=1)|0,16777215<r>>>0?n=r:(n=r<<8,b[e>>2]=n,r=b[e+16>>2],b[e+16>>2]=r+1,a=M[r+b[e+12>>2]|0]|a<<8,b[e+4>>2]=a),s=_[o>>1],(r=y(s,n>>>11|0))>>>0<=a>>>0?(a=a-r|0,b[e+4>>2]=a,r=n-r|0,b[e>>2]=r,g[o>>1]=s-(s>>>5|0),t|=1):(b[e>>2]=r,g[o>>1]=(2048-s>>>5|0)+s),t>>>0<i>>>0;);b[e+104>>2]=(t-i|0)+l}function D(e){for(var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=e+28392|0,d=e+28388|0;;){t=b[e+64>>2];e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{d:{h:{p:{f:{if(n=b[132105],(r=b[132106])>>>0<=n>>>0){if(7==(0|t))break f;return 0}if(8<t>>>0)continue;switch(t-1|0){case 4:break l;case 3:break c;case 2:break u;case 1:break d;case 0:break h;case 6:break f;case 7:break a;case 5:break s;default:break p}}t=b[e+76>>2];break o}if(a=1,b[132105]=n+1,!(t=M[b[132104]+n|0]))break i;if(!(1!=(0|t)&&t>>>0<=223)){g[e+80>>1]=256,b[e+60>>2]||(r=b[132108],b[e+24>>2]=r+b[132107],b[e+44>>2]=b[132109]-r),b[e+28>>2]=0,b[e+32>>2]=0,b[e+36>>2]=0,b[e+40>>2]=0;break n}if(!M[e+80|0])break n;return 7}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=2,b[e+72>>2]=b[e+72>>2]+(t<<8);continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=3,b[e+72>>2]=1+(t+b[e+72>>2]|0);continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=4,b[e+76>>2]=t<<8;continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=b[e+68>>2],b[e+76>>2]=1+(t+b[e+76>>2]|0);continue}if(b[132105]=n+1,a=7,224<(t=M[b[132104]+n|0])>>>0)break i;if(r=e,i=t>>>(n=0)<45?0:(t=(t=t+-45|0)-y(i=((255&t)>>>0)/45|0,45)|0,i+1|0),b[r+116>>2]=-1<<i^-1,9<=(255&t)>>>0&&(n=1+(r=((255&(t=t+-9|0))>>>0)/9|0)|0,t=t-y(r,9)|0),b[e+112>>2]=n,t&=255,4<(b[e+108>>2]=t)+n>>>0)break i;for(b[e+112>>2]=-1<<n^-1,t=0,b[e+100>>2]=0,b[e+92>>2]=0,b[e+96>>2]=0,b[e+84>>2]=0,b[e+88>>2]=0;g[120+((t<<1)+e|0)>>1]=1024,14134!=(0|(t=t+1|0)););b[e+64>>2]=6,b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0}if((a=b[e+76>>2])>>>0<5)return 7;if(n=b[e+8>>2])for(t=b[132105],i=b[132106];;){if((0|t)==(0|i))return 0;if(o=b[e+4>>2],r=t+1|0,b[132105]=r,t=M[b[132104]+t|0],n=n+-1|0,b[e+8>>2]=n,b[e+4>>2]=t|o<<8,t=r,!n)break}b[e+64>>2]=7,t=a+-5|0,b[e+76>>2]=t}r=b[e+32>>2],n=(n=b[132109]-b[132108]|0)>>>0<(a=b[e+72>>2])>>>0?n:a,a=b[e+44>>2],b[e+40>>2]=n>>>0<a-r>>>0?r+n|0:a,n=(i=b[132106])-(r=b[132105])|0,a=b[e+28388>>2];o:{if(!t||a){if(S(4+(a+d|0)|0,i=b[132104]+r|0,t=n>>>0<(t=(t=t-a|0)>>>0<(r=42-a|0)>>>0?t:r)>>>0?n:t),(0|(r=(n=b[e+28388>>2])+t|0))!=b[e+76>>2]){if(r>>>0<=20){b[e+28388>>2]=r,b[132105]=t+b[132105];break o}r=r+-21|0}else C(4+(t+(n+d|0)|0)|0,63-r|0),r=t+b[e+28388>>2]|0;if(b[e+16>>2]=0,b[e+12>>2]=u,b[e+20>>2]=r,a=7,!f(e))break i;if(r=b[e+16>>2],(n=b[e+28388>>2])+t>>>0<r>>>0)break i;if(t=b[e+76>>2]-r|0,b[e+76>>2]=t,r>>>0<n>>>0){t=n-r|0,function(e,t,n){var r=0,i=0;s:if((0|e)!=(0|t)){if(!(e>>>0<t+n>>>0&&t>>>0<(i=e+n|0)>>>0))return S(e,t,n);if(r=3&(e^t),e>>>0<t>>>0){if(!r){if(3&e)for(;;){if(!n)break s;if(x[0|e]=M[0|t],t=t+1|0,n=n+-1|0,!(3&(e=e+1|0)))break}if(!(n>>>0<=3)){for(r=n;b[e>>2]=b[t>>2],t=t+4|0,e=e+4|0,3<(r=r+-4|0)>>>0;);n&=3}}if(n)for(;x[0|e]=M[0|t],e=e+1|0,t=t+1|0,n=n+-1|0;);}else{if(!r){if(3&i)for(;;){if(!n)break s;if(x[0|(r=(n=n+-1|0)+e|0)]=M[t+n|0],!(3&r))break}if(!(n>>>0<=3))for(;b[(n=n+-4|0)+e>>2]=b[t+n>>2],3<n>>>0;);}if(!n)break s;for(;x[(n=n+-1|0)+e|0]=M[t+n|0],n;);}}}(u,4+(r+d|0)|0,b[e+28388>>2]=t);break o}r=b[132105]+(r-n|0)|0,b[132105]=r,b[e+28388>>2]=0,n=(i=b[132106])-r|0}if(21<=n>>>0){if(a=b[132104],b[e+16>>2]=r,b[e+12>>2]=a,b[e+20>>2]=n>>>0<t+21>>>0?i+-21|0:t+r|0,a=7,!f(e))break i;if((t=b[e+76>>2])>>>0<(n=(r=b[e+16>>2])-b[132105]|0)>>>0)break i;if(t=t-n|0,b[e+76>>2]=t,b[132105]=r,20<(n=b[132106]-r|0)>>>0)break o}t=t>>>0<n>>>0?t:n,S(u,b[132104]+r|0,t),b[e+28388>>2]=t,b[132105]=t+b[132105]}if(n=(t=b[e+32>>2])-(a=b[e+28>>2])|0,b[(r=e)+60>>2]&&((0|t)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,a+b[e+24>>2]|0,n),t=b[e+32>>2]),b[r+28>>2]=t,t=n+b[132108]|0,b[132108]=t,r=b[e+72>>2]-n|0,!(b[e+72>>2]=r)){if(a=7,b[e+4>>2]|(b[e+76>>2]|b[e+104>>2]))break i;b[e+64>>2]=0;break t}if(((a=0)|t)==b[132109])break i;if(b[132105]!=b[132106]|w[e+28388>>2]>=w[e+76>>2])continue;break i}if(!(i=b[e+76>>2]))break r;if(!(r>>>(a=0)<=n>>>0))for(;;){if((t=b[132109])>>>0<=(o=b[132108])>>>0)break i;if(c=i,s=b[e+32>>2],i=i>>>0<(t=(l=b[e+44>>2]-s|0)>>>0<(t=(r=r-n|0)>>>0<(t=t-o|0)>>>0?r:t)>>>0?l:t)>>>0?i:t,b[e+76>>2]=c-i,S(b[e+24>>2]+s|0,b[132104]+n|0,i),t=i+b[e+32>>2]|0,b[e+32>>2]=t,w[e+36>>2]<t>>>0&&(b[e+36>>2]=t),b[(r=e)+60>>2]&&((0|t)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,b[132104]+b[132105]|0,i),t=b[e+32>>2]),b[r+28>>2]=t,b[132108]=i+b[132108],n=i+b[132105]|0,b[132105]=n,!(i=b[e+76>>2]))break r;if(!(n>>>0<(r=b[132106])>>>0))break}}return a}b[e+64>>2]=0;continue}if(-1<t<<24>>24)break e;if(b[e+64>>2]=1,b[e+72>>2]=t<<16&2031616,192<=t>>>0){b[e+68>>2]=5,x[e+81|0]=0;continue}if(M[e+81|0])return 7;if(b[e+68>>2]=6,t>>>0<160)continue;for(b[e+84>>2]=0,t=b[e+88>>2]=0,b[e+100>>2]=0,b[e+92>>2]=0,b[e+96>>2]=0;g[120+((t<<1)+e|0)>>1]=1024,14134!=(0|(t=t+1|0)););}b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0;continue}if(!(t>>>0<=2))break;b[e+64>>2]=3,b[e+68>>2]=8}return 7}function s(){var e,t,n=0;if(e=P(1208)){if(b[e+36>>2]=2,n=(t=P(28456))?(b[t+52>>2]=8388608,b[t+60>>2]=2,b[t+56>>2]=0,b[t+24>>2]=0,t):0,b[e+1200>>2]=n)return x[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,C(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,e;E(e)}return 0}function l(e){var t,n,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0,g=0,i=b[e+36>>2]?b[e>>2]:(x[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,C(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,0),_=b[132108],y=b[132105];b[e+16>>2]=y,t=e+96|0,f=(r=e)+182|0,n=r+176|0,c=r+168|0;e:{t:{n:{r:{i:{for(;;)if(!(9<i>>>0)){e=c;a:{o:{s:{l:{c:{u:switch(i-1|0){case 1:l=b[132106],i=b[132104],o=b[r+172>>2],a=b[r+168>>2];break c;default:if(a=b[132105],i=b[132106]-a|0,s=b[r+168>>2],i=i>>>0<(l=b[r+172>>2]-s|0)>>>0?i:l,S(8+(s+c|0)|0,a+b[132104]|0,i),b[132105]=i+b[132105],o=0,i=i+b[r+168>>2]|0,a=b[r+172>>2],b[r+168>>2]=(0|a)==(0|i)?0:i,(0|i)!=(0|a))break e;if(b[r>>2]=1,L(n,1024,6)){o=5;break e}if((0|T(f,2,0))!=(M[r+184|0]|M[r+185|0]<<8|(M[r+186|0]<<16|M[r+187|0]<<24))){o=7;break e}if(o=6,M[0|f])break e;if(i=M[r+183|0],15<(b[r+32>>2]=i)>>>0)break e;if(o=2,!(1<<i&19)|4<i>>>0)break e;break;case 4:break o;case 3:break s;case 2:break l;case 0:break u;case 8:break n;case 7:break r;case 6:break i;case 5:break a}if((0|(l=b[132106]))==(0|(a=b[132105]))){o=0;break e}if(i=b[132104],!(s=M[a+i|0])){b[132105]=a+1,b[r+16>>2]=a,i=6,b[r>>2]=6;continue}b[r+168>>2]=0,o=4+(s<<(b[r>>2]=2))|0,b[r+172>>2]=o,b[r+64>>2]=o,a=0}if(s=l,S(8+(e+a|0)|0,i+(l=b[132105])|0,s=(s=s-l|0)>>>0<(o=o-a|0)>>>0?s:o),b[132105]=s+b[132105],o=0,e=s+b[r+168>>2]|0,i=b[r+172>>2],b[r+168>>2]=(0|i)==(0|e)?0:e,(0|e)!=(0|i))break e;if(e=e+-4|0,i=T(n,b[r+172>>2]=e,0),d=b[r+172>>2],(0|i)!=(M[176+(e=d+r|0)|0]|M[e+177|0]<<8|(M[e+178|0]<<16|M[e+179|0]<<24))){o=7;break e}if(b[r+168>>2]=2,63&(m=x[r+177|0])){o=6;break e}if(i=2,s=a=v=u=-1,64&m){for((l=b[r+4>>2])||(b[r+8>>2]=0,b[r+12>>2]=0);;){if(d>>>0<=i>>>0){o=7;break e}h=M[8+(i+c|0)|0],i=i+1|0,b[r+168>>2]=i,g=b[(e=r)+12>>2],p=127&h,o=31&(a=l),a=32<=(63&a)>>>0?(s=p<<o,0):(s=(1<<o)-1&p>>>32-o,p<<o),a|=b[r+8>>2],s=o=s|g,b[e+8>>2]=a,b[e+12>>2]=s;c:{if(!(128&h)){if(h|!l)break c;o=7;break e}if(l=l+(o=7)|0,63!=(0|(b[r+4>>2]=l)))continue;break e}break}b[r+4>>2]=0}if(b[r+48>>2]=a,b[r+52>>2]=s,(0|m)<=-1){for((l=b[r+4>>2])||(b[r+8>>2]=0,b[r+12>>2]=0);;){if(d>>>0<=i>>>0){o=7;break e}h=M[8+(i+c|0)|0],i=i+1|0,b[r+168>>2]=i,p=b[(e=r)+12>>2],u=127&h,o=31&(a=l),u=(a=32<=(63&a)>>>0?(s=u<<o,0):(s=(1<<o)-1&u>>>32-o,u<<o))|b[r+8>>2],v=a=s|p,b[e+8>>2]=u,b[e+12>>2]=a;c:{if(!(128&h)){if(h|!l)break c;o=7;break e}if(l=l+(o=7)|0,63!=(0|(b[r+4>>2]=l)))continue;break e}break}b[r+4>>2]=0}if(b[r+56>>2]=u,b[r+60>>2]=v,d-i>>>0<2){o=7;break e}if(a=i+1|0,b[r+168>>2]=a,33!=M[8+(i+c|0)|0]){o=6;break e}if(e=i+2|0,b[r+168>>2]=e,1!=M[8+(a+c|0)|0]){o=6;break e}if(o=7,(0|e)==(0|d))break e;if(b[r+168>>2]=i+3,o=function(e,t){var n=0,r=0;n=6;c:if(!(39<t>>>0)){if(t=(1&t|2)<<11+(t>>>1|0),b[e+48>>2]=t,r=b[e+60>>2]){if(n=4,t>>>0>w[e+52>>2])break c;if(b[e+44>>2]=t,!(2!=(0|r)|w[e+56>>2]>=t>>>0||(E(b[e+24>>2]),t=P(b[e+48>>2]),b[e+24>>2]=t)))return b[e+56>>2]=0,3}b[e+28388>>2]=0,b[e+64>>2]=0,x[e+80|0]=1,b[e+104>>2]=0,n=0}return n}(b[r+1200>>2],M[8+(e+c|0)|0]))break e;i=b[r+168>>2],a=b[r+172>>2];c:{for(;;){if(a>>>0<=i>>>0)break c;if(e=i+1|0,s=i+c|0,i=b[r+168>>2]=e,M[s+8|0])break}o=6;break e}b[r+168>>2]=0,b[r+80>>2]=0,b[r+84>>2]=0,b[r+72>>2]=0,b[r+76>>2]=0,b[r>>2]=3}if(b[r+16>>2]=b[132105],b[r+20>>2]=b[132108],o=D(b[r+1200>>2]),e=b[(i=r)+76>>2],(s=(a=b[132105]-b[r+16>>2]|0)+b[r+72>>2]|0)>>>0<a>>>0&&(e=e+1|0),l=s,a=e,b[i+72>>2]=s,b[i+76>>2]=e,e=b[r+84>>2],d=b[r+20>>2],(h=(s=u=b[132108]-d|0)+b[r+80>>2]|0)>>>0<s>>>0&&(e=e+1|0),s=e,b[i+80>>2]=h,b[i+84>>2]=e,(0|(e=b[r+52>>2]))==(0|a)&l>>>0>w[r+48>>2]|e>>>0<a>>>0){o=7;break e}if((0|(e=b[r+60>>2]))==(0|s)&h>>>0>w[r+56>>2]|e>>>0<s>>>0){o=7;break e}l:if(!(3<(i=b[r+32>>2]+-1|0)>>>0)){e=r;c:{u:switch(i-1|0){default:i=T(d+b[132107]|0,u,b[r+24>>2]),a=0;break c;case 0:case 1:break l;case 2:}i=function(e,t,n,r){var i=0;if(n^=-1,r^=-1,t)for(;i=2080+((M[0|e]^255&n)<<3)|0,n=b[i>>2]^((255&r)<<24|n>>>8),r=b[i+4>>2]^r>>>8,e=e+1|0,t=t+-1|0;);return A=-1^r,-1^n}(d+b[132107]|0,u,b[r+24>>2],b[r+28>>2]),a=A}b[e+24>>2]=i,b[e+28>>2]=a}if(1!=(0|o))break e;if(i=e=b[r+52>>2],!(-1==(0|(a=b[r+48>>2]))&-1==(0|i)|b[r+72>>2]==(0|a)&b[r+76>>2]==(0|i))){o=7;break e}if(e=b[r+80>>2],i=b[r+84>>2],s=l=b[r+60>>2],-1==(0|(a=b[r+56>>2]))&-1==(0|s))a=e,s=i;else if(o=7,(0|e)!=(0|a)|(0|i)!=(0|s))break e;s=s+b[r+108>>2]|0,(i=a+b[r+104>>2]|0)>>>0<a>>>0&&(s=s+1|0),b[r+104>>2]=i,b[r+108>>2]=s,s=b[r+100>>2],e=b[r+76>>2],(l=(a=b[r+64>>2])+b[r+72>>2]|0)>>>0<a>>>0&&(e=e+1|0),e=e+s|0,e=(a=l+b[r+96>>2]|0)>>>0<l>>>0?e+1|0:e,(a=(s=a)+M[b[r+32>>2]+1040|0]|0)>>>0<s>>>0&&(e=e+1|0),b[r+96>>2]=a,b[r+100>>2]=e,b[r+112>>2]=T(t,24,b[r+112>>2]),b[r>>2]=4,i=b[r+92>>2],(a=b[r+88>>2]+1|0)>>>0<1&&(i=i+1|0),b[r+88>>2]=a,b[r+92>>2]=i}if(s=b[r+76>>2],3&(a=b[r+72>>2]))for(i=b[132105],l=b[132106];;){if((0|i)==(0|l)){o=0;break e}if(e=i+1|0,b[132105]=e,M[b[132104]+i|0]){o=7;break e}if((a=a+1|0)>>>0<1&&(s=s+1|0),b[r+72>>2]=a,b[r+76>>2]=s,i=e,!(3&a))break}b[r>>2]=5}o:{s:if(!(3<(i=(e=b[r+32>>2])+-1|0)>>>0)){l:switch(i-1|0){default:for(i=b[132105],o=b[132106];;){if((0|i)==(0|o)){o=0;break e}if(l=b[r+24>>2],a=b[r+28>>2],e=b[r+4>>2],s=i+1|0,b[132105]=s,u=M[b[132104]+i|0],d=l,i=a,l=31&e,(0|u)!=(255&(32<=(63&e)>>>0?i>>>l|0:((1<<l)-1&i)<<32-l|d>>>l))){o=7;break e}if(e=e+8|0,i=s,!((b[r+4>>2]=e)>>>0<32))break}b[r+24>>2]=0,b[r+28>>2]=0;break o;case 0:case 1:break s;case 2:}for(i=b[132105],o=b[132106];;){if((0|i)==(0|o)){o=0;break e}if(l=b[r+24>>2],a=b[r+28>>2],e=b[r+4>>2],s=i+1|0,b[132105]=s,u=M[b[132104]+i|0],d=l,i=a,l=31&e,(0|u)!=(255&(32<=(63&e)>>>0?i>>>l|0:((1<<l)-1&i)<<32-l|d>>>l))){o=7;break e}if(e=e+8|0,i=s,!((b[r+4>>2]=e)>>>0<64))break}b[r+24>>2]=0,b[r+28>>2]=0;break o}if(i=b[r+4>>2],!((e=M[e+1040|0])>>>0<=i>>>0))for(o=b[132105],a=b[132106];;){if((0|o)==(0|a)){o=0;break e}if(o=o+1|0,b[132105]=o,i=i+1|0,(0|e)==(0|(b[r+4>>2]=i)))break}}b[r+4>>2]=0,i=1,b[r>>2]=1;continue}break}for(h=r+144|0;;){p=b[132106],u=b[132104],(e=b[r+4>>2])||(b[r+8>>2]=0,b[r+12>>2]=0),i=b[132105];a:{for(;;){if(p>>>0<=i>>>0)o=0;else if(c=M[i+u|0],i=i+1|0,b[132105]=i,f=b[(l=r)+12>>2],d=127&c,o=31&e,a=32<=(63&e)>>>0?(s=d<<o,0):(s=(1<<o)-1&d>>>32-o,d<<o),a|=b[r+8>>2],s=o=s|f,b[l+8>>2]=a,b[l+12>>2]=s,128&c){if(e=e+(o=7)|0,63!=(0|(b[r+4>>2]=e)))continue}else{if(c|!e)break a;o=7}break}e=b[r+132>>2],(c=(s=(a=i)-(i=b[r+16>>2])|0)+b[r+128>>2]|0)>>>0<s>>>0&&(e=e+1|0),b[r+128>>2]=c,b[r+132>>2]=e,b[r+24>>2]=T(i+u|0,s,b[r+24>>2]),b[r+28>>2]=0;break e}b[r+4>>2]=0;a:{if((e=b[r+120>>2])>>>0<=2){o:switch(e-1|0){default:if(b[r+136>>2]=a,b[r+140>>2]=s,(0|a)!=b[r+88>>2]|(0|s)!=b[r+92>>2]){o=7;break e}b[r+120>>2]=1;break a;case 1:e=s+b[r+156>>2]|0,(s=a+b[r+152>>2]|0)>>>0<a>>>0&&(e=e+1|0),b[r+152>>2]=s,b[r+156>>2]=e,b[r+160>>2]=T(h,24,b[r+160>>2]),b[r+120>>2]=1,s=b[r+140>>2]+-1|0,(i=b[r+136>>2]+-1|0)>>>0<4294967295&&(s=s+1|0),a=i,b[r+136>>2]=i,b[r+140>>2]=s;break a;case 0:}b[r+120>>2]=2,e=s+b[r+148>>2]|0,(s=a+b[r+144>>2]|0)>>>0<a>>>0&&(e=e+1|0),b[r+144>>2]=s,b[r+148>>2]=e}a=b[r+136>>2],s=b[r+140>>2]}if(!(a|s))break}b[r>>2]=7}a=b[r+132>>2],d=((i=b[132105])+(((s=b[r+16>>2])-i|0)-(c=b[r+128>>2])&3)|0)-s|0;i:{for(;;){if(e=a,(o=(l=u=i-s|0)+c|0)>>>0<l>>>0&&(e=e+1|0),!(3&(l=o)))break i;if(o=b[132104],b[132106]==(0|i)){b[r+128>>2]=l,b[r+132>>2]=e,b[r+24>>2]=T(o+s|0,u,b[r+24>>2]),o=b[r+28>>2]=0;break e}if(e=i+1|0,l=i+o|0,i=b[132105]=e,M[0|l])break}o=7;break e}if(i=b[132104],b[r+128>>2]=l,b[r+132>>2]=e,b[r+24>>2]=T(i+s|0,d,b[r+24>>2]),o=7,L(t,r+144|(b[r+28>>2]=0),24))break e;b[r>>2]=8}for(i=b[132105],o=b[132106];;){if((0|i)==(0|o)){o=0;break e}if(c=b[r+24>>2],s=b[r+28>>2],a=b[r+4>>2],e=i+1|0,b[132105]=e,l=b[132104],u=M[l+i|0],d=c,i=s,c=31&a,(0|u)!=(255&(32<=(63&a)>>>0?i>>>c|0:((1<<c)-1&i)<<32-c|d>>>c))){o=7;break e}if(a=a+8|0,i=e,!((b[r+4>>2]=a)>>>0<32))break}b[r+172>>2]=12,b[r+24>>2]=0,b[r+28>>2]=0,b[r>>2]=9,b[r+4>>2]=0,i=12;break t}e=b[132105],l=b[132104],o=b[132106],i=b[r+172>>2]}a=o-e|0,S(176+(r+(s=b[r+168>>2])|0)|0,e+l|0,i=a>>>0<(i=i-s|0)>>>0?a:i),b[132105]=i+b[132105],o=0,e=i+b[r+168>>2]|0,i=b[r+172>>2],b[r+168>>2]=(0|i)==(0|e)?0:e,(0|e)==(0|i)&&(o=7,23129==(M[r+186|0]|M[r+187|0]<<8)&&(0|T(r+180|0,6,0))==(M[r+176|0]|M[r+177|0]<<8|(M[r+178|0]<<16|M[r+179|0]<<24))&&(e=(i=b[r+132>>2])>>>2|0,M[r+184|0]|(M[r+180|0]|M[r+181|0]<<8|(M[r+182|0]<<16|M[r+183|0]<<24))!=((3&i)<<30|b[r+128>>2]>>>2)|e||(o=b[r+32>>2]==M[r+185|0]?1:7)))}e:{if(!b[r+36>>2]){if(o){if(r=1==(0|o),e=o,o=1,r)break e}else e=b[132105]==b[132106]?7:8;return b[132108]=_,b[132105]=y,e}if(!(b[132105]!=(0|y)|o|b[132108]!=(0|_)))return e=M[r+40|0],x[r+40|0]=1,e<<3;x[r+40|0]=0}return o}function m(e){var t;return(-1>>>(t=31&e)&-2)<<t|(-1<<(e=0-e&31)&-2)>>>e}return{__wasm_call_ctors:function(){},init_decompressor:function(){var e=0;return b[132108]=0,b[132109]=524288,b[132107]=528448,b[132105]=0,b[132106]=0,b[132104]=4128,function(){for(var e=0,t=0,n=0;e=((t=(0-(1&(e=(0-(1&(e=((t=n>>>1|0)^0-(1&n)&-306674912)>>>1|0))&-306674912^(t=(e^0-(1&t)&-306674912)>>>1|0))>>>1|0))&-306674912^(e=(e^0-(1&t)&-306674912)>>>1|0))>>>1|0)^0-(1&e)&-306674912)>>>1|0,b[1056+(n<<2)>>2]=0-(1&e)&-306674912^(e^0-(1&t)&-306674912)>>>1,256!=(0|(n=n+1|0)););}(),function(){for(var e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0;t=(e=o)>>>1|0,n=1&(e=(1&e)<<31|s>>>1),t^=0-(0<(a=1&s)>>>0)&-915646571,a=e^(i=0-a&-679014590),e=t>>>1|0,e^=0-(0<n>>>0)&-915646571,n=(t=(1&t)<<31|a>>>1)^(r=0-n&-679014590),r=e>>>1|0,n=1&(e=(1&e)<<31|n>>>1),i=0-(t&=1)&-679014590,t=r^0-(0<t>>>0)&-915646571,r=e^i,e=t>>>1|0,r=0-n&-679014590^(t=(1&t)<<31|r>>>1),e=(n=e^0-(0<n>>>0)&-915646571)>>>1|0,t=(1&(e^=0-(0<(t&=1)>>>0)&-915646571))<<31|(t=(n=(1&n)<<31|r>>>1)^(i=0-t&-679014590))>>>1,e=(n=0-(0<(r=1&n)>>>0)&-915646571^e>>>1)>>>1|0,r=1&(n=(1&n)<<31|(r=t^(a=0-r&-679014590))>>>1),n^=0-(t&=1)&-679014590,t=(e^=0-(0<t>>>0)&-915646571)>>>1|0,b[(i=2080+(l<<3)|0)>>2]=0-r&-679014590^((1&e)<<31|n>>>1),b[i+4>>2]=t^0-(0<r>>>0)&-915646571,l=l+1|0,e=o,(o=s+1|0)>>>0<1&&(e=e+1|0),256!=(0|(s=o))|(o=e););}(),e=s(),0|(e=(b[263184]=e)?0:(o(0),1))},decompress:function(){var e,t=0;e:{if((e=l(b[263184]))>>>0<=8){t:switch(e-1|0){case 0:return o(b[263184]),0;case 2:return o(b[263184]),1;case 3:return o(b[263184]),2;case 4:return o(b[263184]),4;case 5:return o(b[263184]),5;case 6:case 7:break t;default:break e}return o(b[263184]),6}o(b[263184]),t=7}return 0|t},get_in_buffer_ptr:function(){return b[132104]},get_out_buffer_ptr:function(){return b[132107]},in_buffer_set_pos:function(e){e|=0,b[132105]=e},in_buffer_set_size:function(e){e|=0,b[132106]=e>>>0<524288?e:524288},out_buffer_set_pos:function(e){e|=0,b[132108]=e},out_buffer_set_size:function(e){e|=0,b[132109]=e>>>0<524288?e:524288},get_curr_output_length:function(){return b[132108]},is_input_end_reached:function(){return b[132105]==b[132106]|0},stackSave:function(){return 0|h},stackAlloc:function(e){return 0|(h=e=h-(e|=0)&-16)},stackRestore:function(e){h=e|=0},__growWasmMemory:function(e){return 0|r()}}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0,Math:Math},n,r.buffer))}},instantiate:function(t,n){return{then:function(e){e({instance:new rg.Instance(new rg.Module(t,n))})}}},RuntimeError:Error},ig=[];"object"!=typeof rg&&tg("no native wasm support detected");var ag=new rg.Table({initial:1,maximum:1,element:"anyfunc"}),og=!1;function sg(e,t){e||Tg("Assertion failed: "+t)}function lg(e){var t=jv["_"+e];return sg(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function cg(e,t,n,r){var i={string:function(e){var t,n=0;return null!=e&&0!==e&&(t=1+(e.length<<2),n=Vg(t),function(e,t,n,r){if(0<r){for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s,l=e.charCodeAt(o);if(55296<=l&&l<=57343&&(s=e.charCodeAt(++o),l=65536+((1023&l)<<10)|1023&s),l<=127){if(a<=n)break;t[n++]=l}else if(l<=2047){if(a<=n+1)break;t[n++]=192|l>>6,t[n++]=128|63&l}else if(l<=65535){if(a<=n+2)break;t[n++]=224|l>>12,t[n++]=128|l>>6&63,t[n++]=128|63&l}else{if(a<=n+3)break;t[n++]=240|l>>18,t[n++]=128|l>>12&63,t[n++]=128|l>>6&63,t[n++]=128|63&l}}t[n]=0}}(e,pg,n,t)),n},array:function(e){var t,n,r=Vg(e.length);return t=e,n=r,hg.set(t,n),r}};var a=lg(e),o=[],s=0;if(r)for(var l=0;l<r.length;l++){var c=i[n[l]];c?(0===s&&(s=Ug()),o[l]=c(r[l])):o[l]=r[l]}var u,d,h,p=a.apply(null,o);return u=p,p="string"===t?(d=u)?function(e,t,n){for(var r=t+n,i=t;e[i]&&!(r<=i);)++i;if(16<i-t&&e.subarray&&ug)return ug.decode(e.subarray(t,i));for(var a="";t<i;){var o,s,l,c=e[t++];128&c?(o=63&e[t++],192!=(224&c)?(s=63&e[t++],(c=224==(240&c)?(15&c)<<12|o<<6|s:(7&c)<<18|o<<12|s<<6|63&e[t++])<65536?a+=String.fromCharCode(c):(l=c-65536,a+=String.fromCharCode(55296|l>>10,56320|1023&l))):a+=String.fromCharCode((31&c)<<6|o)):a+=String.fromCharCode(c)}return a}(pg,d,h):"":"boolean"===t?Boolean(u):u,0!==s&&kg(s),p}var ug="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var dg,hg,pg,fg;var mg,vg=jv.TOTAL_MEMORY||16777216;function gg(e){for(;0<e.length;){var t,n=e.shift();"function"!=typeof n?"number"==typeof(t=n.func)?void 0===n.arg?jv.dynCall_v(t):jv.dynCall_vi(t,n.arg):t(void 0===n.arg?null:n.arg):n()}}(ng=jv.wasmMemory?jv.wasmMemory:new rg.Memory({initial:vg/65536,maximum:vg/65536}))&&(dg=ng.buffer),vg=dg.byteLength,dg=mg=dg,jv.HEAP8=hg=new Int8Array(mg),jv.HEAP16=new Int16Array(mg),jv.HEAP32=fg=new Int32Array(mg),jv.HEAPU8=pg=new Uint8Array(mg),jv.HEAPU16=new Uint16Array(mg),jv.HEAPU32=new Uint32Array(mg),jv.HEAPF32=new Float32Array(mg),jv.HEAPF64=new Float64Array(mg),fg[263312]=6296288;var _g=[],yg=[],xg=[],bg=[];function Mg(){if(jv.preRun)for("function"==typeof jv.preRun&&(jv.preRun=[jv.preRun]);jv.preRun.length;)e=jv.preRun.shift(),_g.unshift(e);var e;gg(_g)}function wg(){if(jv.postRun)for("function"==typeof jv.postRun&&(jv.postRun=[jv.postRun]);jv.postRun.length;)e=jv.postRun.shift(),bg.unshift(e);var e;gg(bg)}var Ag=0,Sg=null;function Tg(e){throw jv.onAbort&&jv.onAbort(e),eg(e+=""),tg(e),og=!0,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.",new rg.RuntimeError(e)}jv.preloadedImages={},jv.preloadedAudios={};var Eg="data:application/octet-stream;base64,";function Cg(e){return String.prototype.startsWith?e.startsWith(Eg):0===e.indexOf(Eg)}var Pg,Lg="xz.wasm";function Rg(){try{if(ig)return new Uint8Array(ig);var e=Ig(Lg);if(e)return e;if(Hv)return Hv(Lg);throw"both async and sync fetching of the wasm failed"}catch(e){Tg(e)}}function Dg(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];255<r&&(r&=255),t.push(String.fromCharCode(r))}return t.join("")}Cg(Lg)||(Pg=Lg,Lg=jv.locateFile?jv.locateFile(Pg,$v):$v+Pg),yg.push({func:function(){zg()}});var Ng="function"==typeof atob?atob:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");t=s.indexOf(e.charAt(c++))<<2|(i=s.indexOf(e.charAt(c++)))>>4,n=(15&i)<<4|(a=s.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(o=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==a&&(l+=String.fromCharCode(n)),64!==o&&(l+=String.fromCharCode(r)),c<e.length;);return l};function Ig(e){if(Cg(e))return function(t){if("boolean"==typeof Kv&&Kv){var n;try{n=Buffer.from(t,"base64")}catch(e){n=new Buffer(t,"base64")}return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}try{for(var e=Ng(t),r=new Uint8Array(e.length),i=0;i<e.length;++i)r[i]=e.charCodeAt(i);return r}catch(e){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(Eg.length))}var Og={emscripten_memcpy_big:function(e,t,n){pg.set(pg.subarray(t,t+n),e)},emscripten_resize_heap:function(e){Tg("OOM")},memory:ng,table:ag},Fg=function(){var t={env:Og,wasi_snapshot_preview1:Og};function n(e,t){var n,r=e.exports;jv.asm=r,Ag--,jv.monitorRunDependencies&&jv.monitorRunDependencies(Ag),0==Ag&&Sg&&(n=Sg,Sg=null,n())}function r(e){n(e.instance)}function i(e){return(ig||!Zv&&!Qv||"function"!=typeof fetch?new Promise(function(e,t){e(Rg())}):fetch(Lg,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Lg+"'";return e.arrayBuffer()}).catch(Rg)).then(function(e){return rg.instantiate(e,t)}).then(e,function(e){tg("failed to asynchronously prepare wasm: "+e),Tg(e)})}if(Ag++,jv.monitorRunDependencies&&jv.monitorRunDependencies(Ag),jv.instantiateWasm)try{return jv.instantiateWasm(t,n)}catch(e){return tg("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(ig||"function"!=typeof rg.instantiateStreaming||Cg(Lg)||"function"!=typeof fetch)return i(r);fetch(Lg,{credentials:"same-origin"}).then(function(e){return rg.instantiateStreaming(e,t).then(r,function(e){tg("wasm streaming compile failed: "+e),tg("falling back to ArrayBuffer instantiation"),i(r)})})}(),{}}();jv.asm=Fg;var Bg,zg=jv.___wasm_call_ctors=function(){return(zg=jv.___wasm_call_ctors=jv.asm.__wasm_call_ctors).apply(null,arguments)},Ug=(jv._init_decompressor=function(){return(jv._init_decompressor=jv.asm.init_decompressor).apply(null,arguments)},jv._decompress=function(){return(jv._decompress=jv.asm.decompress).apply(null,arguments)},jv._get_in_buffer_ptr=function(){return(jv._get_in_buffer_ptr=jv.asm.get_in_buffer_ptr).apply(null,arguments)},jv._get_out_buffer_ptr=function(){return(jv._get_out_buffer_ptr=jv.asm.get_out_buffer_ptr).apply(null,arguments)},jv._in_buffer_set_pos=function(){return(jv._in_buffer_set_pos=jv.asm.in_buffer_set_pos).apply(null,arguments)},jv._in_buffer_set_size=function(){return(jv._in_buffer_set_size=jv.asm.in_buffer_set_size).apply(null,arguments)},jv._out_buffer_set_pos=function(){return(jv._out_buffer_set_pos=jv.asm.out_buffer_set_pos).apply(null,arguments)},jv._out_buffer_set_size=function(){return(jv._out_buffer_set_size=jv.asm.out_buffer_set_size).apply(null,arguments)},jv._get_curr_output_length=function(){return(jv._get_curr_output_length=jv.asm.get_curr_output_length).apply(null,arguments)},jv._is_input_end_reached=function(){return(jv._is_input_end_reached=jv.asm.is_input_end_reached).apply(null,arguments)},jv.stackSave=function(){return(Ug=jv.stackSave=jv.asm.stackSave).apply(null,arguments)}),Vg=jv.stackAlloc=function(){return(Vg=jv.stackAlloc=jv.asm.stackAlloc).apply(null,arguments)},kg=jv.stackRestore=function(){return(kg=jv.stackRestore=jv.asm.stackRestore).apply(null,arguments)},Gg=jv.__growWasmMemory=function(){return(Gg=jv.__growWasmMemory=jv.asm.__growWasmMemory).apply(null,arguments)};function jg(e){function t(){Bg||(Bg=!0,og||(gg(yg),gg(xg),jv.onRuntimeInitialized&&jv.onRuntimeInitialized(),wg()))}0<Ag||(Mg(),0<Ag||(jv.setStatus?(jv.setStatus("Running..."),setTimeout(function(){setTimeout(function(){jv.setStatus("")},1),t()},1)):t()))}if(jv.asm=Fg,jv.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?lg(e):function(){return cg(e,t,n,arguments)}},Sg=function e(){Bg||jg(),Bg||(Sg=e)},jv.run=jg,jv.preInit)for("function"==typeof jv.preInit&&(jv.preInit=[jv.preInit]);0<jv.preInit.length;)jv.preInit.pop()();jg(),jv._lock=!1;var Wg=["","Memory allocation failed","Memory usage limit reached","Unsupported check; not verifying file integrity","Not an .xz file","Unsupported options in the .xz headers","File is corrupt","Unknown decompression bug"];function Xg(e){this.manager=void 0!==e?e:Uu}Object.assign(Xg.prototype,{crossOrigin:"Anonymous",load:function(r,i,a,o){void 0===r&&(r=""),void 0!==this.path&&(r=this.path+r);var s=this,e=Bu.get(r);if(void 0!==e)return s.manager.itemStart(r),setTimeout(function(){i&&i(e),s.manager.itemEnd(r)},0),e;var t=new XMLHttpRequest;return t.open("GET",r,!0),t.addEventListener("load",function(e){var t,n=e.target.response;200===this.status||0===this.status?(0===this.status&&console.warn("v3d.XZLoader: HTTP Status 0 received."),t=function(){jv._lock?setTimeout(t,1):s.decompressArrayBuffer(n,function(e){setTimeout(function(){i&&i(e),s.manager.itemEnd(r),Bu.add(r,e)},1)},function(e){a&&a((+e+2)/3)},function(e){o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r)})},setTimeout(t,1)):(o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r))},!1),a&&t.addEventListener("progress",function(e){var t;t=e.lengthComputable?e.loaded/e.total:1,a(2*t/3)},!1),t.addEventListener("error",function(e){o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r)},!1),t.responseType="arraybuffer",t.send(null),s.manager.itemStart(r),t},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},decompressArrayBuffer:function(e,l,c,u){var d=this;function h(e){var t=d._emGetInBufferPtr();jv.HEAPU8.set(e,t),d._emInBufferSetPos(0),d._emInBufferSetSize(e.length),p()}function p(){d._emOutBufferSetPos(0)}jv._lock=!0;var t=d._emInitDecompressor();if(0!=t)return console.error("XZLoader._emInitDecompressor: error code "+t+" ("+Wg[t]+")"),void(u&&u(t));var f=new Uint8Array(e),m=f.length,v=[],g=0,_=Math.min(524288,m),y=0;h(f.subarray(g,_)),function e(){var t,n,r,i,a,o,s=d._emDecompress();s?(console.error("XZLoader._emDecompress: error code "+s+" ("+Wg[s]+")"),jv._lock=!1,u&&u(s)):(t=d._emGetCurrOutputLength(),v.push((a=t,o=d._emGetOutBufferPtr(),new Uint8Array(jv.HEAPU8.subarray(o,o+a)))),p(),d._emIsInputEndReached()&&(g=_,_=Math.min(_+524288,m),h(f.subarray(g,_))),c&&c(g/m),g==_?(n=v.reduce(function(e,t,n,r){return e+t.length},0),r=new Uint8Array(n),i=0,v.forEach(function(e){r.set(e,i),i+=e.length}),jv._lock=!1,l&&l(r.buffer)):++y%2==0?setTimeout(e,1):e())}()},_emInitDecompressor:jv.cwrap("init_decompressor","number"),_emDecompress:jv.cwrap("decompress","number"),_emGetInBufferPtr:jv.cwrap("get_in_buffer_ptr","number"),_emGetOutBufferPtr:jv.cwrap("get_out_buffer_ptr","number"),_emInBufferSetPos:jv.cwrap("in_buffer_set_pos",null,["number"]),_emInBufferSetSize:jv.cwrap("in_buffer_set_size",null,["number"]),_emOutBufferSetPos:jv.cwrap("out_buffer_set_pos",null,["number"]),_emOutBufferSetSize:jv.cwrap("out_buffer_set_size",null,["number"]),_emGetCurrOutputLength:jv.cwrap("get_curr_output_length","number"),_emIsInputEndReached:jv.cwrap("is_input_end_reached","number")});function Hg(e){Xu.call(this,e),this.type=it}function Yg(e,t){nc.call(this,e,t),this.type="BlenderTextGeometry",this.computeBoundingBox();var n,r,i=this.boundingBox.max.x-this.boundingBox.min.x,a=this.boundingBox.max.y-this.boundingBox.min.y;switch(t.alignX){case"left":n=0;break;case"center":n=-.5*i;break;case"right":n=-i}switch(t.alignY){case"bottom":r=0;break;case"center":r=-.5*a;break;case"top":r=-a}(0<Math.abs(n)||0<Math.abs(r))&&this.translate(n,r,0)}Hg.prototype=Object.assign(Object.create(Xu.prototype),{constructor:Hg,parse:function(e){function _(e,t){switch(e){case 1:console.error("RGBELoader Read Error: "+(t||""));break;case 2:console.error("RGBELoader Write Error: "+(t||""));break;case 3:console.error("RGBELoader Bad File Format: "+(t||""));break;default:console.error("RGBELoader: Error: "+(t||""))}return-1}function l(e,t,n){t=t||1024;for(var r=e.pos,i=-1,a=0,o="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));(i=s.indexOf("\n"))<0&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))}var a,o,t=(a=new Float32Array(1),o=new Int32Array(a.buffer),function(e,t,n,r){var i=e[t+3],a=Math.pow(2,i-128)/255;n[r+0]=s(e[t+0]*a),n[r+1]=s(e[t+1]*a),n[r+2]=s(e[t+2]*a)});function s(e){a[0]=e;var t=o[0],n=t>>16&32768,r=t>>12&2047,i=t>>23&255;return i<103?n:142<i?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)}var n=new Uint8Array(e);n.pos=0;var r,i,c,u,d,h,p=function(e){var t,n,r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=e.byteLength||!(t=l(e)))return _(1,"no header found");if(!(n=t.match(/^#\?(\S+)$/)))return _(3,"bad initial token");for(s.valid|=1,s.programtype=n[1],s.string+=t+"\n";!1!==(t=l(e));)if(s.string+=t+"\n","#"!==t.charAt(0)){if((n=t.match(r))&&(s.gamma=parseFloat(n[1],10)),(n=t.match(i))&&(s.exposure=parseFloat(n[1],10)),(n=t.match(a))&&(s.valid|=2,s.format=n[1]),(n=t.match(o))&&(s.valid|=4,s.height=parseInt(n[1],10),s.width=parseInt(n[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=t+"\n";return 2&s.valid?4&s.valid?s:_(3,"missing image size specifier"):_(3,"missing format specifier")}(n);if(-1!==p){var f=p.width,m=p.height,v=function(e,t,n){var r,i,a,o,s,l,c,u,d,h,p,f,m,v=t,g=n;if(v<8||32767<v||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(v!==(e[2]<<8|e[3]))return _(3,"wrong scanline width");if(!(r=new Uint8Array(4*t*n))||!r.length)return _(4,"unable to allocate buffer space");for(a=i=0,u=4*v,m=new Uint8Array(4),l=new Uint8Array(u);0<g&&a<e.byteLength;){if(a+4>e.byteLength)return _(1);if(m[0]=e[a++],m[1]=e[a++],m[2]=e[a++],m[3]=e[a++],2!=m[0]||2!=m[1]||(m[2]<<8|m[3])!=v)return _(3,"bad rgbe scanline format");for(c=0;c<u&&a<e.byteLength;){if((f=128<(o=e[a++]))&&(o-=128),0===o||u<c+o)return _(3,"bad scanline data");if(f)for(s=e[a++],d=0;d<o;d++)l[c++]=s;else l.set(e.subarray(a,a+o),c),c+=o,a+=o}for(h=v,d=0;d<h;d++)p=0,r[i]=l[d+p],p+=v,r[i+1]=l[d+p],p+=v,r[i+2]=l[d+p],p+=v,r[i+3]=l[d+p],i+=4;g--}return r}(n.subarray(n.pos),f,m);if(-1!==v){switch(this.type){case it:var g=v,y=S,x=it;break;case st:for(var b=v.length/4*3,M=new Float32Array(b),w=0;w<b;w++)c=M,u=3*w,0,d=(r=v)[(i=4*w)+3],h=Math.pow(2,d-128)/255,c[u+0]=r[i+0]*h,c[u+1]=r[i+1]*h,c[u+2]=r[i+2]*h;g=M,y=ut,x=st;break;case lt:for(var b=v.length/4*3,A=new Uint16Array(b),w=0;w<b;w++)t(v,4*w,A,3*w);g=A,y=ut,x=lt;break;default:console.error("v3d.RGBELoader: unsupported type: ",this.type)}return{width:f,height:m,data:g,header:p.string,gamma:p.gamma,exposure:p.exposure,format:y,type:x}}}return null},setDataType:function(e){return this.type=e,this},load:function(e,n,t,r){return Xu.prototype.load.call(this,e,function(e,t){switch(e.type){case it:e.encoding=Pt,e.minFilter=Je,e.magFilter=Je,e.generateMipmaps=!1,e.flipY=!0;break;case st:case lt:e.encoding=Tt,e.minFilter=tt,e.magFilter=tt,e.generateMipmaps=!1,e.flipY=!0}n&&n(e,t)},t,r)}}),((Yg.prototype=Object.create(nc.prototype)).constructor=Yg).prototype.cloneWithText=function(e){var t=this.parameters.parameters;return new Yg(e,{font:t.font,size:t.size,height:t.height,curveSegments:t.curveSegments,bevelEnabled:t.bevelEnabled,bevelThickness:t.bevelThickness,bevelSize:t.bevelSize,alignX:t.alignX,alignY:t.alignY})};var qg=["TEXTURE_BL","TEX_IMAGE_BL","TEX_ENVIRONMENT_BL","TEXTURE_GF","TEX_ENVIRONMENT_MX","BITMAP_MX","BITMAP_ENV_MX","REFLECT_REFRACT_MX","AI_SKYDOME_LIGHT_MY","FILE_MY","TEXTURE","TEX_IMAGE","TEX_ENVIRONMENT","TEX_ENVIRONMENT_MAX","BITMAP_MAX","BITMAP_ENV_MAX","REFLECT_REFRACT_MAX"];function Zg(e){this.manager=void 0!==e?e:Uu,this.crossOrigin="Anonymous",this.onProgress=null}function Qg(){var n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}Object.assign(Zg.prototype,{load:function(e,t,n,r){var i=this;i.onProgress=n||function(){};var a,o=this.path&&"string"==typeof this.path?this.path:Dd.extractUrlBase(e),s=-1!=e.indexOf(".xz",e.length-3);s?a=new Xg(i.manager):(a=new Gu(i.manager)).setResponseType("arraybuffer");function l(e){i.onProgress&&i.onProgress(.3*e*100)}var c=a instanceof Gu?function(e){var t=e.lengthComputable?e.loaded/e.total:1;l(t)}:l;a.load(e,function(e){i.parse(e,o,t,r,s)},c,r)},setCrossOrigin:function(e){this.crossOrigin=e},setPath:function(e){this.path=e},parse:function(e,t,s,n,r){var i,l=this,a={},o=S_(new Uint8Array(e,0,4))===e_?(a[Kg.KHR_BINARY_GLTF]=new r_(e),a[Kg.KHR_BINARY_GLTF].content):S_(new Uint8Array(e)),c=JSON.parse(o);void 0===c.asset||c.asset.version[0]<2?n(new Error("v3d.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")):(-1<(i=c.asset.generator||"").indexOf("Verge3D")&&"ALL"!=Wt&&[["Blender","BLENDER"],["3ds Max","MAX"],["Maya","MAYA"]].forEach(function(e){var t=e[0],n=e[1];-1<i.indexOf(t)&&Wt!=n&&console.warn("The glTF asset was exported from "+t+". It may not be fully compatible with Verge3D "+ei()+".")}),c.extensionsUsed&&(0<=c.extensionsUsed.indexOf(Kg.S8S_V3D_DATA)&&(a[Kg.S8S_V3D_DATA]=new Jg(c)),0<=c.extensionsUsed.indexOf(Kg.S8S_V3D_MATERIAL_DATA)&&(a[Kg.S8S_V3D_MATERIAL_DATA]=new $g)),new E_(c,a,{path:t||this.path,crossOrigin:this.crossOrigin,loadBinXZ:r,manager:this.manager,onProgress:function(e){l.onProgress&&l.onProgress(e)}}).parse(function(e,t,n,r,i,a){var o={scene:e,scenes:t,world:n,cameras:r,animations:i,renderer:a};l.onProgress&&l.onProgress(100),s(o)},n))}});var Kg={KHR_BINARY_GLTF:"KHR_binary_glTF",S8S_V3D_ANIMATION_DATA:"S8S_v3d_animation_data",S8S_V3D_DATA:"S8S_v3d_data",S8S_V3D_CAMERA_DATA:"S8S_v3d_camera_data",S8S_V3D_MATERIAL_DATA:"S8S_v3d_material_data",S8S_V3D_MESH_DATA:"S8S_v3d_mesh_data",S8S_V3D_NODE_DATA:"S8S_v3d_node_data",S8S_V3D_SCENE_DATA:"S8S_v3d_scene_data",S8S_V3D_TEXTURE_DATA:"S8S_v3d_texture_data"};function Jg(e){this.name=Kg.S8S_V3D_DATA;var t=e.extensions&&e.extensions[Kg.S8S_V3D_DATA]||{};this.lights={};var n=t.lights||{};for(var r in n){var i,a=n[r],o=(new Lr).fromArray(a.color),s=a.intensity;switch(a.type){case"point":i=new Sd(o,s);break;case"directional":i=new Cd(o,s),Jr(a.shadow)&&Jr(a.shadow.csm)&&(i.shadow=new Ed);break;case"spot":i=new wd(o,s);break;case"hemisphere":i=new Md(o,new Lr(0,0,0),s);break;case"ambient":i=new Pd(o,s)}i&&(Jr(a.distance)&&(i.distance=a.distance),Jr(a.decay)&&(i.decay=a.decay,"blender"==a.profile&&2<=a.decay&&(i.intensity/=4*Math.PI)),Jr(a.angle)&&(i.angle=a.angle),Jr(a.penumbra)&&(i.penumbra=a.penumbra),Jr(a.shadow)?(Jr(a.shadow.enabled)||(a.shadow.enabled=!0),i.castShadow=a.shadow.enabled,i.shadow.bias=a.shadow.bias,Jr(a.shadow.expBias)&&(i.shadow.expBias=a.shadow.expBias),Jr(a.shadow.slopeScaledBias)&&(i.shadow.slopeScaledBias=a.shadow.slopeScaledBias),i.shadow.radius=a.shadow.radius,i.shadow.mapSize.width=a.shadow.mapSize,i.shadow.mapSize.height=a.shadow.mapSize,i.shadow.camera.near=a.shadow.cameraNear,i.shadow.camera.far=a.shadow.cameraFar,i.isSpotLight?(i.shadow.camera.fov=Kt.radToDeg(a.shadow.cameraFov),i.shadow.useMinFov90="blender"===a.profile):i.isDirectionalLight&&(Jr(a.shadow.cameraOrthoLeft)&&Jr(a.shadow.cameraOrthoRight)&&Jr(a.shadow.cameraOrthoBottom)&&Jr(a.shadow.cameraOrthoTop)&&(i.shadow.camera.left=a.shadow.cameraOrthoLeft,i.shadow.camera.right=a.shadow.cameraOrthoRight,i.shadow.camera.bottom=a.shadow.cameraOrthoBottom,i.shadow.camera.top=a.shadow.cameraOrthoTop),i.shadow.isDirectionalLightShadowCSM&&(i.shadow.maxDistance=a.shadow.csm.maxDistance)),i.shadow.camera.updateProjectionMatrix()):i.castShadow=!1,i.name=a.name||"light_"+r,this.lights[r]=i)}this.nodeGraphs={};var l=t.nodeGraphs||[];for(var c in l){var u=l[c];this.nodeGraphs[c]=u}}function $g(e){this.name=Kg.S8S_V3D_MATERIAL_DATA}Jg.prototype.loadCurves=function(e,t){var n=e.extensions&&e.extensions[Kg.S8S_V3D_DATA]||{};this.curves={};var r=n.curves||{};for(var i in r){var a=r[i];switch(a.type){case"font":var o=new Wd(a.font),s=0<a.bevelSize||0<a.bevelThickness,l=new Ci(new Yg(a.text,{font:o,size:a.size,height:a.height,curveSegments:a.curveSegments,bevelEnabled:s,bevelThickness:a.bevelThickness,bevelSize:a.bevelSize,bevelSegments:a.bevelSegments,alignX:a.alignX,alignY:a.alignY}),t&&t[a.material]?t[a.material]:new wc({color:new Lr(.8,.8,.8)}))}l&&(l.name=a.name||"curve_"+i,this.curves[i]=l)}},$g.prototype.extendParams=function(e,t,n){var r=t.extensions[this.name],i=[];if(Jr(r.nodeGraph)){var a=r.nodeGraph;e.nodeGraph=bu.nodeGraphFromExtGraph(a);for(var o=0;o<a.nodes.length;o++){var s=a.nodes[o];-1<qg.indexOf(s.type)&&(u=bu.nodeTexUniName(s.type,s.texture),i.push(n.assignTextureNode(e,u,s.texture)))}var l=n.extensions[Kg.S8S_V3D_DATA];if(l)for(var c in e.additionalNodeGraphs={},l.nodeGraphs){a=l.nodeGraphs[c];e.additionalNodeGraphs[c]=bu.nodeGraphFromExtGraph(a);for(o=0;o<a.nodes.length;o++){var u,s=a.nodes[o];-1<qg.indexOf(s.type)&&(u=bu.nodeTexUniName(s.type,s.texture),i.push(n.assignTextureNode(e,u,s.texture)))}}}return Jr(r.profile)&&(e.profile=r.profile),Jr(r.renderSide)&&(e.side=M_[r.renderSide]),Jr(r.useShadows)&&(e.receiveShadow=r.useShadows),Jr(r.useCastShadows)&&(e.castShadow=r.useCastShadows),Jr(r.depthWrite)&&(e.depthWrite=r.depthWrite),Jr(r.depthTest)&&(e.depthTest=r.depthTest),Jr(r.dithering)&&(e.dithering=r.dithering),Promise.all(i)};var e_="glTF",t_=12,n_={JSON:1313821514,BIN:5130562};function r_(e){this.name=Kg.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,t_);if(this.header={magic:S_(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==e_)throw new Error("v3d.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("v3d.GLTFLoader: Legacy binary file detected. Use GLTFLoader instead.");for(var n=new DataView(e,t_),r=0;r<n.byteLength;){var i=n.getUint32(r,!0);r+=4;var a,o,s=n.getUint32(r,!0);r+=4,s===n_.JSON?(a=new Uint8Array(e,t_+r,i),this.content=S_(a)):s===n_.BIN&&(o=t_+r,this.body=e.slice(o,o+i)),r+=i}if(null===this.content)throw new Error("v3d.GLTFLoader: JSON content not found.")}var i_=0,a_=1,o_=2,s_=3,l_=4,c_=5,u_=6,d_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},h_={9728:Je,9729:tt,9984:1004,9985:1007,9986:1005,9987:1008},p_={33071:Qe,33648:Ke,10497:Ze},f_={6406:h,6407:ut,6408:dt,6409:p,6410:f},m_={5121:it,32819:c,32820:u,33635:d},v_={32774:de,32778:he,32779:pe},g_={0:ge,1:_e,768:ye,769:xe,770:be,771:Me,772:we,773:Ae,774:Se,775:Te,776:Ee},__={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},y_={CATMULLROMSPLINE:Mt,CUBICSPLINE:Mt,LINEAR:bt,STEP:r},x_="OPAQUE",b_="MASK",M_={FRONT:re,BACK:Le,DOUBLE:ie};function w_(e,t,n){if(!e)return Promise.resolve();var r,i=[];if("[object Array]"===Object.prototype.toString.call(e)){r=[];for(var a,o=e.length,s=0;s<o;s++){(a=t.call(n||this,e[s],s))&&(i.push(a),a instanceof Promise?a.then(function(e,t){r[e]=t}.bind(this,s)):r[s]=a)}}else for(var l in r={},e){e.hasOwnProperty(l)&&(a=t.call(n||this,e[l],l))&&(i.push(a),a instanceof Promise?a.then(function(e,t){r[e]=t}.bind(this,l)):r[l]=a)}return Promise.all(i).then(function(){return r})}function A_(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:(t||"")+e}function S_(e){if(void 0!==window.TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);return t}function T_(e,t){var n=Jr(e.attributes.color)&&!t.isMeshNodeMaterial,r=void 0===e.attributes.normal,i=t.isMeshNodeMaterial&&(t.nodeValue.length||t.nodeRGB.length),a=t.morphTargets,o=t.isMeshNodeMaterial&&t.hasNode("TEX_COORD_BL");return n||r||i||a||o}function E_(e,t,n){this.json=e||{},this.extensions=t||{},this.options=n||{},this.onProgress=n.onProgress||function(){},this.cache=new Qg,this.clonedResources={materials:[]}}E_.prototype._withDependencies=function(e){for(var t=this,n={},r=0;r<e.length;r++){var i,a=e[r],o="load"+a.charAt(0).toUpperCase()+a.slice(1),s=t.cache.get(a);void 0!==s?n[a]=s:t[o]&&(i=new Promise(function(e){e(o)}).then(function(e){return t[e]()}),t.cache.add(a,i),n[a]=i)}return w_(n,function(e){return e})},E_.prototype.parse=function(f,e){var m=this,v=this.json;this.cache.removeAll(),this._withDependencies(["scenes","nodes","materials","cameras","animations","clonedMaterials"]).then(function(i){var e=[];i.scenes=i.scenes||[];for(var t=0;t<i.scenes.length;t++)e.push(i.scenes[t]);var n=Jr(v.scene)?v.scenes[v.scene]:v.scenes[0],r=Jr(v.scene)?i.scenes[v.scene]:e[0],a={};n&&(d=m.getExt(n,Kg.S8S_V3D_SCENE_DATA))&&Jr(d.worldMaterial)&&(a.material=i.materials[d.worldMaterial]),i.materials=i.materials||[],[].concat(i.materials,i.clonedMaterials).forEach(function(r){r.isMeshNodeMaterial&&r.traverseNodes(function(e){var t,n;"TEX_COORD_BL"!==e.originData.type||(t=i.nodes[e.originData.object])&&(n=r.nodeTexCoordObjectMap[e.originData.name],r.nodeTexCoordObject[n]=t)})});var o=[];i.cameras=i.cameras||[];for(t=0;t<i.cameras.length;t++){var s=i.cameras[t],l=!1;s.traverseAncestors(function(e){e==r&&(l=!0)}),l&&o.push(s)}var c=[];i.animations=i.animations||[];for(t=0;t<i.animations.length;t++){var u=i.animations[t];u.clip&&void 0!==u.clip.name&&(u.clip.name=u.clip.name),c.push(u)}var d,h,p={};if(n&&(d=m.getExt(n,Kg.S8S_V3D_SCENE_DATA))){if(Jr(d.shadowMap)){switch(p.shadowMap={enabled:!0},d.shadowMap.type){case"BASIC":p.shadowMap.type=Y;break;case"BILINEAR":p.shadowMap.type=ne;break;case"PCF":p.shadowMap.type=q;break;case"PCFSOFT":p.shadowMap.type=Z;break;case"PCFPOISSON":p.shadowMap.type=te;break;case"ESM":p.shadowMap.type=ee}h=d.shadowMap.renderSingleSided?d.shadowMap.renderReverseSided?Le:re:ie,r.traverse(function(e){var t=e.material;t&&(t.shadowSide=h)}),p.esmDistanceScale=d.shadowMap.esmDistanceScale}if(Jr(d.physicallyCorrectLights)&&(p.physicallyCorrectLights=d.physicallyCorrectLights),Jr(d.aaMethod)&&(p.aaMethod=d.aaMethod),Jr(d.useHDR)&&(p.useHDR=d.useHDR),Jr(d.unitsScaleFactor)?p.unitsScaleFactor=d.unitsScaleFactor:p.unitsScaleFactor=1,Jr(d.toneMapping))switch(d.toneMapping.type){case"logarithmicMax":p.toneMapping=Ue,p.toneMappingBrightness=d.toneMapping.brightness,p.toneMappingContrast=d.toneMapping.contrast,p.toneMappingMidTones=d.toneMapping.midTones,p.toneMappingPhysicalScale=d.toneMapping.physicalScale,p.toneMappingChromaticAdaptation=d.toneMapping.chromaticAdaptation,p.toneMappingWhiteColor=(new Lr).fromArray(d.toneMapping.whiteColor),p.toneMappingColorDifferentiation=d.toneMapping.colorDifferentiation,p.toneMappingExteriorDaylight=d.toneMapping.exteriorDaylight;break;case"physicalMax":p.toneMapping=Ve,p.toneMappingWhiteBalance=(new Lr).fromArray(d.toneMapping.whiteBalance),p.toneMappingHighlights=d.toneMapping.highlights,p.toneMappingMidTones=d.toneMapping.midTones,p.toneMappingShadows=d.toneMapping.shadows,p.toneMappingSaturation=d.toneMapping.saturation,p.toneMappingPhysicalScale=d.toneMapping.physicalScale,p.toneMappingAperture=d.toneMapping.aperture,p.toneMappingShutter=d.toneMapping.shutter,p.toneMappingISO=d.toneMapping.iso,p.toneMappingVignetting=d.toneMapping.vignetting;break;case"filmicBlender":p.toneMapping=ke}if(Jr(d.pmremMaxTileSize)&&(p.pmremMaxTileSize=d.pmremMaxTileSize),Jr(d.iblEnvironmentMode))switch(d.iblEnvironmentMode){case"PMREM":p.iblEnvironmentMode=Yt;break;case"PROBE_CUBEMAP":p.iblEnvironmentMode=1;break;case"PROBE":p.iblEnvironmentMode=2;break;default:p.iblEnvironmentMode=Yt}}f(r,e,a,o,c,p)}).catch(e)},E_.prototype.getDependency=function(e,t){var n,r=this,i=e+":"+t,a=r.cache.get(i);return a||(n="load"+e.charAt(0).toUpperCase()+e.slice(1),a=new Promise(function(e){e()}).then(function(){return r[n](t)}),r.cache.add(i,a)),a},E_.prototype.loadBuffer=function(e){var a=this,o=this.json.buffers[e];if(o.type&&"arraybuffer"!==o.type)throw new Error("v3d.GLTFLoader: %s buffer type is not supported.",o.type);if(void 0===o.uri&&0===e)return Promise.resolve(this.extensions[Kg.KHR_BINARY_GLTF].body);var s=this.options;return new Promise(function(e){var t,n;s.loadBinXZ?(t=A_(o.uri,s.path)+".xz",n=new Xg):(t=A_(o.uri,s.path),(n=new Gu).setResponseType("arraybuffer"));function r(e){var t;a.onProgress&&(t=100*(.3+.7*e),a.onProgress(t))}var i=n instanceof Gu?function(e){var t=e.lengthComputable?e.loaded/e.total:1;r(t)}:r;n.load(t,e,i)})},E_.prototype.loadBufferView=function(e){var r=this.json.bufferViews[e];return this.getDependency("buffer",r.buffer).then(function(e){var t=r.byteLength||0,n=r.byteOffset||0;return e.slice(n,n+t)})},E_.prototype.loadAccessors=function(){var e=this,s=this.json;return w_(s.accessors,function(o){return e.getDependency("bufferView",o.bufferView).then(function(e){var t=__[o.type],n=d_[o.componentType],r=n.BYTES_PER_ELEMENT,i=r*t,a=s.bufferViews[o.bufferView].byteStride;return a&&a!==i?new _s(new ms(new n(e),a/r),t,o.byteOffset/r):new Vr(new n(e,o.byteOffset,o.count*t),t)})})},E_.prototype.loadTexture=function(e){var t,n,a=this,r=this.json,o=this.options,i=(this.extensions,window.URL||window.webkitURL),s=r.textures[e],l=r.images[s.source],c=l.uri,u=!1,d=a.getExt(s,Kg.S8S_V3D_TEXTURE_DATA);return n=d?(t=!!d.isCubeTexture,"linear"==d.colorSpace||"non-color"==d.colorSpace?Tt:Et):(t=!1,Et),void 0!==l.bufferView&&(c=this.getDependency("bufferView",l.bufferView).then(function(e){u=!0;var t=new Blob([e],{type:l.mimeType});return c=i.createObjectURL(t)})),Promise.resolve(c).then(function(r){"hdr"!=r.split(".").pop()&&"image/vnd.radiance"!=l.mimeType||(n=Pt);var i=a.options.manager.getHandler(r);return(i=i||new(n==Pt?Hg:t?kv:qu)).setCrossOrigin(o.crossOrigin),new Promise(function(e,t){var n=i.load(A_(r,o.path),e,void 0,function(e){t(n)})}).then(function(e){return e},function(e){return e.isCubeTexture&&(e.images=new Array(6).fill(document.createElement("img"))),e})}).then(function(e){!0===u&&i.revokeObjectURL(c),e.flipY=!1,void 0!==s.name&&(e.name=s.name),e.format=void 0!==s.format?f_[s.format]:dt,void 0!==s.internalFormat&&e.format!==f_[s.internalFormat]&&console.warn("v3d.GLTFLoader: Three.js does not support texture internalFormat which is different from texture format. internalFormat will be forced to be the same value as format."),e.type=void 0!==s.type?m_[s.type]:it;var t=(r.samplers||{})[s.sampler]||{};return e.magFilter=h_[t.magFilter]||tt,e.minFilter=h_[t.minFilter]||1008,e.wrapS=p_[t.wrapS]||Ze,e.wrapT=p_[t.wrapT]||Ze,(e.encoding=n)==Pt&&(e.minFilter=tt,e.magFilter=tt),d&&(Jr(d.anisotropy)&&(e.anisotropy=d.anisotropy),Jr(d.uvTransform)&&(e.matrix=(new $t).fromArray(d.uvTransform),e.matrixAutoUpdate=!1)),e})},E_.prototype.assignTexture=function(t,n,e){return this.getDependency("texture",e).then(function(e){t[n]=e})},E_.prototype.assignTextureNode=function(t,n,e){return this.getDependency("texture",e).then(function(e){t.nodeTextures=t.nodeTextures||{},t.nodeTextures[n]=e})},E_.prototype.loadMaterials=function(){var p=this,e=this.json,f=this.extensions;return w_(e.materials,function(t){var n,e,r,i,a,o={},s=[],l=p.getExt(t,Kg.S8S_V3D_MATERIAL_DATA);Jr(t.pbrMetallicRoughness)?(n=wc,e=t.pbrMetallicRoughness,o.color=new Lr(1,1,1),o.opacity=1,Array.isArray(e.baseColorFactor)&&(r=e.baseColorFactor,o.color.fromArray(r),o.opacity=r[3]),Jr(e.baseColorTexture)&&s.push(p.assignTexture(o,"map",e.baseColorTexture.index)),o.metalness=Jr(e.metallicFactor)?e.metallicFactor:1,o.roughness=Jr(e.roughnessFactor)?e.roughnessFactor:1,Jr(e.metallicRoughnessTexture)&&(i=e.metallicRoughnessTexture.index,s.push(p.assignTexture(o,"metalnessMap",i)),s.push(p.assignTexture(o,"roughnessMap",i))),Jr(t.normalTexture)&&(s.push(p.assignTexture(o,"normalMap",t.normalTexture.index)),o.normalScale=new Jt(1,1),Jr(t.normalTexture.scale)&&o.normalScale.set(t.normalTexture.scale,t.normalTexture.scale)),Jr(t.occlusionTexture)&&(s.push(p.assignTexture(o,"aoMap",t.occlusionTexture.index)),Jr(t.occlusionTexture.strength)&&(o.aoMapIntensity=t.occlusionTexture.strength)),Jr(t.emissiveFactor)&&(o.emissive=(new Lr).fromArray(t.emissiveFactor)),Jr(t.emissiveTexture)&&s.push(p.assignTexture(o,"emissiveMap",t.emissiveTexture.index))):n=l?bu:wc,l&&(a=f[Kg.S8S_V3D_MATERIAL_DATA],s.push(a.extendParams(o,t,p))),!0===t.doubleSided&&(o.side=ie);var c,u=t.alphaMode||x_,d=u!==x_,h=u===b_;return o.premultipliedAlpha=d,o.transparent=d,o.alphaTest=h?Jr(t.alphaCutoff)?t.alphaCutoff:.5:0,d&&(l&&Jr(l.blendMode)?(c=l.blendMode,o.blending=ue,Jr(c.blendEquation)&&(o.blendEquation=v_[c.blendEquation]),Jr(c.blendEquationAlpha)&&(o.blendEquationAlpha=v_[c.blendEquationAlpha]),Jr(c.srcRGB)&&(o.blendSrc=g_[c.srcRGB]),Jr(c.dstRGB)&&(o.blendDst=g_[c.dstRGB]),Jr(c.srcAlpha)&&(o.blendSrcAlpha=g_[c.srcAlpha]),Jr(c.dstAlpha)&&(o.blendDstAlpha=g_[c.dstAlpha])):(o.blending=ue,o.blendEquation=de,o.blendSrc=_e,o.blendDst=Me)),Promise.all(s).then(function(){var e=new n(o);return void 0!==t.name&&(e.name=t.name),t.extras&&(e.userData.v3d=t.extras),(t.pbrMetallicRoughness||e.isMeshNodeMaterial)&&e.envMap&&(e.envMap.mapping=We,e.envMap.flipY=!0),e.isMeshStandardMaterial&&(e.map&&(e.map.encoding=Et),e.emissiveMap&&(e.emissiveMap.encoding=Et),e.normalScale&&l&&Jr(l.profile)&&"max"==l.profile&&(e.normalScale.y=-e.normalScale.y)),e})})},E_.prototype.loadClonedMaterials=function(){var e=this;return this._withDependencies(["meshes","nodes"]).then(function(){return Promise.resolve(e.clonedResources.materials)})},E_.prototype.loadGeometries=function(e){var s=this;return this._withDependencies(["accessors"]).then(function(o){return w_(e,function(e){var t=new ui,n=e.attributes;for(var r in n){var i=n[r];if(void 0===i)return;var a=o.accessors[i];switch(r){case"POSITION":t.setAttribute("position",a);break;case"NORMAL":t.setAttribute("normal",a);break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":t.setAttribute("uv",a);break;case"COLOR_0":case"COLOR0":case"COLOR":t.setAttribute("color",a);break;case"WEIGHTS_0":case"WEIGHT":t.setAttribute("skinWeight",a);break;case"JOINTS_0":case"JOINT":t.setAttribute("skinIndex",a);break;case"TANGENT":t.setAttribute("tangent",a);break;default:-1<r.indexOf("TEXCOORD_")&&t.setAttribute(s.texcoordToAttrName(r),a),-1<r.indexOf("COLOR_")&&t.setAttribute(s.colorToAttrName(r),a)}}return void 0!==e.indices&&t.setIndex(o.accessors[e.indices]),t})})},E_.prototype.loadMeshes=function(){var g=this,e=this.json;return this._withDependencies(["accessors","materials"]).then(function(v){return w_(e.meshes,function(d,h){var p=new as,f=d.primitives||[],m=g.getExt(d,Kg.S8S_V3D_MESH_DATA);return g.loadGeometries(f).then(function(e){for(var t=0;t<f.length;t++){var n,r=f[t],i=e[t],a=void 0===r.material?new wc({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:re,receiveShadow:!0,castShadow:!0}):v.materials[r.material];a.aoMap&&void 0===i.attributes.uv2&&void 0!==i.attributes.uv&&i.setAttribute("uv2",new Vr(i.attributes.uv.array,2)),n=!(!Jr(i.attributes.color)||a.isMeshNodeMaterial);var o,s,l,c=void 0===i.attributes.normal;if(a.isMeshNodeMaterial&&m){if(m.uvLayers)for(var u in m.uvLayers)a.nodeUVAliases[u]=g.texcoordToAttrName(m.uvLayers[u]);if(m.colorLayers)for(var u in m.colorLayers)a.nodeVCAliases[u]=g.colorToAttrName(m.colorLayers[u]);a.updateNodeGraph()}if(n&&(a.vertexColors=_,a.needsUpdate=!0),c&&(a.flatShading=!0),r.mode===l_||void 0===r.mode)l=new Ci(i,a);else if(r.mode===c_)(l=new Ci(i,a)).drawMode=1;else if(r.mode===u_)(l=new Ci(i,a)).drawMode=2;else if(r.mode===a_){l=m?((o=new Av).fromBufferGeometry(i),s=new Tv({color:Jr(m.lineColor)?(new Lr).fromArray(m.lineColor):new Lr(1,1,1),lineWidth:Jr(m.lineWidth)?m.lineWidth:1,sizeAttenuation:0}),new Ci(o.geometry,s)):new nl(i,a)}else if(r.mode===s_)l=new $s(i,a);else if(r.mode===o_)l=new rl(i,a);else{if(r.mode!==i_)throw new Error("v3d.GLTFLoader: Primitive mode unsupported: ",r.mode);l=new cl(i,a)}if(l.name=d.name||"mesh_"+h,void 0!==r.targets&&function(e,t,n,r){var i=e.geometry,a=e.material,o=n.targets,s=i.morphAttributes;s.position=[],s.normal=[],a.morphTargets=!0;for(var l=0,c=o.length;l<c;l++){var u,d,h=o[l],p=Jr(t.extras)&&Jr(t.extras.targetNames)?t.extras.targetNames[l]:"morphTarget"+l;if(void 0!==h.POSITION){u=r.accessors[h.POSITION].clone();for(var f=i.attributes.position,m=0,v=u.count;m<v;m++)u.setXYZ(m,u.getX(m)+f.getX(m),u.getY(m)+f.getY(m),u.getZ(m)+f.getZ(m))}else u=i.attributes.position.clone();if(void 0!==h.NORMAL){a.morphNormals=!0,d=r.accessors[h.NORMAL].clone();for(var g=i.attributes.normal,m=0,v=d.count;m<v;m++)d.setXYZ(m,d.getX(m)+g.getX(m),d.getY(m)+g.getY(m),d.getZ(m)+g.getZ(m))}else d=i.attributes.normal.clone();h.TANGENT,u.name=p,d.name=p,s.position.push(u),s.normal.push(d)}if(e.updateMorphTargets(),void 0!==t.weights)for(l=0,c=t.weights.length;l<c;l++)e.morphTargetInfluences[l]=t.weights[l]}(l,d,r,v),T_(l.geometry,l.material)&&(l.material=l.material.clone(),g.clonedResources.materials.push(l.material)),!(1<f.length))return l;l.name+="_"+t,l.isMaterialGeneratedMesh=!0,p.add(l)}return p})})})},E_.prototype.loadCameras=function(){var e=this.json,o=this;return w_(e.cameras,function(e){var t,n,r,i=e[e.type];if(i){"perspective"===e.type?(t=i.aspectRatio||1,n=i.yfov,r=new Xi(Kt.radToDeg(n),t,i.znear||1,i.zfar||2e6)):"orthographic"===e.type&&(r=new na(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),Jr(e.name)&&(r.name=e.name);var a=o.getExt(e,Kg.S8S_V3D_CAMERA_DATA);if(a){if(r.controls={},r.controls.type=a.controls,r.viewportFit.type=3,Jr(a.viewportFitType))switch(a.viewportFitType){case"VERTICAL":r.viewportFit.type=1;break;case"HORIZONTAL":r.viewportFit.type=2;break;case"AUTO":r.viewportFit.type=3}Jr(a.viewportFitInitialAspect)&&(r.viewportFit.initialAspect=a.viewportFitInitialAspect),Jr(a.enablePan)?r.controls.enablePan=a.enablePan:r.controls.enablePan=!0,Jr(a.rotateSpeed)?r.controls.rotateSpeed=a.rotateSpeed:r.controls.rotateSpeed=1,Jr(a.moveSpeed)?r.controls.moveSpeed=a.moveSpeed:r.controls.moveSpeed=1,Jr(a.orbitMinDistance)&&(r.controls.orbitMinDistance=a.orbitMinDistance),Jr(a.orbitMaxDistance)&&(r.controls.orbitMaxDistance=a.orbitMaxDistance),Jr(a.orbitMinPolarAngle)&&(r.controls.orbitMinPolarAngle=a.orbitMinPolarAngle),Jr(a.orbitMaxPolarAngle)&&(r.controls.orbitMaxPolarAngle=a.orbitMaxPolarAngle),Jr(a.orbitMinAzimuthAngle)?r.controls.orbitMinAzimuthAngle=a.orbitMinAzimuthAngle:r.controls.orbitMinAzimuthAngle=-1/0,Jr(a.orbitMaxAzimuthAngle)?r.controls.orbitMaxAzimuthAngle=a.orbitMaxAzimuthAngle:r.controls.orbitMaxAzimuthAngle=1/0,Jr(a.orbitTarget)&&(a.orbitTarget instanceof Array?(r.controls.orbitTarget=new Bn,r.controls.orbitTarget.position.fromArray(a.orbitTarget)):o._withDependencies(["nodes"]).then(function(e){r.controls.orbitTarget=e.nodes[a.orbitTarget]})),Jr(a.fpsCollisionMaterial)?r.controls.collisionMaterial=a.fpsCollisionMaterial:r.controls.collisionMaterial=null,Jr(a.fpsGazeLevel)?r.controls.gazeLevel=a.fpsGazeLevel:r.controls.gazeLevel=1.8,Jr(a.fpsStoryHeight)?r.controls.storyHeight=a.fpsStoryHeight:r.controls.storyHeight=3}return e.extras&&(r.userData.v3d=e.extras),r}console.warn("v3d.GLTFLoader: Missing camera parameters.")})},E_.prototype.loadSkins=function(){var e=this.json;return this._withDependencies(["accessors"]).then(function(t){return w_(e.skins,function(e){return{joints:e.joints,inverseBindMatrices:t.accessors[e.inverseBindMatrices]}})})},E_.prototype.loadAnimations=function(){var R=this,e=this.json;return this._withDependencies(["accessors","materials","nodes"]).then(function(L){return w_(e.animations,function(e,t){for(var n=[],r=-1,i=0;i<e.channels.length;i++){var a=e.channels[i],o=e.samplers[a.sampler];if(o&&-1<o.input&&-1<o.output){var s=a.target,l=void 0!==s.node?s.node:s.id,c=void 0!==e.parameters?e.parameters[o.input]:o.input,u=void 0!==e.parameters?e.parameters[o.output]:o.output,d=L.accessors[c];if(d.count<=1)continue;var h=L.accessors[u],p=L.nodes[l];if(p){r=p.id;p.updateMatrix(),p.matrixAutoUpdate=!0;var f="";switch(s.path){case"weights":m=Lu,f="morphTargetInfluences";break;case"rotation":m=Du,f="quaternion";break;case"translation":m=Iu,f="position";break;case"scale":m=Iu,f="scale";break;case"intensity":m=Lu,f="intensity";break;default:var m=Iu;-1<s.path.indexOf("nodeValue")?f="material.nodeValue["+s.path.match(/".*"/g)[0]+"]":-1<s.path.indexOf("nodeRGB")&&(f="material.nodeRGB["+s.path.match(/".*"/g)[0]+"]")}var v=p.name?p.name:p.uuid;"CATMULLROMSPLINE"==o.interpolation&&console.warn("v3d.GLTFLoader: CATMULLROMSPLINE interpolation is not supported. Using CUBICSPLINE instead.");var g=Jr(o.interpolation)?y_[o.interpolation]:bt,_=[];"weights"==s.path?p.traverse(function(e){e.isMesh&&e.material.morphTargets&&_.push(e.name?e.name:e.uuid)}):-1<s.path.indexOf("material")?p.traverse(function(e){var t,n;e.isMesh&&e.material.isMeshNodeMaterial&&(n=!1,(n=!s.extras||(n=L.materials[s.extras.material].name===e.material.name,t=s.path.match(/\["(.*)"\]/),n&&null!==t&&null!==e.material.findNodeByName(t[1])))&&_.push(e.name?e.name:e.uuid))}):_.push(v);for(var y=0,x=_.length;y<x;y++){var b=Su.arraySlice(d.array,0),M=Su.arraySlice(h.array,0);if(g==Mt){for(var w=new M.constructor(M.length/3),A=w.length/b.length,S=0;S<w.length/A;S++)for(var T=0;T<A;T++)w[A*S+T]=M[3*A*S+A+T];g=bt,M=w}n.push(new m(_[y]+"."+f,b,M,g))}}}}var E={clip:new Ou(l=Jr(e.name)?e.name:"animation_"+t,void 0,n),nodeId:r,auto:!0,loop:2201,repetitions:1/0,startAt:0},C=R.getExt(e,Kg.S8S_V3D_ANIMATION_DATA);if(C){E.auto=C.auto;var P=C.repeatInfinite?1/0:C.repeatCount;switch(C.loop){case"ONCE":E.loop=2200;break;case"REPEAT":E.loop=2201,E.repetitions=P;break;case"PING_PONG":E.loop=2202,E.repetitions=P}E.startAt=C.offset}return E})})},E_.prototype.loadNodes=function(){var x=this.json,b=this,t=x.nodes||[],e=x.skins||[],n={},r={};for(var i in e.forEach(function(e){e.joints.forEach(function(e){t[e].isBone=!0})}),t){var a=t[i];Jr(a.mesh)&&(Jr(n[a.mesh])||(n[a.mesh]=r[a.mesh]=0),n[a.mesh]++)}return b._withDependencies(["materials","meshes","skins","cameras"]).then(function(y){var e=b.getExt(b,Kg.S8S_V3D_DATA);return e&&e.loadCurves(x,y.materials),w_(x.nodes,function(e){var t=b.getExt(e,Kg.S8S_V3D_NODE_DATA);if(!0===e.isBone)return new ks;if(void 0===e.mesh)return void 0!==e.camera?y.cameras[e.camera]:t&&Jr(t.curve)?b.getExt(b,Kg.S8S_V3D_DATA).curves[t.curve]:t&&Jr(t.light)?b.getExt(b,Kg.S8S_V3D_DATA).lights[t.light].clone():new Bn;var n=y.meshes[e.mesh];return 0<r[e.mesh]&&((n=n.clone()).name+="_instance_"+r[e.mesh],void 0!==n.geometry&&void 0!==n.material&&T_(n.geometry,n.material)&&(n.material=n.material.clone(),b.clonedResources.materials.push(n.material))),r[e.mesh]++,n}).then(function(_){return w_(_,function(d,e){var h=x.nodes[e];if(Jr(h.skin)){for(var t=[],n=0<d.children.length?d.children:[d],r=0;r<n.length;r++){var i=n[r];if(i.isMesh){var a=y.skins[h.skin],o=i.geometry,s=i.material.clone();b.clonedResources.materials.push(s),s.skinning=!0;var l=new Bs(o,s);l.morphTargetInfluences=i.morphTargetInfluences,l.name=i.name,l.isMaterialGeneratedMesh=i.isMaterialGeneratedMesh;for(var c=[],u=[],p=0,f=a.joints.length;p<f;p++){var m,v=a.joints[p],g=_[v];g?(c.push(g),m=new _n,Jr(a.inverseBindMatrices)&&m.fromArray(a.inverseBindMatrices.array,16*p),u.push(m)):console.warn('v3d.GLTFLoader: Joint "%s" could not be found.',v)}l.bind(new Vs(c,u),l.matrixWorld),t.push(l)}}t.length&&(0<d.children.length?(d.remove.apply(d,d.children),d.add.apply(d,t)):d=t[0])}return d.traverse(function(e){var t,n=d==e,r=b.getExt(h,Kg.S8S_V3D_NODE_DATA);if(n){void 0!==h.name&&(e.name=h.name),void 0!==h.matrix?((t=new _n).fromArray(h.matrix),e.applyMatrix4(t)):(void 0!==h.translation&&e.position.fromArray(h.translation),void 0!==h.rotation&&e.quaternion.fromArray(h.rotation),void 0!==h.scale&&e.scale.fromArray(h.scale));var i=r&&r.target?_[r.target]:null;if((e.isDirectionalLight||e.isSpotLight||e.isHemisphereLight)&&(i?(e.target=i,e.isFreeLight=!1):e.isFreeLight=!0),e.isCamera&&e.controls&&"FIRST_PERSON"==e.controls.type&&(e.controls.collisionMaterial=y.materials[e.controls.collisionMaterial]),r&&r.hidden&&(e.visible=!1),r&&Jr(r.constraints))for(var a=0;a<r.constraints.length;a++){var o,s,l,c=r.constraints[a];"lockedTrack"==c.type?(c.trackAxis=c.trackAxis.toUpperCase(),c.lockAxis=c.lockAxis||"Y"):"trackTo"==c.type?(c.trackAxis=c.trackAxis.toUpperCase(),c.upAxis=c.upAxis||"Y"):"floor"==c.type?c.floorLocation=c.floorLocation.toUpperCase():"copyTransforms"==c.type&&(o=new Hm(i=_[c.target]),s=new Ym(i),l=new qm(i),o.name=s.name=l.name=c.name,o.mute=s.mute=l.mute=c.mute,e.constraints.push(o),e.constraints.push(s),e.constraints.push(l));var u=null;switch(c.type){case"copyLocation":u=new Hm(_[c.target]);break;case"copyRotation":u=new Ym(_[c.target]);break;case"copyScale":u=new qm(_[c.target]);break;case"limitLocation":(u=new Qm).min.set(Number(c.minX),Number(c.minY),Number(c.minZ)),u.max.set(Number(c.maxX),Number(c.maxY),Number(c.maxZ));break;case"limitRotation":(u=new Km).axis=c.axis,u.min=c.min,u.max=c.max;break;case"limitScale":(u=new Jm).min.set(Number(c.minX),Number(c.minY),Number(c.minZ)),u.max.set(Number(c.maxX),Number(c.maxY),Number(c.maxZ));break;case"lockedTrack":(u=new $m(_[c.target])).trackAxis=c.trackAxis,u.lockAxis=c.lockAxis;break;case"trackTo":(u=new ev(_[c.target])).trackAxis=c.trackAxis,u.upAxis=c.upAxis;break;case"childOf":(u=new Xm(_[c.target])).offsetMatrix=(new _n).fromArray(c.offsetMatrix);break;case"floor":(u=new Zm(_[c.target])).floorLocation=c.floorLocation,u.offset=c.offset}u&&(u.name=c.name,u.mute=c.mute,e.constraints.push(u))}}e.isMesh&&(r&&Jr(r.useCastShadows)?e.castShadow=r.useCastShadows:Jr(e.material.castShadow)&&(e.castShadow=e.material.castShadow),r&&Jr(r.useShadows)?e.receiveShadow=r.useShadows:Jr(e.material.receiveShadow)&&(e.receiveShadow=e.material.receiveShadow)),h.extras&&(e.userData.v3d=h.extras),r&&(e.renderOrder=r.renderOrder,e.frustumCulled=r.frustumCulling,Jr(r.groupNames)?e.groupNames=r.groupNames:e.groupNames=[])}),d})})})},E_.prototype.loadScenes=function(){var c=this.json,l=this,u=this.extensions;return this._withDependencies(["nodes"]).then(function(s){return w_(c.scenes,function(e){var t=new zn;Jr(e.name)&&(t.name=e.name),e.extras&&(t.userData.v3d=e.extras);for(var n=e.nodes||[],r=0,i=n.length;r<i;r++){!function e(t,n,r){var i=r[t];n.add(i),(i.isDirectionalLight||i.isSpotLight||i.isHemisphereLight)&&i.isFreeLight&&n.add(i.target);var a=c.nodes[t];if(a.children)for(var o=a.children,s=0,l=o.length;s<l;s++)e(o[s],i,r)}(n[r],t,s.nodes)}var a,o=l.getExt(e,Kg.S8S_V3D_SCENE_DATA);return o&&(Jr(o.light)&&(a=u[Kg.S8S_V3D_DATA].lights,t.add(a[o.light])),Jr(o.postprocessing)&&(t.postprocessing=o.postprocessing)),t})})},E_.prototype.getExt=function(e,t){return e.extensions&&e.extensions[t]?e.extensions[t]:null},E_.prototype.texcoordToAttrName=function(e){return"TEXCOORD_0"==e?"uv":"uv"+String(Number(e.split("TEXCOORD_")[1])+1)},E_.prototype.colorToAttrName=function(e){return"COLOR_0"==e?"color":"color"+String(Number(e.split("COLOR_")[1])+1)};var C_=256,P_=[{relSize:1,sigma:0,origin:[0,0]},{relSize:.5,sigma:.025,origin:[0,2/3]},{relSize:.25,sigma:.07,origin:[.5,2/3]},{relSize:1/8,sigma:.18,origin:[.75,2/3]},{relSize:1/16,sigma:.24,origin:[.875,2/3]},{relSize:1/16,sigma:.3,origin:[.875,17/24]},{relSize:1/16,sigma:.36,origin:[.875,.75]},{relSize:1/16,sigma:.42,origin:[.875,19/24]},{relSize:1/16,sigma:.48,origin:[.875,20/24]},{relSize:1/16,sigma:.54,origin:[.875,.875]},{relSize:1/16,sigma:.6,origin:[.875,22/24]}];function L_(e){return P_[e].relSize*C_}var R_,D_,N_,I_,O_,F_=20,B_=(_defineProperty(n={},Tt,0),_defineProperty(n,Et,1),_defineProperty(n,Pt,2),_defineProperty(n,Rt,3),_defineProperty(n,Dt,4),_defineProperty(n,Nt,5),_defineProperty(n,Ct,6),n),z_=new na,U_=(R_=F_,D_=C_,N_=new Float32Array(R_),I_=new un(0,1,0),(O_=new Mc({defines:{n:R_,cubeUV_maxTileSize:ti(D_)},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:N_},latitudinal:{value:!1},dTheta:{value:0},lodIdx:{value:0},poleAxis:{value:I_},inputEncoding:{value:B_[Tt]},outputEncoding:{value:B_[Tt]}},vertexShader:oy(),fragmentShader:"\nprecision highp float;\nprecision highp int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float lodIdx;\nuniform vec3 poleAxis;\n\n".concat(sy(),"\n\n#define ENVMAP_TYPE_CUBE_UV\n#include <cube_uv_reflection_fragment>\n\nvec3 getSample(float theta, vec3 axis) {\n float cosTheta = cos(theta);\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross(axis, vOutputDirection) * sin(theta)\n + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n return bilinearCubeUV(envMap, sampleDirection, lodIdx);\n}\n\nvoid main() {\n vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n if (all(equal(axis, vec3(0.0))))\n axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n axis = normalize(axis);\n gl_FragColor = vec4(0.0);\n gl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n for (int i = 1; i < n; i++) {\n if (i >= samples)\n break;\n float theta = dTheta * float(i);\n gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n gl_FragColor.rgb += weights[i] * getSample(theta, axis);\n }\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n "),blending:ae,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",O_),V_=null,k_=null,G_=P_.map(function(e,t){for(var n=1/(L_(t)-1),r=-n/2,i=1+n/2,a=[r,r,i,r,i,i,r,r,i,i,r,i],o=new Float32Array(108),s=new Float32Array(72),l=new Float32Array(36),c=0;c<6;c++){var u=c%3*2/3-1,d=2<c?0:-1,h=[u,d,0,u+2/3,d,0,u+2/3,1+d,0,u,d,0,u+2/3,1+d,0,u,1+d,0];o.set(h,18*c),s.set(a,12*c);var p=[c,c,c,c,c,c];l.set(p,6*c)}var f=new ui;return f.setAttribute("position",new Vr(o,3)),f.setAttribute("uv",new Vr(s,2)),f.setAttribute("faceIndex",new Vr(l,1)),f}),j_=null,W_=null,X_=null,H_=(1+Math.sqrt(5))/2,Y_=1/H_,q_=[new un(1,1,1),new un(-1,1,1),new un(1,1,-1),new un(-1,1,-1),new un(0,H_,Y_),new un(0,H_,-Y_),new un(Y_,0,H_),new un(-Y_,0,H_),new un(H_,Y_,0),new un(-H_,Y_,0)];function Z_(e){this.flipCubemapX=!0,W_=e,J_(U_),Object.defineProperty(this,"maxTileSize",{get:function(){return C_},set:function(e){C_=e}})}function Q_(e,t){var n={magFilter:Je,minFilter:Je,generateMipmaps:!1,type:e?e.type:it,format:e?e.format:S,encoding:e?e.encoding:Pt,depthBuffer:!1,stencilBuffer:!1};Object.assign(n,t);var r=$_(n);return r.depthBuffer=!e,j_=$_(n),r}function K_(e){j_.dispose(),W_.setRenderTarget(X_),e.scissorTest=!1,e.setSize(e.width,e.height)}function J_(e){var t=new zn;t.add(new Ci(G_[0],e)),W_.compile(t,z_)}function $_(e){var t=L_(0),n=new an(3*t,3*t,e);return n.texture.mapping=Ye,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ey(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function ty(e){var t=W_.autoClear;W_.autoClear=!1;for(var n=1;n<P_.length;n++){var r=P_[n].sigma,i=P_[n-1].sigma;ny(e,n-1,n,Math.sqrt(r*r-i*i),q_[(n-1)%q_.length])}W_.autoClear=t}function ny(e,t,n,r,i){ry(e,j_,t,n,r,"latitudinal",i),ry(j_,e,n,n,r,"longitudinal",i)}function ry(e,t,n,r,i,a,o){"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");var s=new zn;s.add(new Ci(G_[r],U_));var l=U_.uniforms,c=L_(n)-1,u=isFinite(i)?Math.PI/(2*c):2*Math.PI/(2*F_-1),d=i/u,h=isFinite(i)?1+Math.floor(3*d):F_;F_<h&&(u=i/(d=((h=F_)-1)/3));for(var p=[],f=0,m=0;m<F_;++m){var v=m/d,g=Math.exp(-v*v/2);p.push(g),0==m?f+=g:m<h&&(f+=2*g)}for(m=0;m<p.length;m++)p[m]=p[m]/f;l.envMap.value=e.texture,l.samples.value=h,l.weights.value=p,l.latitudinal.value="latitudinal"===a,o&&(l.poleAxis.value=o),l.dTheta.value=u,l.lodIdx.value=n,l.inputEncoding.value=B_[e.texture.encoding],l.outputEncoding.value=B_[e.texture.encoding],U_.defines.cubeUV_maxTileSize=ti(L_(0));var _=_slicedToArray(P_[r].origin.map(function(e){return e*C_*3}),2),v=_[0],y=_[1],x=L_(r);ey(t,v,y,3*x,2*x),W_.setRenderTarget(t),W_.render(s,z_)}function iy(){var e=new Mc({uniforms:{envMap:{value:null},texelSize:{value:new Jt(1,1)},inputEncoding:{value:B_[Tt]},outputEncoding:{value:B_[Tt]}},vertexShader:oy(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n".concat(sy(),"\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n gl_FragColor = vec4(0.0);\n vec3 outputDirection = normalize(vOutputDirection);\n vec2 uv;\n uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n vec2 f = fract(uv / texelSize - 0.5);\n uv -= f * texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize.x;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize.y;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize.x;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n gl_FragColor.rgb = mix(tm, bm, f.y);\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n "),blending:ae,depthTest:!1,depthWrite:!1});return e.type="EquirectangularToCubeUV",e}function ay(){var e=new Mc({uniforms:{envMap:{value:null},inputEncoding:{value:B_[Tt]},outputEncoding:{value:B_[Tt]},flipCubemapX:{value:!0}},vertexShader:oy(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\nuniform bool flipCubemapX;\n\n".concat(sy(),"\n\nvoid main() {\n gl_FragColor = vec4(0.0);\n gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3(vOutputDirection.x * (flipCubemapX ? -1.0 : 1.0), vOutputDirection.yz))).rgb;\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n "),blending:ae,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function oy(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n uv = 2.0 * uv - 1.0;\n vec3 direction = vec3(uv, 1.0);\n if (face == 0.0) {\n direction = direction.zyx;\n direction.z *= -1.0;\n } else if (face == 1.0) {\n direction = direction.xzy;\n direction.z *= -1.0;\n } else if (face == 3.0) {\n direction = direction.zyx;\n direction.x *= -1.0;\n } else if (face == 4.0) {\n direction = direction.xzy;\n direction.y *= -1.0;\n } else if (face == 5.0) {\n direction.xz *= -1.0;\n }\n return direction;\n}\nvoid main() {\n vOutputDirection = getDirection(uv, faceIndex);\n gl_Position = vec4(position, 1.0);\n}\n "}function sy(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include <encodings_pars_fragment>\n\nvec4 inputTexelToLinear(vec4 value){\n if(inputEncoding == 0){\n return value;\n }else if(inputEncoding == 1){\n return sRGBToLinear(value);\n }else if(inputEncoding == 2){\n return RGBEToLinear(value);\n }else if(inputEncoding == 3){\n return RGBMToLinear(value, 7.0);\n }else if(inputEncoding == 4){\n return RGBMToLinear(value, 16.0);\n }else if(inputEncoding == 5){\n return RGBDToLinear(value, 256.0);\n }else{\n return GammaToLinear(value, 2.2);\n }\n}\n\nvec4 linearToOutputTexel(vec4 value){\n if(outputEncoding == 0){\n return value;\n }else if(outputEncoding == 1){\n return LinearTosRGB(value);\n }else if(outputEncoding == 2){\n return LinearToRGBE(value);\n }else if(outputEncoding == 3){\n return LinearToRGBM(value, 7.0);\n }else if(outputEncoding == 4){\n return LinearToRGBM(value, 16.0);\n }else if(outputEncoding == 5){\n return LinearToRGBD(value, 256.0);\n }else{\n return LinearToGamma(value, 2.2);\n }\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n return inputTexelToLinear(color);\n}\n "}function ly(e,t,n,r,i){this._domElement=e,this._keyCode=t,this._callback=n,this._repeats=r,this._period=i,this._timer=0,this._counter=0,this._keydownCb=function(e){e.keyCode==this._keyCode&&(this._timer||(this._timer=window.setTimeout(function(){this._counter=0,this._timer=null}.bind(this),1e3*i)),++this._counter>=r&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}function cy(e){this.data=void 0!==e?e:null,this.equirecInvertU=!1,this.equirecOffsetU=0,this.useHDR=!1}Z_.prototype={constructor:Z_,fromScene:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.1,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:100;X_=W_.getRenderTarget();var i=Q_();return function(e,t,n,r){var i=new Xi(90,1,t,n),a=[1,1,1,1,-1,1],o=[1,1,-1,-1,-1,1],s=W_.outputEncoding,l=W_.toneMapping,c=W_.toneMappingExposure,u=W_.getClearColor(),d=W_.getClearAlpha();W_.toneMapping=ze,W_.toneMappingExposure=1,W_.outputEncoding=Tt,e.scale.z*=-1;var h=e.background;{var p,f,m;h&&h.isColor&&(h.convertSRGBToLinear(),p=Math.max(h.r,h.g,h.b),f=Math.min(Math.max(Math.ceil(Math.log2(p)),-128),127),h=h.multiplyScalar(Math.pow(2,-f)),m=(f+128)/255,W_.setClearColor(h,m),e.background=null)}for(var v=0;v<6;v++){var g=v%3;0==g?(i.up.set(0,a[v],0),i.lookAt(o[v],0,0)):1==g?(i.up.set(0,0,a[v]),i.lookAt(0,o[v],0)):(i.up.set(0,a[v],0),i.lookAt(0,0,o[v]));var _=L_(0);ey(r,g*_,2<v?_:0,_,_),W_.setRenderTarget(r),W_.render(e,i)}W_.toneMapping=l,W_.toneMappingExposure=c,W_.outputEncoding=s,W_.setClearColor(u,d),e.scale.z*=-1}(e,n,r,i),0<t&&ny(i,0,0,t),ty(i),K_(i),i},fromEquirectangular:function(e){return e.magFilter=Je,e.minFilter=Je,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){X_=W_.getRenderTarget();var t=Q_(e);return function(e,t,n){var r=new zn;e.isCubeTexture?null==k_&&(k_=ay()):null==V_&&(V_=iy());var i=e.isCubeTexture?k_:V_;r.add(new Ci(G_[0],i));var a=i.uniforms;(a.envMap.value=e).isCubeTexture?a.flipCubemapX.value=n||!1:a.texelSize.value.set(1/e.image.width,1/e.image.height);a.inputEncoding.value=B_[e.encoding],a.outputEncoding.value=B_[e.encoding];var o=L_(0);ey(t,0,0,3*o,2*o),W_.setRenderTarget(t),W_.render(r,z_)}(e,t,this.flipCubemapX),ty(t),K_(t),t},fromCubeRenderTarget:function(e,t){var n=Q_(e.texture,t);return function(e,t,n){var r=new zn;null==k_&&(k_=ay());var i=k_;r.add(new Ci(G_[0],i));var a=i.uniforms;a.envMap.value=e.texture,a.flipCubemapX.value=n||!1,a.inputEncoding.value=B_[e.texture.encoding],a.outputEncoding.value=B_[t.texture.encoding];var o=L_(0);ey(t,0,0,3*o,2*o),W_.setRenderTarget(t),W_.render(r,z_)}(e,n,this.flipCubemapX),ty(n),K_(n),n},compileCubemapShader:function(){null==k_&&J_(k_=ay())},compileEquirectangularShader:function(){null==V_&&J_(V_=iy())},dispose:function(){U_.dispose(),null!=k_&&k_.dispose(),null!=V_&&V_.dispose();for(var e=0;e<G_.length;e++)G_[e].dispose()}},Object.assign(ly.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._timer&&window.clearTimeout(this._timer)}}),Object.assign(cy.prototype,{isSceneBackground:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(e){null===e.data?this.data=null:e.data.isColor?this.data=e.data.clone():e.data.isCubeTexture||e.data.isTexture?(this.data=e.data.clone(),this.data.needsUpdate=!0):e.data.isWebGLCubeRenderTarget?(this.data=e.data.clone(),this.data.texture.needsUpdate=!0):this.data=e.data,this.equirecInvertU=e.equirecInvertU,this.equirecOffsetU=e.equirecOffsetU,this.useHDR=e.useHDR},toJSON:function(e){var t={metadata:{version:4.5,type:"SceneBackground",generator:"SceneBackground.toJSON"}};return null!==this.data&&(t.data=this.data.toJSON(e)),!0===this.equirecInvertU&&(t.equirecInvertU=!0),0!==this.equirecOffsetU&&(t.equirecOffsetU=this.equirecOffsetU),t}});var uy={createMultiMaterialObject:function(e,t){for(var n=new as,r=0,i=t.length;r<i;r++)n.add(new Ci(e,t[r]));return n},detach:function(e,t,n){e.applyMatrix(t.matrixWorld),t.remove(e),n.add(e)},attach:function(e,t,n){e.applyMatrix((new _n).getInverse(n.matrixWorld)),t.remove(e),n.add(e)},getMaterialByName:function(e,t){var n=this.getMaterialsByName(e,t);return n.length?n[0]:null},getMaterialsByName:function(e,t){for(var n=[],r=0;r<e.materials.length;r++){var i=e.materials[r];i.name==t&&n.push(i)}var a=e.worldMaterial;return a&&a.name==t&&n.push(a),n},getAnimationActionByName:function(e,t){for(var n=0;n<e.actions.length;n++){var r=e.actions[n];if(r.getClip().name==t)return r}return null},checkActionIsUsed:function(n,e){return Boolean(e._propertyBindings.find(function(e){var t=e.binding.node;return t&&t.findRoot()===n}))},createEnvironmentMaterial:function(e,t,n){var r,i=new Ic.DiGraph(6),a={};return i.node(0).originData={name:"Light Path",type:"LIGHT_PATH_BL",inputs:[],outputs:[0,0,0,0,0,0,0,0,0,0,0,0,0],is_active_output:!1},i.node(1).originData={name:"Lighting Texture",type:"TEX_ENVIRONMENT_BL",projection:"EQUIRECTANGULAR",inputs:[[0,0,0]],outputs:[[0,0,0,0]],texture:0,is_active_output:!1},a[bu.nodeTexUniName("TEX_ENVIRONMENT_BL",0)]=t,n instanceof Lr?((r=[0,0,0,0])[0]=n.r,r[1]=n.g,r[2]=n.b,r[3]=1,i.node(2).originData={name:"Background Color",type:"RGB_BL",inputs:[],outputs:[r],is_active_output:!1}):(i.node(2).originData={name:"Background Texture",type:"TEX_ENVIRONMENT_BL",projection:"EQUIRECTANGULAR",inputs:[[0,0,0]],outputs:[[0,0,0,0]],texture:1,is_active_output:!1},a[bu.nodeTexUniName("TEX_ENVIRONMENT_BL",1)]=n),i.node(3).originData={name:"Mix",type:"MIX_RGB_BL",blendType:"MIX",inputs:[0,[0,0,0,0],[0,0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1},i.node(4).originData={name:"Background",type:"BACKGROUND_BL",inputs:[[0,0,0,0],1],outputs:[[0,0,0,0]],is_active_output:!1},i.node(5).originData={name:"Output",type:"OUTPUT_WORLD_BL",inputs:[[0,0,0,0],[0,0,0,0]],outputs:[],is_active_output:!0},Mu(i,0,0,3,0),Mu(i,1,0,3,1),Mu(i,2,0,3,2),Mu(i,3,0,4,0),Mu(i,4,0,5,0),new bu({name:e,nodeGraph:i,nodeTextures:a})},calcSceneBox:function(e){var t=new Jn;return t.expandByObject(e),t},createDefaultCamera:function(e,t){var n=new un,r=2*e.getSize(n).length(),i=new Xi(45,t,r/1e4,r);return i.position.copy(e.max).multiplyScalar(2),i.lookAt(e.getCenter(n)),i},assignDefaultControls:function(e,t){var n=new Bn;t.getCenter(n.position),e.controls={type:"ORBIT",enablePan:!0,rotateSpeed:1,moveSpeed:1,orbitMinDistance:e.near,orbitMaxDistance:e.far,orbitMinPolarAngle:0,orbitMaxPolarAngle:Math.PI,orbitMinAzimuthAngle:-1/0,orbitMaxAzimuthAngle:1/0,orbitTarget:n}}},dy=function(){var n=0,r=document.createElement("div");function e(e){return r.appendChild(e.dom),e}function t(e){for(var t=0;t<r.children.length;t++)r.children[t].style.display=t===e?"block":"none";n=e}r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(e){e.preventDefault(),t(++n%r.children.length)},!1);var i,a=(performance||Date).now(),o=a,s=0,l=e(new dy.Panel("FPS","#0ff","#002")),c=e(new dy.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=e(new dy.Panel("MB","#f08","#201"))),t(0),{REVISION:16,dom:r,addPanel:e,showPanel:t,begin:function(){a=(performance||Date).now()},end:function(){s++;var e,t=(performance||Date).now();return c.update(t-a,200),o+1e3<=t&&(l.update(1e3*s/(t-o),100),o=t,s=0,i&&(e=performance.memory,i.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){a=this.end()},domElement:r,setMode:t}};dy.Panel=function(n,r,i){var a=1/0,o=0,s=Math.round,l=s(window.devicePixelRatio||1),c=80*l,e=48*l,u=3*l,d=2*l,h=3*l,p=15*l,f=74*l,m=30*l,v=document.createElement("canvas");v.width=c,v.height=e,v.style.cssText="width:80px;height:48px";var g=v.getContext("2d");return g.font="bold "+9*l+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=i,g.fillRect(0,0,c,e),g.fillStyle=r,g.fillText(n,u,d),g.fillRect(h,p,f,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(h,p,f,m),{dom:v,update:function(e,t){a=Math.min(a,e),o=Math.max(o,e),g.fillStyle=i,g.globalAlpha=1,g.fillRect(0,0,c,p),g.fillStyle=r,g.fillText(s(e)+" "+n+" ("+s(a)+"-"+s(o)+")",u,d),g.drawImage(v,h+l,p,f-l,m,h,p,f-l,m),g.fillRect(h+f-l,p,l,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(h+f-l,p,l,s((1-e/t)*m))}}};var hy=["toneMapping","toneMappingMidTones","toneMappingPhysicalScale","toneMappingBrightness","toneMappingContrast","toneMappingChromaticAdaptation","toneMappingWhiteColor","toneMappingColorDifferentiation","toneMappingExteriorDaylight","toneMappingWhiteBalance","toneMappingHighlights","toneMappingShadows","toneMappingSaturation","toneMappingAperture","toneMappingShutter","toneMappingISO","toneMappingVignetting"];function py(e,t,n){var r,i,a;o.call(this),this.container=e instanceof HTMLElement?e:document.getElementById(e),os.checkWebGL()?(this.scene=null,this.camera=null,this.clock=new uh,this.mixer=null,this.renderCallbacks=[],this.compileCallbacks=[],this.elapsed=0,this.frame=0,this.preloader=n,this.worldMaterial=null,this.worldCubemapRes=1024,this._pmremMaxTileSize=256,this._lightProbeCubemapRes=64,this.xrSession=null,this.xrControllers=[],void 0===(t=t||{}).alpha&&(t.alpha=!1),void 0===t.depth&&(t.depth=!0),void 0===t.stencil&&(t.stencil=!0),void 0===t.antialias&&(t.antialias=!0),void 0===t.premultipliedAlpha&&(t.premultipliedAlpha=!0),void 0===t.preserveDrawingBuffer&&(t.preserveDrawingBuffer=!1),t.xrCompatible=!0,r=document.createElement("canvas"),i=os.checkWebGL2(),os.checkIOS()&&(i=!1),a=r.getContext(i?"webgl2":"webgl",t)||r.getContext("experimental-webgl",t),this.renderer=new hs({canvas:r,context:a}),zv.prepareRenderer(this.renderer),this.clearBkgOnLoad=!1,this.frameRateDivider=1,this.enableRender=!0,this.disableRenderTrigger=0,this.ssaaOnPause=!1,this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.renderer.outputEncoding=Et,this.container.appendChild(this.renderer.domElement),this.container.classList.add("v3d-container"),this.renderer.domElement.classList.add("v3d-canvas"),this.loader=new Zg,ui.prototype.computeBoundsTree=cm,ui.prototype.disposeBoundsTree=um,Ci.prototype.raycast=lm,this.actions=[],this.materials=[],this._envIBLMode=Yt,this._envRTargetIBL=null,this._envLightProbe=null,this._resizeCb=null,this._loadingTime=0,this._postprocessingSave=null,this.stats=null,Bv.drawWatermark(this),Bv.addToAppList(this),os.checkIOS()&&"polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill&&Bv.requestDeviceMotionPermissions()):os.showWebGLErrorMessage(this.container)}function fy(e,t,n){return 2*Kt.RAD2DEG*Math.atan(Math.tan(Kt.DEG2RAD*e/2)*t/n)}py.prototype=Object.assign(Object.create(o.prototype),{constructor:py,_updateRendererFromGLTF:function(e){var t=os.checkHalfFloatTex(this.renderer,!0);if(e.renderer.shadowMap?(this.renderer.shadowMap.enabled=e.renderer.shadowMap.enabled,this.renderer.shadowMap.type=e.renderer.shadowMap.type,t||this.renderer.shadowMap.type!==ee||(this.renderer.shadowMap.type=Z,e.scene.traverse(function(e){e.isLight&&e.castShadow&&e.shadow&&(e.shadow.bias/=100,e.shadow.isDirectionalLightShadowCSM&&(e.shadow.radius*=100/e.shadow.mapSize.x/2,e.shadow=(new Td).copy(e.shadow),e.shadow.camera.updateProjectionMatrix()))}))):(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Z),e.renderer.physicallyCorrectLights&&(this.renderer.physicallyCorrectLights=!0),this.aaMethod=e.renderer.aaMethod||"AUTO",this.useHDR=Boolean(e.renderer.useHDR&&t),this.renderer.unitsScaleFactor=e.renderer.unitsScaleFactor,e.renderer.toneMapping)for(var n=0;n<hy.length;n++){var r=hy[n];Jr(e.renderer[r])&&(this.renderer[r]=e.renderer[r])}void 0!==e.renderer.pmremMaxTileSize&&(this._pmremMaxTileSize=e.renderer.pmremMaxTileSize),void 0!==e.renderer.iblEnvironmentMode&&(this._envIBLMode=e.renderer.iblEnvironmentMode),void 0!==e.renderer.esmDistanceScale&&(this.renderer.shadowMap.esmDistanceScale=e.renderer.esmDistanceScale)},_updateMeshesRaycastFromGLTF:function(e){e.scene&&e.scene.traverse(function(e){var t=e.geometry;e.isMesh&&(!t.computeBoundsTree||0!==Object.keys(t.morphAttributes).length||t.attributes.position.isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute||t.computeBoundsTree({verbose:!1}))})},_updateMaterialsFromGLTF:function(e){var n=this;e.scene&&e.scene.traverse(function(e){var t=e.material;t&&(n.useHDR&&(t.useHDR=!0,t.useFloatTex=os.checkFloatTex(n.renderer,!0),t.isMeshNodeMaterial&&t.updateNodeGraph()),-1==n.materials.indexOf(t)&&n.materials.push(t))})},_updateAnimationsFromGLTF:function(e,r){var i=this;!i.mixer&&e.animations&&e.animations.length&&(i.mixer=new Bh(i.scene)),(e.animations||[]).forEach(function(e){var t,n=r.getObjectById(e.nodeId);n&&((t=n.id==r.id||""!==n.name&&"root"!==n.name&&"."!==n.name&&n.name!==r.name&&n.name!==r.uuid?i.mixer.clipAction(e.clip,r):i.mixer.clipAction(e.clip,n)).setLoop(e.loop,e.repetitions),t.startAt(e.startAt+i.mixer.time),t.clampWhenFinished=!0,e.auto?t.play():(t.stop(),t.paused=!0),i.actions.push(t))})},_updateSceneEnvIBL:function(e,t){null!==t&&this._traverseSceneForEnvUpdates(e,function(e){e.material.envMap=t.texture,e.material.needsUpdate=!0})},_traverseSceneForEnvUpdates:function(e,t){e.traverse(function(e){e.isMesh&&e.material&&(e.material.isMeshStandardMaterial||e.material.isMeshPhysicalMaterial||e.material.isMeshNodeMaterial&&"PHYSICAL"in e.material.defines)&&t(e)})},_traverseSceneForTexUniforms:function(e,n){e.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(function(e){void 0!==e.program&&n(t,e,e.program.getTexUniformCount())})})},_checkMSAA:function(e,t){return Math.min(t,e.capabilities.maxSamples)},_precompileSceneAsync:function(e,t,n,r){for(var i=this,a=i.compileCallbacks,o=0;o<a.length;o++)a[o](i);var s=i.renderer.getRenderTarget();i.renderer.setRenderTarget(n),i.renderer.compileAsync(e,t,function(e){1<=e&&i.renderer.setRenderTarget(s),r&&r(100*e)})},load:function(e,t,n,r){console.warn("v3d.App.load has been deprecated. Use v3d.App.loadScene instead.");var i=this;i.loadScene(e,function(e){t(e),r&&i.run()},null,n)},loadScene:function(e,i,a,t){var o=this;o.renderer?(o._loadingTime=performance.now(),this.loader.load(e,function(e){o.scene=e.scene||new zn;var t=null;e.cameras&&e.cameras.length?o.camera=e.cameras[0]:(t=uy.calcSceneBox(o.scene),o.camera=uy.createDefaultCamera(t,o.container.offsetWidth/o.container.offsetHeight),o.scene.add(o.camera)),o.camera.controls||(t=t||uy.calcSceneBox(o.scene),uy.assignDefaultControls(o.camera,uy.calcSceneBox(o.scene)),o.camera.viewportFit.type=1),o._updateRendererFromGLTF(e),o._updateMaterialsFromGLTF(e),o._updateAnimationsFromGLTF(e,o.scene),o._updateMeshesRaycastFromGLTF(e);var n=e.world.material;n&&(o.scene.background=new cy,o.updateEnvironment(n),o.worldMaterial=n),o.initPostprocessing(),o.onResize&&o.onResize(),o.scene.updateMatrixWorld(),o.scene.visible=!1,o.scene.disableChildRendering=!0;var r=o.postprocessing?o.postprocessing.composer.renderTarget1:null;o._precompileSceneAsync(o.scene,o.camera,r,function(e){var t=60+.4*e;a&&a(t),o.preloader&&o.preloader.onUpdate(t),100<=t&&(o._traverseSceneForTexUniforms(o.scene,function(e,t,n){8<n&&console.warn('v3d.App: Material "'.concat(t.name,'" on object ')+'"'.concat(e.name,'" exceeds iOS limit of ')+"".concat(8," textures ")+"(has ".concat(n,")."))}),i&&setTimeout(function(){o.scene.visible=!0,o.scene.disableChildRendering=!1,o._loadingTime=performance.now()-o._loadingTime,o.dispatchEvent({type:"loadSceneEnd"}),i(o.scene)},16))}),o.clearBkgOnLoad&&(o.scene.background=null),o._tripleP=new ly(window,tv.P,function(){Bv.printPerformanceInfo(o,1)},3,1),o._tripleF=new ly(window,tv.F,function(){o.stats?o.hideFPS():o.showFPS()},3,1)},function(e){var t=.6*e;a&&a(t),o.preloader&&o.preloader.onUpdate(t)},function(e){console.error(e),t&&t(e)}),window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=function(){o.onResize&&o.onResize()},window.addEventListener("resize",this._resizeCb,!1)):t&&t("WebGL not found")},appendScene:function(e,a,o,t,s,l){var c=this;c.renderer?(void 0===s&&(s=!0),void 0===l&&(l=!0),this.loader.load(e,function(e){var n=e.scene||new zn,t=[];n.traverse(function(e){(e.isCamera&&!s||e.isLight&&!l)&&t.push(e)}),t.forEach(function(e){c.unload(e)}),c.scene&&(c.scene.add(n),c._updateMaterialsFromGLTF(e),c._updateAnimationsFromGLTF(e,n),c._updateMeshesRaycastFromGLTF(e),c._updateSceneEnvIBL(n,c._envRTargetIBL),c.scene.updateMatrixWorld());var r=c.postprocessing?c.postprocessing.composer.renderTarget1:null,i=c.scene||n;n.visible=!1,n.disableChildRendering=!0,c._precompileSceneAsync(i,c.camera,r,function(e){var t=60+.4*e;o&&o(t),c.preloader&&c.preloader.onUpdate(t),100<=t&&(c._traverseSceneForTexUniforms(n,function(e,t,n){8<n&&console.warn('v3d.App: Material "'.concat(t.name,'" on object ')+'"'.concat(e.name,'" exceeds iOS limit of ')+"".concat(8," textures ")+"(has ".concat(n,")."))}),a&&setTimeout(function(){n.visible=!0,n.disableChildRendering=!1,a(n)},16))})},function(e){var t=.6*e;o&&o(t),c.preloader&&c.preloader.onUpdate(t)},function(e){console.error(e),t&&t(e)})):t&&t("WebGL not found")},unload:function(e){var n=this;function r(e){var t;e.isAnnotation?e.dispose():e.isLight&&e.shadow&&e.shadow.isLightShadow?e.shadow.dispose():e.isCamera&&e.controls&&e.controls.orbitTarget?r(e.controls.orbitTarget):e.isMesh&&(e.geometry.dispose(),e.geometry.disposeBoundsTree&&e.geometry.disposeBoundsTree(),t=e.material,Gm.disposeTextures(t),t.dispose())}if((e=e||n.scene)===n.scene){if(n.scene&&(n.scene.traverse(r),n.disposeEnvironment()),n.scene=null,n.controls&&n.controls.dispose&&n.controls.dispose(),n.controls=null,n.camera=null,n.materials=[],n.mixer&&(n.mixer.stopAllAction(),n.actions.forEach(function(e){n.mixer.uncacheAction(e.getClip(),e.getRoot())})),n.mixer=null,n.actions=[],n.postprocessing){if(n.postprocessing.composer)for(var t in n.postprocessing){var i=n.postprocessing[t];(i instanceof uv||i instanceof Uv)&&i.dispose()}n.disablePostprocessing()}n.postprocessing=null,n.renderer&&n.renderer.disposeInternalCaches(),n._tripleP&&n._tripleP.dispose(),n._tripleF&&n._tripleF.dispose()}else if(n.scene&&(e.traverse(r),e.parent&&e.parent.remove(e)),n.materials=[],n.scene&&n.scene.traverse(function(e){var t=e.material;t&&-1==n.materials.indexOf(t)&&n.materials.push(t)}),n.mixer)for(var a=n.actions.length-1;0<=a;a--){var o=n.actions[a];uy.checkActionIsUsed(n.scene,o)||(o.stop(),n.mixer.uncacheAction(o.getClip(),o.getRoot()),n.actions.splice(a,1))}},dispose:function(){this.scene&&this.unload(),this.renderer&&(this.renderer.forceContextLoss(),this.renderer.dispose(),this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement)),this.renderer=null,window.removeEventListener("resize",this._resizeCb,!1),Bv.removeFromAppList(this),Bu.clear(),this.dispatchEvent({type:"dispose"})},getWidth:function(){return this.container.offsetWidth},getHeight:function(){return this.container.offsetHeight},onResize:function(){this.enableRender&&!this.ssaaOnPause||(this.enableRendering(),this.disableRendering(1));var e,t=this.getWidth(),n=this.getHeight();if(this.renderer.setSize(t,n),this.postprocessing&&(e=this.renderer.getPixelRatio(),this.postprocessing.composer.setSize(t*e,n*e)),this.scene){var r=t/n,i=this.camera;if(i.isPerspectiveCamera)switch(i.viewportFit.type){case 1:i.aspect=r;break;case 2:i.fov=fy(i.fov,i.aspect,r),i.aspect=r;break;case 3:var a=i.aspect<i.viewportFit.initialAspect,o=r<i.viewportFit.initialAspect;a&&o?i.fov=fy(i.fov,i.aspect,r):a&&!o?i.fov=fy(i.fov,i.aspect,i.viewportFit.initialAspect):!a&&o&&(i.fov=fy(i.fov,i.viewportFit.initialAspect,r)),i.aspect=r}else if(i.isOrthographicCamera)switch(i.viewportFit.type){case 1:var s=i.top*r;i.left=-s,i.right=s;break;case 2:var l=i.right/r;i.bottom=-l,i.top=l;break;case 3:a=(i.right-i.left)/(i.top-i.bottom)<i.viewportFit.initialAspect,o=r<i.viewportFit.initialAspect,s=a&&o?i.right:a&&!o?i.right*r/i.viewportFit.initialAspect:!a&&o?i.top*i.viewportFit.initialAspect:i.top*r,i.left=-s,i.right=s,i.bottom=-s/r,i.top=s/r}i.updateProjectionMatrix()}},run:function(){this.preloader&&(this.preloader.onFinish(),this.preloader=null),this.animate()},animate:function(){var r=this;r.renderer.setAnimationLoop(function(){r.stats&&r.stats.begin();var e=r.clock.getDelta();r.elapsed=e,r.mixer&&r.mixer.update(e),r.controls&&!r.xrSession&&r.controls.update(e);for(var t=r.renderCallbacks,n=0;n<t.length;n++)t[n](e,r.clock.elapsedTime);r.frame%r.frameRateDivider==0&&r.enableRender&&r.render(),r.frame++,r.disableRenderTrigger&&0==--r.disableRenderTrigger&&(r.enableRender=!1),r.stats&&r.stats.end()})},enableRendering:function(){this.disableRenderTrigger=0,this.enableRender=!0,this.ssaaOnPause&&this.enableSSAA(0,!0)},disableRendering:function(e){((e=e||0)||this.ssaaOnPause)&&this.enableRender&&0==this.disableRenderTrigger?(this.disableRenderTrigger=this.ssaaOnPause?32:e,this.ssaaOnPause&&this.enableSSAA(4,!0)):0==e&&(this.enableRender=!1)},setFrameRateDivider:function(e){this.frameRateDivider=e},render:function(){this.postprocessing?this.postprocessing.composer.render(this.elapsed):this.scene&&this.camera&&this.renderer.render(this.scene,this.camera)},enableControls:function(e){var n=this.camera;if(n.controls){switch(n.controls.type){case"ORBIT":this.controls=new sv(n,e||this.renderer.domElement),this.controls.targetObj=n.controls.orbitTarget,this.controls.minDistance=n.controls.orbitMinDistance,this.controls.maxDistance=n.controls.orbitMaxDistance,this.controls.minPolarAngle=n.controls.orbitMinPolarAngle,this.controls.maxPolarAngle=n.controls.orbitMaxPolarAngle,this.controls.minAzimuthAngle=n.controls.orbitMinAzimuthAngle,this.controls.maxAzimuthAngle=n.controls.orbitMaxAzimuthAngle;break;case"FLYING":this.controls=new iv(n,this.renderer.domElement),this.controls.panSpeedTouch*=n.controls.moveSpeed,this.controls.zoomSpeedKey*=n.controls.moveSpeed;break;case"FIRST_PERSON":this.controls=new rv(n,this.renderer.domElement),this.controls.collisionMeshes=[];var r=this;this.scene.traverse(function(e){var t=e.material;t&&n.controls.collisionMaterial&&t.name==n.controls.collisionMaterial.name&&r.controls.collisionMeshes.push(e)}),r.controls.gazeLevel=n.controls.gazeLevel,r.controls.storyHeight=n.controls.storyHeight,this.controls.zoomSpeedKey*=n.controls.moveSpeed;break;default:this.controls=null}this.controls&&(this.controls.enablePan=n.controls.enablePan,this.controls.rotateSpeed*=n.controls.rotateSpeed,this.controls.rotateSpeedTouch*=n.controls.rotateSpeed,this.controls.panSpeed*=n.controls.moveSpeed,this.controls.panSpeedKey*=n.controls.moveSpeed,this.controls.zoomSpeed*=n.controls.moveSpeed,this.controls.zoomSpeedTouch*=n.controls.moveSpeed,this.controls.update())}},setCamera:function(e){if(this.camera=e,this.postprocessing)for(var t=this.postprocessing.composer.passes,n=0;n<t.length;n++)t[n].setCamera(e);this.controls&&this.controls.dispose(),this.enableControls(),this.onResize()},getCamera:function(){return this.camera},cleanup:function(){if(console.warn("v3d.App.cleanup has been deprecated. Use v3d.App.unload or v3d.App.dispose instead."),this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild);this.loader&&this.mixer&&this.mixer.stopAllAction()},initPostprocessing:function(){(this.scene.postprocessing&&this.scene.postprocessing.length||this.useHDR||"AUTO"!=this.aaMethod)&&this.enablePostprocessing(this.scene.postprocessing||[])},enablePostprocessing:function(e){var t={format:dt,stencilBuffer:!1};if(this.useHDR?(t.type=lt,t.encoding=Tt):(t.type=it,t.encoding=Et),this.postprocessing)i=this.postprocessing.composer;else{this.postprocessing={};var n=new Cv(this.scene,this.camera);this.postprocessing.renderPass=n;var r,i,a,o,s=0;switch(this.aaMethod){case"AUTO":case"MSAA4":s=this._checkMSAA(this.renderer,4);break;case"MSAA8":s=this._checkMSAA(this.renderer,8);break;case"MSAA16":s=this._checkMSAA(this.renderer,16)}os.checkSwiftShader(this.renderer)&&(s=0,console.warn("v3d.App: disabling buggy multisampling on SwiftShader renderer")),s?(r=new on(this.getWidth(),this.getHeight(),t)).samples=s:r=new an(this.getWidth(),this.getHeight(),t),r.texture.name="EffectComposer.rt1",(i=new Uv(this.renderer,r)).addPass(n),this.postprocessing.composer=i,this.useHDR&&(a=new Ov,i.addPass(a),this.postprocessing.toneMapPass=a),s||(o=new vv(this.scene,this.camera),i.addPass(o),this.postprocessing.fxaaPass=o)}e.length&&this.postprocessing.copyPass&&(i.passes.splice(i.passes.indexOf(this.postprocessing.copyPass),1),this.postprocessing.copyPass=null);for(var l,c=0;c<e.length;c++){var u,d,h,p,f,m,v,g,_=e[c],y=i.passes.length-1;switch(i.passes[y]instanceof vv||y++,this.useHDR&&y--,_.type){case"bloom":var x,b=_.strength,M=_.radius,w=_.threshold;this.postprocessing.bloomPass?((x=this.postprocessing.bloomPass).strength=b,x.radius=M,x.threshold=w):(x=new hv(new Jt(this.getWidth(),this.getHeight()),b,M,w,t),i.insertPass(x,y),this.postprocessing.bloomPass=x);break;case"brightnessContrast":this.postprocessing.brightnessContrastPass?u=this.postprocessing.brightnessContrastPass:(u=new mv,i.insertPass(u,y),this.postprocessing.brightnessContrastPass=u),u.brightness=_.brightness,u.contrast=_.contrast;break;case"dof":this.postprocessing.bokehPass?d=this.postprocessing.bokehPass:(d=new pv(this.scene,this.camera,{width:this.getWidth(),height:this.getHeight()}),i.insertPass(d,y),this.postprocessing.bokehPass=d),d.focus=_.focus,d.aperture=_.aperture,d.maxblur=_.maxblur,d.depthLeakThreshold=_.depthLeakThreshold;break;case"grayscale":this.postprocessing.grayscalePass||(h=new gv,i.insertPass(h,y),this.postprocessing.grayscalePass=h);break;case"outline":this.postprocessing.outlinePass?p=this.postprocessing.outlinePass:(p=new Ev(new Jt(this.getWidth(),this.getHeight()),this.scene,this.camera),i.insertPass(p,y),this.postprocessing.outlinePass=p),p.edgeStrength=_.edgeStrength,p.edgeGlow=_.edgeGlow,p.edgeThickness=_.edgeThickness,p.pulsePeriod=_.pulsePeriod,p.visibleEdgeColor.fromArray(_.visibleEdgeColor),p.hiddenEdgeColor.fromArray(_.hiddenEdgeColor),void 0===_.renderHiddenEdge?(f=0===_.hiddenEdgeColor[0]&&0===_.hiddenEdgeColor[1]&&0===_.hiddenEdgeColor[2],p.hiddenEdgeColor.setW(Number(!f))):p.hiddenEdgeColor.setW(Number(_.renderHiddenEdge));break;case"ssao":if(!os.checkDepthTex(this.renderer)){console.warn("v3d.App: disabling SSAO since your hardware does not support depth textures");break}if(!os.checkFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSAO since your hardware does not support float textures");break}this.postprocessing.ssaoPass?m=this.postprocessing.ssaoPass:(m=new Nv(this.scene,this.camera,this.getWidth(),this.getHeight()),i.insertPass(m,y),this.postprocessing.ssaoPass=m),m.kernelRadius=_.radius,m.minDistance=_.minDistance||.005,m.maxDistance=_.maxDistance||.1;break;case"ssr":if(!os.checkHalfFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSR since your hardware does not support half float textures");break}((v=!!Jr(_.useRefract)&&_.useRefract)?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect)?g=v?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect:(g=new Iv(this.scene,this.camera),i.insertPassAfter(g,[this.postprocessing.renderPass,this.postprocessing.ssrPassRefract,this.postprocessing.ssrPassReflect]),v?this.postprocessing.ssrPassRefract=g:this.postprocessing.ssrPassReflect=g),g.useRefract=v,Jr(_.objects)&&(g.objects=_.objects),Jr(_.intensity)&&(g.intensity=_.intensity),Jr(_.steps)&&(g.steps=_.steps),Jr(_.stride)&&(g.stride=_.stride),Jr(_.binarySearchSteps)&&(g.binarySearchSteps=_.binarySearchSteps),Jr(_.renderTargetScale)&&(g.renderTargetScale=_.renderTargetScale),Jr(_.thickness)&&(g.thickness=_.thickness),Jr(_.maxDistance)&&(g.maxDistance=_.maxDistance),Jr(_.jitter)&&(g.jitter=_.jitter),Jr(_.renderAfter)&&(g.renderAfter=_.renderAfter),Jr(_.simpleRefraction)&&(g.simpleRefraction=_.simpleRefraction),this.onResize&&this.onResize();break;default:console.error("v3d.App: wrong postprocessing effect")}}1==i.passes.length&&(l=new fv(oa.copy),i.passes.push(l),this.postprocessing.copyPass=l)},disablePostprocessing:function(e){if(this.postprocessing){var t=["bloomPass","brightnessContrastPass","bokehPass","grayscalePass","ssaoPass","ssrPassReflect","ssrPassRefract"];e||t.push("outlinePass");for(var n=this.postprocessing.composer,r=0;r<t.length;r++){var i=t[r];this.postprocessing[i]&&(n.passes.splice(n.passes.indexOf(this.postprocessing[i]),1),this.postprocessing[i].dispose(),this.postprocessing[i]=null)}!this.useHDR&&"AUTO"==this.aaMethod&&n.passes.length<=2&&(this.postprocessing.renderPass.dispose(),this.postprocessing.fxaaPass&&this.postprocessing.fxaaPass.dispose(),this.postprocessing.composer.dispose(),this.postprocessing=null)}},enableSSAA:function(t,e){var n,r,i;this.postprocessing||this.enablePostprocessing([]),0<t&&(this.postprocessing.ssrPassRefract||this.postprocessing.ssrPassReflect)||((n=this).scene.traverse(function(e){e.isAnnotationControl&&(e.update(n.camera),e.doUpdate=!Boolean(t))}),r=this.postprocessing.composer,0<t&&r.passes[0]instanceof Cv?(this.postprocessing.ssaaRenderPass?i=this.postprocessing.ssaaRenderPass:(i=new Pv(this.scene,this.camera),this.postprocessing.ssaaRenderPass=i,e&&i.addEventListener("iteration",function(e){e.frame==t*t-1&&(r.enableAllPasses(),r.renderToScreen=!0,n.disableRenderTrigger=1)})),i.sampleLevel=t||4,r.passes[0]=i,this.postprocessing.fxaaPass&&r.passes.splice(r.passes.length-1,1),e&&(i.iterative=!0,i.iterativeFrame=0,r.disableAllPasses(),r.renderToScreen=!1,i.enabled=!0)):0<t?(r.passes[0].sampleLevel=t||4,e&&(i.iterative=!0,i.iterativeFrame=0,r.disableAllPasses(),r.renderToScreen=!1,i.enabled=!0)):0==t&&r.passes[0]instanceof Pv&&(r.passes[0]=this.postprocessing.renderPass,this.postprocessing.fxaaPass&&r.passes.push(this.postprocessing.fxaaPass),r.enableAllPasses(),r.renderToScreen=!0))},updateEnvironment:function(e){this.disposeEnvironment(),e.useHDR=!0;var t,n={encoding:Et,format:dt,generateMipmaps:!0,minFilter:rt},r=Dv.renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,n),i=r;switch((e.hasNode("LIGHT_PATH_BL")||e.hasNode("LIGHT_PATH_MY"))&&(t=e.defines.LIGHT_PATH_IS_CAM_RAY,e.defines.LIGHT_PATH_IS_CAM_RAY=0,i=Dv.renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,n),e.defines.LIGHT_PATH_IS_CAM_RAY=t),this._envIBLMode){case Yt:this._envRTargetIBL=this.generateRTargetPMREM(i),i!==r&&i.dispose(),this._updateSceneEnvIBL(this.scene,this._envRTargetIBL),this.renderer.compatSettings.useSpecEnvBlenderApprox=!0;break;case 1:var a=new lv(i.texture,this._pmremMaxTileSize,{mapping:Ge});a.update(this.renderer),this._envRTargetIBL=a.renderTarget,this._updateSceneEnvIBL(this.scene,this._envRTargetIBL);var o=new lv(i.texture,this._lightProbeCubemapRes,{type:it,format:dt,encoding:Pt});o.update(this.renderer),this._envLightProbe=(new Zd).copy($d.fromCubeRenderTarget(this.renderer,o.renderTarget)),this.scene.add(this._envLightProbe),o.dispose(),i!==r&&i.dispose(),this.renderer.compatSettings.useSpecEnvBlenderApprox=!1;break;case 2:var s=new lv(i.texture,this._lightProbeCubemapRes,{type:it,format:dt,encoding:Pt});s.update(this.renderer),i!==r&&i.dispose(),this._envLightProbe=(new Zd).copy($d.fromCubeRenderTarget(this.renderer,s.renderTarget)),this.scene.add(this._envLightProbe),s.dispose(),this.renderer.compatSettings.useSpecEnvBlenderApprox=!1}null!==this.scene.background&&this.scene.background.isSceneBackground&&(this.scene.background.data=r,this.scene.background.useHDR=this.useHDR)},disposeEnvironment:function(){null!==this._envRTargetIBL&&(this._envRTargetIBL.dispose(),this._traverseSceneForEnvUpdates(this.scene,function(e){e.material.envMap.dispose()})),(this._envRTargetIBL=null)!==this._envLightProbe&&(this.scene.remove(this._envLightProbe),void 0!==this._envLightProbe.dispose&&this._envLightProbe.dispose(),this._envLightProbe=null);var e=this.scene.background;e&&(e.isSceneBackground&&(e=e.data),e&&(e.isTexture||e.isWebGLRenderTarget)&&e.dispose())},generateRTargetPMREM:function(e){if(!e.isWebGLCubeRenderTarget)return null;var t=new Z_(this.renderer);t.flipCubemapX=!1,t.maxTileSize=this._pmremMaxTileSize;var n=t.fromCubeRenderTarget(e,{encoding:Tt});return t.dispose(),n},initWebXR:function(i,a,o,e,r){o=o||function(){},e=e||function(){},r=r||function(){};var s=this;function l(e){s.xrSession.removeEventListener("end",l),s.renderer.xr.setSession(null),r();for(var t=0;t<s.xrControllers.length;t++){var n=s.xrControllers[t];s.scene.remove(n)}s.xrControllers=[],s.xrSession=null,s.postprocessing=s._postprocessingSave,s._postprocessingSave=null,s.onResize()}function c(e){var t,n,r=e.data,i=e.target;"tracked-pointer"==r.targetRayMode?((t=new $s((new ui).setFromPoints([new un(0,0,0),new un(0,0,-1)]))).name=i.name+"_RAY",t.scale.z=5,i.add(t)):"gaze"==r.targetRayMode&&((n=new Ds(new ys({map:(new qu).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAIQXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZhZltw2DEX/uYosQSQ4LofjOdlBlp8LSqquHt12nD+X3JIKYpEg3sMDZDP/+XuZv/iIOGd8SDmWGA8+vvjiKjf5OD91n+3h93l//PWI76/s5vHAYRKucn7N8bJP7I7x7rL3a56KPTxNVOb1oL1+UK+JXL4WuOz3QmLPBY5rYlOvicRdK18utnNbRyw5PW+hX+PX9XyHgT+jJy/JxRBt8py9O1KKhfvsDp+I21BHV3dFfxfaNdGb7+Ye6vDJTbFycM7qoeC+FKmi93rGaSzCvUjY53J6ClrOHIn7csf1689Xnpvb9QvyV5A+7uwn9iekzQ7o/UDeIBQf1w/tNrzYzTOkG7enlWN8rPzKnufRXu35Rk3/1hp5rXnurvrIluO1qXsr+45xTaO1fxU5En/hyBpsPQpHJiU6PBqQrHF0W6wDxmW9HbbaZee+dttx0bvpElfnuhPbDcYMGMX1DbfXwy6XAH5IBvgOHQSre/hi97JlL9dtZuFhs4E9lsksP/lPh/nOoLU0oaw98iNW+OU00/BCkbPWHJZhIGLXFdSwA3wfbz+Kq4Bg2GHObLAeTWcA/hbsC7lkAy0MDFzPBLZpXBMQIjwIOGMFBI5oJdhoj4SwJWsJZAagiutOvGvAYkNwAyedF4mAQxawNr9Jdg91wZ1mhBAggkQjCWxITcDyPsCf5DMcqkGCDyHEkEIOJdQoUTMsxhRVUWuS5FNIMaWUU0nVZMk+hxxzyjmXXIsrguKGQj6WXEqplUUrM1d+XRlQa3NNmm+hxZZabqXV7kyX7nvosaeee+l1uCGDPB5xpJFHGXXaCZWmn2HGmWaeZdYF1ZYsv8KKK628iln1gdoF67vjJ1CzF2puI6UD0wM1rCndU1iVk6CYgZjzFsCTImDFOKeYHdl67xQ5xewoTkXQ4WRQcIZVxEDQT+vCsg/sXpALRuLvwc0AhPsdyBmF7hvIvcftI9RG3YVONkKahhrUQ8i+VdbM1eWqlfLLq/nRgO9e/0z0Z6LfNtEKlJIcBGEJdi4Y3YtQv/vMn9hbb2uO2qngQp1HkExeIqtF6sbqOjSLnimwjeScNfUo89iTZO/b7GHNot9iXc1v+ypRmpg4x9DZbZ/owSyht5CoP3X52YZQTUprFa0ItmIdx22xPvAvogdcVPyXdoNjrZpJ4+lZTtdDaj62hxnWigOhXduzQx+mQvaPZrNbk99ZfVDsDIMlgtBQLro75kMVI3Xb63P8HRXr6s2O0hI7YuI8TZLWlq8z1NZmxkfWRLdoCMcQIVAj5kCbeFkOhcg11PO8o7M6r+Z4Y/iJq4KdFVJt3w261qI9nXagWtvw6cKp96g4ZMIw/NZERidb2NYSDUzpabXiF3EzpaKqdZNqZSuTXqnN0CtBntdNmZYJStprx7kgxZCka/XWsc9qwzRVdkRnFEWjy8mRQDknXhkExoYgj6QNm96PWsKsM8EoejmdKOblTRMIQOt3ucsgJUigEUldCH5vJRCMcd1I1wWdMmKMNfyqcepalKOCefgzY9iGzOJ/Jd3Mhw9aLbrhTCyntQ44IOYBgdocpAPBbbGP1siF1bRxHYNyFKjJcD0EaAQs0EU0zcCEBBDNiuQn3CFPANTv3epZWd+CRs2zU7Og7coEZKcArFQGA8BOU5faUL/I3J0OuVAw2xqHzAHbywZiudFiNEM9XIMa3edcw7USP5WUzT5RLsA6JZ9SD/K07JoZAFUiPmdQak0CPlGYa/MptVDJT20yYguxkIT0DXQKexSrkjpz8QhlimYmdYF13enoS7Lj9CkCxcXzCa7Esl8AQBq6rDabFASNxDfMWcgaRzTRgIFeBRmje5n4GAJmnGIHE2qUtOBqhOpzOhnrHtCJiJnTPoAA9FmVwgzCETw7yqmHPwbBfIbCOxC6jSogCHVjYzWhLEk1KTQonoYhUIEbIQd4p42Wliu5ngJtT8Le6LXS6CdV5xIA+p3l6GY+dKCrHMp8mK0bSBPGK/WJ/d4U1PdiM3WhDiU9dQCRH6o4sxerpKcUyJGASZrjLVvTQ/XiJ0sAAj9ayPYW+8IbpLzW/3KkLUIvEnQKEG6FLW3OF3aksFMFtoZp+I0+giNUtd4xUutm3LTnZxLXmFQ5el3WkFEIPtPMorRGG2sfslIJ8NIaqxnbBKp7ckpOgDThLLn1kBGbnmRkvcgIlH+WkbLIoOC1LCAksc5RuviYqfE0yZeFd/2vomk+DSfceh1PLZ5k35uI3vXUvC+oKlTrUVBJ56eSyhJ5flhTzS8U1Q+v5ptF9aXK7ZuWNaXDJshY1S4xofutu27qtutxVSPSrffPqhGj39Ujan+5K9IXxXq+FPp3UhsAdw3TwQG5G3aWmEBohrt4qthpkCbBz4ntlcQXXreum5R1sbAXHs2QldBo9LOroE+gIaj52mBwabjzC2+lX17NjwbodeuhtFsPof1Q0UMOyTI0EO45g2lqG8k2i809EsB4quEkUrK1cKgW8mZb+UkcIAdcUXKyI9scHR1MY6I3jzUIZ2ODum6EgoaiEIrp9/YJmYP0QbMBnHLaCW2meqzsfm6AyYtX7S+id3W/vKle3e/OPRojdI/oDyOdRFVlrAORRx/igFKtQDte/oV654VGuvIKzMM2eCFuVB4SbD3CppXcXFE7i8guPY8i0l5XcpVqGsNjp1bjzGyCNLRgySyT5TY9R2fu2joo2cRhR6bsdCYa8P8MEJnzEqJpHiH6KEA6wXcCRHzMrwRovzykVEY/b/U/r81981+vfyb6M9H/MBF5RKaafwEjmLcIrlR0mgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+MCAwojJyJFeN4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAd0lEQVR42u3YUQqAIBAFwLUDdf9zdCH7lwwEI2VnPkWQfWCvigAAAAAAgDTK1wecNWq7dpX+uaP7lw7gaZi3oUb3z3BkvwICEIAW+KcFRte3DWBGO7gCAhCAAHZ9FY6IpC3QG963gGeAAASgBRb6IwQAAAAAQCY34QUtIL9dJTwAAAAASUVORK5CYII="),sizeAttenuation:!1}))).name=i.name+"_RETICLE",n.scale.multiplyScalar(.1),n.position.z=-5,i.add(n)),i.userData.v3d.inputSource=r}function u(e){for(var t=e.target,n=t.children.length-1;0<=n;n--){var r=t.children[n];-1<r.name.indexOf(t.name)&&(r.geometry.dispose(),r.material.dispose(),t.remove(r))}}var t={optionalFeatures:[a]};"immersive-ar"==i&&t.optionalFeatures.push("hit-test"),navigator.xr.requestSession(i,t).then(function(e){s._postprocessingSave=s.postprocessing,s.postprocessing=null,s.renderer.xr.setReferenceSpaceType(a),(s.xrSession=e).addEventListener("end",l);for(var t="immersive-vr"==i?2:1,n=0;n<t;n++){var r=s.renderer.xr.getController(n);s.scene.add(r),s.xrControllers.push(r),r.addEventListener("connected",c),r.addEventListener("disconnected",u)}"immersive-vr"==i?2<=window.devicePixelRatio&&s.renderer.xr.setFramebufferScaleFactor(.5):(s.scene.background=null,s.renderer.autoClear=!1,s.onResize()),s.renderer.xr.enabled=!0,s.renderer.xr.setSession(e),o()}).catch(e)},endWebXR:function(){this.xrSession&&this.xrSession.end()},printPerformanceInfo:function(e){Bv.printPerformanceInfo(this,e)},showFPS:function(){var e;this.container&&(this.hideFPS(),(e=new dy).showPanel(0),this.container.appendChild(e.dom),this.stats=e)},hideFPS:function(){this.container&&this.stats&&(this.container.removeChild(this.stats.dom),this.stats=null)}});var my="SceneLoadError",vy="LogicLoadError",gy="EditorLoadError";function _y(e,t,n){console.warn("v3d.AppPuzzles has been deprecated. Use v3d.PuzzlesLoader instead."),py.call(this,e,t,n),this._editorJSFile="puzzles.min.js",this._editorCSSFile="puzzles.css",this._editorMediaDir="media/",this._libraryXML="library.xml",this.ExternalInterface={}}_y.prototype=Object.assign(Object.create(py.prototype),{constructor:_y,onSceneLoad:function(){},onEditorLoad:function(){},onLogicLoad:function(){},onLoadFinished:function(e,t,n){e&&this.run()},onError:function(e){console.error(e)},run:function(){this.enableControls(),py.prototype.run.call(this);var e=ni();e.v3d.PL&&e.v3d.PL.init(this)},_createSceneLoadError:function(e){var t=new Error(e);return t.name=my,t},_createLogicLoadError:function(e){var t=new Error(e);return t.name=vy,t},_createEditorLoadError:function(e){var t=new Error(e);return t.name=gy,t},_getScenePromise:function(n){var r=this;return new Promise(function(e,t){py.prototype.load.call(r,n,function(){e()},function(){t(r._createSceneLoadError("Unable to load the scene file: '"+n+"'."))},!1)})},_getLogicPromise:function(n){var r=this;return new Promise(function(e,t){Bv.loadScript(n,document.body,function(){e()},function(){t(r._createLogicLoadError("Unable to load the logic file: '"+n+"'."))})})},_getEditorPromise:function(r,i){var a=this;return new Promise(function(e,t){var n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=i,document.head.appendChild(n),Bv.loadScript(r,document.body,function(){e()},function(){t(a._createEditorLoadError("Unable to load the Puzzles Editor: '"+r+"'."))})})},_getLogicViaEditorPromise:function(a,o,s){var l=this;return new Promise(function(t,n){var r,e=ni(),i=a.match(/(.*)\.js$/);i?e.v3d.PE?(r=i[1]+".xml",e.v3d.PE.init(o,function(e){e?t():n(l._createLogicLoadError("Unable to load The Puzzles Editor's XML logic file: '"+r+"'."))},l,r,s)):n(l._createLogicLoadError("Unable to load Puzzles' logic. The Puzzles Editor isn't loaded.")):n(l._createLogicLoadError("Unable to load Puzzles' logic. The provided file should be of type JS: '"+a+"'."))})},loadScene:function(e){var t;1<arguments.length?py.prototype.loadScene.call(this,e,arguments[1],arguments[2],arguments[3]):(t=this)._getScenePromise(e).then(function(){t.onSceneLoad(),t.onLoadFinished(!0,!1,!1)}).catch(function(e){switch(t.onError(e),e.name){case my:t.onLoadFinished(!1,!1,!1)}})},loadSceneWithLogic:function(e,t){var n=this;n._getScenePromise(e).then(function(){return n.onSceneLoad(),n._getLogicPromise(t)}).then(function(){n.onLogicLoad(),n.onLoadFinished(!0,!0,!1)}).catch(function(e){switch(n.onError(e),e.name){case my:n.onLoadFinished(!1,!1,!1);break;case vy:n.onLoadFinished(!0,!1,!1)}})},loadSceneWithEditor:function(e,t,n){var r=this,i=n+r._editorJSFile,a=n+r._editorCSSFile,o=n+r._editorMediaDir,s=n+r._libraryXML;r._getScenePromise(e).then(function(){return r.onSceneLoad(),r._getEditorPromise(i,a)}).then(function(){return r.onEditorLoad(),r._getLogicViaEditorPromise(t,o,s)}).then(function(){r.onLogicLoad(),r.onLoadFinished(!0,!0,!0)}).catch(function(e){switch(r.onError(e),e.name){case my:r.onLoadFinished(!1,!1,!1);break;case gy:r.onLoadFinished(!0,!1,!1);break;case vy:r.onLoadFinished(!0,!1,!0)}})}});var yy={normalizeDialectOptions:function(e){var t={delimiter:",",doublequote:!0,lineterminator:"\n",quotechar:'"',skipinitialspace:!0,skipinitialrows:0};for(var n in e)t[n.toLowerCase()]=e[n];return t}};yy.parse=function(e,t){t&&(!t||t.lineterminator)||(e=yy.normalizeLineTerminator(e,t));var n=yy.normalizeDialectOptions(t);e=yy.chomp(e,n.lineterminator);for(var r="",i=!1,a=!1,o="",s=[],l=[],c=function(e){var t=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")};return!0!==a&&(""===e?e=null:!0===n.skipinitialspace&&(e=t(e)),/^\d+$/.test(e)?e=parseInt(e,10):/^\d*\.\d+$|^\d+\.\d*$/.test(e)&&(e=parseFloat(e,10))),e},u=0;u<e.length;u+=1)r=e.charAt(u),!1!==i||r!==n.delimiter&&r!==n.lineterminator?r!==n.quotechar?o+=r:i?e.charAt(u+1)===n.quotechar?(o+=n.quotechar,u+=1):i=!1:a=i=!0:(o=c(o),s.push(o),r===n.lineterminator&&(l.push(s),s=[]),o="",a=!1);return o=c(o),s.push(o),l.push(s),n.skipinitialrows&&(l=l.slice(n.skipinitialrows)),l},yy.normalizeLineTerminator=function(e,t){return(t=t||{}).lineterminator?e:e.replace(/(\r\n|\n|\r)/gm,"\n")},yy.chomp=function(e,t){return e.charAt(e.length-t.length)!==t?e:e.substring(0,e.length-t.length)};var xy,by,My,wy=new un(1,0,0);function Ay(e,t){e=void 0!==e?e:new Lr(1,0,0),t=void 0!==t?t:2;var n=new xv;n.setGeometry([0,0,0,wy.x,wy.y,wy.z]);var r=new Tv({color:e,lineWidth:t,sizeAttenuation:0});Ci.call(this,n.geometry,r),this.elemHTML=null,this.offset=5}function Sy(){}function Ty(e){for(var t in Sy.call(this),e){var n=e[t];switch(t){case"container":void 0===n?this.container=document.body:n instanceof HTMLElement?this.container=n:this.container=document.getElementById(n)}}this.bar=document.createElement("div"),this.bar.setAttribute("class","v3d-simple-preloader-bar"),this.logo=document.createElement("div"),this.logo.setAttribute("class","v3d-simple-preloader-logo"),this.logoCont=document.createElement("div"),this.logoCont.setAttribute("id","v3d_preloader_container"),this.logoCont.setAttribute("class","v3d-simple-preloader-container"),this.background=document.createElement("div"),this.background.setAttribute("class","v3d-simple-preloader-background"),this.background.appendChild(this.logoCont),this.logoCont.appendChild(this.logo),this.logoCont.appendChild(this.bar),this.container.appendChild(this.background),"none"==getComputedStyle(this.logo).backgroundImage&&this.logo.setAttribute("style",'background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCiAgIGlkPSJzdmcyNzc1IgogICB2ZXJzaW9uPSIxLjEiCiAgIHZpZXdCb3g9IjAgMCAyOS4xMDQxNjYgMzEuNzUwMDAxIgogICBoZWlnaHQ9IjEyMCIKICAgd2lkdGg9IjExMCI+CiAgPGRlZnMKICAgICBpZD0iZGVmczI3NjkiPgogICAgPGxpbmVhckdyYWRpZW50CiAgICAgICBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIKICAgICAgIHkyPSI1My44MDY2MTgiCiAgICAgICB4Mj0iMTkzLjc4NDciCiAgICAgICB5MT0iNzguNjg5NDA3IgogICAgICAgeDE9IjE3Mi45MTMzNiIKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDMwNzktOCIKICAgICAgIHhsaW5rOmhyZWY9IiNsaW5lYXJHcmFkaWVudDMwNzciCiAgICAgICBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDEuMTY0NzU5NCwwLDAsMS4xNTgzOTgyLC0xOTcuMTUzMTksMjAzLjUxNjUxKSIgLz4KICAgIDxsaW5lYXJHcmFkaWVudAogICAgICAgaWQ9ImxpbmVhckdyYWRpZW50MzA3NyI+CiAgICAgIDxzdG9wCiAgICAgICAgIGlkPSJzdG9wMzA3MyIKICAgICAgICAgb2Zmc2V0PSIwIgogICAgICAgICBzdHlsZT0ic3RvcC1jb2xvcjojMDA0OGE1O3N0b3Atb3BhY2l0eToxIiAvPgogICAgICA8c3RvcAogICAgICAgICBpZD0ic3RvcDMwNzUiCiAgICAgICAgIG9mZnNldD0iMSIKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzRiODZkMTtzdG9wLW9wYWNpdHk6MSIgLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxtZXRhZGF0YQogICAgIGlkPSJtZXRhZGF0YTI3NzIiPgogICAgPHJkZjpSREY+CiAgICAgIDxjYzpXb3JrCiAgICAgICAgIHJkZjphYm91dD0iIj4KICAgICAgICA8ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD4KICAgICAgICA8ZGM6dHlwZQogICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+CiAgICAgICAgPGRjOnRpdGxlPjwvZGM6dGl0bGU+CiAgICAgIDwvY2M6V29yaz4KICAgIDwvcmRmOlJERj4KICA8L21ldGFkYXRhPgogIDxnCiAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwtMjY1LjI0OTk2KSIKICAgICBpZD0ibGF5ZXIxIj4KICAgIDxwYXRoCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDp1cmwoI2xpbmVhckdyYWRpZW50MzA3OS04KTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MC45MjA0NTI2NTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxIgogICAgICAgZD0ibSAxNC42MjI3OTMsMjY1LjI1MDA0IGMgLTEuNjgyMTUsLTAuMDA3IC0zLjM2OTMsMS4xMDUxMSAtNy4yODAyNDk3LDMuMzI3ODYgLTcuODIxOTEwMDcsNC40NDU1IC03LjI4MTA3MDA3LDMuNTIzMzggLTcuMzIwOTcwMDcsMTIuNDgzMDkgLTAuMDM5OSw4Ljk1OTcxIC0wLjU3MjQ3LDguMDMyODUgNy4yMDk1NTAwNywxMi41NDcwNyA3Ljc4MTk4OTcsNC41MTQyNCA2LjcwODYwOTcsNC41MDk1IDE0LjUzMDQ5OTcsMC4wNjM5IDcuODIxOTEsLTQuNDQ1NDkgNy4yODEwNjIsLTMuNTIzMzcgNy4zMjA5NzEsLTEyLjQ4MzA5IDAuMDM5OSwtOC45NTk3MSAwLjU3MjQ1OCwtOC4wMzI4NSAtNy4yMDk1NTEsLTEyLjU0NzA3IC0zLjg5MSwtMi4yNTcxMiAtNS41NjgxMiwtMy4zODQ0NSAtNy4yNTAyNSwtMy4zOTE4NiB6IG0gLTAuMDEzMywyLjg1MTY3IGMgMS42OTU5NCwwLjAwNyAzLjM4ODMzLDAuODEyODEgNi4xNjAxNiwyLjQyMDY5IDUuNTQzNjIsMy4yMTU3OCA2LjE1MTkzMSw0LjI3NDM4IDYuMTIzNDkxLDEwLjY1Njk2IC0wLjAyODQsNi4zODI2IC0wLjY0NjEwMSw3LjQzNTc2IC02LjIxODE1MSwxMC42MDI1OCAtNS41NzIwMywzLjE2NjgxIC02Ljc5OCwzLjE2MTM5IC0xMi4zNDE2Mzk3LC0wLjA1NDMgLTUuNTQzNjEsLTMuMjE1NzcgLTYuMTUxODksLTQuMjc0MzcgLTYuMTIzNDksLTEwLjY1Njk2IDAuMDI4NiwtNi4zODI1OCAwLjY0NjEsLTcuNDM1NzUgNi4yMTgxNiwtMTAuNjAyNTggMi43ODYwMjk3LC0xLjU4MzQgNC40ODU1Mzk3LC0yLjM3Mzc3IDYuMTgxNDY5NywtMi4zNjYzIHogbSAtMC4xNTUzNywxLjYxNzY5IGMgLTIuNzEzOTEsMC4wMzQxIC01LjcyNDk5OTcsMy4wNzAwOCAtNy4yODkzNTk3LDYuMDc1NDkgLTEuNTg5MjEsMy4wNTMxMSAtMi40OTg1Miw1Ljk0NDU2IC0yLjEyNDA1LDkuNjU3NTEgMC4xNjMwNywxLjYxNjU0IDEuNzEwODIsMy42Nzk4NCAzLjU2Mzc2LDQuNzE0MjYgLTAuMzkzODIsLTMuMjA2MiAtMC4xNzIsLTYuMzQzMDUgMC41NDM5NjEsLTguOTQ2OTIgMC43MTU5NTksLTIuNjAzODcgMi44NTI5Nzg3LC02LjgyODgxIDUuMzc2MjQ4NywtNi44MjMxNiAyLjUyMzMxLDAuMDA2IDQuNjYwMjcsNC4yMjcwNCA1LjM3NjIyLDYuODMwODkgMC43MTU5MywyLjYwMzg4IDAuOTM3NzcsNS43NDA3NSAwLjU0Mzk0LDguOTQ2OTQgMS44NTI5NCwtMS4wMzQ0MyAzLjQwMDcxLC0zLjA5Nzc4IDMuNTYzNzcsLTQuNzE0MzEgMC4zNzQ0OCwtMy43MTI5OCAtMC41MzQ3MSwtNi42MDQyNyAtMi4xMjM5MywtOS42NTc0IC0xLjU1ODkzLC0yLjk5NDk4IC00LjU1NDY1LC02LjAxOTg4IC03LjMwMTU1LC02LjA4MjY2IC0wLjA0MzEsLTkuOGUtNCAtMC4wODYsLTkuOGUtNCAtMC4xMjg5NywtNi4xZS00IHogbSAwLjEzMjY3LDguOTE4NDEgYSAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0xLjE5NzM0LDAuMjkxNTIgMi40OTEyNjMxLDIuNDc3NjU3MyAwIDAgMCAtMS4wMjUzNCwzLjM1MjI5IDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMy4zNzA2OSwxLjAxOTcxIDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMS4wMjUzNCwtMy4zNTIyOCAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0yLjE3MzM1LC0xLjMxMTI0IHoiCiAgICAgICBpZD0icGF0aDYwNDctMiIgLz4KICA8L2c+Cjwvc3ZnPgo=");'),this.clock=new uh}Ay.prototype=Object.assign(Object.create(Ci.prototype),{constructor:Ay,isLineHTML:!0,onBeforeRender:(xy=new un,by=new un,My=new sn,function(e,t,n,r,i,a){var o,s,l,c,u,d,h,p,f,m,v,g,_,y,x,b,M;Ci.prototype.onBeforeRender.call(this),this.elemHTML&&(o=e.domElement.offsetHeight,s=e.domElement.offsetWidth,c=((l=this.elemHTML.getBoundingClientRect()).left+l.right)/2,u=(l.top+l.bottom)/2,h=((d=this.getWorldPosition(xy).project(n)).x+1)/2*s,f=(u-(p=(1-d.y)/2*o))/(c-h),m=(l.height+2*this.offset)/(l.width+2*this.offset),Math.abs(f)>m?v=((g=u<p?Math.min(l.bottom+this.offset,p):Math.max(l.top-this.offset,p))-p)/f+h:g=((v=h<c?Math.max(l.left-this.offset,h):Math.min(l.right+this.offset,h))-h)*f+p,_=2*v/s-1,y=1-2*g/o,(x=by.set(_,y,-1)).unproject(n),this.parent&&this.parent.worldToLocal(x),b=x.length(),this.scale.setScalar(b),x.normalize(),M=My.setFromUnitVectors(wy,x),this.setRotationFromQuaternion(M),this.updateMatrixWorld())})}),Object.assign(Sy.prototype,{onUpdate:function(e){},onFinish:function(){}}),Ty.prototype=Object.assign(Object.create(Sy.prototype),{constructor:Ty,onUpdate:function(e){e=Math.round(e),this.bar.style.width=e+"%"},onFinish:function(){this.container.removeChild(this.background)}});var Ey,Cy,Py,Ly;function Ry(){}function Dy(e){Ci.call(this),this.type="CubeTextureHelper",this.geometry=new Fi(2,2,2,1,1,1),this.geometry.computeBoundingSphere(),this.material=new zr,this.material.envMap=e}function Ny(e){Bn.call(this),this.doUpdate=!0,this.projected=new un,this.container=e,this.updatedCallback=null}function Iy(e,t,n){Ny.call(this,e),this.type="Annotation",this.character=t,this.dialogContents=n,this.annotation=document.createElement("div"),this.annotation.innerHTML=t,this.annotation.className="v3d-annotation",this.container.appendChild(this.annotation),this.annotationDialogVisible=!1,this.annotationDialog=document.createElement("div"),this.annotationDialog.innerHTML=n,this.annotationDialog.className="v3d-annotation-dialog",this.annotation.appendChild(this.annotationDialog),this.fadeObscured=!0,this.obscured=!1,this.text=this.dialogContents,this.annotationText=this.annotationDialog;var r=!1,i=this;function a(e){e.target==i.annotation?0==i.annotationDialog.innerHTML.length||i.obscured||(i.annotationDialogVisible=!i.annotationDialogVisible,i.annotationDialog.style.visibility=i.annotationDialogVisible?"visible":"hidden",i.annotationDialogVisible?i.annotation.style.zIndex="1":i.annotation.style.zIndex="auto"):"v3d-annotation"==e.target.className&&(i.annotationDialogVisible=!1,i.annotationDialog.style.visibility="hidden",i.annotation.style.zIndex="auto")}this._touchstartCb=function(e){a(e),r=!0},document.body.addEventListener("touchstart",this._touchstartCb,!1),this._mousedownCb=function(e){r||a(e),r=!1},document.body.addEventListener("mousedown",this._mousedownCb,!1)}Object.assign(Ry.prototype,{_logicFileLoadError:function(e){var t=new Error(e);return t.name="LogicFileLoadError",t},_editorLoadError:function(e){var t=new Error(e);return t.name="EditorLoadError",t},_getLogicPromise:function(n){var r=this;return new Promise(function(e,t){Bv.loadScript(n,document.body,function(){e()},function(){t(r._logicFileLoadError("Unable to load the logic file: '"+n+"'."))})})},_getEditorPromise:function(n,e){var r=this;return new Promise(function(e,t){Bv.loadScript(n,document.body,function(){e()},function(){t(r._editorLoadError("Unable to load the Puzzles Editor: '"+n+"'."))})})},_getLogicViaEditorPromise:function(a,o){var s=this;return new Promise(function(t,n){var e,r,i=ni();i.v3d&&i.v3d.PE?((e=o.split("."))[e.length-1]="xml",r=e.join("."),i.v3d.PE.init(a,r,function(e){e?t():n(s._logicFileLoadError("Unable to load the Puzzles Editor's XML logic file: '"+r+"'."))})):n(s._editorLoadError("Unable to load Puzzles' logic. The Puzzles Editor isn't loaded."))})},_getAmmoJSPromise:function(){return"function"==typeof window.Ammo?new Promise(function(e,t){window.Ammo().then(function(){window.Ammo=Ammo,e()})}):Promise.resolve()},loadLogic:function(e,t,n){var r=this;this._getLogicPromise(e).then(function(){return r._getAmmoJSPromise()}).then(function(){t&&t()},function(e){console.error(e),n&&n(e)})},loadEditorWithLogic:function(e,t,n,r){var i=this;i._getEditorPromise(e+"puzzles.min.js").then(function(){return i._getLogicViaEditorPromise(e,t)}).catch(function(e){return"LogicFileLoadError"===e.name?Promise.resolve():Promise.reject(e)}).then(function(){return i._getAmmoJSPromise()}).then(function(){n&&n()}).catch(function(e){console.error(e),r&&r(e)})}}),(Dy.prototype=Object.create(Ci.prototype)).constructor=Dy,Ny.prototype=Object.assign(Object.create(Bn.prototype),{constructor:Ny,isAnnotationControl:!0,clone:function(){return new this.constructor(this.container).copy(this)},update:function(e){var t,n,r,i,a,o;this.doUpdate&&(t=this.projected,this.getWorldPosition(t).project(e),n=this.container.offsetWidth,r=this.container.offsetHeight,i=(.5+t.x/2)*n,a=(.5-t.y/2)*r,t.x=i,t.y=a,o=t.z<=1&&0<=i&&i<=n&&0<=a&&a<=r,this.visible=o,this.updatedCallback&&this.updatedCallback(t.x,t.y,o))}}),Iy.prototype=Object.assign(Object.create(Ny.prototype),{constructor:Iy,isAnnotation:!0,raycast:function(){},clone:function(){return new this.constructor(this.container,this.character,this.dialogContents).copy(this)},update:(Ey=new ss,Cy=new un,Py=new un,Ly=new un,function(e){Ny.prototype.update.call(this,e);var t,n=this.projected,r=this.annotation;r.style.transform="translate("+n.x+"px, "+n.y+"px)",r.style.visibility=this.visible?"visible":"hidden",this.annotationDialog.style.visibility=this.visible&&this.annotationDialogVisible?"visible":"hidden",this.fadeObscured&&(e.getWorldPositionNU(Cy),this.getWorldPositionNU(Py),Ly.copy(Py).sub(Cy).normalize(),Ey.set(Cy,Ly),Ey.far=Cy.distanceTo(Py),1<(t=Ey.intersectObject(this.findRoot(),!0)).length||1==t.length&&t[0].object!=this.parent?(r.className="v3d-annotation v3d-annotation-transparent",this.obscured=!0,this.annotationDialog.style.visibility="hidden"):(r.className="v3d-annotation",this.obscured=!1))}),setDialogVisibility:function(e){e?(this.annotationDialogVisible=!0,this.annotationDialog.style.visibility="visible",this.annotation.style.zIndex="1"):(this.annotationDialogVisible=!1,this.annotationDialog.style.visibility="hidden",this.annotation.style.zIndex="auto")},dispose:function(){var e=this.annotation.parentElement;e&&e.removeChild(this.annotation),document.body.removeEventListener("touchstart",this._touchstartCb,!1),document.body.removeEventListener("mousedown",this._mousedownCb,!1)}});var Oy,Fy,By={translateVRCamera:function(){var i=new un;new _n;return function(e,t,n){var r=e.parent;r&&!r.isScene&&(i.copy(t).applyQuaternion(e.quaternion).applyQuaternion(r.quaternion),r.position.add(i.multiplyScalar(n)))}}(),rotateVRCamera:(Oy=new sn,Fy=new sn,function(e,t,n){var r=e.parent;r&&!r.isScene&&(Oy.setFromAxisAngle(t,n),Oy.premultiply(e.quaternion),Oy.premultiply(r.quaternion),r.quaternion.multiplyQuaternions(Oy,Fy.copy(e.quaternion).inverse()))})};"undefined"!=typeof __v3d_DEVTOOLS__&&__v3d_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:REVISION}}));var zy,Uy=ni();Uy.v3d&&(Uy.THREE=Uy.v3d),"undefined"!=typeof document&&((zy=document.createElement("style")).appendChild(document.createTextNode(".v3d-container {\n \n overflow: hidden;\n z-index: 0;\n}\n.v3d-canvas {\n \n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n \n z-index: -1;\n}\n.v3d-simple-preloader-background {\n background-color: #fff;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n z-index: 1;\n height: 100%;\n width: 100%;\n}\n.v3d-simple-preloader-container {\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -90px;\n margin-left: -90px;\n width: 180px;\n height: 180px;\n}\n.v3d-simple-preloader-bar {\n background: linear-gradient(90deg, #1458ae, #4388e0);\n width: 0%;\n height: 3px;\n margin: 15px -1px;\n border: 1px solid;\n border-radius: 5px;\n border-color: #2b70c7;\n}\n.v3d-simple-preloader-logo {\n width: 110px;\n height: 120px;\n background-repeat: no-repeat;\n margin: 20px auto;\n}\n.v3d-annotation {\n position: absolute;\n top: -16px;\n left: -16px;\n width: auto;\n min-width: 14px;\n height: 26px;\n padding: 2px 8px;\n border: 1px solid #fff;\n border-radius: 18px;\n font-size: 16px;\n font-family: sans-serif;\n line-height: 26px;\n color: #fff;\n text-align: center;\n user-select: none;\n background: rgba(0, 0, 0, 0.8);\n}\n.v3d-annotation-transparent {\n opacity: 0.5;\n}\n.v3d-annotation-dialog {\n position: absolute;\n top: 0;\n left: 0;\n margin-left: 15px;\n margin-top: 31px;\n font-family: sans-serif;\n user-select: none;\n padding: 1em;\n min-width: 200px;\n color: #fff;\n background: rgba(0, 0, 0, 0.8);\n border-radius: .5em;\n font-size: 12px;\n line-height: 1.2;\n transition: opacity .5s;\n visibility: hidden;\n}\n.v3d-webgl-error {\n color: #015fb1;\n background-color: white;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -44px;\n margin-left: -256px;\n text-align: center;\n border-style: solid;\n border-width: 3px;\n border-radius: 8px;\n border-color: #015fb1;\n font-size: 20px;\n font-family: sans-serif;\n padding: 10px;\n line-height: 30px;\n z-index: 10;\n}\n@media only screen and (max-width: 540px) {\n .v3d-webgl-error {\n top: 50%;\n left: 10px;\n right: 10px;\n margin-top: -58px;\n margin-left: 0px;\n }\n}\n.v3d-webgl-error-link {\n color: #015fb1;\n}\n.v3d-device-motion-permissions-dialog {\n z-index: 1;\n position: absolute;\n width: 100%;\n background-color: #f00;\n color: #000;\n text-align: center;\n padding: 10px;\n}\n")),document.head.insertBefore(zy,document.head.firstChild)),t.ACESFilmicToneMapping=H,t.AVERAGE=1,t.AddEquation=de,t.AddOperation=k,t.AdditiveBlending=se,t.AlphaFormat=h,t.AlwaysDepth=Re,t.AlwaysStencilFunc=kt,t.AmbientLight=Pd,t.AmbientLightProbe=Kd,t.AnimationClip=Ou,t.AnimationLoader=ju,t.AnimationMixer=Bh,t.AnimationObjectGroup=Oh,t.AnimationUtils=Su,t.Annotation=Iy,t.AnnotationControl=Ny,t.App=py,t.AppPuzzles=_y,t.AppUtils=Bv,t.ArcCurve=Ku,t.ArrayCamera=is,t.ArrowHelper=bp,t.Audio=vh,t.AudioAnalyser=Mh,t.AudioContext=Hd,t.AudioListener=mh,t.AudioLoader=Yd,t.AxesHelper=Mp,t.AxisHelper=function(e){return console.warn("v3d.AxisHelper has been renamed to v3d.AxesHelper."),new Mp(e)},t.BackSide=Le,t.BasicDepthPacking=It,t.BasicShadowMap=Y,t.BilinearShadowMap=ne,t.BinaryTextureLoader=function(e){return console.warn("v3d.BinaryTextureLoader has been renamed to v3d.DataTextureLoader."),new Xu(e)},t.BlenderCubeTextureLoader=kv,t.BloomPass=hv,t.BokehPass=pv,t.Bone=ks,t.BooleanKeyframeTrack=Cu,t.BoundingBoxHelper=function(e,t){return console.warn("v3d.BoundingBoxHelper has been deprecated. Creating a v3d.BoxHelper instead."),new mp(e,t)},t.Box2=Gh,t.Box3=Jn,t.Box3Helper=vp,t.BoxBufferGeometry=Bi,t.BoxGeometry=Fi,t.BoxHelper=mp,t.BrightnessContrastPass=mv,t.BufferAttribute=Vr,t.BufferGeometry=ui,t.BufferGeometryLoader=Od,t.ByteType=i,t.CENTER=qf,t.CSVParser=yy,t.Cache=Bu,t.Camera=Wi,t.CameraHelper=hp,t.CameraUtils=ch,t.CanvasRenderer=function(){console.error("v3d.CanvasRenderer has been removed")},t.CanvasTexture=pl,t.CatmullRomCurve3=rd,t.ChildOfConstraint=Xm,t.CineonToneMapping=X,t.CircleBufferGeometry=yc,t.CircleGeometry=_c,t.ClampToEdgeWrapping=Qe,t.ClearMaskPass=yv,t.Clock=uh,t.ClosedSplineCurve3=wp,t.Color=Lr,t.ColorKeyframeTrack=Pu,t.Compat=zv,t.CompressedTexture=hl,t.CompressedTextureLoader=Wu,t.ConeBufferGeometry=gc,t.ConeGeometry=vc,t.Constraint=jm,t.CopyLocationConstraint=Hm,t.CopyRotationConstraint=Ym,t.CopyScaleConstraint=qm,t.CubeCamera=Hi,t.CubeCopy=lv,t.CubeGeometry=Fi,t.CubeReflectionMapping=Ge,t.CubeRefractionMapping=je,t.CubeTexture=_a,t.CubeTextureHelper=Dy,t.CubeTextureLoader=Yu,t.CubeUVReflectionMapping=Ye,t.CubeUVRefractionMapping=qe,t.CubicBezierCurve=sd,t.CubicBezierCurve3=ld,t.CubicInterpolant=Tu,t.CullFaceBack=K,t.CullFaceFront=J,t.CullFaceFrontBack=3,t.CullFaceNone=Q,t.Curve=Zu,t.CurvePath=_d,t.CustomBlending=ue,t.CylinderBufferGeometry=mc,t.CylinderGeometry=fc,t.Cylindrical=Vh,t.DataTexture=qi,t.DataTexture2DArray=ya,t.DataTexture3D=xa,t.DataTextureLoader=Xu,t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=Uu,t.DepthFormat=ht,t.DepthStencilFormat=pt,t.DepthTexture=fl,t.Detector=os,t.DirectionalLight=Cd,t.DirectionalLightHelper=cp,t.DirectionalLightShadow=Td,t.DirectionalLightShadowCSM=Ed,t.DiscreteInterpolant=Nc,t.DodecahedronBufferGeometry=El,t.DodecahedronGeometry=Tl,t.DoubleSide=ie,t.DstAlphaFactor=we,t.DstColorFactor=Se,t.DynamicBufferAttribute=function(e,t){return console.warn("v3d.DynamicBufferAttribute has been removed. Use new v3d.BufferAttribute().setUsage(v3d.DynamicDrawUsage) instead."),new Vr(e,t).setUsage(jt)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=jt,t.DynamicReadUsage=35049,t.ESMDistancePacking=Bt,t.ESMShadowMap=ee,t.EdgesGeometry=pc,t.EdgesHelper=function(e,t){return console.warn("v3d.EdgesHelper has been removed. Use v3d.EdgesGeometry instead."),new nl(new pc(e.geometry),new Ys({color:void 0!==t?t:16777215}))},t.EffectComposer=Uv,t.EllipseCurve=Qu,t.EqualDepth=Ie,t.EqualStencilFunc=514,t.EquiCube=cv,t.EquirectangularReflectionMapping=We,t.EquirectangularRefractionMapping=Xe,t.Euler=bn,t.EventDispatcher=o,t.ExtrudeBufferGeometry=$l,t.ExtrudeGeometry=Jl,t.FXAAPass=vv,t.Face3=Or,t.Face4=function(e,t,n,r,i,a,o){return console.warn("v3d.Face4 has been removed. A v3d.Face3 will be created instead."),new Or(e,t,n,i,a,o)},t.FaceColors=1,t.FileLoader=Gu,t.FilmicBlenderToneMapping=ke,t.FirstPersonControls=rv,t.FlatShading=1,t.Float32Attribute=function(e,t){return console.warn("v3d.Float32Attribute has been removed. Use new v3d.Float32BufferAttribute() instead."),new qr(e,t)},t.Float32BufferAttribute=qr,t.Float64Attribute=function(e,t){return console.warn("v3d.Float64Attribute has been removed. Use new v3d.Float64BufferAttribute() instead."),new Zr(e,t)},t.Float64BufferAttribute=Zr,t.FloatType=st,t.FloorConstraint=Zm,t.FlyingControls=iv,t.Fog=fs,t.FogExp2=ps,t.Font=Wd,t.FontLoader=Xd,t.FrontFaceDirectionCCW=1,t.FrontFaceDirectionCW=0,t.FrontSide=re,t.Frustum=Ki,t.GLTFLoader=Zg,t.GammaEncoding=Ct,t.Geometry=Oi,t.GeometryUtils=Tp,t.GraphUtils=Ic,t.GrayscalePass=gv,t.GreaterDepth=Fe,t.GreaterEqualDepth=Oe,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=ip,t.Group=as,t.HalfFloatType=lt,t.HemisphereLight=Md,t.HemisphereLightHelper=rp,t.HemisphereLightProbe=Qd,t.IBLEnvironmentPMREM=Yt,t.IBLEnvironmentProbe=2,t.IBLEnvironmentProbeCubemap=1,t.IcosahedronBufferGeometry=Sl,t.IcosahedronGeometry=Al,t.ImageBitmapLoader=Gd,t.ImageLoader=Hu,t.ImageUtils=en,t.ImmediateRenderObject=Hh,t.IncrementStencilOp=7682,t.IncrementWrapStencilOp=34055,t.InstancedBufferAttribute=Id,t.InstancedBufferGeometry=Nd,t.InstancedInterleavedBuffer=Uh,t.InstancedMesh=Hs,t.Int16Attribute=function(e,t){return console.warn("v3d.Int16Attribute has been removed. Use new v3d.Int16BufferAttribute() instead."),new Wr(e,t)},t.Int16BufferAttribute=Wr,t.Int32Attribute=function(e,t){return console.warn("v3d.Int32Attribute has been removed. Use new v3d.Int32BufferAttribute() instead."),new Hr(e,t)},t.Int32BufferAttribute=Hr,t.Int8Attribute=function(e,t){return console.warn("v3d.Int8Attribute has been removed. Use new v3d.Int8BufferAttribute() instead."),new kr(e,t)},t.Int8BufferAttribute=kr,t.IntType=l,t.InterleavedBuffer=ms,t.InterleavedBufferAttribute=_s,t.Interpolant=Dc,t.InterpolateDiscrete=r,t.InterpolateLinear=bt,t.InterpolateSmooth=Mt,t.InvertStencilOp=5386,t.JSONLoader=function(){console.error("v3d.JSONLoader has been removed.")},t.KeepStencilOp=Vt,t.KeyframeTrack=Eu,t.Keys=tv,t.LOD=Fs,t.LatheBufferGeometry=cc,t.LatheGeometry=lc,t.Layers=Mn,t.LensFlare=function(){console.error("v3d.LensFlare has been moved to /examples/js/objects/Lensflare.js")},t.LessDepth=De,t.LessEqualDepth=Ne,t.LessEqualStencilFunc=515,t.LessStencilFunc=513,t.Light=bd,t.LightProbe=Zd,t.LightProbeGenerator=$d,t.LightShadow=zo,t.LimitLocationConstraint=Qm,t.LimitRotationConstraint=Km,t.LimitScaleConstraint=Jm,t.Line=$s,t.Line3=Xh,t.LineBasicMaterial=Ys,t.LineCurve=cd,t.LineCurve3=ud,t.LineDashedMaterial=Lc,t.LineHTML=Ay,t.LineLoop=rl,t.LinePieces=1,t.LineSegments=nl,t.LineStrip=0,t.LinearDepthPacking=3202,t.LinearEncoding=Tt,t.LinearFilter=tt,t.LinearInterpolant=Gc,t.LinearMipMapLinearFilter=1008,t.LinearMipMapNearestFilter=1007,t.LinearMipmapLinearFilter=rt,t.LinearMipmapNearestFilter=nt,t.LinearToneMapping=ze,t.Loader=Vu,t.LoaderUtils=Dd,t.LoadingManager=zu,t.LockedTrackConstraint=$m,t.LogLuvEncoding=Lt,t.LogarithmicMaxToneMapping=Ue,t.LoopOnce=2200,t.LoopPingPong=2202,t.LoopRepeat=2201,t.LuminanceAlphaFormat=f,t.LuminanceFormat=p,t.MOD_SUITE=Wt,t.MOUSE=me,t.MaskPass=_v,t.Material=Br,t.MaterialLoader=Rd,t.MaterialUtils=Gm,t.Math=Kt,t.MathUtils=Kt,t.Matrix3=$t,t.Matrix4=_n,t.MaxEquation=ve,t.Mesh=Ci,t.MeshBVH=$f,t.MeshBasicMaterial=zr,t.MeshDepthMaterial=Ho,t.MeshDistanceMaterial=Yo,t.MeshFaceMaterial=function(e){return console.warn("v3d.MeshFaceMaterial has been removed. Use an Array instead."),e},t.MeshLambertMaterial=Cc,t.MeshLine=xv,t.MeshLineIndexed=Av,t.MeshLineMaterial=Tv,t.MeshMaskMaterial=Rc,t.MeshMatcapMaterial=Pc,t.MeshNodeMaterial=bu,t.MeshNormalMaterial=Ec,t.MeshPhongMaterial=Sc,t.MeshPhysicalMaterial=Ac,t.MeshStandardMaterial=wc,t.MeshToonMaterial=Tc,t.MinEquation=fe,t.MirroredRepeatWrapping=Ke,t.MixOperation=V,t.MultiMaterial=function(e){return void 0===e&&(e=[]),console.warn("v3d.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,(e.materials=e).clone=function(){return e.slice()},e},t.MultiplyBlending=ce,t.MultiplyOperation=U,t.NearestFilter=Je,t.NearestMipMapLinearFilter=1005,t.NearestMipMapNearestFilter=1004,t.NearestMipmapLinearFilter=et,t.NearestMipmapNearestFilter=$e,t.NeverDepth=Ce,t.NeverStencilFunc=512,t.NoBlending=ae,t.NoColors=s,t.NoToneMapping=G,t.NormalBlending=oe,t.NotEqualDepth=Be,t.NotEqualStencilFunc=517,t.NumberKeyframeTrack=Lu,t.Object3D=Bn,t.ObjectLoader=Bd,t.ObjectSpaceNormalMap=Ut,t.OctahedronBufferGeometry=wl,t.OctahedronGeometry=Ml,t.OneFactor=_e,t.OneMinusDstAlphaFactor=Ae,t.OneMinusDstColorFactor=Te,t.OneMinusSrcAlphaFactor=Me,t.OneMinusSrcColorFactor=xe,t.OrbitControls=sv,t.OrthographicCamera=na,t.OutlinePass=Ev,t.PCFShadowMap=q,t.PCFShadowMapPoissonDisk=te,t.PCFSoftShadowMap=Z,t.PMREMGenerator=Z_,t.ParametricBufferGeometry=gl,t.ParametricGeometry=vl,t.Particle=function(e){return console.warn("v3d.Particle has been renamed to v3d.Sprite."),new Ds(e)},t.ParticleBasicMaterial=function(e){return console.warn("v3d.ParticleBasicMaterial has been renamed to v3d.PointsMaterial."),new il(e)},t.ParticleSystem=function(e,t){return console.warn("v3d.ParticleSystem has been renamed to v3d.Points."),new cl(e,t)},t.ParticleSystemMaterial=function(e){return console.warn("v3d.ParticleSystemMaterial has been renamed to v3d.PointsMaterial."),new il(e)},t.Pass=uv,t.Path=yd,t.PerspectiveCamera=Xi,t.PhysicalMaxToneMapping=Ve,t.Plane=mr,t.PlaneBufferGeometry=ia,t.PlaneGeometry=ra,t.PlaneHelper=gp,t.PointCloud=function(e,t){return console.warn("v3d.PointCloud has been renamed to v3d.Points."),new cl(e,t)},t.PointCloudMaterial=function(e){return console.warn("v3d.PointCloudMaterial has been renamed to v3d.PointsMaterial."),new il(e)},t.PointLight=Sd,t.PointLightHelper=$h,t.Points=cl,t.PointsMaterial=il,t.PolarGridHelper=ap,t.PolyhedronBufferGeometry=yl,t.PolyhedronGeometry=_l,t.PositionalAudio=bh,t.Preloader=Sy,t.PropertyBinding=Ih,t.PropertyMixer=wh,t.PuzzlesLoader=Ry,t.QuadraticBezierCurve=dd,t.QuadraticBezierCurve3=hd,t.Quaternion=sn,t.QuaternionKeyframeTrack=Du,t.QuaternionLinearInterpolant=Ru,t.REVISION=Pe,t.RGBADepthPacking=Ot,t.RGBADistancePacking=Ft,t.RGBAFormat=dt,t.RGBAIntegerFormat=x,t.RGBA_ASTC_10x10_Format=_t,t.RGBA_ASTC_10x5_Format=mt,t.RGBA_ASTC_10x6_Format=vt,t.RGBA_ASTC_10x8_Format=gt,t.RGBA_ASTC_12x10_Format=yt,t.RGBA_ASTC_12x12_Format=xt,t.RGBA_ASTC_4x4_Format=R,t.RGBA_ASTC_5x4_Format=D,t.RGBA_ASTC_5x5_Format=N,t.RGBA_ASTC_6x5_Format=I,t.RGBA_ASTC_6x6_Format=O,t.RGBA_ASTC_8x5_Format=F,t.RGBA_ASTC_8x6_Format=B,t.RGBA_ASTC_8x8_Format=z,t.RGBA_PVRTC_2BPPV1_Format=P,t.RGBA_PVRTC_4BPPV1_Format=C,t.RGBA_S3TC_DXT1_Format=M,t.RGBA_S3TC_DXT3_Format=w,t.RGBA_S3TC_DXT5_Format=A,t.RGBDEncoding=Nt,t.RGBEEncoding=Pt,t.RGBEFormat=S,t.RGBELoader=Hg,t.RGBFormat=ut,t.RGBIntegerFormat=y,t.RGBM16Encoding=Dt,t.RGBM7Encoding=Rt,t.RGB_ETC1_Format=L,t.RGB_PVRTC_2BPPV1_Format=E,t.RGB_PVRTC_4BPPV1_Format=T,t.RGB_S3TC_DXT1_Format=b,t.RGFormat=v,t.RGIntegerFormat=g,t.RawShaderMaterial=Mc,t.Ray=dr,t.Raycaster=ss,t.RectAreaLight=Ld,t.RedFormat=ft,t.RedIntegerFormat=m,t.ReinhardToneMapping=j,t.RenderPass=Cv,t.RenderUtils=Dv,t.RepeatWrapping=Ze,t.ReplaceStencilOp=7681,t.ReverseSubtractEquation=pe,t.RingBufferGeometry=sc,t.RingGeometry=oc,t.SAH=Zf,t.SSAARenderPass=Pv,t.SSAOPass=Nv,t.Scene=zn,t.SceneBackground=cy,t.SceneUtils=uy,t.ShaderChunk=aa,t.ShaderLib=oa,t.ShaderMaterial=ji,t.ShaderPass=fv,t.ShadowMaterial=bc,t.Shape=xd,t.ShapeBufferGeometry=dc,t.ShapeGeometry=uc,t.ShapePath=jd,t.ShapeUtils=Zl,t.ShortType=a,t.SimplePreloader=Ty,t.Skeleton=Vs,t.SkeletonHelper=Jh,t.SkinnedMesh=Bs,t.SmoothShading=2,t.Sphere=rr,t.SphereBufferGeometry=ac,t.SphereGeometry=ic,t.Spherical=Zc,t.SphericalHarmonics3=qd,t.SphericalReflectionMapping=He,t.Spline=Sp,t.SplineCurve=pd,t.SplineCurve3=Ap,t.SpotLight=wd,t.SpotLightHelper=qh,t.SpotLightShadow=Uo,t.Sprite=Ds,t.SpriteMaterial=ys,t.SrcAlphaFactor=be,t.SrcAlphaSaturateFactor=Ee,t.SrcColorFactor=ye,t.StaticCopyUsage=35046,t.StaticDrawUsage=Gt,t.StaticReadUsage=35045,t.Stats=dy,t.StereoCamera=ah,t.StreamCopyUsage=35042,t.StreamDrawUsage=35040,t.StreamReadUsage=35041,t.StringKeyframeTrack=Nu,t.SubtractEquation=he,t.SubtractiveBlending=le,t.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},t.TangentSpaceNormalMap=zt,t.TargetConstraint=Wm,t.TetrahedronBufferGeometry=bl,t.TetrahedronGeometry=xl,t.TextBufferGeometry=rc,t.TextGeometry=nc,t.Texture=nn,t.TextureLoader=qu,t.ToneMapPass=Ov,t.TorusBufferGeometry=Nl,t.TorusGeometry=Dl,t.TorusKnotBufferGeometry=Rl,t.TorusKnotGeometry=Ll,t.TrackToConstraint=ev,t.Triangle=Tr,t.TriangleFanDrawMode=2,t.TriangleStripDrawMode=1,t.TrianglesDrawMode=0,t.TubeBufferGeometry=Pl,t.TubeGeometry=Cl,t.UVMapping=300,t.Uint16Attribute=function(e,t){return console.warn("v3d.Uint16Attribute has been removed. Use new v3d.Uint16BufferAttribute() instead."),new Xr(e,t)},t.Uint16BufferAttribute=Xr,t.Uint32Attribute=function(e,t){return console.warn("v3d.Uint32Attribute has been removed. Use new v3d.Uint32BufferAttribute() instead."),new Yr(e,t)},t.Uint32BufferAttribute=Yr,t.Uint8Attribute=function(e,t){return console.warn("v3d.Uint8Attribute has been removed. Use new v3d.Uint8BufferAttribute() instead."),new Gr(e,t)},t.Uint8BufferAttribute=Gr,t.Uint8ClampedAttribute=function(e,t){return console.warn("v3d.Uint8ClampedAttribute has been removed. Use new v3d.Uint8ClampedBufferAttribute() instead."),new jr(e,t)},t.Uint8ClampedBufferAttribute=jr,t.Uncharted2ToneMapping=W,t.Uniform=zh,t.UniformsLib=Ji,t.UniformsUtils=Vi,t.UnsignedByteType=it,t.UnsignedInt248Type=ct,t.UnsignedIntType=ot,t.UnsignedShort4444Type=c,t.UnsignedShort5551Type=u,t.UnsignedShort565Type=d,t.UnsignedShortType=at,t.V3DL=Xt,t.VSMShadowMap=$,t.Vector2=Jt,t.Vector3=un,t.Vector4=rn,t.VectorKeyframeTrack=Iu,t.Vertex=function(e,t,n){return console.warn("v3d.Vertex has been removed. Use v3d.Vector3 instead."),new un(e,t,n)},t.VertexColors=_,t.VideoTexture=dl,t.ViewportFitAuto=3,t.ViewportFitHorizontal=2,t.ViewportFitNone=Ht,t.ViewportFitVertical=1,t.Visualizer=im,t.WebGLCubeRenderTarget=Yi,t.WebGLMultisampleRenderTarget=on,t.WebGLRenderTarget=an,t.WebGLRenderTargetCube=function(e,t,n){return console.warn("v3d.WebGLRenderTargetCube(width, height, options) is now WebGLCubeRenderTarget(size, options)."),new Yi(e,n)},t.WebGLRenderer=hs,t.WebGLUtils=ts,t.WebXRUtils=By,t.WireframeGeometry=ml,t.WireframeHelper=function(e,t){return console.warn("v3d.WireframeHelper has been removed. Use v3d.WireframeGeometry instead."),new nl(new ml(e.geometry),new Ys({color:void 0!==t?t:16777215}))},t.WrapAroundEnding=St,t.XHRLoader=function(e){return console.warn("v3d.XHRLoader has been renamed to v3d.FileLoader."),new Gu(e)},t.XZ=jv,t.XZLoader=Xg,t.ZeroCurvatureEnding=wt,t.ZeroFactor=ge,t.ZeroSlopeEnding=At,t.ZeroStencilOp=0,t.acceleratedRaycast=lm,t.arrayMax=Kr,t.arrayMin=function(e){if(0===e.length)return 1/0;for(var t=e[0],n=1,r=e.length;n<r;++n)e[n]<t&&(t=e[n]);return t},t.clampArray=$r,t.computeBoundsTree=cm,t.disposeBoundsTree=um,t.getGlobalScope=ni,t.isDef=Jr,t.sRGBEncoding=Et,t.shaderFloatStr=ti,Object.defineProperty(t,"__esModule",{value:!0})});