!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.THREE=t.THREE||{})}(this,(function(t){"use strict";function e(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i>=4,r[t]=n[19===t?3&i|8:i]);return r.join("")}),clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},random16:function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*jt.DEG2RAD},radToDeg:function(t){return t*jt.RAD2DEG},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};function Wt(t,e){this.x=t||0,this.y=e||0}function Xt(t,e,i,n,r,a,o,s,c,h){Object.defineProperty(this,"id",{value:te()}),this.uuid=jt.generateUUID(),this.name="",this.sourceFile="",this.image=void 0!==t?t:Xt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Xt.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:et,this.wrapT=void 0!==n?n:et,this.magFilter=void 0!==r?r:st,this.minFilter=void 0!==a?a:ht,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:gt,this.type=void 0!==s?s:ut,this.offset=new Wt(0,0),this.repeat=new Wt(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:Dt,this.version=0,this.onUpdate=null}Wt.prototype={constructor:Wt,isVector2:!0,get width(){return this.x},set width(t){this.x=t},get height(){return this.y},set height(t){this.y=t},set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return void 0===o&&(o=new Wt,s=new Wt),o.set(t,t),s.set(e,e),this.clamp(o,s)},clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/i)},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(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this},rotateAround:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*i-a*n+t.x,this.y=r*n+a*i+t.y,this}},Xt.DEFAULT_IMAGE=void 0,Xt.DEFAULT_MAPPING=W,Xt.prototype={constructor:Xt,isTexture:!0,set needsUpdate(t){!0===t&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.4,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],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;void 0===i.uuid&&(i.uuid=jt.generateUUID()),void 0===t.images[i.uuid]&&(t.images[i.uuid]={uuid:i.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(i)}),e.image=i.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping===W){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case tt:t.x=t.x-Math.floor(t.x);break;case et:t.x=t.x<0?0:1;break;case it:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case tt:t.y=t.y-Math.floor(t.y);break;case et:t.y=t.y<0?0:1;break;case it:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}},Object.assign(Xt.prototype,e.prototype);var Yt,qt,Zt,Jt,Qt,Kt,$t=0;function te(){return $t++}function ee(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==n?n:1}function ie(t,e,i){this.uuid=jt.generateUUID(),this.width=t,this.height=e,this.scissor=new ee(0,0,t,e),this.scissorTest=!1,this.viewport=new ee(0,0,t,e),void 0===(i=i||{}).minFilter&&(i.minFilter=st),this.texture=new Xt(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function ne(t,e,i){ie.call(this,t,e,i),this.activeCubeFace=0,this.activeMipMapLevel=0}function re(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==n?n:1}function ae(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}function oe(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function se(t,e,i,n,r,a,o,s,c,h){t=void 0!==t?t:[],e=void 0!==e?e:X,Xt.call(this,t,e,i,n,r,a,o,s,c,h),this.flipY=!1}ee.prototype={constructor:ee,isVector4:!0,set:function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){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: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,n,r,a=.01,o=.1,s=t.elements,c=s[0],h=s[4],l=s[8],u=s[1],p=s[5],d=s[9],f=s[2],m=s[6],g=s[10];if(Math.abs(h-u)y&&v>x?vx?y0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(l-c)*e,this._y=(a-h)*e,this._z=(o-r)*e):n>s&&n>u?(e=2*Math.sqrt(1+n-s-u),this._w=(l-c)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(a+h)/e):s>u?(e=2*Math.sqrt(1+s-n-u),this._w=(a-h)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(c+l)/e):(e=2*Math.sqrt(1+u-n-s),this._w=(o-r)/e,this._x=(a+h)/e,this._y=(c+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(i,n){return void 0===t&&(t=new ae),(e=i.dot(n)+1)<1e-6?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,n),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,n=t._y,r=t._z,a=t._w,o=e._x,s=e._y,c=e._z,h=e._w;return this._x=i*h+a*o+n*c-r*s,this._y=n*h+a*s+r*o-i*c,this._z=r*h+a*c+i*s-n*o,this._w=a*h-i*o-n*s-r*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,n=this._y,r=this._z,a=this._w,o=a*t._w+i*t._x+n*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=n,this._z=r,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(i+this._x),this._y=.5*(n+this._y),this._z=.5*(r+this._z),this;var c=Math.atan2(s,o),h=Math.sin((1-e)*c)/s,l=Math.sin(e*c)/s;return this._w=a*h+this._w*l,this._x=i*h+this._x*l,this._y=n*h+this._y*l,this._z=r*h+this._z*l,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(re,{slerp:function(t,e,i,n){return i.copy(t).slerp(e,n)},slerpFlat:function(t,e,i,n,r,a,o){var s=i[n+0],c=i[n+1],h=i[n+2],l=i[n+3],u=r[a+0],p=r[a+1],d=r[a+2],f=r[a+3];if(l!==f||s!==u||c!==p||h!==d){var m=1-o,g=s*u+c*p+h*d+l*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var x=Math.sqrt(y),_=Math.atan2(x,g*v);m=Math.sin(m*_)/x,o=Math.sin(o*_)/x}var b=o*v;if(s=s*m+u*b,c=c*m+p*b,h=h*m+d*b,l=l*m+f*b,m===1-o){var w=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=w,c*=w,h*=w,l*=w}}t[e]=s,t[e+1]=c,t[e+2]=h,t[e+3]=l}}),ae.prototype={constructor:ae,isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return!1===(t&&t.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===Zt&&(Zt=new re),this.applyQuaternion(Zt.setFromEuler(t))},applyAxisAngle:function(){var t;return function(e,i){return void 0===t&&(t=new re),this.applyQuaternion(t.setFromAxisAngle(e,i))}}(),applyMatrix3:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12],this.y=r[1]*e+r[5]*i+r[9]*n+r[13],this.z=r[2]*e+r[6]*i+r[10]*n+r[14],this},applyProjection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements,a=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*a,this},applyQuaternion:function(t){var e=this.x,i=this.y,n=this.z,r=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*n-o*i,h=s*i+o*e-r*n,l=s*n+r*i-a*e,u=-r*e-a*i-o*n;return this.x=c*s+u*-r+h*-o-l*-a,this.y=h*s+u*-a+l*-r-c*-o,this.z=l*s+u*-o+c*-a-h*-r,this},project:function(t){return void 0===qt&&(qt=new oe),qt.multiplyMatrices(t.projectionMatrix,qt.getInverse(t.matrixWorld)),this.applyProjection(qt)},unproject:function(){var t;return function(e){return void 0===t&&(t=new oe),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyProjection(t)}}(),transformDirection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(i,n){return void 0===t&&(t=new ae,e=new ae),t.set(i,i,i),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/i)},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(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var i=this.x,n=this.y,r=this.z;return this.x=n*t.z-r*t.y,this.y=r*t.x-i*t.z,this.z=i*t.y-n*t.x,this},crossVectors:function(t,e){var i=t.x,n=t.y,r=t.z,a=e.x,o=e.y,s=e.z;return this.x=n*s-r*o,this.y=r*a-i*s,this.z=i*o-n*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return void 0===Yt&&(Yt=new ae),Yt.copy(this).projectOnVector(t),this.sub(Yt)},reflect:function(){var t;return function(e){return void 0===t&&(t=new ae),this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(jt.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var i=t;t=e,e=i}return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this}},oe.prototype={constructor:oe,isMatrix4:!0,set:function(t,e,i,n,r,a,o,s,c,h,l,u,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new oe).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new ae);var i=this.elements,n=e.elements,r=1/t.setFromMatrixColumn(e,0).length(),a=1/t.setFromMatrixColumn(e,1).length(),o=1/t.setFromMatrixColumn(e,2).length();return i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[4]=n[4]*a,i[5]=n[5]*a,i[6]=n[6]*a,i[8]=n[8]*o,i[9]=n[9]*o,i[10]=n[10]*o,this}}(),makeRotationFromEuler:function(t){!1===(t&&t.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,n=t.y,r=t.z,a=Math.cos(i),o=Math.sin(i),s=Math.cos(n),c=Math.sin(n),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){var u=a*h,p=a*l,d=o*h,f=o*l;e[0]=s*h,e[4]=-s*l,e[8]=c,e[1]=p+d*c,e[5]=u-f*c,e[9]=-o*s,e[2]=f-u*c,e[6]=d+p*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*h,g=s*l,v=c*h,y=c*l;e[0]=m+y*o,e[4]=v*o-g,e[8]=a*c,e[1]=a*l,e[5]=a*h,e[9]=-o,e[2]=g*o-v,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order)m=s*h,g=s*l,v=c*h,y=c*l,e[0]=m-y*o,e[4]=-a*l,e[8]=v+g*o,e[1]=g+v*o,e[5]=a*h,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s;else if("ZYX"===t.order)u=a*h,p=a*l,d=o*h,f=o*l,e[0]=s*h,e[4]=d*c-p,e[8]=u*c+f,e[1]=s*l,e[5]=f*c+u,e[9]=p*c-d,e[2]=-c,e[6]=o*s,e[10]=a*s;else if("YZX"===t.order){var x=a*s,_=a*c,b=o*s,w=o*c;e[0]=s*h,e[4]=w-x*l,e[8]=b*l+_,e[1]=l,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=_*l+b,e[10]=x-w*l}else"XZY"===t.order&&(x=a*s,_=a*c,b=o*s,w=o*c,e[0]=s*h,e[4]=-l,e[8]=c*h,e[1]=x*l+w,e[5]=a*h,e[9]=_*l-b,e[2]=b*l-_,e[6]=o*h,e[10]=w*l+x);return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,i=t.x,n=t.y,r=t.z,a=t.w,o=i+i,s=n+n,c=r+r,h=i*o,l=i*s,u=i*c,p=n*s,d=n*c,f=r*c,m=a*o,g=a*s,v=a*c;return e[0]=1-(p+f),e[4]=l-v,e[8]=u+g,e[1]=l+v,e[5]=1-(h+f),e[9]=d-m,e[2]=u-g,e[6]=d+m,e[10]=1-(h+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(t,e,i){void 0===Jt&&(Jt=new ae,Qt=new ae,Kt=new ae);var n=this.elements;return Kt.subVectors(t,e).normalize(),0===Kt.lengthSq()&&(Kt.z=1),Jt.crossVectors(i,Kt).normalize(),0===Jt.lengthSq()&&(Kt.z+=1e-4,Jt.crossVectors(i,Kt).normalize()),Qt.crossVectors(Kt,Jt),n[0]=Jt.x,n[4]=Qt.x,n[8]=Kt.x,n[1]=Jt.y,n[5]=Qt.y,n[9]=Kt.y,n[2]=Jt.z,n[6]=Qt.z,n[10]=Kt.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,a=i[0],o=i[4],s=i[8],c=i[12],h=i[1],l=i[5],u=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],x=i[11],_=i[15],b=n[0],w=n[4],M=n[8],E=n[12],T=n[1],S=n[5],A=n[9],L=n[13],R=n[2],P=n[6],C=n[10],I=n[14],U=n[3],N=n[7],D=n[11],O=n[15];return r[0]=a*b+o*T+s*R+c*U,r[4]=a*w+o*S+s*P+c*N,r[8]=a*M+o*A+s*C+c*D,r[12]=a*E+o*L+s*I+c*O,r[1]=h*b+l*T+u*R+p*U,r[5]=h*w+l*S+u*P+p*N,r[9]=h*M+l*A+u*C+p*D,r[13]=h*E+l*L+u*I+p*O,r[2]=d*b+f*T+m*R+g*U,r[6]=d*w+f*S+m*P+g*N,r[10]=d*M+f*A+m*C+g*D,r[14]=d*E+f*L+m*I+g*O,r[3]=v*b+y*T+x*R+_*U,r[7]=v*w+y*S+x*P+_*N,r[11]=v*M+y*A+x*C+_*D,r[15]=v*E+y*L+x*I+_*O,this},multiplyToArray:function(t,e,i){var n=this.elements;return this.multiplyMatrices(t,e),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToVector3Array:function(){var t;return function(e,i,n){void 0===t&&(t=new ae),void 0===i&&(i=0),void 0===n&&(n=e.length);for(var r=0,a=i;r0)return t;var r=e*i,a=ue[r];if(void 0===a&&(a=new Float32Array(r),ue[r]=a),0!==e){n.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=i,t[o].toArray(a,s)}return a}function fe(t,e){var i=pe[e];void 0===i&&(i=new Int32Array(e),pe[e]=i);for(var n=0;n!==e;++n)i[n]=t.allocTextureUnit();return i}function me(t,e){t.uniform1f(this.addr,e)}function ge(t,e){t.uniform1i(this.addr,e)}function ve(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function ye(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function xe(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function _e(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function be(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function we(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function Me(t,e,i){var n=i.allocTextureUnit();t.uniform1i(this.addr,n),i.setTexture2D(e||ce,n)}function Ee(t,e,i){var n=i.allocTextureUnit();t.uniform1i(this.addr,n),i.setTextureCube(e||he,n)}function Te(t,e){t.uniform2iv(this.addr,e)}function Se(t,e){t.uniform3iv(this.addr,e)}function Ae(t,e){t.uniform4iv(this.addr,e)}function Le(t,e){t.uniform1fv(this.addr,e)}function Re(t,e){t.uniform1iv(this.addr,e)}function Pe(t,e){t.uniform2fv(this.addr,de(e,this.size,2))}function Ce(t,e){t.uniform3fv(this.addr,de(e,this.size,3))}function Ie(t,e){t.uniform4fv(this.addr,de(e,this.size,4))}function Ue(t,e){t.uniformMatrix2fv(this.addr,!1,de(e,this.size,4))}function Ne(t,e){t.uniformMatrix3fv(this.addr,!1,de(e,this.size,9))}function De(t,e){t.uniformMatrix4fv(this.addr,!1,de(e,this.size,16))}function Oe(t,e,i){var n=e.length,r=fe(i,n);t.uniform1iv(this.addr,r);for(var a=0;a!==n;++a)i.setTexture2D(e[a]||ce,r[a])}function Fe(t,e,i){var n=e.length,r=fe(i,n);t.uniform1iv(this.addr,r);for(var a=0;a!==n;++a)i.setTextureCube(e[a]||he,r[a])}function Be(t,e,i){this.id=t,this.addr=i,this.setValue=function(t){switch(t){case 5126:return me;case 35664:return ve;case 35665:return ye;case 35666:return xe;case 35674:return _e;case 35675:return be;case 35676:return we;case 35678:return Me;case 35680:return Ee;case 5124:case 35670:return ge;case 35667:case 35671:return Te;case 35668:case 35672:return Se;case 35669:case 35673:return Ae}}(e.type)}function ze(t,e,i){this.id=t,this.addr=i,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Le;case 35664:return Pe;case 35665:return Ce;case 35666:return Ie;case 35674:return Ue;case 35675:return Ne;case 35676:return De;case 35678:return Oe;case 35680:return Fe;case 5124:case 35670:return Re;case 35667:case 35671:return Te;case 35668:case 35672:return Se;case 35669:case 35673:return Ae}}(e.type)}function Ge(t){this.id=t,le.call(this)}Ge.prototype.setValue=function(t,e){for(var i=this.seq,n=0,r=i.length;n!==r;++n){var a=i[n];a.setValue(t,e[a.id])}};var He=/([\w\d_]+)(\])?(\[|\.)?/g;function Ve(t,e){t.seq.push(e),t.map[e.id]=e}function ke(t,e,i){var n=t.name,r=n.length;for(He.lastIndex=0;;){var a=He.exec(n),o=He.lastIndex,s=a[1],c="]"===a[2],h=a[3];if(c&&(s|=0),void 0===h||"["===h&&o+2===r){Ve(i,void 0===h?new Be(s,t,e):new ze(s,t,e));break}var l=i.map[s];void 0===l&&Ve(i,l=new Ge(s)),i=l}}function je(t,e,i){le.call(this),this.renderer=i;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r!==n;++r){var a=t.getActiveUniform(e,r),o=a.name;ke(a,t.getUniformLocation(e,o),this)}}je.prototype.setValue=function(t,e,i){var n=this.map[e];void 0!==n&&n.setValue(t,i,this.renderer)},je.prototype.set=function(t,e,i){var n=this.map[i];void 0!==n&&n.setValue(t,e[i],this.renderer)},je.prototype.setOptional=function(t,e,i){var n=e[i];void 0!==n&&this.setValue(t,i,n)},je.upload=function(t,e,i,n){for(var r=0,a=e.length;r!==a;++r){var o=e[r],s=i[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,n)}},je.seqWithValue=function(t,e){for(var i=[],n=0,r=t.length;n!==r;++n){var a=t[n];a.id in e&&i.push(a)}return i};var We={merge:function(t){for(var e={},i=0;i 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn 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 ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\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 ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return 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.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return 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.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return 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 ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return 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 ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include \n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include \n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#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 ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_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 ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\t\t\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const 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 ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return 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 ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include \n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n}\n",normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include \n}\n",normal_vert:"varying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};function Ye(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}Ye.prototype={constructor:Ye,isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(){function t(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}return function(e,i,n){if(e=jt.euclideanModulo(e,1),i=jt.clamp(i,0,1),n=jt.clamp(n,0,1),0===i)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+i):n+i-n*i,a=2*n-r;this.r=t(a,r,e+1/3),this.g=t(a,r,e),this.b=t(a,r,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(o,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var h,l=(h=i[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}return t&&t.length>0&&(void 0!==(h=qe[t])?this.setHex(h):console.warn("THREE.Color: Unknown color "+t)),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(){var t=this.r,e=this.g,i=this.b;return this.r=t*t,this.g=e*e,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,i,n=t||{h:0,s:0,l:0},r=this.r,a=this.g,o=this.b,s=Math.max(r,a,o),c=Math.min(r,a,o),h=(c+s)/2;if(c===s)e=0,i=0;else{var l=s-c;switch(i=h<=.5?l/(s+c):l/(2-s-c),s){case r:e=(a-o)/l+(a.001&&R.scale>.001&&(b.x=R.x,b.y=R.y,b.z=R.z,x=R.size*R.scale/f.w,_.x=x*g,_.y=x,l.uniform3f(s.screenPosition,b.x,b.y,b.z),l.uniform2f(s.scale,_.x,_.y),l.uniform1f(s.rotation,R.rotation),l.uniform1f(s.opacity,R.opacity),l.uniform3f(s.color,R.color.r,R.color.g,R.color.b),u.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),t.setTexture2D(R.texture,1),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0))}}}u.enable(l.CULL_FACE),u.enable(l.DEPTH_TEST),u.setDepthWrite(!0),t.resetGLState()}var P,C}}function $e(t,e){var i,n,r,a,o,s,c=t.context,h=t.state,l=new ae,u=new re,p=new ae;function d(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(f,m){if(0!==e.length){void 0===r&&function(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),h=new Uint16Array([0,1,2,0,2,3]);i=c.createBuffer(),n=c.createBuffer(),c.bindBuffer(c.ARRAY_BUFFER,i),c.bufferData(c.ARRAY_BUFFER,e,c.STATIC_DRAW),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n),c.bufferData(c.ELEMENT_ARRAY_BUFFER,h,c.STATIC_DRAW),r=function(){var e=c.createProgram(),i=c.createShader(c.VERTEX_SHADER),n=c.createShader(c.FRAGMENT_SHADER);return c.shaderSource(i,["precision "+t.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),c.shaderSource(n,["precision "+t.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),c.compileShader(i),c.compileShader(n),c.attachShader(e,i),c.attachShader(e,n),c.linkProgram(e),e}(),a={position:c.getAttribLocation(r,"position"),uv:c.getAttribLocation(r,"uv")},o={uvOffset:c.getUniformLocation(r,"uvOffset"),uvScale:c.getUniformLocation(r,"uvScale"),rotation:c.getUniformLocation(r,"rotation"),scale:c.getUniformLocation(r,"scale"),color:c.getUniformLocation(r,"color"),map:c.getUniformLocation(r,"map"),opacity:c.getUniformLocation(r,"opacity"),modelViewMatrix:c.getUniformLocation(r,"modelViewMatrix"),projectionMatrix:c.getUniformLocation(r,"projectionMatrix"),fogType:c.getUniformLocation(r,"fogType"),fogDensity:c.getUniformLocation(r,"fogDensity"),fogNear:c.getUniformLocation(r,"fogNear"),fogFar:c.getUniformLocation(r,"fogFar"),fogColor:c.getUniformLocation(r,"fogColor"),alphaTest:c.getUniformLocation(r,"alphaTest")};var l=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");l.width=8,l.height=8;var u=l.getContext("2d");u.fillStyle="white",u.fillRect(0,0,8,8),(s=new Xt(l)).needsUpdate=!0}(),c.useProgram(r),h.initAttributes(),h.enableAttribute(a.position),h.enableAttribute(a.uv),h.disableUnusedAttributes(),h.disable(c.CULL_FACE),h.enable(c.BLEND),c.bindBuffer(c.ARRAY_BUFFER,i),c.vertexAttribPointer(a.position,2,c.FLOAT,!1,16,0),c.vertexAttribPointer(a.uv,2,c.FLOAT,!1,16,8),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n),c.uniformMatrix4fv(o.projectionMatrix,!1,m.projectionMatrix.elements),h.activeTexture(c.TEXTURE0),c.uniform1i(o.map,0);var g=0,v=0,y=f.fog;y?(c.uniform3f(o.fogColor,y.color.r,y.color.g,y.color.b),y&&y.isFog?(c.uniform1f(o.fogNear,y.near),c.uniform1f(o.fogFar,y.far),c.uniform1i(o.fogType,1),g=1,v=1):y&&y.isFogExp2&&(c.uniform1f(o.fogDensity,y.density),c.uniform1i(o.fogType,2),g=2,v=2)):(c.uniform1i(o.fogType,0),g=0,v=0);for(var x=0,_=e.length;x<_;x++)(w=e[x]).modelViewMatrix.multiplyMatrices(m.matrixWorldInverse,w.matrixWorld),w.z=-w.modelViewMatrix.elements[14];e.sort(d);var b=[];for(x=0,_=e.length;x<_;x++){var w,M=(w=e[x]).material;if(!1!==M.visible){c.uniform1f(o.alphaTest,M.alphaTest),c.uniformMatrix4fv(o.modelViewMatrix,!1,w.modelViewMatrix.elements),w.matrixWorld.decompose(l,u,p),b[0]=p.x,b[1]=p.y;var E=0;f.fog&&M.fog&&(E=v),g!==E&&(c.uniform1i(o.fogType,E),g=E),null!==M.map?(c.uniform2f(o.uvOffset,M.map.offset.x,M.map.offset.y),c.uniform2f(o.uvScale,M.map.repeat.x,M.map.repeat.y)):(c.uniform2f(o.uvOffset,0,0),c.uniform2f(o.uvScale,1,1)),c.uniform1f(o.opacity,M.opacity),c.uniform3f(o.color,M.color.r,M.color.g,M.color.b),c.uniform1f(o.rotation,M.rotation),c.uniform2fv(o.scale,b),h.setBlending(M.blending,M.blendEquation,M.blendSrc,M.blendDst),h.setDepthTest(M.depthTest),h.setDepthWrite(M.depthWrite),M.map?t.setTexture2D(M.map,0):t.setTexture2D(s,0),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}h.enable(c.CULL_FACE),t.resetGLState()}}}function ti(){Object.defineProperty(this,"id",{value:vi()}),this.uuid=jt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=_,this.side=d,this.shading=v,this.vertexColors=y,this.opacity=1,this.transparent=!1,this.blendSrc=A,this.blendDst=L,this.blendEquation=S,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=I,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this._needsUpdate=!0}Je.physical={uniforms:We.merge([Je.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},Qe.prototype={constructor:Qe,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new Wt).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new Wt).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new Wt;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},ti.prototype={constructor:ti,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},setValues:function(t){if(void 0!==t)for(var e in t){var i=t[e];if(void 0!==i){var n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]="overdraw"===e?Number(i):i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t;e&&(t={textures:{},images:{}});var i={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};function n(t){var e=[];for(var i in t){var n=t[i];delete n.metadata,e.push(n)}return e}if(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.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==_&&(i.blending=this.blending),this.shading!==v&&(i.shading=this.shading),this.side!==d&&(i.side=this.side),this.vertexColors!==y&&(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,this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),i.skinning=this.skinning,i.morphTargets=this.morphTargets,e){var r=n(t.textures),a=n(t.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.shading=t.shading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,i=null;if(null!==e){var n=e.length;i=new Array(n);for(var r=0;r!==n;++r)i[r]=e[r].clone()}return this.clippingPlanes=i,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(ti.prototype,e.prototype);var ei,ii,ni,ri,ai,oi,si,ci,hi,li,ui,pi,di,fi,mi,gi=0;function vi(){return gi++}function yi(t){ti.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",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,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function xi(t){ti.call(this),this.type="MeshDepthMaterial",this.depthPacking=Vt,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.lights=!1,this.setValues(t)}function _i(t,e){this.min=void 0!==t?t:new ae(1/0,1/0,1/0),this.max=void 0!==e?e:new ae(-1/0,-1/0,-1/0)}function bi(t,e){this.center=void 0!==t?t:new ae,this.radius=void 0!==e?e:0}function wi(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function Mi(t,e){this.normal=void 0!==t?t:new ae(1,0,0),this.constant=void 0!==e?e:0}function Ei(t,e,i,n,r,a){this.planes=[void 0!==t?t:new Mi,void 0!==e?e:new Mi,void 0!==i?i:new Mi,void 0!==n?n:new Mi,void 0!==r?r:new Mi,void 0!==a?a:new Mi]}function Ti(t,e,i,n){var r=t.context,a=t.state,o=new Ei,s=new oe,c=e.shadows,h=new Wt,l=new Wt(n.maxTextureSize,n.maxTextureSize),p=new ae,g=new ae,v=[],y=new Array(4),x=new Array(4),_={},b=[new ae(1,0,0),new ae(-1,0,0),new ae(0,0,1),new ae(0,0,-1),new ae(0,1,0),new ae(0,-1,0)],w=[new ae(0,1,0),new ae(0,1,0),new ae(0,1,0),new ae(0,1,0),new ae(0,0,1),new ae(0,0,-1)],M=[new ee,new ee,new ee,new ee,new ee,new ee],E=new xi;E.depthPacking=kt,E.clipping=!0;for(var T=Je.distanceRGBA,S=We.clone(T.uniforms),A=0;4!==A;++A){var L=!!(1&A),R=!!(2&A),P=E.clone();P.morphTargets=L,P.skinning=R,y[A]=P;var C=new yi({defines:{USE_SHADOWMAP:""},uniforms:S,vertexShader:T.vertexShader,fragmentShader:T.fragmentShader,morphTargets:L,skinning:R,clipping:!0});x[A]=C}var I=this;function U(e,i,n,r){var a=e.geometry,o=null,s=y,c=e.customDepthMaterial;if(n&&(s=x,c=e.customDistanceMaterial),c)o=c;else{var h=!1;i.morphTargets&&(a&&a.isBufferGeometry?h=a.morphAttributes&&a.morphAttributes.position&&a.morphAttributes.position.length>0:a&&a.isGeometry&&(h=a.morphTargets&&a.morphTargets.length>0));var l=0;h&&(l|=1),e.isSkinnedMesh&&i.skinning&&(l|=2),o=s[l]}if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var u=o.uuid,p=i.uuid,g=_[u];void 0===g&&(g={},_[u]=g);var v=g[p];void 0===v&&(v=o.clone(),g[p]=v),o=v}o.visible=i.visible,o.wireframe=i.wireframe;var b=i.side;return I.renderSingleSided&&b==m&&(b=d),I.renderReverseSided&&(b===d?b=f:b===f&&(b=d)),o.side=b,o.clipShadows=i.clipShadows,o.clippingPlanes=i.clippingPlanes,o.wireframeLinewidth=i.wireframeLinewidth,o.linewidth=i.linewidth,n&&void 0!==o.uniforms.lightPos&&o.uniforms.lightPos.value.copy(r),o}function N(t,e,i){if(!1!==t.visible){t.layers.mask&e.layers.mask&&(t.isMesh||t.isLine||t.isPoints)&&(!t.castShadow||!1!==t.frustumCulled&&!0!==o.intersectsObject(t)||!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),v.push(t)));for(var n=t.children,r=0,a=n.length;rr&&(r=h),l>a&&(a=l),u>o&&(o=u)}this.min.set(e,i,n),this.max.set(r,a,o)},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new ae).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return void 0===ii&&(ii=new ae),this.clampPoint(t.center,ii),ii.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=t.constant&&i>=t.constant},clampPoint:function(t,e){return(e||new ae).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new ae;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new ae;return function(e){var i=e||new bi;return this.getCenter(i.center),i.radius=.5*this.getSize(t).length(),i}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(ei=[new ae,new ae,new ae,new ae,new ae,new ae,new ae,new ae],function(t){return this.isEmpty()||(ei[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ei[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ei[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ei[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ei[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ei[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ei[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ei[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ei)),this}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},bi.prototype={constructor:bi,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(ni=new _i,function(t,e){var i=this.center;void 0!==e?i.copy(e):ni.setFromPoints(t).getCenter(i);for(var n=0,r=0,a=t.length;rthis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new _i;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}},wi.prototype={constructor:wi,isMatrix3:!0,set:function(t,e,i,n,r,a,o,s,c){var h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=r,h[5]=s,h[6]=i,h[7]=a,h[8]=c,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(t){var e=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]),this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToVector3Array:function(){var t;return function(e,i,n){void 0===t&&(t=new ae),void 0===i&&(i=0),void 0===n&&(n=e.length);for(var r=0,a=i;r1?void 0:n.copy(r).multiplyScalar(o).add(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new ae).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new ae,e=new wi;return function(i,n){var r=this.coplanarPoint(t).applyMatrix4(i),a=n||e.getNormalMatrix(i),o=this.normal.applyMatrix3(a).normalize();return this.constant=-r.dot(o),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},Ei.prototype={constructor:Ei,set:function(t,e,i,n,r,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,n=i[0],r=i[1],a=i[2],o=i[3],s=i[4],c=i[5],h=i[6],l=i[7],u=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(o-n,l-s,f-u,y-m).normalize(),e[1].setComponents(o+n,l+s,f+u,y+m).normalize(),e[2].setComponents(o+r,l+c,f+p,y+g).normalize(),e[3].setComponents(o-r,l-c,f-p,y-g).normalize(),e[4].setComponents(o-a,l-h,f-d,y-v).normalize(),e[5].setComponents(o+a,l+h,f+d,y+v).normalize(),this},intersectsObject:(oi=new bi,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),oi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(oi)}),intersectsSprite:function(){var t=new bi;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,i=t.center,n=-t.radius,r=0;r<6;r++)if(e[r].distanceToPoint(i)0?t.min.x:t.max.x,ai.x=n.normal.x>0?t.max.x:t.min.x,ri.y=n.normal.y>0?t.min.y:t.max.y,ai.y=n.normal.y>0?t.max.y:t.min.y,ri.z=n.normal.z>0?t.min.z:t.max.z,ai.z=n.normal.z>0?t.max.z:t.min.z;var r=n.distanceToPoint(ri),a=n.distanceToPoint(ai);if(r<0&&a<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}},Si.prototype={constructor:Si,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new ae).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new ae;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var i=e||new ae;i.subVectors(t,this.origin);var n=i.dot(this.direction);return n<0?i.copy(this.origin):i.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new ae;return function(e){var i=t.subVectors(e,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(i).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:(ci=new ae,hi=new ae,li=new ae,function(t,e,i,n){ci.copy(t).add(e).multiplyScalar(.5),hi.copy(e).sub(t).normalize(),li.copy(this.origin).sub(ci);var r,a,o,s,c=.5*t.distanceTo(e),h=-this.direction.dot(hi),l=li.dot(this.direction),u=-li.dot(hi),p=li.lengthSq(),d=Math.abs(1-h*h);if(d>0)if(a=h*l-u,s=c*d,(r=h*u-l)>=0)if(a>=-s)if(a<=s){var f=1/d;o=(r*=f)*(r+h*(a*=f)+2*l)+a*(h*r+a+2*u)+p}else a=c,o=-(r=Math.max(0,-(h*a+l)))*r+a*(a+2*u)+p;else a=-c,o=-(r=Math.max(0,-(h*a+l)))*r+a*(a+2*u)+p;else a<=-s?o=-(r=Math.max(0,-(-h*c+l)))*r+(a=r>0?-c:Math.min(Math.max(-c,-u),c))*(a+2*u)+p:a<=s?(r=0,o=(a=Math.min(Math.max(-c,-u),c))*(a+2*u)+p):o=-(r=Math.max(0,-(h*c+l)))*r+(a=r>0?c:Math.min(Math.max(-c,-u),c))*(a+2*u)+p;else a=h>0?-c:c,o=-(r=Math.max(0,-(h*a+l)))*r+a*(a+2*u)+p;return i&&i.copy(this.direction).multiplyScalar(r).add(this.origin),n&&n.copy(hi).multiplyScalar(a).add(ci),o}),intersectSphere:function(){var t=new ae;return function(e,i){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),r=t.dot(t)-n*n,a=e.radius*e.radius;if(r>a)return null;var o=Math.sqrt(a-r),s=n-o,c=n+o;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var i,n,r,a,o,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(i=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),i>a||r>n?null:((r>i||i!=i)&&(i=r),(a=0?(o=(t.min.z-u.z)*l,s=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,s=(t.min.z-u.z)*l),i>s||o>n?null:((o>i||i!=i)&&(i=o),(s=0?i:n,e)))},intersectsBox:(si=new ae,function(t){return null!==this.intersectBox(t,si)}),intersectTriangle:function(){var t=new ae,e=new ae,i=new ae,n=new ae;return function(r,a,o,s,c){e.subVectors(a,r),i.subVectors(o,r),n.crossVectors(e,i);var h,l=this.direction.dot(n);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}t.subVectors(this.origin,r);var u=h*this.direction.dot(i.crossVectors(t,i));if(u<0)return null;var p=h*this.direction.dot(e.cross(t));if(p<0)return null;if(u+p>l)return null;var d=-h*t.dot(n);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}},Ai.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Ai.DefaultOrder="XYZ",Ai.prototype={constructor:Ai,isEuler:!0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,i){var n=jt.clamp,r=t.elements,a=r[0],o=r[4],s=r[8],c=r[1],h=r[5],l=r[9],u=r[2],p=r[6],d=r[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,h),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,a),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(c,a))):"ZYX"===e?(this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,a)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(p,h),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var t;return function(e,i,n){return void 0===t&&(t=new oe),t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,i,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(ui=new re,function(t){return ui.setFromEuler(this),this.setFromQuaternion(ui,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new ae(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Li.prototype={constructor:Li,set:function(t){this.mask=1<1){for(var e=0;e1)for(var e=0;e0){n.children=[];for(var r=0;r0&&(i.geometries=a),o.length>0&&(i.materials=o),s.length>0&&(i.textures=s),c.length>0&&(i.images=c)}return i.object=n,i;function h(t){var e=[];for(var i in t){var n=t[i];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var i=0;i0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}),Fi.barycoordFromPoint=function(){var t=new ae,e=new ae,i=new ae;return function(n,r,a,o,s){t.subVectors(o,r),e.subVectors(a,r),i.subVectors(n,r);var c=t.dot(t),h=t.dot(e),l=t.dot(i),u=e.dot(e),p=e.dot(i),d=c*u-h*h,f=s||new ae;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(u*l-h*p)*m,v=(c*p-h*l)*m;return f.set(1-g-v,v,g)}}(),Fi.containsPoint=function(){var t=new ae;return function(e,i,n,r){var a=Fi.barycoordFromPoint(e,i,n,r,t);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),Fi.prototype={constructor:Fi,set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new ae,e=new ae;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new ae).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Fi.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new Mi).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Fi.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Fi.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,i,n;return function(r,a){void 0===t&&(t=new Mi,e=[new Oi,new Oi,new Oi],i=new ae,n=new ae);var o=a||new ae,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(r,i),!0===this.containsPoint(i))o.copy(i);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,i;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,n,r;for(i=0,n=this.faces.length;i0&&(t+=e[i].distanceTo(e[i-1])),this.lineDistances[i]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new _i),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new bi),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(!1!==(t&&t.isGeometry)){var n,r=this.vertices.length,a=this.vertices,o=t.vertices,s=this.faces,c=t.faces,h=this.faceVertexUvs[0],l=t.faceVertexUvs[0],u=this.colors,p=t.colors;void 0===i&&(i=0),void 0!==e&&(n=(new wi).getNormalMatrix(e));for(var d=0,f=o.length;d=0;i--){var f=p[i];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,x=0;if(x=M(x,0,0),x=M(x,1,!0),x=M(x,2,!1),x=M(x,3,f),x=M(x,4,m),x=M(x,5,g),x=M(x,6,v),x=M(x,7,y),o.push(x),o.push(d.a,d.b,d.c),o.push(d.materialIndex),f){var _=this.faceVertexUvs[0][r];o.push(S(_[0]),S(_[1]),S(_[2]))}if(m&&o.push(E(d.normal)),g){var b=d.vertexNormals;o.push(E(b[0]),E(b[1]),E(b[2]))}if(v&&o.push(T(d.color)),y){var w=d.vertexColors;o.push(T(w[0]),T(w[1]),T(w[2]))}}function M(t,e,i){return i?t|1<0&&(t.data.colors=h),u.length>0&&(t.data.uvs=[u]),t.data.faces=o,t},clone:function(){return(new ji).copy(this)},copy:function(t){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]],this.colors=[];for(var e=t.vertices,i=0,n=e.length;i65535?Uint32Array:Uint16Array)(p),f=new Float32Array(3*u),m=new Float32Array(3*u),g=new Float32Array(2*u),v=0,y=0,x=0,_=0,b=0;function w(t,e,i,n,r,a,o,s,c,h,u){for(var p=a/c,w=o/h,M=a/2,E=o/2,T=s/2,S=c+1,A=h+1,L=0,R=0,P=new ae,C=0;C0?1:-1,m[v]=P.x,m[v+1]=P.y,m[v+2]=P.z,g[y]=U/c,g[y+1]=1-C/h,v+=3,y+=2,L+=1}for(C=0;C65535?Uint32Array:Uint16Array)(o*s*6);for(v=0;v0,o=r[1]&&r[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var h=0;h0){for(l=[],h=0;h0){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Gi(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Gi(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var r=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Gi(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Gi(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var o=new(t.vertices.length>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Gi(o,1).copyIndicesArray(t.indices))}for(var s in this.groups=t.groups,t.morphTargets){for(var c=[],h=t.morphTargets[s],l=0,u=h.length;l0){var f=new ki(4*t.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new ki(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new _i);var t=this.attributes.position.array;void 0!==t?this.boundingBox.setFromArray(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new _i,e=new ae;return function(){null===this.boundingSphere&&(this.boundingSphere=new bi);var i=this.attributes.position;if(i){var n=i.array,r=this.boundingSphere.center;t.setFromArray(n),t.getCenter(r);for(var a=0,o=0,s=n.length;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new qi).copy(this)},copy:function(t){var e=t.index;null!==e&&this.setIndex(e.clone());var i=t.attributes;for(var n in i){var r=i[n];this.addAttribute(n,r.clone())}for(var a=t.groups,o=0,s=a.length;o0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,i=t.length;ee.far?null:{distance:c,point:g.clone(),object:t}}function x(t,e,i,o,s,c,p,f){n.fromArray(o,3*c),r.fromArray(o,3*p),a.fromArray(o,3*f);var m=y(t,e,i,n,r,a,d);return m&&(s&&(h.fromArray(s,2*c),l.fromArray(s,2*p),u.fromArray(s,2*f),m.uv=v(d,n,r,a,h,l,u)),m.face=new Bi(c,p,f,Fi.normal(n,r,a)),m.faceIndex=c),m}return function(p,f){var m,g,_=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===_.boundingSphere&&_.computeBoundingSphere(),i.copy(_.boundingSphere),i.applyMatrix4(w),!1!==p.ray.intersectsSphere(i)&&(t.getInverse(w),e.copy(p.ray).applyMatrix4(t),null===_.boundingBox||!1!==e.intersectsBox(_.boundingBox))))if(_&&_.isBufferGeometry){var M,E,T,S=_.index,A=_.attributes,L=A.position.array;if(void 0!==A.uv&&(m=A.uv.array),null!==S)for(var R=S.array,P=0,C=R.length;P0&&(m=z);for(var G=0,H=B.length;G/g,(function(t,e){var i=Xe[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return fn(i)}))}function mn(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,(function(t,e,i,n){for(var r="",a=parseInt(e);a0?t.gammaFactor:1,_=function(t,e,i){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(pn).join("\n")}(a,n,t.extensions),b=function(t){var e=[];for(var i in t){var n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(o),w=r.createProgram();i.isRawShaderMaterial?(m=[b,"\n"].filter(pn).join("\n"),g=[_,b,"\n"].filter(pn).join("\n")):(m=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+i.__webglShader.name,b,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+x,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",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.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.vertexColors?"#define USE_COLOR":"",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":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(pn).join("\n"),g=[_,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+i.__webglShader.name,b,n.alphaTest?"#define ALPHATEST "+n.alphaTest:"","#define GAMMA_FACTOR "+x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",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.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",n.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",n.toneMapping!==G?"#define TONE_MAPPING":"",n.toneMapping!==G?Xe.tonemapping_pars_fragment:"",n.toneMapping!==G?un("toneMapping",n.toneMapping):"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?Xe.encodings_pars_fragment:"",n.mapEncoding?ln("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?ln("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?ln("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?("linearToOutputTexel",v=n.outputEncoding,y=hn(v),"vec4 linearToOutputTexel( vec4 value ) { return LinearTo"+y[0]+y[1]+"; }"):"",n.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(pn).join("\n")),s=dn(s=fn(s),n),c=dn(c=fn(c),n),i.isShaderMaterial||(s=mn(s),c=mn(c));var M=m+s,E=g+c,T=an(r,r.VERTEX_SHADER,M),S=an(r,r.FRAGMENT_SHADER,E);r.attachShader(w,T),r.attachShader(w,S),void 0!==i.index0AttributeName?r.bindAttribLocation(w,0,i.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(w,0,"position"),r.linkProgram(w);var A,L,R=r.getProgramInfoLog(w),P=r.getShaderInfoLog(T),C=r.getShaderInfoLog(S),I=!0,U=!0;return!1===r.getProgramParameter(w,r.LINK_STATUS)?(I=!1,console.error("THREE.WebGLProgram: shader error: ",r.getError(),"gl.VALIDATE_STATUS",r.getProgramParameter(w,r.VALIDATE_STATUS),"gl.getProgramInfoLog",R,P,C)):""!==R?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",R):""!==P&&""!==C||(U=!1),U&&(this.diagnostics={runnable:I,material:i,programLog:R,vertexShader:{log:P,prefix:m},fragmentShader:{log:C,prefix:g}}),r.deleteShader(T),r.deleteShader(S),this.getUniforms=function(){return void 0===A&&(A=new je(r,w,t)),A},this.getAttributes=function(){return void 0===L&&(L=function(t,e,i){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),a=0;a0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===m,flipSided:i.side===f,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(t,e){var i=[];if(e.shaderID?i.push(e.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)i.push(n),i.push(t.defines[n]);for(var a=0;a65535?Uint32Array:Uint16Array)(o),1);return r(m,t.ELEMENT_ARRAY_BUFFER),n.wireframe=m,m},update:function(e){var i=n.get(e);e.geometry.isGeometry&&i.updateFromObject(e);var a=i.index,o=i.attributes;for(var s in null!==a&&r(a,t.ELEMENT_ARRAY_BUFFER),o)r(o[s],t.ARRAY_BUFFER);var c=i.morphAttributes;for(var s in c)for(var h=c[s],l=0,u=h.length;le||t.height>e){var i=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*i),n.height=Math.floor(t.height*i),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+n.width+"x"+n.height,t),n}return t}function l(t){return jt.isPowerOfTwo(t.width)&&jt.isPowerOfTwo(t.height)}function u(e){return e===rt||e===at||e===ot?t.NEAREST:t.LINEAR}function p(e){var i=e.target;i.removeEventListener("dispose",p),function(e){var i=n.get(e);if(e.image&&i.__image__webglTextureCube)t.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture)}n.delete(e)}(i),s.textures--}function d(e){var i=e.target;i.removeEventListener("dispose",d),function(e){var i=n.get(e),r=n.get(e.texture);if(e){if(void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e&&e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(i.__webglFramebuffer[a]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[a]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer);n.delete(e.texture),n.delete(e)}}(i),s.textures--}function f(e,o){var u=n.get(e);if(e.version>0&&u.__version!==e.version){var d=e.image;if(void 0===d)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==d.complete)return void function(e,n,o){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),s.textures++),i.activeTexture(t.TEXTURE0+o),i.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var u=h(n.image,r.maxTextureSize);(function(t){return t.wrapS!==et||t.wrapT!==et||t.minFilter!==rt&&t.minFilter!==st})(n)&&!1===l(u)&&(u=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=jt.nearestPowerOfTwo(t.width),e.height=jt.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}(u));var d=l(u),f=a(n.format),g=a(n.type);m(t.TEXTURE_2D,n,d);var v,y=n.mipmaps;if(n&&n.isDepthTexture){var x=t.DEPTH_COMPONENT;if(n.type===dt){if(!c)throw new Error("Float Depth Texture only supported in WebGL2.0");x=t.DEPTH_COMPONENT32F}else c&&(x=t.DEPTH_COMPONENT16);n.format===xt&&(x=t.DEPTH_STENCIL),i.texImage2D(t.TEXTURE_2D,0,x,u.width,u.height,0,f,g,null)}else if(n&&n.isDataTexture)if(y.length>0&&d){for(var _=0,b=y.length;_-1?i.compressedTexImage2D(t.TEXTURE_2D,_,f,v.width,v.height,0,v.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(t.TEXTURE_2D,_,f,v.width,v.height,0,f,g,v.data);else if(y.length>0&&d){for(_=0,b=y.length;_1||n.get(o).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function g(e,r,o,s){var c=a(r.texture.format),h=a(r.texture.type);i.texImage2D(s,0,c,r.width,r.height,0,c,h,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,o,s,n.get(r.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,i){t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):i.depthBuffer&&i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,i.width,i.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(e,o){var c=n.get(e);if(6===e.image.length)if(e.version>0&&c.__version!==e.version){c.__image__webglTextureCube||(e.addEventListener("dispose",p),c.__image__webglTextureCube=t.createTexture(),s.textures++),i.activeTexture(t.TEXTURE0+o),i.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var u=e&&e.isCompressedTexture,d=e.image[0]&&e.image[0].isDataTexture,f=[],g=0;g<6;g++)f[g]=u||d?d?e.image[g].image:e.image[g]:h(e.image[g],r.maxCubemapSize);var v=l(f[0]),y=a(e.format),x=a(e.type);for(m(t.TEXTURE_CUBE_MAP,e,v),g=0;g<6;g++)if(u)for(var _,b=f[g].mipmaps,w=0,M=b.length;w-1?i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,y,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,y,_.width,_.height,0,y,x,_.data);else d?i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,f[g].width,f[g].height,0,y,x,f[g].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,y,x,f[g]);e.generateMipmaps&&v&&t.generateMipmap(t.TEXTURE_CUBE_MAP),c.__version=e.version,e.onUpdate&&e.onUpdate(e)}else i.activeTexture(t.TEXTURE0+o),i.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,r){i.activeTexture(t.TEXTURE0+r),i.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var r=n.get(e),a=n.get(e.texture);e.addEventListener("dispose",d),a.__webglTexture=t.createTexture(),s.textures++;var o=e&&e.isWebGLRenderTargetCube,c=l(e);if(o){r.__webglFramebuffer=[];for(var h=0;h<6;h++)r.__webglFramebuffer[h]=t.createFramebuffer()}else r.__webglFramebuffer=t.createFramebuffer();if(o){for(i.bindTexture(t.TEXTURE_CUBE_MAP,a.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,c),h=0;h<6;h++)g(r.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);e.texture.generateMipmaps&&c&&t.generateMipmap(t.TEXTURE_CUBE_MAP),i.bindTexture(t.TEXTURE_CUBE_MAP,null)}else i.bindTexture(t.TEXTURE_2D,a.__webglTexture),m(t.TEXTURE_2D,e.texture,c),g(r.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&c&&t.generateMipmap(t.TEXTURE_2D),i.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&function(e){var i=n.get(e),r=e&&e.isWebGLRenderTargetCube;if(e.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),f(i.depthTexture,0);var r=n.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===yt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(i.depthTexture.format!==xt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}(i.__webglFramebuffer,e)}else if(r){i.__webglDepthbuffer=[];for(var a=0;a<6;a++)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer[a]),i.__webglDepthbuffer[a]=t.createRenderbuffer(),v(i.__webglDepthbuffer[a],e)}else t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),v(i.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}(e)},this.updateRenderTargetMipmap=function(e){var r=e.texture;if(r.generateMipmaps&&l(e)&&r.minFilter!==rt&&r.minFilter!==st){var a=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,o=n.get(r).__webglTexture;i.bindTexture(a,o),t.generateMipmap(a),i.bindTexture(a,null)}}}function bn(){var t={};return{get:function(e){var i=e.uuid,n=t[i];return void 0===n&&(n={},t[i]=n),n},delete:function(e){delete t[e.uuid]},clear:function(){t={}}}}function wn(t,e,i){var n=new function(){var e=!1,i=new ee,n=null,r=new ee;return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,a,o){i.set(e,n,a,o),!1===r.equals(i)&&(t.clearColor(e,n,a,o),r.copy(i))},reset:function(){e=!1,n=null,r.set(0,0,0,1)}}},r=new function(){var e=!1,i=null,n=null,r=null;return{setTest:function(e){e?J(t.DEPTH_TEST):Q(t.DEPTH_TEST)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case R:t.depthFunc(t.NEVER);break;case P:t.depthFunc(t.ALWAYS);break;case C:t.depthFunc(t.LESS);break;case I:t.depthFunc(t.LEQUAL);break;case U:t.depthFunc(t.EQUAL);break;case N:t.depthFunc(t.GEQUAL);break;case D:t.depthFunc(t.GREATER);break;case O:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},a=new function(){var e=!1,i=null,n=null,r=null,a=null,o=null,s=null,c=null,h=null;return{setTest:function(e){e?J(t.STENCIL_TEST):Q(t.STENCIL_TEST)},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,o){n===e&&r===i&&a===o||(t.stencilFunc(e,i,o),n=e,r=i,a=o)},setOp:function(e,i,n){o===e&&s===i&&c===n||(t.stencilOp(e,i,n),o=e,s=i,c=n)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,i=null,n=null,r=null,a=null,o=null,s=null,c=null,h=null}}},o=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(o),u=new Uint8Array(o),p=new Uint8Array(o),d={},f=null,m=null,g=null,v=null,y=null,T=null,S=null,A=null,L=!1,F=null,B=null,z=null,G=null,H=null,V=null,k=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),j=null,W={},X=new ee,Y=new ee;function q(e,i,n){var r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var o=0;o0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a=void 0!==i.precision?i.precision:"highp",o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);var s=!0===i.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),u=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),d=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=h>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var i=e.get("EXT_texture_filter_anisotropic");return n=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:u,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}function En(t){var e={};return{get:function(i){if(void 0!==e[i])return e[i];var n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(i)}return null===n&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),e[i]=n,n}}}function Tn(){var t=this,e=null,i=0,n=!1,r=!1,a=new Mi,o=new wi,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(e,i,n,r){var c=null!==e?e.length:0,h=null;if(0!==c){if(h=s.value,!0!==r||null===h){var l=n+4*c,u=i.matrixWorldInverse;o.getNormalMatrix(u),(null===h||h.length=0&&t.numSupportedMorphTargets++}if(t.morphNormals)for(t.numSupportedMorphNormals=0,l=0;l=0&&t.numSupportedMorphNormals++;var u=n.__webglShader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=Y.numPlanes,n.numIntersection=Y.numIntersection,u.clippingPlanes=Y.uniform),n.fog=e,n.lightsHash=$.hash,t.lights&&(u.ambientLightColor.value=$.ambient,u.directionalLights.value=$.directional,u.spotLights.value=$.spot,u.pointLights.value=$.point,u.hemisphereLights.value=$.hemi,u.directionalShadowMap.value=$.directionalShadowMap,u.directionalShadowMatrix.value=$.directionalShadowMatrix,u.spotShadowMap.value=$.spotShadowMap,u.spotShadowMatrix.value=$.spotShadowMatrix,u.pointShadowMap.value=$.pointShadowMap,u.pointShadowMatrix.value=$.pointShadowMatrix);var p=n.program.getUniforms(),d=je.seqWithValue(p.seq,u);n.uniformsList=d}(i,e,n),i.needsUpdate=!1);var o,s,c=!1,h=!1,l=!1,u=r.program,p=u.getUniforms(),d=r.__webglShader.uniforms;if(u.id!==E&&(w.useProgram(u.program),E=u.id,c=!0,h=!0,l=!0),i.id!==P&&(P=i.id,h=!0),c||t!==I){if(p.set(w,t,"projectionMatrix"),Lt.logarithmicDepthBuffer&&p.setValue(w,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==I&&(I=t,h=!0,l=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var f=p.map.cameraPosition;void 0!==f&&f.setValue(w,K.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&p.setValue(w,"viewMatrix",t.matrixWorldInverse),p.set(w,M,"toneMappingExposure"),p.set(w,M,"toneMappingWhitePoint")}if(i.skinning){p.setOptional(w,n,"bindMatrix"),p.setOptional(w,n,"bindMatrixInverse");var m=n.skeleton;m&&(Lt.floatVertexTextures&&m.useVertexTexture?(p.set(w,m,"boneTexture"),p.set(w,m,"boneTextureWidth"),p.set(w,m,"boneTextureHeight")):p.setOptional(w,m,"boneMatrices"))}return h&&(i.lights&&(s=l,(o=d).ambientLightColor.needsUpdate=s,o.directionalLights.needsUpdate=s,o.pointLights.needsUpdate=s,o.spotLights.needsUpdate=s,o.hemisphereLights.needsUpdate=s),e&&i.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(d,e),(i.isMeshBasicMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshDepthMaterial)&&function(t,e){var i;if(t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?i=e.map:e.specularMap?i=e.specularMap:e.displacementMap?i=e.displacementMap:e.normalMap?i=e.normalMap:e.bumpMap?i=e.bumpMap:e.roughnessMap?i=e.roughnessMap:e.metalnessMap?i=e.metalnessMap:e.alphaMap?i=e.alphaMap:e.emissiveMap&&(i=e.emissiveMap),void 0!==i){i.isWebGLRenderTarget&&(i=i.texture);var n=i.offset,r=i.repeat;t.offsetRepeat.value.set(n.x,n.y,r.x,r.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}(d,i),i.isLineBasicMaterial?pe(d,i):i.isLineDashedMaterial?(pe(d,i),function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(d,i)):i.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*V,t.scale.value=.5*G,t.map.value=e.map,null!==e.map){var i=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}}(d,i):i.isMeshLambertMaterial?function(t,e){e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(d,i):i.isMeshPhongMaterial?function(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(d,i):i.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,de(t,e)}(d,i):i.isMeshStandardMaterial?de(d,i):i.isMeshDepthMaterial?i.displacementMap&&(d.displacementMap.value=i.displacementMap,d.displacementScale.value=i.displacementScale,d.displacementBias.value=i.displacementBias):i.isMeshNormalMaterial&&(d.opacity.value=i.opacity),je.upload(w,r.uniformsList,d,M)),p.set(w,n,"modelViewMatrix"),p.set(w,n,"normalMatrix"),p.setValue(w,"modelMatrix",n.matrixWorld),u}function pe(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function de(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function fe(t){var e;if(t===tt)return w.REPEAT;if(t===et)return w.CLAMP_TO_EDGE;if(t===it)return w.MIRRORED_REPEAT;if(t===rt)return w.NEAREST;if(t===at)return w.NEAREST_MIPMAP_NEAREST;if(t===ot)return w.NEAREST_MIPMAP_LINEAR;if(t===st)return w.LINEAR;if(t===ct)return w.LINEAR_MIPMAP_NEAREST;if(t===ht)return w.LINEAR_MIPMAP_LINEAR;if(t===ut)return w.UNSIGNED_BYTE;if(1017===t)return w.UNSIGNED_SHORT_4_4_4_4;if(1018===t)return w.UNSIGNED_SHORT_5_5_5_1;if(1019===t)return w.UNSIGNED_SHORT_5_6_5;if(1010===t)return w.BYTE;if(1011===t)return w.SHORT;if(t===pt)return w.UNSIGNED_SHORT;if(1013===t)return w.INT;if(1014===t)return w.UNSIGNED_INT;if(t===dt)return w.FLOAT;if(t===ft&&null!==(e=vt.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(1021===t)return w.ALPHA;if(t===mt)return w.RGB;if(t===gt)return w.RGBA;if(1024===t)return w.LUMINANCE;if(1025===t)return w.LUMINANCE_ALPHA;if(t===yt)return w.DEPTH_COMPONENT;if(t===xt)return w.DEPTH_STENCIL;if(t===S)return w.FUNC_ADD;if(101===t)return w.FUNC_SUBTRACT;if(102===t)return w.FUNC_REVERSE_SUBTRACT;if(200===t)return w.ZERO;if(201===t)return w.ONE;if(202===t)return w.SRC_COLOR;if(203===t)return w.ONE_MINUS_SRC_COLOR;if(t===A)return w.SRC_ALPHA;if(t===L)return w.ONE_MINUS_SRC_ALPHA;if(206===t)return w.DST_ALPHA;if(207===t)return w.ONE_MINUS_DST_ALPHA;if(208===t)return w.DST_COLOR;if(209===t)return w.ONE_MINUS_DST_COLOR;if(210===t)return w.SRC_ALPHA_SATURATE;if((t===_t||t===bt||t===wt||t===Mt)&&null!==(e=vt.get("WEBGL_compressed_texture_s3tc"))){if(t===_t)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===bt)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===wt)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Mt)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===Et||t===Tt||t===St||t===At)&&null!==(e=vt.get("WEBGL_compressed_texture_pvrtc"))){if(t===Et)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===Tt)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===St)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===At)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(2151===t&&null!==(e=vt.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((103===t||104===t)&&null!==(e=vt.get("EXT_blend_minmax"))){if(103===t)return e.MIN_EXT;if(104===t)return e.MAX_EXT}return 1020===t&&null!==(e=vt.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}this.getContext=function(){return w},this.getContextAttributes=function(){return w.getContextAttributes()},this.forceContextLoss=function(){vt.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return Lt.getMaxAnisotropy()},this.getPrecision=function(){return Lt.precision},this.getPixelRatio=function(){return V},this.setPixelRatio=function(t){void 0!==t&&(V=t,this.setSize(W.z,W.w,!1))},this.getSize=function(){return{width:z,height:G}},this.setSize=function(t,i,n){z=t,G=i,e.width=t*V,e.height=i*V,!1!==n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i)},this.setViewport=function(t,e,i,n){Rt.viewport(W.set(t,e,i,n))},this.setScissor=function(t,e,i,n){Rt.scissor(k.set(t,e,i,n))},this.setScissorTest=function(t){Rt.setScissorTest(j=t)},this.getClearColor=function(){return F},this.setClearColor=function(t,e){F.set(t),B=void 0!==e?e:1,jt(F.r,F.g,F.b,B)},this.getClearAlpha=function(){return B},this.setClearAlpha=function(t){B=t,jt(F.r,F.g,F.b,B)},this.clear=function(t,e,i){var n=0;(void 0===t||t)&&(n|=w.COLOR_BUFFER_BIT),(void 0===e||e)&&(n|=w.DEPTH_BUFFER_BIT),(void 0===i||i)&&(n|=w.STENCIL_BUFFER_BIT),w.clear(n)},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.clearTarget=function(t,e,i,n){this.setRenderTarget(t),this.clear(e,i,n)},this.resetGLState=Xt,this.dispose=function(){p=[],d=-1,l=[],u=-1,e.removeEventListener("webglcontextlost",Qt,!1)},this.renderBufferImmediate=function(t,e,i){Rt.initAttributes();var n=Pt.get(t);t.hasPositions&&!n.position&&(n.position=w.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=w.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=w.createBuffer()),t.hasColors&&!n.color&&(n.color=w.createBuffer());var r=e.getAttributes();if(t.hasPositions&&(w.bindBuffer(w.ARRAY_BUFFER,n.position),w.bufferData(w.ARRAY_BUFFER,t.positionArray,w.DYNAMIC_DRAW),Rt.enableAttribute(r.position),w.vertexAttribPointer(r.position,3,w.FLOAT,!1,0,0)),t.hasNormals){if(w.bindBuffer(w.ARRAY_BUFFER,n.normal),!i.isMeshPhongMaterial&&!i.isMeshStandardMaterial&&i.shading===g)for(var a=0,o=3*t.count;a8&&(l.length=8);var f=i.morphAttributes;for(u=0,p=l.length;u=0){var l=a[c];if(void 0!==l){var u=w.FLOAT,p=l.array,d=l.normalized;p instanceof Float32Array?u=w.FLOAT:p instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):p instanceof Uint16Array?u=w.UNSIGNED_SHORT:p instanceof Int16Array?u=w.SHORT:p instanceof Uint32Array?u=w.UNSIGNED_INT:p instanceof Int32Array?u=w.INT:p instanceof Int8Array?u=w.BYTE:p instanceof Uint8Array&&(u=w.UNSIGNED_BYTE);var f=l.itemSize,m=It.getAttributeBuffer(l);if(l.isInterleavedBufferAttribute){var g=l.data,v=g.stride,y=l.offset;g&&g.isInstancedInterleavedBuffer?(Rt.enableAttributeAndDivisor(h,g.meshPerAttribute,r),void 0===i.maxInstancedCount&&(i.maxInstancedCount=g.meshPerAttribute*g.count)):Rt.enableAttribute(h),w.bindBuffer(w.ARRAY_BUFFER,m),w.vertexAttribPointer(h,f,u,d,v*g.array.BYTES_PER_ELEMENT,(n*v+y)*g.array.BYTES_PER_ELEMENT)}else l.isInstancedBufferAttribute?(Rt.enableAttributeAndDivisor(h,l.meshPerAttribute,r),void 0===i.maxInstancedCount&&(i.maxInstancedCount=l.meshPerAttribute*l.count)):Rt.enableAttribute(h),w.bindBuffer(w.ARRAY_BUFFER,m),w.vertexAttribPointer(h,f,u,d,0,n*f*l.array.BYTES_PER_ELEMENT)}else if(void 0!==s){var x=s[c];if(void 0!==x)switch(x.length){case 2:w.vertexAttrib2fv(h,x);break;case 3:w.vertexAttrib3fv(h,x);break;case 4:w.vertexAttrib4fv(h,x);break;default:w.vertexAttrib1fv(h,x)}}}}Rt.disableUnusedAttributes()}}(n,o,i),null!==m&&w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,It.getAttributeBuffer(m)));var b=0;null!==m?b=m.count:void 0!==x&&(b=x.count);var M=i.drawRange.start*_,E=i.drawRange.count*_,T=null!==a?a.start*_:0,S=null!==a?a.count*_:1/0,A=Math.max(M,T),L=Math.min(b,M+E,T+S)-1,R=Math.max(0,L-A+1);if(0!==R){if(r.isMesh)if(!0===n.wireframe)Rt.setLineWidth(n.wireframeLinewidth*kt()),y.setMode(w.LINES);else switch(r.drawMode){case Nt:y.setMode(w.TRIANGLES);break;case 1:y.setMode(w.TRIANGLE_STRIP);break;case 2:y.setMode(w.TRIANGLE_FAN)}else if(r.isLine){var P=n.linewidth;void 0===P&&(P=1),Rt.setLineWidth(P*kt()),r.isLineSegments?y.setMode(w.LINES):y.setMode(w.LINE_STRIP)}else r.isPoints&&y.setMode(w.POINTS);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&y.renderInstances(i,A,R):y.render(A,R)}},this.render=function(t,e,i,n){if(void 0===e||!0===e.isCamera){C="",P=-1,I=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),Q.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),X.setFromMatrix(Q),h.length=0,u=-1,d=-1,_.length=0,b.length=0,Z=this.localClippingEnabled,q=Y.init(this.clippingPlanes,Z,e),ce(t,e),l.length=u+1,p.length=d+1,!0===M.sortObjects&&(l.sort(ie),p.sort(ne)),q&&Y.beginShadows(),function(t){for(var e=0,i=0,n=t.length;i=Lt.maxTextures&&console.warn("WebGLRenderer: trying to use "+t+" texture units while this GPU supports only "+Lt.maxTextures),O+=1,t},this.setTexture2D=(qt=!1,function(t,e){t&&t.isWebGLRenderTarget&&(qt||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),qt=!0),t=t.texture),Ct.setTexture2D(t,e)}),this.setTexture=function(){var t=!1;return function(e,i){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),Ct.setTexture2D(e,i)}}(),this.setTextureCube=function(){var t=!1;return function(e,i){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?Ct.setTextureCube(e,i):Ct.setTextureCubeDynamic(e,i)}}(),this.getCurrentRenderTarget=function(){return T},this.setRenderTarget=function(t){T=t,t&&void 0===Pt.get(t).__webglFramebuffer&&Ct.setupRenderTarget(t);var e,i=t&&t.isWebGLRenderTargetCube;if(t){var n=Pt.get(t);e=i?n.__webglFramebuffer[t.activeCubeFace]:n.__webglFramebuffer,U.copy(t.scissor),N=t.scissorTest,D.copy(t.viewport)}else e=null,U.copy(k).multiplyScalar(V),N=j,D.copy(W).multiplyScalar(V);if(R!==e&&(w.bindFramebuffer(w.FRAMEBUFFER,e),R=e),Rt.scissor(U),Rt.setScissorTest(N),Rt.viewport(D),i){var r=Pt.get(t.texture);w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,r.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,i,n,r,a){if(!1!==(t&&t.isWebGLRenderTarget)){var o=Pt.get(t).__webglFramebuffer;if(o){var s=!1;o!==R&&(w.bindFramebuffer(w.FRAMEBUFFER,o),s=!0);try{var c=t.texture,h=c.format,l=c.type;if(h!==gt&&fe(h)!==w.getParameter(w.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===ut||fe(l)===w.getParameter(w.IMPLEMENTATION_COLOR_READ_TYPE)||l===dt&&(vt.get("OES_texture_float")||vt.get("WEBGL_color_buffer_float"))||l===ft&&vt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");w.checkFramebufferStatus(w.FRAMEBUFFER)===w.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&w.readPixels(e,i,n,r,fe(h),fe(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&w.bindFramebuffer(w.FRAMEBUFFER,R)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function An(t,e){this.name="",this.color=new Ye(t),this.density=void 0!==e?e:25e-5}function Ln(t,e,i){this.name="",this.color=new Ye(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function Rn(){Ri.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Pn(t,e,i,n,r){Ri.call(this),this.lensFlares=[],this.positionScreen=new ae,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,i,n,r)}function Cn(t){ti.call(this),this.type="SpriteMaterial",this.color=new Ye(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function In(t){Ri.call(this),this.type="Sprite",this.material=void 0!==t?t:new Cn}function Un(){Ri.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Nn(t,e,i,n,r,a,o,s,c,h,l,u){Xt.call(this,null,a,o,s,c,h,n,r,l,u),this.image={data:t,width:e,height:i},this.magFilter=void 0!==c?c:rt,this.minFilter=void 0!==h?h:rt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Dn(t,e,i){if(this.useVertexTexture=void 0===i||i,this.identityMatrix=new oe,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var n=Math.sqrt(4*this.bones.length);n=jt.nextPowerOfTwo(Math.ceil(n)),n=Math.max(n,4),this.boneTextureWidth=n,this.boneTextureHeight=n,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new Nn(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,gt,dt)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var r=0,a=this.bones.length;r=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}()}function Wn(t,e,i,n,r,a,o,s,c,h,l,u){Xt.call(this,null,a,o,s,c,h,n,r,l,u),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Xn(t,e,i,n,r,a,o,s,c){Xt.call(this,t,e,i,n,r,a,o,s,c),this.needsUpdate=!0}function Yn(t,e,i,n,r,a,o,s,c,h){if((h=void 0!==h?h:yt)!==yt&&h!==xt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");Xt.call(this,null,n,r,a,o,s,h,i,c),this.image={width:t,height:e},this.type=void 0!==i?i:pt,this.magFilter=void 0!==o?o:rt,this.minFilter=void 0!==s?s:rt,this.flipY=!1,this.generateMipmaps=!1}function qn(t){qi.call(this);var e=[0,0],i={};function n(t,e){return t-e}var r=["a","b","c"];if(t&&t.isGeometry){for(var a=t.vertices,o=t.faces,s=0,c=new Uint32Array(6*o.length),h=0,l=o.length;h65535?Vi:Hi)(m,1)),this.addAttribute("position",ki(c,3)),this.addAttribute("uv",ki(h,2)),this.computeVertexNormals()}function Jn(t,e,i){ji.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i},this.fromBufferGeometry(new Zn(t,e,i)),this.mergeVertices()}function Qn(t,e,i,n){qi.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n},i=i||1;var r=[],a=[];function o(t,e,i,n){var r,a,o=Math.pow(2,n),c=[];for(r=0;r<=o;r++){c[r]=[];var h=t.clone().lerp(i,r/o),l=e.clone().lerp(i,r/o),u=o-r;for(a=0;a<=u;a++)c[r][a]=0===a&&r===o?h:h.clone().lerp(l,a/u)}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),i<.2&&(a[t+2]+=1),n<.2&&(a[t+4]+=1))}}()}(),this.addAttribute("position",ki(r,3)),this.addAttribute("normal",ki(r.slice(),3)),this.addAttribute("uv",ki(a,2)),this.normalizeNormals(),this.boundingSphere=new bi(new ae,i)}function Kn(t,e){Qn.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],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function $n(t,e){ji.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Kn(t,e)),this.mergeVertices()}function tr(t,e){Qn.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],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function er(t,e){ji.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new tr(t,e)),this.mergeVertices()}function ir(t,e){var i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];Qn.call(this,n,[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],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function nr(t,e){ji.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ir(t,e)),this.mergeVertices()}function rr(t,e){var i=(1+Math.sqrt(5))/2,n=1/i,r=[-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,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n];Qn.call(this,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],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ar(t,e){ji.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new rr(t,e)),this.mergeVertices()}function or(t,e,i,n){ji.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n},this.fromBufferGeometry(new Qn(t,e,i,n)),this.mergeVertices()}function sr(t,e,i,n,r){qi.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r},e=e||64,i=i||1,n=n||8,r=r||!1;var a=t.computeFrenetFrames(e,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new ae,h=new ae,l=new Wt,u=[],p=[],d=[],f=[];function m(r){var o=t.getPointAt(r/e),l=a.normals[r],d=a.binormals[r];for(s=0;s<=n;s++){var f=s/n*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);h.x=g*l.x+m*d.x,h.y=g*l.y+m*d.y,h.z=g*l.z+m*d.z,h.normalize(),p.push(h.x,h.y,h.z),c.x=o.x+i*h.x,c.y=o.y+i*h.y,c.z=o.z+i*h.z,u.push(c.x,c.y,c.z)}}!function(){for(o=0;o65535?Vi:Hi)(f,1)),this.addAttribute("position",ki(u,3)),this.addAttribute("normal",ki(p,3)),this.addAttribute("uv",ki(d,2))}function cr(t,e,i,n,r,a){ji.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new sr(t,e,i,n,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function hr(t,e,i,n,r,a){qi.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:a},t=t||100,e=e||40,i=Math.floor(i)||64,r=r||2,a=a||3;var o,s,c=((n=Math.floor(n)||8)+1)*(i+1),h=n*i*2*3,l=new Gi(new(h>65535?Uint32Array:Uint16Array)(h),1),u=new Gi(new Float32Array(3*c),3),p=new Gi(new Float32Array(3*c),3),d=new Gi(new Float32Array(2*c),2),f=0,m=0,g=new ae,v=new ae,y=new Wt,x=new ae,_=new ae,b=new ae,w=new ae,M=new ae;for(o=0;o<=i;++o){var E=o/i*r*Math.PI*2;for(I(E,r,a,t,x),I(E+.01,r,a,t,_),w.subVectors(_,x),M.addVectors(_,x),b.crossVectors(w,M),M.crossVectors(b,w),b.normalize(),M.normalize(),s=0;s<=n;++s){var T=s/n*Math.PI*2,S=-e*Math.cos(T),A=e*Math.sin(T);g.x=x.x+(S*M.x+A*b.x),g.y=x.y+(S*M.y+A*b.y),g.z=x.z+(S*M.z+A*b.z),u.setXYZ(f,g.x,g.y,g.z),v.subVectors(g,x).normalize(),p.setXYZ(f,v.x,v.y,v.z),y.x=o/i,y.y=s/n,d.setXY(f,y.x,y.y),f++}}for(s=1;s<=i;s++)for(o=1;o<=n;o++){var L=(n+1)*(s-1)+(o-1),R=(n+1)*s+(o-1),P=(n+1)*s+o,C=(n+1)*(s-1)+o;l.setX(m,L),m++,l.setX(m,R),m++,l.setX(m,C),m++,l.setX(m,R),m++,l.setX(m,P),m++,l.setX(m,C),m++}function I(t,e,i,n,r){var a=Math.cos(t),o=Math.sin(t),s=i/e*t,c=Math.cos(s);r.x=n*(2+c)*.5*a,r.y=n*(2+c)*o*.5,r.z=n*Math.sin(s)*.5}this.setIndex(l),this.addAttribute("position",u),this.addAttribute("normal",p),this.addAttribute("uv",d)}function lr(t,e,i,n,r,a,o){ji.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:a},void 0!==o&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new hr(t,e,i,n,r,a)),this.mergeVertices()}function ur(t,e,i,n,r){qi.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},t=t||100,e=e||40,i=Math.floor(i)||8,n=Math.floor(n)||6,r=r||2*Math.PI;var a,o,s=(i+1)*(n+1),c=i*n*2*3,h=new(c>65535?Uint32Array:Uint16Array)(c),l=new Float32Array(3*s),u=new Float32Array(3*s),p=new Float32Array(2*s),d=0,f=0,m=0,g=new ae,v=new ae,y=new ae;for(a=0;a<=i;a++)for(o=0;o<=n;o++){var x=o/n*r,_=a/i*Math.PI*2;v.x=(t+e*Math.cos(_))*Math.cos(x),v.y=(t+e*Math.cos(_))*Math.sin(x),v.z=e*Math.sin(_),l[d]=v.x,l[d+1]=v.y,l[d+2]=v.z,g.x=t*Math.cos(x),g.y=t*Math.sin(x),y.subVectors(v,g).normalize(),u[d]=y.x,u[d+1]=y.y,u[d+2]=y.z,p[f]=o/n,p[f+1]=a/i,d+=3,f+=2}for(a=1;a<=i;a++)for(o=1;o<=n;o++){var b=(n+1)*a+o-1,w=(n+1)*(a-1)+o-1,M=(n+1)*(a-1)+o,E=(n+1)*a+o;h[m]=b,h[m+1]=w,h[m+2]=E,h[m+3]=w,h[m+4]=M,h[m+5]=E,m+=6}this.setIndex(new Gi(h,1)),this.addAttribute("position",new Gi(l,3)),this.addAttribute("normal",new Gi(u,3)),this.addAttribute("uv",new Gi(p,2))}function pr(t,e,i,n,r){ji.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},this.fromBufferGeometry(new ur(t,e,i,n,r))}An.prototype.isFogExp2=!0,An.prototype.clone=function(){return new An(this.color.getHex(),this.density)},An.prototype.toJSON=function(t){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},Ln.prototype.isFog=!0,Ln.prototype.clone=function(){return new Ln(this.color.getHex(),this.near,this.far)},Ln.prototype.toJSON=function(t){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},Rn.prototype=Object.create(Ri.prototype),Rn.prototype.constructor=Rn,Rn.prototype.copy=function(t,e){return Ri.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},Rn.prototype.toJSON=function(t){var e=Ri.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e},Pn.prototype=Object.assign(Object.create(Ri.prototype),{constructor:Pn,isLensFlare:!0,copy:function(t){Ri.prototype.copy.call(this,t),this.positionScreen.copy(t.positionScreen),this.customUpdateCallback=t.customUpdateCallback;for(var e=0,i=t.lensFlares.length;ethis.scale.x*this.scale.y/4||e.push({distance:Math.sqrt(i),point:this.position,face:null,object:this})}),clone:function(){return new this.constructor(this.material).copy(this)}}),Un.prototype=Object.assign(Object.create(Ri.prototype),{constructor:Un,copy:function(t){Ri.prototype.copy.call(this,t,!1);for(var e=t.levels,i=0,n=e.length;i1){t.setFromMatrixPosition(i.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var r=t.distanceTo(e);n[0].object.visible=!0;for(var a=1,o=n.length;a=n[a].distance;a++)n[a-1].object.visible=!1,n[a].object.visible=!0;for(;ao||(p.applyMatrix4(this.matrixWorld),(M=n.ray.origin.distanceTo(p))n.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this}))}else for(v=0,y=m.length/3-1;vo||(p.applyMatrix4(this.matrixWorld),(M=n.ray.origin.distanceTo(p))n.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this}))}else if(s&&s.isGeometry){var b=s.vertices,w=b.length;for(v=0;vo||(p.applyMatrix4(this.matrixWorld),(M=n.ray.origin.distanceTo(p))n.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this}))}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Gn.prototype=Object.assign(Object.create(zn.prototype),{constructor:Gn,isLineSegments:!0}),Hn.prototype=Object.create(ti.prototype),Hn.prototype.constructor=Hn,Hn.prototype.isPointsMaterial=!0,Hn.prototype.copy=function(t){return ti.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Vn.prototype=Object.assign(Object.create(Ri.prototype),{constructor:Vn,isPoints:!0,raycast:function(){var t=new oe,e=new Si,i=new bi;return function(n,r){var a=this,o=this.geometry,s=this.matrixWorld,c=n.params.Points.threshold;if(null===o.boundingSphere&&o.computeBoundingSphere(),i.copy(o.boundingSphere),i.applyMatrix4(s),!1!==n.ray.intersectsSphere(i)){t.getInverse(s),e.copy(n.ray).applyMatrix4(t);var h=c/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,u=new ae;if(o&&o.isBufferGeometry){var p=o.index,d=o.attributes.position.array;if(null!==p)for(var f=p.array,m=0,g=f.length;mn.far)return;r.push({distance:h,distanceToRay:Math.sqrt(o),point:c.clone(),index:i,face:null,object:a})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),kn.prototype=Object.assign(Object.create(Ri.prototype),{constructor:kn}),jn.prototype=Object.create(Xt.prototype),jn.prototype.constructor=jn,Wn.prototype=Object.create(Xt.prototype),Wn.prototype.constructor=Wn,Wn.prototype.isCompressedTexture=!0,Xn.prototype=Object.create(Xt.prototype),Xn.prototype.constructor=Xn,Yn.prototype=Object.create(Xt.prototype),Yn.prototype.constructor=Yn,Yn.prototype.isDepthTexture=!0,qn.prototype=Object.create(qi.prototype),qn.prototype.constructor=qn,Zn.prototype=Object.create(qi.prototype),Zn.prototype.constructor=Zn,Jn.prototype=Object.create(ji.prototype),Jn.prototype.constructor=Jn,Qn.prototype=Object.create(qi.prototype),Qn.prototype.constructor=Qn,Kn.prototype=Object.create(Qn.prototype),Kn.prototype.constructor=Kn,$n.prototype=Object.create(ji.prototype),$n.prototype.constructor=$n,tr.prototype=Object.create(Qn.prototype),tr.prototype.constructor=tr,er.prototype=Object.create(ji.prototype),er.prototype.constructor=er,ir.prototype=Object.create(Qn.prototype),ir.prototype.constructor=ir,nr.prototype=Object.create(ji.prototype),nr.prototype.constructor=nr,rr.prototype=Object.create(Qn.prototype),rr.prototype.constructor=rr,ar.prototype=Object.create(ji.prototype),ar.prototype.constructor=ar,or.prototype=Object.create(ji.prototype),or.prototype.constructor=or,sr.prototype=Object.create(qi.prototype),sr.prototype.constructor=sr,cr.prototype=Object.create(ji.prototype),cr.prototype.constructor=cr,hr.prototype=Object.create(qi.prototype),hr.prototype.constructor=hr,lr.prototype=Object.create(ji.prototype),lr.prototype.constructor=lr,ur.prototype=Object.create(qi.prototype),ur.prototype.constructor=ur,pr.prototype=Object.create(ji.prototype),pr.prototype.constructor=pr;var dr={area:function(t){for(var e=t.length,i=0,n=e-1,r=0;r=-Number.EPSILON&&w>=-Number.EPSILON&&b>=-Number.EPSILON))return!1;return!0}return function(e,i){var n=e.length;if(n<3)return null;var r,a,o,s=[],c=[],h=[];if(dr.area(e)>0)for(a=0;a2;){if(u--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?h:s;if(l<=(r=a)&&(r=0),l<=(a=r+1)&&(a=0),l<=(o=a+1)&&(o=0),t(e,r,a,o,l,c)){var p,d,f,m,g;for(p=c[r],d=c[a],f=c[o],s.push([e[p],e[d],e[f]]),h.push([c[r],c[a],c[o]]),m=a,g=a+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,i){return t.x!==e.x?t.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=h*l-c*u)<0||f>p)return[]}else{if(d>0||d0||fM?[]:y===M?a?[]:[g]:x<=M?[g,v]:[g,b])}function a(t,e,i,n){var r=e.x-t.x,a=e.y-t.y,o=i.x-t.x,s=i.y-t.y,c=n.x-t.x,h=n.y-t.y,l=r*s-a*o,u=r*h-a*c;if(Math.abs(l)>Number.EPSILON){var p=c*s-h*o;return l>0?u>=0&&p>=0:u>=0||p>=0}return u>0}i(t),e.forEach(i);for(var o,s,c,h,l,u,p={},d=t.concat(),f=0,m=e.length;fr&&(s=0);var c=a(n[t],n[o],n[s],i[e]);if(!c)return!1;var h=i.length-1,l=e-1;l<0&&(l=h);var u=e+1;return u>h&&(u=0),!!(c=a(i[e],i[l],i[u],n[t]))}function s(t,e){var i,a;for(i=0;i0)return!0;return!1}var c=[];function h(t,i){var n,a,o,s;for(n=0;n0)return!0;return!1}for(var l,u,p,d,f,m,g,v,y,x,_=[],b=0,w=e.length;b0;){if(--E<0){console.log("Infinite Loop! Holes left:"+c.length+", Probably Hole outside Shape!");break}for(u=M;u=0)break;_[m]=!0}if(l>=0)break}}return n}(t,e),v=dr.triangulate(g,!1);for(o=0,s=v.length;o0)&&M.push(E,T,A),(m!==i-1||s65535?Vi:Hi)(M,1)),this.addAttribute("position",h),this.addAttribute("normal",l),this.addAttribute("uv",u),this.boundingSphere=new bi(new ae,t)}function vr(t,e,i,n,r,a,o){ji.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new gr(t,e,i,n,r,a,o))}function yr(t,e,i,n,r,a){qi.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:a},t=t||20,e=e||50,r=void 0!==r?r:0,a=void 0!==a?a:2*Math.PI;var o,s,c,h=((i=void 0!==i?Math.max(3,i):8)+1)*((n=void 0!==n?Math.max(1,n):1)+1),l=i*n*2*3,u=new Gi(new(l>65535?Uint32Array:Uint16Array)(l),1),p=new Gi(new Float32Array(3*h),3),d=new Gi(new Float32Array(3*h),3),f=new Gi(new Float32Array(2*h),2),m=0,g=0,v=t,y=(e-t)/n,x=new ae,_=new Wt;for(s=0;s<=n;s++){for(c=0;c<=i;c++)o=r+c/i*a,x.x=v*Math.cos(o),x.y=v*Math.sin(o),p.setXYZ(m,x.x,x.y,x.z),d.setXYZ(m,0,0,1),_.x=(x.x/e+1)/2,_.y=(x.y/e+1)/2,f.setXY(m,_.x,_.y),m++;v+=y}for(s=0;s65535?Uint32Array:Uint16Array)(c),1),l=new Gi(new Float32Array(3*s),3),u=new Gi(new Float32Array(2*s),2),p=0,d=0,f=1/e,m=new ae,g=new Wt;for(a=0;a<=e;a++){var v=i+a*f*n,y=Math.sin(v),x=Math.cos(v);for(o=0;o<=t.length-1;o++)m.x=t[o].x*y,m.y=t[o].y,m.z=t[o].x*x,l.setXYZ(p,m.x,m.y,m.z),g.x=a/e,g.y=o/(t.length-1),u.setXY(p,g.x,g.y),p++}for(a=0;a0&&h++,e>0&&h++);var l=function(){var t=(n+1)*(r+1);return!1===a&&(t+=(n+1)*h+n*h),t}(),u=function(){var t=n*r*2*3;return!1===a&&(t+=n*h*3),t}(),p=new Gi(new(u>65535?Uint32Array:Uint16Array)(u),1),d=new Gi(new Float32Array(3*l),3),f=new Gi(new Float32Array(3*l),3),m=new Gi(new Float32Array(2*l),2),g=0,v=0,y=[],x=i/2,_=0;function b(i){var r,a,h,l=new Wt,u=new ae,y=0,b=!0===i?t:e,w=!0===i?1:-1;for(a=g,r=1;r<=n;r++)d.setXYZ(g,0,x*w,0),f.setXYZ(g,0,w,0),l.x=.5,l.y=.5,m.setXY(g,l.x,l.y),g++;for(h=g,r=0;r<=n;r++){var M=r/n*s+o,E=Math.cos(M),T=Math.sin(M);u.x=b*T,u.y=x*w,u.z=b*E,d.setXYZ(g,u.x,u.y,u.z),f.setXYZ(g,0,w,0),l.x=.5*E+.5,l.y=.5*T*w+.5,m.setXY(g,l.x,l.y),g++}for(r=0;r0&&b(!0),e>0&&b(!1)),this.setIndex(p),this.addAttribute("position",d),this.addAttribute("normal",f),this.addAttribute("uv",m)}function Sr(t,e,i,n,r,a,o,s){ji.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new Tr(t,e,i,n,r,a,o,s)),this.mergeVertices()}function Ar(t,e,i,n,r,a,o){Sr.call(this,0,t,e,i,n,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}function Lr(t,e,i,n,r,a,o){Tr.call(this,0,t,e,i,n,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}function Rr(t,e,i,n){qi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},t=t||50,e=void 0!==e?Math.max(3,e):8,i=void 0!==i?i:0,n=void 0!==n?n:2*Math.PI;var r=e+2,a=new Float32Array(3*r),o=new Float32Array(3*r),s=new Float32Array(2*r);o[2]=1,s[0]=.5,s[1]=.5;for(var c=0,h=3,l=2;c<=e;c++,h+=3,l+=2){var u=i+c/e*n;a[h]=t*Math.cos(u),a[h+1]=t*Math.sin(u),o[h+2]=1,s[l]=(a[h]/t+1)/2,s[l+1]=(a[h+1]/t+1)/2}var p=[];for(h=1;h<=e;h++)p.push(h,h+1,0);this.setIndex(new Gi(new Uint16Array(p),1)),this.addAttribute("position",new Gi(a,3)),this.addAttribute("normal",new Gi(o,3)),this.addAttribute("uv",new Gi(s,2)),this.boundingSphere=new bi(new ae,t)}function Pr(t,e,i,n){ji.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},this.fromBufferGeometry(new Rr(t,e,i,n))}function Cr(t,e,i,n,r,a){ji.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new Ji(t,e,i,n,r,a)),this.mergeVertices()}fr.prototype=Object.create(ji.prototype),fr.prototype.constructor=fr,fr.prototype.addShapeList=function(t,e){for(var i=t.length,n=0;nNumber.EPSILON){var p=Math.sqrt(l),d=Math.sqrt(c*c+h*h),f=e.x-s/p,m=e.y+o/p,g=((i.x-h/d-f)*h-(i.y+c/d-m)*c)/(o*h-s*c),v=(n=f+o*g-t.x)*n+(r=m+s*g-t.y)*r;if(v<=2)return new Wt(n,r);a=Math.sqrt(v/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(h)&&(y=!0),y?(n=-s,r=o,a=Math.sqrt(l)):(n=o,r=s,a=Math.sqrt(l/2))}return new Wt(n/a,r/a)}for(var B=[],z=0,G=A.length,H=G-1,V=z+1;z=0;R--){for(C=R/d,I=u*Math.cos(C*Math.PI/2),P=p*Math.sin(C*Math.PI/2),z=0,G=A.length;z=0;){i=z,(n=z-1)<0&&(n=t.length-1);var r=0,a=g+2*d;for(r=0;r0||0===t.search(/^data\:image\/jpeg/);r.format=n?mt:gt,r.image=i,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this}}),$r.prototype=Object.assign(Object.create(Ri.prototype),{constructor:$r,isLight:!0,copy:function(t){return Ri.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Ri.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),ta.prototype=Object.assign(Object.create($r.prototype),{constructor:ta,isHemisphereLight:!0,copy:function(t){return $r.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(ea.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),ia.prototype=Object.assign(Object.create(ea.prototype),{constructor:ia,isSpotLightShadow:!0,update:function(t){var e=2*jt.RAD2DEG*t.angle,i=this.mapSize.width/this.mapSize.height,n=t.distance||500,r=this.camera;e===r.fov&&i===r.aspect&&n===r.far||(r.fov=e,r.aspect=i,r.far=n,r.updateProjectionMatrix())}}),na.prototype=Object.assign(Object.create($r.prototype),{constructor:na,isSpotLight:!0,copy:function(t){return $r.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ra.prototype=Object.assign(Object.create($r.prototype),{constructor:ra,isPointLight:!0,copy:function(t){return $r.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),aa.prototype=Object.assign(Object.create(ea.prototype),{constructor:aa}),oa.prototype=Object.assign(Object.create($r.prototype),{constructor:oa,isDirectionalLight:!0,copy:function(t){return $r.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),sa.prototype=Object.assign(Object.create($r.prototype),{constructor:sa,isAmbientLight:!0});var ca,ha,la,ua,pa={arraySlice:function(t,e,i){return pa.isTypedArray(t)?new t.constructor(t.subarray(e,i)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,i=new Array(e),n=0;n!==e;++n)i[n]=n;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){for(var n=t.length,r=new t.constructor(n),a=0,o=0;o!==n;++a)for(var s=i[a]*e,c=0;c!==e;++c)r[o++]=t[s+c];return r},flattenJSON:function(t,e,i,n){for(var r=1,a=t[0];void 0!==a&&void 0===a[n];)a=t[r++];if(void 0!==a){var o=a[n];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[n])&&(e.push(a.time),i.push.apply(i,o)),a=t[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[n])&&(e.push(a.time),o.toArray(i,i.length)),a=t[r++]}while(void 0!==a);else do{void 0!==(o=a[n])&&(e.push(a.time),i.push(o)),a=t[r++]}while(void 0!==a)}}};function da(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function fa(t,e,i,n){da.call(this,t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function ma(t,e,i,n){da.call(this,t,e,i,n)}function ga(t,e,i,n){da.call(this,t,e,i,n)}function va(t,e,i,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=pa.convertArray(e,this.TimeBufferType),this.values=pa.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function ya(t,e,i,n){va.call(this,t,e,i,n)}function xa(t,e,i,n){da.call(this,t,e,i,n)}function _a(t,e,i,n){va.call(this,t,e,i,n)}function ba(t,e,i,n){va.call(this,t,e,i,n)}function wa(t,e,i,n){va.call(this,t,e,i,n)}function Ma(t,e,i){va.call(this,t,e,i)}function Ea(t,e,i,n){va.call(this,t,e,i,n)}function Ta(t,e,i,n){va.apply(this,arguments)}function Sa(t,e,i){this.name=t,this.tracks=i,this.duration=void 0!==e?e:-1,this.uuid=jt.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Aa(t){this.manager=void 0!==t?t:Wr,this.textures={}}function La(t){this.manager=void 0!==t?t:Wr}function Ra(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function Pa(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Wr,this.withCredentials=!1}function Ca(t){this.manager=void 0!==t?t:Wr,this.texturePath=""}function Ia(){}function Ua(t,e){this.v1=t,this.v2=e}function Na(){this.curves=[],this.autoClose=!1}function Da(t,e,i,n,r,a,o,s){this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s||0}da.prototype={constructor:da,evaluate:function(t){var e=this.parameterPositions,i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{var a;i:{n:if(!(t=r)break t;var s=e[1];for(t=(r=e[--i-1]))break e}a=i,i=0}for(;i>>1;te;)--a;if(++a,0!==r||a!==n){r>=a&&(r=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=pa.arraySlice(i,r,a),this.values=pa.arraySlice(this.values,r*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("invalid value size in track",this),t=!1);var i=this.times,n=this.values,r=i.length;0===r&&(console.error("track is empty",this),t=!1);for(var a=null,o=0;o!==r;o++){var s=i[o];if("number"==typeof s&&isNaN(s)){console.error("time is not a valid number",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("out of order keys",this,o,s,a),t=!1;break}a=s}if(void 0!==n&&pa.isTypedArray(n)){o=0;for(var c=n.length;o!==c;++o){var h=n[o];if(isNaN(h)){console.error("value is not a valid number",this,o,h),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),n=this.getInterpolation()===Pt,r=1,a=t.length-1,o=1;o0){for(t[r]=t[a],f=a*i,m=r*i,p=0;p!==i;++p)e[m+p]=e[f+p];++r}return r!==t.length&&(this.times=pa.arraySlice(t,0,r),this.values=pa.arraySlice(e,0,r*i)),this}},ya.prototype=Object.assign(Object.create(ca),{constructor:ya,ValueTypeName:"vector"}),xa.prototype=Object.assign(Object.create(da.prototype),{constructor:xa,interpolate_:function(t,e,i,n){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(i-e)/(n-e),h=s+o;s!==h;s+=4)re.slerpFlat(r,0,a,s-o,a,s,c);return r}}),_a.prototype=Object.assign(Object.create(ca),{constructor:_a,ValueTypeName:"quaternion",DefaultInterpolation:Rt,InterpolantFactoryMethodLinear:function(t){return new xa(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),ba.prototype=Object.assign(Object.create(ca),{constructor:ba,ValueTypeName:"number"}),wa.prototype=Object.assign(Object.create(ca),{constructor:wa,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Lt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ma.prototype=Object.assign(Object.create(ca),{constructor:Ma,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Lt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ea.prototype=Object.assign(Object.create(ca),{constructor:Ea,ValueTypeName:"color"}),Ta.prototype=ca,ca.constructor=Ta,Object.assign(Ta,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Ta._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var i=[],n=[];pa.flattenJSON(t.keys,i,n,"value"),t.times=i,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:pa.convertArray(t.times,Array),values:pa.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ba;case"vector":case"vector2":case"vector3":case"vector4":return ya;case"color":return Ea;case"quaternion":return _a;case"bool":case"boolean":return Ma;case"string":return wa}throw new Error("Unsupported typeName: "+t)}}),Sa.prototype={constructor:Sa,resetDuration:function(){for(var t=0,e=0,i=this.tracks.length;e!==i;++e){var n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var t=0;t1){var h=n[u=c[1]];h||(n[u]=h=[]),h.push(s)}}var l=[];for(var u in n)l.push(Sa.CreateFromMorphTargetSequence(u,n[u],e,i));return l},parseAnimation:function(t,e){if(!t)return console.error(" no animation in JSONLoader data"),null;for(var i=function(t,e,i,n,r){if(0!==i.length){var a=[],o=[];pa.flattenJSON(i,a,o,n),0!==a.length&&r.push(new t(e,a,o))}},n=[],r=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[n+1]:0,s=e>2?t.skinWeights[n+2]:0,c=e>3?t.skinWeights[n+3]:0;i.skinWeights.push(new ee(a,o,s,c))}if(t.skinIndices)for(n=0,r=t.skinIndices.length;n1?t.skinIndices[n+1]:0,u=e>2?t.skinIndices[n+2]:0,p=e>3?t.skinIndices[n+3]:0;i.skinIndices.push(new ee(h,l,u,p))}i.bones=t.bones,i.bones&&i.bones.length>0&&(i.skinWeights.length!==i.skinIndices.length||i.skinIndices.length!==i.vertices.length)&&console.warn("When skinning, number of vertices ("+i.vertices.length+"), skinIndices ("+i.skinIndices.length+"), and skinWeights ("+i.skinWeights.length+") should match.")}(),function(e){if(void 0!==t.morphTargets)for(var n=0,r=t.morphTargets.length;n0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=i.faces,u=t.morphColors[0].colors;for(n=0,r=l.length;n0&&(i.animations=e)}(),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:i};var r=Ra.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:i,materials:r}}}),Object.assign(Ca.prototype,{load:function(t,e,i,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var r=this;new Xr(r.manager).load(t,(function(t){r.parse(JSON.parse(t),e)}),i,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var i=this.parseGeometries(t.geometries),n=this.parseImages(t.images,(function(){void 0!==e&&e(o)})),r=this.parseTextures(t.textures,n),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,i,a);return t.animations&&(o.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(o),o},parseGeometries:function(t){var e={};if(void 0!==t)for(var i=new Pa,n=new La,r=0,a=t.length;r0){var a=new Jr(new jr(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new Fn(s,c):new Zi(s,c);break;case"LOD":r=new Un;break;case"Line":r=new zn(a(e.geometry),o(e.material),e.mode);break;case"LineSegments":r=new Gn(a(e.geometry),o(e.material));break;case"PointCloud":case"Points":r=new Vn(a(e.geometry),o(e.material));break;case"Sprite":r=new In(o(e.material));break;case"Group":r=new kn;break;default:r=new Ri}if(r.uuid=e.uuid,void 0!==e.name&&(r.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(r.position,r.quaternion,r.scale)):(void 0!==e.position&&r.position.fromArray(e.position),void 0!==e.rotation&&r.rotation.fromArray(e.rotation),void 0!==e.quaternion&&r.quaternion.fromArray(e.quaternion),void 0!==e.scale&&r.scale.fromArray(e.scale)),void 0!==e.castShadow&&(r.castShadow=e.castShadow),void 0!==e.receiveShadow&&(r.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(r.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(r.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&r.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(r.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.children)for(var h in e.children)r.add(this.parseObject(e.children[h],i,n));if("LOD"===e.type)for(var l=e.levels,u=0;u0)){c=r;break}c=r-1}if(n[r=c]===i)return r/(a-1);var h=n[r];return(r+(i-h)/(n[r+1]-h))/(a-1)},getTangent:function(t){var e=1e-4,i=t-e,n=t+e;i<0&&(i=0),n>1&&(n=1);var r=this.getPoint(i);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var i,n,r,a=new ae,o=[],s=[],c=[],h=new ae,l=new oe;for(i=0;i<=t;i++)n=i/t,o[i]=this.getTangentAt(n),o[i].normalize();s[0]=new ae,c[0]=new ae;var u=Number.MAX_VALUE,p=Math.abs(o[0].x),d=Math.abs(o[0].y),f=Math.abs(o[0].z);for(p<=u&&(u=p,a.set(1,0,0)),d<=u&&(u=d,a.set(0,1,0)),f<=u&&a.set(0,0,1),h.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],h),c[0].crossVectors(o[0],s[0]),i=1;i<=t;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),h.crossVectors(o[i-1],o[i]),h.length()>Number.EPSILON&&(h.normalize(),r=Math.acos(jt.clamp(o[i-1].dot(o[i]),-1,1)),s[i].applyMatrix4(l.makeRotationAxis(h,r))),c[i].crossVectors(o[i],s[i]);if(!0===e)for(r=Math.acos(jt.clamp(s[0].dot(s[t]),-1,1)),r/=t,o[0].dot(h.crossVectors(s[0],s[t]))>0&&(r=-r),i=1;i<=t;i++)s[i].applyMatrix4(l.makeRotationAxis(o[i],r*i)),c[i].crossVectors(o[i],s[i]);return{tangents:o,normals:s,binormals:c}}},Ia.create=function(t,e){return t.prototype=Object.create(Ia.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Ua.prototype=Object.create(Ia.prototype),Ua.prototype.constructor=Ua,Ua.prototype.isLineCurve=!0,Ua.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Ua.prototype.getPointAt=function(t){return this.getPoint(t)},Ua.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},Na.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Na,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ua(e,t))},getPoint:function(t){for(var e=t*this.getLength(),i=this.getCurveLengths(),n=0;n=e){var r=i[n]-e,a=this.curves[n],o=a.getLength(),s=0===o?0:1-r/o;return a.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,i=0,n=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new ji,i=0,n=t.length;ie;)i-=e;ie.length-2?e.length-1:n+1],c=e[n>e.length-3?e.length-1:n+2],h=Oa.interpolate;return new Wt(h(a.x,o.x,s.x,c.x,r),h(a.y,o.y,s.y,c.y,r))},Ba.prototype=Object.create(Ia.prototype),Ba.prototype.constructor=Ba,Ba.prototype.getPoint=function(t){var e=dr.b3;return new Wt(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y))},Ba.prototype.getTangent=function(t){var e=Oa.tangentCubicBezier;return new Wt(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y)).normalize()},za.prototype=Object.create(Ia.prototype),za.prototype.constructor=za,za.prototype.getPoint=function(t){var e=dr.b2;return new Wt(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y))},za.prototype.getTangent=function(t){var e=Oa.tangentQuadraticBezier;return new Wt(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y)).normalize()};var Ga,Ha,Va,ka,ja,Wa,Xa,Ya,qa,Za,Ja,Qa,Ka=Object.assign(Object.create(Na.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,i=t.length;e0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)}});function $a(){to.apply(this,arguments),this.holes=[]}function to(t){Na.call(this),this.currentPoint=new Wt,t&&this.fromPoints(t)}function eo(){this.subPaths=[],this.currentPath=null}function io(t){this.data=t}function no(t){this.manager=void 0!==t?t:Wr}function ro(){return void 0===Ga&&(Ga=new(window.AudioContext||window.webkitAudioContext)),Ga}function ao(t){this.manager=void 0!==t?t:Wr}function oo(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $i,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $i,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function so(t,e,i){Ri.call(this),this.type="CubeCamera";var n=90,r=new $i(n,1,t,e);r.up.set(0,-1,0),r.lookAt(new ae(1,0,0)),this.add(r);var a=new $i(n,1,t,e);a.up.set(0,-1,0),a.lookAt(new ae(-1,0,0)),this.add(a);var o=new $i(n,1,t,e);o.up.set(0,0,1),o.lookAt(new ae(0,1,0)),this.add(o);var s=new $i(n,1,t,e);s.up.set(0,0,-1),s.lookAt(new ae(0,-1,0)),this.add(s);var c=new $i(n,1,t,e);c.up.set(0,-1,0),c.lookAt(new ae(0,0,1)),this.add(c);var h=new $i(n,1,t,e);h.up.set(0,-1,0),h.lookAt(new ae(0,0,-1)),this.add(h);var l={format:mt,magFilter:st,minFilter:st};this.renderTarget=new ne(i,i,l),this.updateCubeMap=function(t,e){null===this.parent&&this.updateMatrixWorld();var i=this.renderTarget,n=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,i.activeCubeFace=0,t.render(e,r,i),i.activeCubeFace=1,t.render(e,a,i),i.activeCubeFace=2,t.render(e,o,i),i.activeCubeFace=3,t.render(e,s,i),i.activeCubeFace=4,t.render(e,c,i),i.texture.generateMipmaps=n,i.activeCubeFace=5,t.render(e,h,i),t.setRenderTarget(null)}}function co(){Ri.call(this),this.type="AudioListener",this.context=ro(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function ho(t){Ri.call(this),this.type="Audio",this.context=t.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function lo(t){ho.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function uo(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function po(t,e,i){this.binding=t,this.valueSize=i;var n,r=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":r=Array,n=this._select;break;default:n=this._lerp}this.buffer=new r(4*i),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function fo(t,e,i){this.path=e,this.parsedPath=i||fo.parseTrackName(e),this.node=fo.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function mo(t){this.uuid=jt.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;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 go(t,e,i){this._mixer=t,this._clip=e,this._localRoot=i||null;for(var n=e.tracks,r=n.length,a=new Array(r),o={endingStart:Ct,endingEnd:Ct},s=0;s!==r;++s){var c=n[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=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 vo(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function yo(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function xo(){qi.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function _o(t,e,i,n){this.uuid=jt.generateUUID(),this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===n}function bo(t,e){this.uuid=jt.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function wo(t,e,i){bo.call(this,t,e),this.meshPerAttribute=i||1}function Mo(t,e,i){Gi.call(this,t,e),this.meshPerAttribute=i||1}function Eo(t,e,i,n){this.ray=new Si(t,e),this.near=i||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function To(t,e){return t.distance-e.distance}function So(t,e,i,n){if(!1!==t.visible&&(t.raycast(e,i),!0===n))for(var r=t.children,a=0,o=r.length;aNumber.EPSILON){if(h<0&&(o=e[a],c=-c,s=e[r],h=-h),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var l=h*(t.x-o.x)-c*(t.y-o.y);if(0===l)return!0;if(l<0)continue;n=!n}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return n}var r=dr.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return i(a);var o,s,c,h=[];if(1===a.length)return s=a[0],(c=new $a).curves=s.curves,h.push(c),h;var l=!r(a[0].getPoints());l=t?!l:l;var u,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=a.length;v1){for(var x=!1,_=[],b=0,w=f.length;b0&&(x||(m=d))}v=0;for(var L=f.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==r;++a)t[e+a]=t[i+a]},_slerp:function(t,e,i,n,r){re.slerpFlat(t,e,t,e,t,i,n)},_lerp:function(t,e,i,n,r){for(var a=1-n,o=0;o!==r;++o){var s=e+o;t[s]=t[s]*a+t[i+o]*n}}},fo.prototype={constructor:fo,getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,i=e.objectName,n=e.propertyName,r=e.propertyIndex;if(t||(t=fo.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(i){var a=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error(" can not bind to material as node does not have a material",this);if(!t.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);t=t.skeleton.bones;for(var o=0;o=i){var u=i++,p=e[u];n[p.uuid]=l,e[l]=p,n[h]=u,e[u]=c;for(var d=0,f=a;d!==f;++d){var m=r[d],g=m[u],v=m[l];m[l]=g,m[u]=v}}}this.nCachedObjects_=i},uncache:function(t){for(var e=this._objects,i=e.length,n=this.nCachedObjects_,r=this._indicesByUUID,a=this._bindings,o=a.length,s=0,c=arguments.length;s!==c;++s){var h=arguments[s].uuid,l=r[h];if(void 0!==l)if(delete r[h],l0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(o),h[l].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var i=this._clip.duration,n=this.loop,r=this._loopCount;if(2200===n){-1===r&&(this.loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=i)e=i;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var a=2202===n;if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=i||e<0){var o=Math.floor(e/i);e-=i*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&!(1&~r))return this.time=e,i-e}return this.time=e,e},_setEndings:function(t,e,i){var n=this._interpolantSettings;i?(n.endingStart=It,n.endingEnd=It):(n.endingStart=t?this.zeroSlopeAtStart?It:Ct:Ut,n.endingEnd=e?this.zeroSlopeAtEnd?It:Ct:Ut)},_scheduleFading:function(t,e,i){var n=this._mixer,r=n.time,a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=e,o[1]=r+t,s[1]=i,this}},Object.assign(vo.prototype,e.prototype,{clipAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Sa.findByName(i,t):t,a=null!==r?r.uuid:t,o=this._actionsByClip[a],s=null;if(void 0!==o){var c=o.actionByRoot[n];if(void 0!==c)return c;s=o.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var h=new go(this,r,e);return this._bindAction(h,s),this._addInactiveAction(h,a,n),h},existingAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Sa.findByName(i,t):t,a=r?r.uuid:t,o=this._actionsByClip[a];return void 0!==o&&o.actionByRoot[n]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==e;++r)t[r].reset();for(r=0;r!==n;++r)i[r].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1,o=0;o!==i;++o){var s=e[o];s.enabled&&s._update(n,t,r,a)}var c=this._bindings,h=this._nActiveBindings;for(o=0;o!==h;++o)c[o].apply(a);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){for(var a=r.knownActions,o=0,s=a.length;o!==s;++o){var c=a[o];this._deactivateAction(c);var h=c._cacheIndex,l=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,l._cacheIndex=h,e[h]=l,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}},uncacheRoot:function(t){var e=t.uuid,i=this._actionsByClip;for(var n in i){var r=i[n].actionByRoot[e];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var a=this._bindingsByRootAndName[e];if(void 0!==a)for(var o in a){var s=a[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),Object.assign(vo.prototype,{_bindAction:function(t,e){var i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,a=t._propertyBindings,o=t._interpolants,s=i.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==r;++l){var u=n[l],p=u.name,d=h[p];if(void 0!==d)a[l]=d;else{if(void 0!==(d=a[l])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[l].binding.parsedPath;++(d=new po(fo.create(i,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),a[l]=d}o[l].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}for(var r=t._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,i=0,n=e.length;i!==n;++i){var r=e[i];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e1&&(n[c=s[1]]||(n[c]={start:1/0,end:-1/0}),a<(h=n[c]).start&&(h.start=a),a>h.end&&(h.end=a),e||(e=c))}for(var c in n){var h=n[c];this.createAnimation(c,h.start,h.end,t)}this.firstAnimation=e},Ro.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},Ro.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},Ro.prototype.setAnimationFPS=function(t,e){var i=this.animationsMap[t];i&&(i.fps=e,i.duration=(i.end-i.start)/i.fps)},Ro.prototype.setAnimationDuration=function(t,e){var i=this.animationsMap[t];i&&(i.duration=e,i.fps=(i.end-i.start)/i.duration)},Ro.prototype.setAnimationWeight=function(t,e){var i=this.animationsMap[t];i&&(i.weight=e)},Ro.prototype.setAnimationTime=function(t,e){var i=this.animationsMap[t];i&&(i.time=e)},Ro.prototype.getAnimationTime=function(t){var e=0,i=this.animationsMap[t];return i&&(e=i.time),e},Ro.prototype.getAnimationDuration=function(t){var e=-1,i=this.animationsMap[t];return i&&(e=i.duration),e},Ro.prototype.playAnimation=function(t){var e=this.animationsMap[t];e?(e.time=0,e.active=!0):console.warn("THREE.MorphBlendMesh: animation["+t+"] undefined in .playAnimation()")},Ro.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},Ro.prototype.update=function(t){for(var e=0,i=this.animationsList.length;en.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var a=n.start+jt.clamp(Math.floor(n.time/r),0,n.length-1),o=n.weight;a!==n.currentFrame&&(this.morphTargetInfluences[n.lastFrame]=0,this.morphTargetInfluences[n.currentFrame]=1*o,this.morphTargetInfluences[a]=0,n.lastFrame=n.currentFrame,n.currentFrame=a);var s=n.time%r/r;n.directionBackwards&&(s=1-s),n.currentFrame!==n.lastFrame?(this.morphTargetInfluences[n.currentFrame]=s*o,this.morphTargetInfluences[n.lastFrame]=(1-s)*o):this.morphTargetInfluences[n.currentFrame]=o}}},Po.prototype=Object.create(Ri.prototype),Po.prototype.constructor=Po,Po.prototype.isImmediateRenderObject=!0,Co.prototype=Object.create(Gn.prototype),Co.prototype.constructor=Co,Co.prototype.update=function(){var t=new ae,e=new ae,i=new wi;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var r=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,c=o.faces,h=0,l=0,u=c.length;l.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(jo.set(t.z,0,-t.x).normalize(),ko=Math.acos(t.y),this.quaternion.setFromAxisAngle(jo,ko))}),Xo.prototype.setLength=function(t,e,i){void 0===e&&(e=.2*t),void 0===i&&(i=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()},Xo.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Yo.prototype=Object.create(Gn.prototype),Yo.prototype.constructor=Yo;var qo=function(){var t=new ae,e=new r,i=new r,n=new r;function r(){}return r.prototype.init=function(t,e,i,n){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-n,this.c3=2*t-2*e+i+n},r.prototype.initNonuniformCatmullRom=function(t,e,i,n,r,a,o){var s=(e-t)/r-(i-t)/(r+a)+(i-e)/a,c=(i-e)/a-(n-e)/(a+o)+(n-i)/o;s*=a,c*=a,this.init(e,i,s,c)},r.prototype.initCatmullRom=function(t,e,i,n,r){this.init(e,i,r*(i-t),r*(n-e))},r.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},Ia.create((function(t){this.points=t||[],this.closed=!1}),(function(r){var a,o,s,c,h,l,u,p,d=this.points;if((c=d.length)<2&&console.log("duh, you need at least 2 points"),s=(a=(c-(this.closed?0:1))*r)-(o=Math.floor(a)),this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/d.length)+1)*d.length:0===s&&o===c-1&&(o=c-2,s=1),this.closed||o>0?h=d[(o-1)%c]:(t.subVectors(d[0],d[1]).add(d[0]),h=t),l=d[o%c],u=d[(o+1)%c],this.closed||o+2e.length-2?e.length-1:n+1],c=e[n>e.length-3?e.length-1:n+2],h=Oa.interpolate;return new ae(h(a.x,o.x,s.x,c.x,r),h(a.y,o.y,s.y,c.y,r),h(a.z,o.z,s.z,c.z,r))})),Qo=Ia.create((function(t,e,i,n){this.v0=t,this.v1=e,this.v2=i,this.v3=n}),(function(t){var e=dr.b3;return new ae(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y),e(t,this.v0.z,this.v1.z,this.v2.z,this.v3.z))})),Ko=Ia.create((function(t,e,i){this.v0=t,this.v1=e,this.v2=i}),(function(t){var e=dr.b2;return new ae(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y),e(t,this.v0.z,this.v1.z,this.v2.z))})),$o=Ia.create((function(t,e){this.v1=t,this.v2=e}),(function(t){if(1===t)return this.v2.clone();var e=new ae;return e.subVectors(this.v2,this.v1),e.multiplyScalar(t),e.add(this.v1),e}));function ts(t,e,i,n,r,a){Da.call(this,t,e,i,i,n,r,a)}ts.prototype=Object.create(Da.prototype),ts.prototype.constructor=ts;var es={createMultiMaterialObject:function(t,e){for(var i=new kn,n=0,r=e.length;nthis.points.length-2?this.points.length-1:i+1,l[3]=i>this.points.length-3?this.points.length-1:i+2,o=this.points[l[0]],s=this.points[l[1]],c=this.points[l[2]],h=this.points[l[3]],a=n*(r=n*n),u.x=p(o.x,s.x,c.x,h.x,n,r,a),u.y=p(o.y,s.y,c.y,h.y,n,r,a),u.z=p(o.z,s.z,c.z,h.z,n,r,a),u},this.getControlPointsArray=function(){var t,e,i=this.points.length,n=[];for(t=0;t