var THREE={};"function"==typeof define&&define.amd?define("three",THREE):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=THREE),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),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(e){"use strict";if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(){function e(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}return function(t,r,i){if(t=THREE.Math.euclideanModulo(t,1),r=THREE.Math.clamp(r,0,1),i=THREE.Math.clamp(i,0,1),0===r)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+r):i+r-i*r,a=2*i-n;this.r=e(a,n,t+1/3),this.g=e(a,n,t),this.b=e(a,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,n=r[1],a=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var h=(l=r[1]).length;if(3===h)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}if(e&&e.length>0){var l=THREE.ColorKeywords[e];void 0!==l?this.setHex(l):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(){var e=this.r,t=this.g,r=this.b;return this.r=e*e,this.g=t*t,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){var t,r,i=e||{h:0,s:0,l:0},n=this.r,a=this.g,o=this.b,s=Math.max(n,a,o),c=Math.min(n,a,o),h=(c+s)/2;if(c===s)t=0,r=0;else{var l=s-c;switch(r=h<=.5?l/(s+c):l/(2-s-c),s){case n:t=(a-o)/l+(a0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(l-c)*t,this._y=(a-h)*t,this._z=(o-n)*t):i>s&&i>u?(t=2*Math.sqrt(1+i-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(a+h)/t):s>u?(t=2*Math.sqrt(1+s-i-u),this._w=(a-h)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-i-s),this._w=(o-n)/t,this._x=(a+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector3),(t=r.dot(i)+1)<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,i),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,i=e._y,n=e._z,a=e._w,o=t._x,s=t._y,c=t._z,h=t._w;return this._x=r*h+a*o+i*c-n*s,this._y=i*h+a*s+n*o-r*c,this._z=n*h+a*c+r*s-i*o,this._w=a*h-r*o-i*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,i=this._y,n=this._z,a=this._w,o=a*e._w+r*e._x+i*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=r,this._y=i,this._z=n,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(r+this._x),this._y=.5*(i+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,o),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=a*h+this._w*l,this._x=r*h+this._x*l,this._y=i*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},Object.assign(THREE.Quaternion,{slerp:function(e,t,r,i){return r.copy(e).slerp(t,i)},slerpFlat:function(e,t,r,i,n,a,o){var s=r[i+0],c=r[i+1],h=r[i+2],l=r[i+3],u=n[a+0],p=n[a+1],d=n[a+2],f=n[a+3];if(l!==f||s!==u||c!==p||h!==d){var E=1-o,m=s*u+c*p+h*d+l*f,g=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){var T=Math.sqrt(v),y=Math.atan2(T,m*g);E=Math.sin(E*y)/T,o=Math.sin(o*y)/T}var R=o*g;if(s=s*E+u*R,c=c*E+p*R,h=h*E+d*R,l=l*E+f*R,E===1-o){var x=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=x,c*=x,h*=x,l*=x}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),THREE.Vector2=function(e,t){this.x=e||0,this.y=t||0},THREE.Vector2.prototype={constructor:THREE.Vector2,get width(){return this.x},set width(e){this.x=e},get height(){return this.y},set height(e){this.y=e},set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e):(this.x=0,this.y=0),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector2,t=new THREE.Vector2),e.set(r,r),t.set(i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this},rotateAround:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*r-a*i+e.x,this.y=n*i+a*r+e.y,this}},THREE.Vector3=function(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0},THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return t instanceof THREE.Euler==!1&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new THREE.Quaternion),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e;return function(t,r){return void 0===e&&(e=new THREE.Quaternion),this.applyQuaternion(e.setFromAxisAngle(t,r))}}(),applyMatrix3:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*i,this.y=n[1]*t+n[4]*r+n[7]*i,this.z=n[2]*t+n[5]*r+n[8]*i,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i+n[12],this.y=n[1]*t+n[5]*r+n[9]*i+n[13],this.z=n[2]*t+n[6]*r+n[10]*i+n[14],this},applyProjection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements,a=1/(n[3]*t+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*r+n[8]*i+n[12])*a,this.y=(n[1]*t+n[5]*r+n[9]*i+n[13])*a,this.z=(n[2]*t+n[6]*r+n[10]*i+n[14])*a,this},applyQuaternion:function(e){var t=this.x,r=this.y,i=this.z,n=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*i-o*r,h=s*r+o*t-n*i,l=s*i+n*r-a*t,u=-n*t-a*r-o*i;return this.x=c*s+u*-n+h*-o-l*-a,this.y=h*s+u*-a+l*-n-c*-o,this.z=l*s+u*-o+c*-a-h*-n,this},project:function(){var e;return function(t){return void 0===e&&(e=new THREE.Matrix4),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyProjection(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new THREE.Matrix4),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyProjection(e)}}(),transformDirection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i,this.y=n[1]*t+n[5]*r+n[9]*i,this.z=n[2]*t+n[6]*r+n[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector3,t=new THREE.Vector3),e.set(r,r,r),t.set(i,i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},cross:function(e,t){if(void 0!==t)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var r=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-r*e.z,this.z=r*e.y-i*e.x,this},crossVectors:function(e,t){var r=e.x,i=e.y,n=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-n*o,this.y=n*a-r*s,this.z=r*o-i*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new THREE.Vector3),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new THREE.Vector3),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(THREE.Math.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this},setFromMatrixColumn:function(e,t){if("number"==typeof e){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var r=e;e=t,t=r}return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this}},THREE.Vector4=function(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1},THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e,this.w*=e):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*n,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*n,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*n,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,i,n,a=e.elements,o=a[0],s=a[4],c=a[8],h=a[1],l=a[5],u=a[9],p=a[2],d=a[6],f=a[10];if(Math.abs(s-h)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+h)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(o+l+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var E=(o+1)/2,m=(l+1)/2,g=(f+1)/2,v=(s+h)/4,T=(c+p)/4,y=(u+d)/4;return E>m&&E>g?E<.01?(r=0,i=.707106781,n=.707106781):(i=v/(r=Math.sqrt(E)),n=T/r):m>g?m<.01?(r=.707106781,i=0,n=.707106781):(r=v/(i=Math.sqrt(m)),n=y/i):g<.01?(r=.707106781,i=.707106781,n=0):(r=T/(n=Math.sqrt(g)),i=y/n),this.set(r,i,n,t),this}var R=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(h-s)*(h-s));return Math.abs(R)<.001&&(R=1),this.x=(d-u)/R,this.y=(c-p)/R,this.z=(h-s)/R,this.w=Math.acos((o+l+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector4,t=new THREE.Vector4),e.set(r,r,r,r),t.set(i,i,i,i),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this.w=e.array[t+3],this}},THREE.Euler=function(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._order=i||THREE.Euler.DefaultOrder},THREE.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],THREE.Euler.DefaultOrder="XYZ",THREE.Euler.prototype={constructor:THREE.Euler,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var i=THREE.Math.clamp,n=e.elements,a=n[0],o=n[4],s=n[8],c=n[1],h=n[5],l=n[9],u=n[2],p=n[6],d=n[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(i(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"===t?(this._x=Math.asin(-i(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"===t?(this._x=Math.asin(i(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"===t?(this._y=Math.asin(-i(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"===t?(this._z=Math.asin(i(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"===t?(this._z=Math.asin(-i(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: "+t),this._order=t,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,r,i){return void 0===e&&(e=new THREE.Matrix4),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,r,i)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new THREE.Quaternion;return function(t){return e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},THREE.Line3=function(e,t){this.start=void 0!==e?e:new THREE.Vector3,this.end=void 0!==t?t:new THREE.Vector3},THREE.Line3.prototype={constructor:THREE.Line3,set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},center:function(e){return(e||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return(e||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var r=t||new THREE.Vector3;return this.delta(r).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(r,i){e.subVectors(r,this.start),t.subVectors(this.end,this.start);var n=t.dot(t),a=t.dot(e)/n;return i&&(a=THREE.Math.clamp(a,0,1)),a}}(),closestPointToPoint:function(e,t,r){var i=this.closestPointToPointParameter(e,t),n=r||new THREE.Vector3;return this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}},THREE.Box2=function(e,t){this.min=void 0!==e?e:new THREE.Vector2(1/0,1/0),this.max=void 0!==t?t:new THREE.Vector2(-1/0,-1/0)},THREE.Box2.prototype={constructor:THREE.Box2,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return(t||new THREE.Vector2).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return(t||new THREE.Vector2).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector2;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},THREE.Box3=function(e,t){this.min=void 0!==e?e:new THREE.Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new THREE.Vector3(-1/0,-1/0,-1/0)},THREE.Box3.prototype={constructor:THREE.Box3,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,r=1/0,i=1/0,n=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;sn&&(n=h),l>a&&(a=l),u>o&&(o=u)}this.min.set(t,r,i),this.max.set(n,a,o)},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return(t||new THREE.Vector3).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e;return function(t){return void 0===e&&(e=new THREE.Vector3),this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=e.constant&&r>=e.constant},clampPoint:function(e,t){return(t||new THREE.Vector3).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector3;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new THREE.Vector3;return function(t){var r=t||new THREE.Sphere;return r.center=this.center(),r.radius=.5*this.size(e).length(),r}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},THREE.Matrix3=function(){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.")},THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(e,t,r,i,n,a,o,s,c){var h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=n,h[5]=s,h[6]=r,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(e){var t=e.elements;return this.set(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]),this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToVector3Array:function(){var e;return function(t,r,i){void 0===e&&(e=new THREE.Vector3),void 0===r&&(r=0),void 0===i&&(i=t.length);for(var n=0,a=r;n0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")},THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(e,t,r,i,n,a,o,s,c,h,l,u,p,d,f,E){var m=this.elements;return m[0]=e,m[4]=t,m[8]=r,m[12]=i,m[1]=n,m[5]=a,m[9]=o,m[13]=s,m[2]=c,m[6]=h,m[10]=l,m[14]=u,m[3]=p,m[7]=d,m[11]=f,m[15]=E,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 THREE.Matrix4).fromArray(this.elements)},copy:function(e){return this.elements.set(e.elements),this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(){var e;return function(t){void 0===e&&(e=new THREE.Vector3);var r=this.elements,i=t.elements,n=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[4]=i[4]*a,r[5]=i[5]*a,r[6]=i[6]*a,r[8]=i[8]*o,r[9]=i[9]*o,r[10]=i[10]*o,this}}(),makeRotationFromEuler:function(e){e instanceof THREE.Euler==!1&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,i=e.y,n=e.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(i),c=Math.sin(i),h=Math.cos(n),l=Math.sin(n);if("XYZ"===e.order){var u=a*h,p=a*l,d=o*h,f=o*l;t[0]=s*h,t[4]=-s*l,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-o*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=a*s}else if("YXZ"===e.order){var E=s*h,m=s*l,g=c*h,v=c*l;t[0]=E+v*o,t[4]=g*o-m,t[8]=a*c,t[1]=a*l,t[5]=a*h,t[9]=-o,t[2]=m*o-g,t[6]=v+E*o,t[10]=a*s}else if("ZXY"===e.order){var E=s*h,m=s*l,g=c*h,v=c*l;t[0]=E-v*o,t[4]=-a*l,t[8]=g+m*o,t[1]=m+g*o,t[5]=a*h,t[9]=v-E*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var u=a*h,p=a*l,d=o*h,f=o*l;t[0]=s*h,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*l,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var T=a*s,y=a*c,R=o*s,x=o*c;t[0]=s*h,t[4]=x-T*l,t[8]=R*l+y,t[1]=l,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=y*l+R,t[10]=T-x*l}else if("XZY"===e.order){var T=a*s,y=a*c,R=o*s,x=o*c;t[0]=s*h,t[4]=-l,t[8]=c*h,t[1]=T*l+x,t[5]=a*h,t[9]=y*l-R,t[2]=R*l-y,t[6]=o*h,t[10]=x*l+T}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z,a=e.w,o=r+r,s=i+i,c=n+n,h=r*o,l=r*s,u=r*c,p=i*s,d=i*c,f=n*c,E=a*o,m=a*s,g=a*c;return t[0]=1-(p+f),t[4]=l-g,t[8]=u+m,t[1]=l+g,t[5]=1-(h+f),t[9]=d-E,t[2]=u-m,t[6]=d+E,t[10]=1-(h+p),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e,t,r;return function(i,n,a){void 0===e&&(e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3);var o=this.elements;return r.subVectors(i,n).normalize(),0===r.lengthSq()&&(r.z=1),e.crossVectors(a,r).normalize(),0===e.lengthSq()&&(r.z+=1e-4,e.crossVectors(a,r).normalize()),t.crossVectors(r,e),o[0]=e.x,o[4]=t.x,o[8]=r.x,o[1]=e.y,o[5]=t.y,o[9]=r.y,o[2]=e.z,o[6]=t.z,o[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,a=r[0],o=r[4],s=r[8],c=r[12],h=r[1],l=r[5],u=r[9],p=r[13],d=r[2],f=r[6],E=r[10],m=r[14],g=r[3],v=r[7],T=r[11],y=r[15],R=i[0],x=i[4],H=i[8],b=i[12],_=i[1],M=i[5],w=i[9],S=i[13],A=i[2],L=i[6],C=i[10],P=i[14],B=i[3],U=i[7],D=i[11],I=i[15];return n[0]=a*R+o*_+s*A+c*B,n[4]=a*x+o*M+s*L+c*U,n[8]=a*H+o*w+s*C+c*D,n[12]=a*b+o*S+s*P+c*I,n[1]=h*R+l*_+u*A+p*B,n[5]=h*x+l*M+u*L+p*U,n[9]=h*H+l*w+u*C+p*D,n[13]=h*b+l*S+u*P+p*I,n[2]=d*R+f*_+E*A+m*B,n[6]=d*x+f*M+E*L+m*U,n[10]=d*H+f*w+E*C+m*D,n[14]=d*b+f*S+E*P+m*I,n[3]=g*R+v*_+T*A+y*B,n[7]=g*x+v*M+T*L+y*U,n[11]=g*H+v*w+T*C+y*D,n[15]=g*b+v*S+T*P+y*I,this},multiplyToArray:function(e,t,r){var i=this.elements;return this.multiplyMatrices(e,t),r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToVector3Array:function(){var e;return function(t,r,i){void 0===e&&(e=new THREE.Vector3),void 0===r&&(r=0),void 0===i&&(i=t.length);for(var n=0,a=r;n0)if(s=p*f-d,c=p*d-f,l=u*m,s>=0)if(c>=-l)if(c<=l){var g=1/m;h=(s*=g)*(s+p*(c*=g)+2*d)+c*(p*s+c+2*f)+E}else c=u,h=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+E;else c=-u,h=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+E;else c<=-l?h=-(s=Math.max(0,-(-p*u+d)))*s+(c=s>0?-u:Math.min(Math.max(-u,-f),u))*(c+2*f)+E:c<=l?(s=0,h=(c=Math.min(Math.max(-u,-f),u))*(c+2*f)+E):h=-(s=Math.max(0,-(p*u+d)))*s+(c=s>0?u:Math.min(Math.max(-u,-f),u))*(c+2*f)+E;else c=p>0?-u:u,h=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+E;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(c).add(e),h}}(),intersectSphere:function(){var e=new THREE.Vector3;return function(t,r){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),n=e.dot(e)-i*i,a=t.radius*t.radius;if(n>a)return null;var o=Math.sqrt(a-n),s=i-o,c=i+o;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var r,i,n,a,o,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(r=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(r=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),h>=0?(n=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),r>a||n>i?null:((n>r||r!=r)&&(r=n),(a=0?(o=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(o=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),r>s||o>i?null:((o>r||r!=r)&&(r=o),(s=0?r:i,t)))},intersectsBox:function(){var e=new THREE.Vector3;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3,i=new THREE.Vector3;return function(n,a,o,s,c){t.subVectors(a,n),r.subVectors(o,n),i.crossVectors(t,r);var h,l=this.direction.dot(i);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}e.subVectors(this.origin,n);var u=h*this.direction.dot(r.crossVectors(e,r));if(u<0)return null;var p=h*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>l)return null;var d=-h*e.dot(i);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},THREE.Sphere=function(e,t){this.center=void 0!==e?e:new THREE.Vector3,this.radius=void 0!==t?t:0},THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new THREE.Box3;return function(t,r){var i=this.center;void 0!==r?i.copy(r):e.setFromPoints(t).center(i);for(var n=0,a=0,o=t.length;athis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(e){var t=e||new THREE.Box3;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}},THREE.Frustum=function(e,t,r,i,n,a){this.planes=[void 0!==e?e:new THREE.Plane,void 0!==t?t:new THREE.Plane,void 0!==r?r:new THREE.Plane,void 0!==i?i:new THREE.Plane,void 0!==n?n:new THREE.Plane,void 0!==a?a:new THREE.Plane]},THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(e,t,r,i,n,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(n),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],c=r[5],h=r[6],l=r[7],u=r[8],p=r[9],d=r[10],f=r[11],E=r[12],m=r[13],g=r[14],v=r[15];return t[0].setComponents(o-i,l-s,f-u,v-E).normalize(),t[1].setComponents(o+i,l+s,f+u,v+E).normalize(),t[2].setComponents(o+n,l+c,f+p,v+m).normalize(),t[3].setComponents(o-n,l-c,f-p,v-m).normalize(),t[4].setComponents(o-a,l-h,f-d,v-g).normalize(),t[5].setComponents(o+a,l+h,f+d,v+g).normalize(),this},intersectsObject:function(){var e=new THREE.Sphere;return function(t){var r=t.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),e.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new THREE.Sphere;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,r=e.center,i=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(r)0?r.min.x:r.max.x,t.x=a.normal.x>0?r.max.x:r.min.x,e.y=a.normal.y>0?r.min.y:r.max.y,t.y=a.normal.y>0?r.max.y:r.min.y,e.z=a.normal.z>0?r.min.z:r.max.z,t.z=a.normal.z>0?r.max.z:r.min.z;var o=a.distanceToPoint(e),s=a.distanceToPoint(t);if(o<0&&s<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}},THREE.Plane=function(e,t){this.normal=void 0!==e?e:new THREE.Vector3(1,0,0),this.constant=void 0!==t?t:0},THREE.Plane.prototype={constructor:THREE.Plane,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(r,i,n){var a=e.subVectors(n,i).cross(t.subVectors(r,i)).normalize();return this.setFromNormalAndCoplanarPoint(a,r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return this.orthoPoint(e,t).sub(e).negate()},orthoPoint:function(e,t){var r=this.distanceToPoint(e);return(t||new THREE.Vector3).copy(this.normal).multiplyScalar(r)},intersectLine:function(){var e=new THREE.Vector3;return function(t,r){var i=r||new THREE.Vector3,n=t.delta(e),a=this.normal.dot(n);if(0!==a){var o=-(t.start.dot(this.normal)+this.constant)/a;if(!(o<0||o>1))return i.copy(n).multiplyScalar(o).add(t.start)}else if(0===this.distanceToPoint(t.start))return i.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return(e||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new THREE.Vector3,t=new THREE.Matrix3;return function(r,i){var n=this.coplanarPoint(e).applyMatrix4(r),a=i||t.getNormalMatrix(r),o=this.normal.applyMatrix3(a).normalize();return this.constant=-n.dot(o),this}}(),translate:function(e){return this.constant=this.constant-e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},THREE.Spherical=function(e,t,r){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==r?r:0,this},THREE.Spherical.prototype={constructor:THREE.Spherical,set:function(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius.copy(e.radius),this.phi.copy(e.phi),this.theta.copy(e.theta),this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(e){return this.radius=e.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(THREE.Math.clamp(e.y/this.radius,-1,1))),this}},THREE.Math={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36),i=0;return function(){for(var n=0;n<36;n++)8===n||13===n||18===n||23===n?r[n]="-":14===n?r[n]="4":(i<=2&&(i=33554432+16777216*Math.random()|0),e=15&i,i>>=4,r[n]=t[19===n?3&e|8:e]);return r.join("")}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},random16:function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*THREE.Math.DEG2RAD},radToDeg:function(e){return e*THREE.Math.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}},THREE.Spline=function(e){function t(e,t,r,i,n,a,o){var s=.5*(r-e),c=.5*(i-t);return(2*(t-r)+s+c)*o+(-3*(t-r)-2*s-c)*a+s*n+t}this.points=e;var r,i,n,a,o,s,c,h,l,u=[],p={x:0,y:0,z:0};this.initFromArray=function(e){this.points=[];for(var t=0;tthis.points.length-2?this.points.length-1:i+1,u[3]=i>this.points.length-3?this.points.length-1:i+2,s=this.points[u[0]],c=this.points[u[1]],h=this.points[u[2]],l=this.points[u[3]],a=n*n,o=n*a,p.x=t(s.x,c.x,h.x,l.x,n,a,o),p.y=t(s.y,c.y,h.y,l.y,n,a,o),p.z=t(s.z,c.z,h.z,l.z,n,a,o),p},this.getControlPointsArray=function(){var e,t,r=this.points.length,i=[];for(e=0;e0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}}(),THREE.Triangle.barycoordFromPoint=function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(i,n,a,o,s){e.subVectors(o,n),t.subVectors(a,n),r.subVectors(i,n);var c=e.dot(e),h=e.dot(t),l=e.dot(r),u=t.dot(t),p=t.dot(r),d=c*u-h*h,f=s||new THREE.Vector3;if(0===d)return f.set(-2,-1,-1);var E=1/d,m=(u*l-h*p)*E,g=(c*p-h*l)*E;return f.set(1-m-g,g,m)}}(),THREE.Triangle.containsPoint=function(){var e=new THREE.Vector3;return function(t,r,i,n){var a=THREE.Triangle.barycoordFromPoint(t,r,i,n,e);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return THREE.Triangle.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return THREE.Triangle.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return THREE.Triangle.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,r,i;return function(n,a){void 0===e&&(e=new THREE.Plane,t=[new THREE.Line3,new THREE.Line3,new THREE.Line3],r=new THREE.Vector3,i=new THREE.Vector3);var o=a||new THREE.Vector3,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(n,r),!0===this.containsPoint(r))o.copy(r);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var c=0;c=n)break e;var o=t[1];e=n)break t}a=r,r=0}}for(;r>>1;e1){for(var t=0;t1)for(var t=0;t0){n.children=[];for(var a=0;a0&&(i.geometries=o),s.length>0&&(i.materials=s),c.length>0&&(i.textures=c),h.length>0&&(i.images=h)}return i.object=n,i},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var r=0;r0)for(d=0;d0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,r,i,n;for(r=0,i=this.faces.length;r0&&(e+=t[r].distanceTo(t[r-1])),this.lineDistances[r]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,r){if(e instanceof THREE.Geometry!=!1){var i,n=this.vertices.length,a=this.vertices,o=e.vertices,s=this.faces,c=e.faces,h=this.faceVertexUvs[0],l=e.faceVertexUvs[0];void 0===r&&(r=0),void 0!==t&&(i=(new THREE.Matrix3).getNormalMatrix(t));for(var u=0,p=o.length;u=0;r--){var f=p[r];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,y=g.vertexNormals.length>0,R=1!==g.color.r||1!==g.color.g||1!==g.color.b,x=g.vertexColors.length>0,H=0;if(H=e(H,0,0),H=e(H,1,!0),H=e(H,2,!1),H=e(H,3,v),H=e(H,4,T),H=e(H,5,y),H=e(H,6,R),H=e(H,7,x),l.push(H),l.push(g.a,g.b,g.c),l.push(g.materialIndex),v){var b=this.faceVertexUvs[0][c];l.push(i(b[0]),i(b[1]),i(b[2]))}if(T&&l.push(t(g.normal)),y){var _=g.vertexNormals;l.push(t(_[0]),t(_[1]),t(_[2]))}if(R&&l.push(r(g.color)),x){var M=g.vertexColors;l.push(r(M[0]),r(M[1]),r(M[2]))}}return n.data={},n.data.vertices=s,n.data.normals=u,d.length>0&&(n.data.colors=d),E.length>0&&(n.data.uvs=[E]),n.data.faces=l,n},clone:function(){return(new THREE.Geometry).copy(this)},copy:function(e){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]];for(var t=e.vertices,r=0,i=t.length;r0,o=n[1]&&n[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(m=0;m0){h=[];for(m=0;m0){var r=new Float32Array(3*e.normals.length);this.addAttribute("normal",new THREE.BufferAttribute(r,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.addAttribute("color",new THREE.BufferAttribute(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new THREE.BufferAttribute(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new THREE.BufferAttribute(a,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var o=new(e.vertices.length>65535?Uint32Array:Uint16Array)(3*e.indices.length);this.setIndex(new THREE.BufferAttribute(o,1).copyIndicesArray(e.indices))}this.groups=e.groups;for(var s in e.morphTargets){for(var c=[],h=e.morphTargets[s],l=0,u=h.length;l0){var f=new THREE.Float32Attribute(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var E=new THREE.Float32Attribute(4*e.skinWeights.length,4);this.addAttribute("skinWeight",E.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var e=this.attributes.position.array;void 0!==e?this.boundingBox.setFromArray(e):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 e=new THREE.Box3,t=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var r=this.attributes.position;if(r){var i=r.array,n=this.boundingSphere.center;e.setFromArray(i),e.center(n);for(var a=0,o=0,s=i.length;o0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new THREE.BufferGeometry).copy(this)},copy:function(e){var t=e.index;null!==t&&this.setIndex(t.clone());var r=e.attributes;for(var i in r){var n=r[i];this.addAttribute(i,n.clone())}for(var a=e.groups,o=0,s=a.length;o0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(o),h[l].accumulate(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var r=this._weightInterpolant;if(null!==r){var i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){t*=r.evaluate(e)[0],e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var r=this._clip.duration,i=this.loop,n=this._loopCount;if(i===THREE.LoopOnce){-1===n&&(this.loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=r)t=r;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var a=i===THREE.LoopPingPong;if(-1===n&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=r||t<0){var o=Math.floor(t/r);t-=r*o,n+=Math.abs(o);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(0===s){var c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1==(1&n))return this.time=t,r-t}return this.time=t,t},_setEndings:function(e,t,r){var i=this._interpolantSettings;r?(i.endingStart=THREE.ZeroSlopeEnding,i.endingEnd=THREE.ZeroSlopeEnding):(i.endingStart=e?this.zeroSlopeAtStart?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding,i.endingEnd=t?this.zeroSlopeAtEnd?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding)},_scheduleFading:function(e,t,r){var i=this._mixer,n=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=n,s[0]=t,o[1]=n+e,s[1]=r,this}},THREE.AnimationClip=function(e,t,r){this.name=e,this.tracks=r,this.duration=void 0!==t?t:-1,this.uuid=THREE.Math.generateUUID(),this.duration<0&&this.resetDuration(),this.trim(),this.optimize()},THREE.AnimationClip.prototype={constructor:THREE.AnimationClip,resetDuration:function(){for(var e=0,t=0,r=this.tracks.length;t!==r;++t){var i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}this.duration=e},trim:function(){for(var e=0;e1){var h=i[u=c[1]];h||(i[u]=h=[]),h.push(s)}}var l=[];for(var u in i)l.push(THREE.AnimationClip.CreateFromMorphTargetSequence(u,i[u],t,r));return l},parseAnimation:function(e,t,r){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var i=function(e,t,r,i,n){if(0!==r.length){var a=[],o=[];THREE.AnimationUtils.flattenJSON(r,a,o,i),0!==a.length&&n.push(new e(t,a,o))}},n=[],a=e.name||"default",o=e.length||-1,s=e.fps||30,c=e.hierarchy||[],h=0;h=r){var u=r++,p=t[u];i[p.uuid]=l,t[l]=p,i[h]=u,t[u]=c;for(var d=0,f=a;d!==f;++d){var E=n[d],m=E[u],g=E[l];E[l]=m,E[u]=g}}}this.nCachedObjects_=r},uncache:function(e){for(var t=this._objects,r=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,a=this._bindings,o=a.length,s=0,c=arguments.length;s!==c;++s){var h=arguments[s].uuid,l=n[h];if(void 0!==l)if(delete n[h],lt;)--a;if(++a,0!==n||a!==i){n>=a&&(a=Math.max(a,1),n=a-1);var o=this.getValueSize();this.times=THREE.AnimationUtils.arraySlice(r,n,a),this.values=THREE.AnimationUtils.arraySlice(this.values,n*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("invalid value size in track",this),e=!1);var r=this.times,i=this.values,n=r.length;0===n&&(console.error("track is empty",this),e=!1);for(var a=null,o=0;o!==n;o++){var s=r[o];if("number"==typeof s&&isNaN(s)){console.error("time is not a valid number",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("out of order keys",this,o,s,a),e=!1;break}a=s}if(void 0!==i&&THREE.AnimationUtils.isTypedArray(i))for(var o=0,c=i.length;o!==c;++o){var h=i[o];if(isNaN(h)){console.error("value is not a valid number",this,o,h),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,r=this.getValueSize(),i=1,n=1,a=e.length-1;n<=a;++n){var o=!1,s=e[n];if(s!==e[n+1]&&(1!==n||s!==s[0]))for(var c=n*r,h=c-r,l=c+r,u=0;u!==r;++u){var p=t[c+u];if(p!==t[h+u]||p!==t[l+u]){o=!0;break}}if(o){if(n!==i){e[i]=e[n];for(var d=n*r,f=i*r,u=0;u!==r;++u)t[f+u]=t[d+u]}++i}}return i!==e.length&&(this.times=THREE.AnimationUtils.arraySlice(e,0,i),this.values=THREE.AnimationUtils.arraySlice(t,0,i*r)),this}},Object.assign(THREE.KeyframeTrack,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=THREE.KeyframeTrack._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var r=[],i=[];THREE.AnimationUtils.flattenJSON(e.keys,r,i,"value"),e.times=r,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t,r=e.constructor;if(void 0!==r.toJSON)t=r.toJSON(e);else{t={name:e.name,times:THREE.AnimationUtils.convertArray(e.times,Array),values:THREE.AnimationUtils.convertArray(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return THREE.NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return THREE.VectorKeyframeTrack;case"color":return THREE.ColorKeyframeTrack;case"quaternion":return THREE.QuaternionKeyframeTrack;case"bool":case"boolean":return THREE.BooleanKeyframeTrack;case"string":return THREE.StringKeyframeTrack}throw new Error("Unsupported typeName: "+e)}}),THREE.PropertyBinding=function(e,t,r){this.path=t,this.parsedPath=r||THREE.PropertyBinding.parseTrackName(t),this.node=THREE.PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e},THREE.PropertyBinding.prototype={constructor:THREE.PropertyBinding,getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,r=t.objectName,i=t.propertyName,n=t.propertyIndex;if(e||(e=THREE.PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(r){var a=t.objectIndex;switch(r){case"materials":if(!e.material)return void console.error(" can not bind to material as node does not have a material",this);if(!e.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);e=e.skeleton.bones;for(h=0;h=.5)for(var a=0;a!==n;++a)e[t+a]=e[r+a]},_slerp:function(e,t,r,i,n){THREE.Quaternion.slerpFlat(e,t,e,t,e,r,i)},_lerp:function(e,t,r,i,n){for(var a=1-i,o=0;o!==n;++o){var s=t+o;e[s]=e[s]*a+e[r+o]*i}}},THREE.BooleanKeyframeTrack=function(e,t,r){THREE.KeyframeTrack.call(this,e,t,r)},THREE.BooleanKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:THREE.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),THREE.ColorKeyframeTrack=function(e,t,r,i){THREE.KeyframeTrack.call(this,e,t,r,i)},THREE.ColorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.ColorKeyframeTrack,ValueTypeName:"color"}),THREE.NumberKeyframeTrack=function(e,t,r,i){THREE.KeyframeTrack.call(this,e,t,r,i)},THREE.NumberKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.NumberKeyframeTrack,ValueTypeName:"number"}),THREE.QuaternionKeyframeTrack=function(e,t,r,i){THREE.KeyframeTrack.call(this,e,t,r,i)},THREE.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodLinear:function(e){return new THREE.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),THREE.StringKeyframeTrack=function(e,t,r,i){THREE.KeyframeTrack.call(this,e,t,r,i)},THREE.StringKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:THREE.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),THREE.VectorKeyframeTrack=function(e,t,r,i){THREE.KeyframeTrack.call(this,e,t,r,i)},THREE.VectorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.VectorKeyframeTrack,ValueTypeName:"vector"}),THREE.Audio=function(e){THREE.Object3D.call(this),this.type="Audio",this.context=e.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]},THREE.Audio.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Audio,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setBuffer:function(e){return this.source.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){var e=this.context.createBufferSource();return e.buffer=this.source.buffer,e.loop=this.source.loop,e.onended=this.source.onended,e.start(0,this.startTime),e.playbackRate.value=this.playbackRate,this.isPlaying=!0,this.source=e,this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.startTime=0,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e1?e.skinWeights[i+1]:0,s=t>2?e.skinWeights[i+2]:0,c=t>3?e.skinWeights[i+3]:0;r.skinWeights.push(new THREE.Vector4(a,o,s,c))}if(e.skinIndices)for(var i=0,n=e.skinIndices.length;i1?e.skinIndices[i+1]:0,u=t>2?e.skinIndices[i+2]:0,p=t>3?e.skinIndices[i+3]:0;r.skinIndices.push(new THREE.Vector4(h,l,u,p))}r.bones=e.bones,r.bones&&r.bones.length>0&&(r.skinWeights.length!==r.skinIndices.length||r.skinIndices.length!==r.vertices.length)&&console.warn("When skinning, number of vertices ("+r.vertices.length+"), skinIndices ("+r.skinIndices.length+"), and skinWeights ("+r.skinWeights.length+") should match.")}(),function(t){if(void 0!==e.morphTargets)for(var i=0,n=e.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var l=r.faces,u=e.morphColors[0].colors,i=0,n=l.length;i0&&(r.animations=t)}(),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:r};var n=THREE.Loader.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:r,materials:n}}}),THREE.LoadingManager=function(e,t,r){var i=this,n=!1,a=0,o=0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){o++,!1===n&&void 0!==i.onStart&&i.onStart(e,a,o),n=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(n=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)}},THREE.DefaultLoadingManager=new THREE.LoadingManager,THREE.BufferGeometryLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},Object.assign(THREE.BufferGeometryLoader.prototype,{load:function(e,t,r,i){var n=this;new THREE.XHRLoader(n.manager).load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},parse:function(e){var t=new THREE.BufferGeometry,r=e.data.index,i={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};if(void 0!==r){s=new i[r.type](r.array);t.setIndex(new THREE.BufferAttribute(s,1))}var n=e.data.attributes;for(var a in n){var o=n[a],s=new i[o.type](o.array);t.addAttribute(a,new THREE.BufferAttribute(s,o.itemSize,o.normalized))}var c=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==c)for(var h=0,l=c.length;h!==l;++h){var u=c[h];t.addGroup(u.start,u.count,u.materialIndex)}var p=e.data.boundingSphere;if(void 0!==p){var d=new THREE.Vector3;void 0!==p.center&&d.fromArray(p.center),t.boundingSphere=new THREE.Sphere(d,p.radius)}return t}}),THREE.MaterialLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.textures={}},Object.assign(THREE.MaterialLoader.prototype,{load:function(e,t,r,i){var n=this;new THREE.XHRLoader(n.manager).load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},setTextures:function(e){this.textures=e},getTexture:function(e){var t=this.textures;return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]},parse:function(e){var t=new THREE[e.type];if(void 0!==e.uuid&&(t.uuid=e.uuid),void 0!==e.name&&(t.name=e.name),void 0!==e.color&&t.color&&t.color.setHex(e.color),void 0!==e.roughness&&(t.roughness=e.roughness),void 0!==e.metalness&&(t.metalness=e.metalness),void 0!==e.emissive&&t.emissive.setHex(e.emissive),void 0!==e.specular&&t.specular.setHex(e.specular),void 0!==e.shininess&&(t.shininess=e.shininess),void 0!==e.uniforms&&(t.uniforms=e.uniforms),void 0!==e.vertexShader&&(t.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(t.fragmentShader=e.fragmentShader),void 0!==e.vertexColors&&(t.vertexColors=e.vertexColors),void 0!==e.shading&&(t.shading=e.shading),void 0!==e.blending&&(t.blending=e.blending),void 0!==e.side&&(t.side=e.side),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.transparent&&(t.transparent=e.transparent),void 0!==e.alphaTest&&(t.alphaTest=e.alphaTest),void 0!==e.depthTest&&(t.depthTest=e.depthTest),void 0!==e.depthWrite&&(t.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(t.colorWrite=e.colorWrite),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(t.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.size&&(t.size=e.size),void 0!==e.sizeAttenuation&&(t.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(t.map=this.getTexture(e.map)),void 0!==e.alphaMap&&(t.alphaMap=this.getTexture(e.alphaMap),t.transparent=!0),void 0!==e.bumpMap&&(t.bumpMap=this.getTexture(e.bumpMap)),void 0!==e.bumpScale&&(t.bumpScale=e.bumpScale),void 0!==e.normalMap&&(t.normalMap=this.getTexture(e.normalMap)),void 0!==e.normalScale){var r=e.normalScale;!1===Array.isArray(r)&&(r=[r,r]),t.normalScale=(new THREE.Vector2).fromArray(r)}if(void 0!==e.displacementMap&&(t.displacementMap=this.getTexture(e.displacementMap)),void 0!==e.displacementScale&&(t.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(t.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(t.roughnessMap=this.getTexture(e.roughnessMap)),void 0!==e.metalnessMap&&(t.metalnessMap=this.getTexture(e.metalnessMap)),void 0!==e.emissiveMap&&(t.emissiveMap=this.getTexture(e.emissiveMap)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(t.specularMap=this.getTexture(e.specularMap)),void 0!==e.envMap&&(t.envMap=this.getTexture(e.envMap),t.combine=THREE.MultiplyOperation),void 0!==e.reflectivity&&(t.reflectivity=e.reflectivity),void 0!==e.lightMap&&(t.lightMap=this.getTexture(e.lightMap)),void 0!==e.lightMapIntensity&&(t.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(t.aoMap=this.getTexture(e.aoMap)),void 0!==e.aoMapIntensity&&(t.aoMapIntensity=e.aoMapIntensity),void 0!==e.materials)for(var i=0,n=e.materials.length;i0){var a=new THREE.LoadingManager(t),o=new THREE.ImageLoader(a);o.setCrossOrigin(this.crossOrigin);for(var s=0,c=e.length;s0?new THREE.SkinnedMesh(s,c):new THREE.Mesh(s,c);break;case"LOD":o=new THREE.LOD;break;case"Line":o=new THREE.Line(n(t.geometry),a(t.material),t.mode);break;case"LineSegments":o=new THREE.LineSegments(n(t.geometry),a(t.material));break;case"PointCloud":case"Points":o=new THREE.Points(n(t.geometry),a(t.material));break;case"Sprite":o=new THREE.Sprite(a(t.material));break;case"Group":o=new THREE.Group;break;default:o=new THREE.Object3D}if(o.uuid=t.uuid,void 0!==t.name&&(o.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(o.position,o.quaternion,o.scale)):(void 0!==t.position&&o.position.fromArray(t.position),void 0!==t.rotation&&o.rotation.fromArray(t.rotation),void 0!==t.scale&&o.scale.fromArray(t.scale)),void 0!==t.castShadow&&(o.castShadow=t.castShadow),void 0!==t.receiveShadow&&(o.receiveShadow=t.receiveShadow),void 0!==t.visible&&(o.visible=t.visible),void 0!==t.userData&&(o.userData=t.userData),void 0!==t.children)for(var h in t.children)o.add(this.parseObject(t.children[h],r,i));if("LOD"===t.type)for(var l=t.levels,u=0;u0||0===e.search(/^data\:image\/jpeg/);n.format=i?THREE.RGBFormat:THREE.RGBAFormat,n.image=r,n.needsUpdate=!0,void 0!==t&&t(n)},r,i),n},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),THREE.CubeTextureLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},Object.assign(THREE.CubeTextureLoader.prototype,{load:function(e,t,r,i){function n(r){o.load(e[r],function(e){a.images[r]=e,6===++s&&(a.needsUpdate=!0,t&&t(a))},void 0,i)}var a=new THREE.CubeTexture,o=new THREE.ImageLoader(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);for(var s=0,c=0;c0&&(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),r){var n=t(e.textures),a=t(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.shading=e.shading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.clipShadows=e.clipShadows;var t=e.clippingPlanes,r=null;if(null!==t){var i=t.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=t[n].clone()}return this.clippingPlanes=r,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(THREE.Material.prototype,THREE.EventDispatcher.prototype),THREE.MaterialIdCount=0,THREE.LineBasicMaterial=function(e){THREE.Material.call(this),this.type="LineBasicMaterial",this.color=new THREE.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(e)},THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial,THREE.LineBasicMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this},THREE.LineDashedMaterial=function(e){THREE.Material.call(this),this.type="LineDashedMaterial",this.color=new THREE.Color(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(e)},THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineDashedMaterial.prototype.constructor=THREE.LineDashedMaterial,THREE.LineDashedMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},THREE.MeshBasicMaterial=function(e){THREE.Material.call(this),this.type="MeshBasicMaterial",this.color=new THREE.Color(16777215),this.map=null,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(e)},THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial,THREE.MeshBasicMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},THREE.MeshDepthMaterial=function(e){THREE.Material.call(this),this.type="MeshDepthMaterial",this.depthPacking=THREE.BasicDepthPacking,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(e)},THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial,THREE.MeshDepthMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},THREE.MeshLambertMaterial=function(e){THREE.Material.call(this),this.type="MeshLambertMaterial",this.color=new THREE.Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new THREE.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial,THREE.MeshLambertMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},THREE.MeshNormalMaterial=function(e){THREE.Material.call(this,e),this.type="MeshNormalMaterial",this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.morphTargets=!1,this.setValues(e)},THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial,THREE.MeshNormalMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},THREE.MeshPhongMaterial=function(e){THREE.Material.call(this),this.type="MeshPhongMaterial",this.color=new THREE.Color(16777215),this.specular=new THREE.Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new THREE.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new THREE.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial,THREE.MeshPhongMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},THREE.MeshStandardMaterial=function(e){THREE.Material.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new THREE.Color(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new THREE.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new THREE.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},THREE.MeshStandardMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshStandardMaterial.prototype.constructor=THREE.MeshStandardMaterial,THREE.MeshStandardMaterial.prototype.copy=function(e){return THREE.Material.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},THREE.MeshPhysicalMaterial=function(e){THREE.MeshStandardMaterial.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)},THREE.MeshPhysicalMaterial.prototype=Object.create(THREE.MeshStandardMaterial.prototype),THREE.MeshPhysicalMaterial.prototype.constructor=THREE.MeshPhysicalMaterial,THREE.MeshPhysicalMaterial.prototype.copy=function(e){return THREE.MeshStandardMaterial.prototype.copy.call(this,e),this.defines={PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearCoat=e.clearCoat,this.clearCoatRoughness=e.clearCoatRoughness,this},THREE.MultiMaterial=function(e){this.uuid=THREE.Math.generateUUID(),this.type="MultiMaterial",this.materials=e instanceof Array?e:[],this.visible=!0},THREE.MultiMaterial.prototype={constructor:THREE.MultiMaterial,toJSON:function(e){for(var t={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},r=this.materials,i=0,n=r.length;i2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}(r)}),t.image=r.uuid}return e.textures[this.uuid]=t,t},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping===THREE.UVMapping){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case THREE.RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case THREE.ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case THREE.RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case THREE.ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}},Object.assign(THREE.Texture.prototype,THREE.EventDispatcher.prototype),THREE.TextureIdCount=0,THREE.DepthTexture=function(e,t,r,i,n,a,o,s,c){THREE.Texture.call(this,null,i,n,a,o,s,THREE.DepthFormat,r,c),this.image={width:e,height:t},this.type=void 0!==r?r:THREE.UnsignedShortType,this.magFilter=void 0!==o?o:THREE.NearestFilter,this.minFilter=void 0!==s?s:THREE.NearestFilter,this.flipY=!1,this.generateMipmaps=!1},THREE.DepthTexture.prototype=Object.create(THREE.Texture.prototype),THREE.DepthTexture.prototype.constructor=THREE.DepthTexture,THREE.CanvasTexture=function(e,t,r,i,n,a,o,s,c){THREE.Texture.call(this,e,t,r,i,n,a,o,s,c),this.needsUpdate=!0},THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture,THREE.CubeTexture=function(e,t,r,i,n,a,o,s,c,h){e=void 0!==e?e:[],t=void 0!==t?t:THREE.CubeReflectionMapping,THREE.Texture.call(this,e,t,r,i,n,a,o,s,c,h),this.flipY=!1},THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CubeTexture.prototype.constructor=THREE.CubeTexture,Object.defineProperty(THREE.CubeTexture.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),THREE.CompressedTexture=function(e,t,r,i,n,a,o,s,c,h,l,u){THREE.Texture.call(this,null,a,o,s,c,h,i,n,l,u),this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1},THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CompressedTexture.prototype.constructor=THREE.CompressedTexture,THREE.DataTexture=function(e,t,r,i,n,a,o,s,c,h,l,u){THREE.Texture.call(this,null,a,o,s,c,h,i,n,l,u),this.image={data:e,width:t,height:r},this.magFilter=void 0!==c?c:THREE.NearestFilter,this.minFilter=void 0!==h?h:THREE.NearestFilter,this.flipY=!1,this.generateMipmaps=!1},THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype),THREE.DataTexture.prototype.constructor=THREE.DataTexture,THREE.VideoTexture=function(e,t,r,i,n,a,o,s,c){function h(){requestAnimationFrame(h),e.readyState>=e.HAVE_CURRENT_DATA&&(l.needsUpdate=!0)}THREE.Texture.call(this,e,t,r,i,n,a,o,s,c),this.generateMipmaps=!1;var l=this;h()},THREE.VideoTexture.prototype=Object.create(THREE.Texture.prototype),THREE.VideoTexture.prototype.constructor=THREE.VideoTexture,THREE.Group=function(){THREE.Object3D.call(this),this.type="Group"},THREE.Group.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Group}),THREE.Points=function(e,t){THREE.Object3D.call(this),this.type="Points",this.geometry=void 0!==e?e:new THREE.BufferGeometry,this.material=void 0!==t?t:new THREE.PointsMaterial({color:16777215*Math.random()})},THREE.Points.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Points,raycast:function(){var e=new THREE.Matrix4,t=new THREE.Ray,r=new THREE.Sphere;return function(i,n){function a(e,r){var a=t.distanceSqToPoint(e);if(ai.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:s.clone(),index:r,face:null,object:o})}}var o=this,s=this.geometry,c=this.matrixWorld,h=i.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),!1!==i.ray.intersectsSphere(r)){e.getInverse(c),t.copy(i.ray).applyMatrix4(e);var l=h/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,p=new THREE.Vector3;if(s instanceof THREE.BufferGeometry){var d=s.index,f=s.attributes.position.array;if(null!==d)for(var E=d.array,m=0,g=E.length;mo)){p.applyMatrix4(this.matrixWorld);(b=i.ray.origin.distanceTo(p))i.far||n.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}else for(var g=0,v=E.length/3-1;go)){p.applyMatrix4(this.matrixWorld);(b=i.ray.origin.distanceTo(p))i.far||n.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}else if(s instanceof THREE.Geometry)for(var R=s.vertices,x=R.length,g=0;go)){p.applyMatrix4(this.matrixWorld);var b=i.ray.origin.distanceTo(p);bi.far||n.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),THREE.LineSegments=function(e,t){THREE.Line.call(this,e,t),this.type="LineSegments"},THREE.LineSegments.prototype=Object.assign(Object.create(THREE.Line.prototype),{constructor:THREE.LineSegments}),THREE.Mesh=function(e,t){THREE.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new THREE.BufferGeometry,this.material=void 0!==t?t:new THREE.MeshBasicMaterial({color:16777215*Math.random()}),this.drawMode=THREE.TrianglesDrawMode,this.updateMorphTargets()},THREE.Mesh.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Mesh,setDrawMode:function(e){this.drawMode=e},copy:function(e){return THREE.Object3D.prototype.copy.call(this,e),this.drawMode=e.drawMode,this},updateMorphTargets:function(){if(void 0!==this.geometry.morphTargets&&this.geometry.morphTargets.length>0){this.morphTargetBase=-1,this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,t=this.geometry.morphTargets.length;et.far?null:{distance:c,point:g.clone(),object:e}}function r(r,i,n,a,h,l,u,E){o.fromArray(a,3*l),s.fromArray(a,3*u),c.fromArray(a,3*E);var g=t(r,i,n,o,s,c,m);return g&&(h&&(p.fromArray(h,2*l),d.fromArray(h,2*u),f.fromArray(h,2*E),g.uv=e(m,o,s,c,p,d,f)),g.face=new THREE.Face3(l,u,E,THREE.Triangle.normal(o,s,c)),g.faceIndex=l),g}var i=new THREE.Matrix4,n=new THREE.Ray,a=new THREE.Sphere,o=new THREE.Vector3,s=new THREE.Vector3,c=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector2,d=new THREE.Vector2,f=new THREE.Vector2,E=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3;return function(E,g){var v=this.geometry,T=this.material,y=this.matrixWorld;if(void 0!==T&&(null===v.boundingSphere&&v.computeBoundingSphere(),a.copy(v.boundingSphere),a.applyMatrix4(y),!1!==E.ray.intersectsSphere(a)&&(i.getInverse(y),n.copy(E.ray).applyMatrix4(i),null===v.boundingBox||!1!==n.intersectsBox(v.boundingBox)))){var R,x;if(v instanceof THREE.BufferGeometry){var H,b,_,M=v.index,w=v.attributes,S=w.position.array;if(void 0!==w.uv&&(R=w.uv.array),null!==M)for(var A=M.array,L=0,C=A.length;L0&&(R=O);for(var G=0,V=N.length;G1){e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;athis.scale.x*this.scale.y/4||r.push({distance:Math.sqrt(i),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),THREE.LensFlare=function(e,t,r,i,n){THREE.Object3D.call(this),this.lensFlares=[],this.positionScreen=new THREE.Vector3,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,r,i,n)},THREE.LensFlare.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.LensFlare,copy:function(e){THREE.Object3D.prototype.copy.call(this,e),this.positionScreen.copy(e.positionScreen),this.customUpdateCallback=e.customUpdateCallback;for(var t=0,r=e.lensFlares.length;t=0&&e.numSupportedMorphTargets++;if(e.morphNormals){e.numSupportedMorphNormals=0;for(var p=0;p=0&&e.numSupportedMorphNormals++}var d=i.__webglShader.uniforms;(e instanceof THREE.ShaderMaterial||e instanceof THREE.RawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=ie.numPlanes,d.clippingPlanes=ie.uniform),e.lights&&(i.lightsHash=he.hash,d.ambientLightColor.value=he.ambient,d.directionalLights.value=he.directional,d.spotLights.value=he.spot,d.pointLights.value=he.point,d.hemisphereLights.value=he.hemi,d.directionalShadowMap.value=he.directionalShadowMap,d.directionalShadowMatrix.value=he.directionalShadowMatrix,d.spotShadowMap.value=he.spotShadowMap,d.spotShadowMatrix.value=he.spotShadowMatrix,d.pointShadowMap.value=he.pointShadowMap,d.pointShadowMatrix.value=he.pointShadowMatrix);var f=i.program.getUniforms(),E=THREE.WebGLUniforms.seqWithValue(f.seq,d);i.uniformsList=E,i.dynamicUniforms=THREE.WebGLUniforms.splitDynamic(E,d)}(r,t,i),r.needsUpdate=!1);var c=!1,h=!1,l=!1,u=n.program,p=u.getUniforms(),d=n.__webglShader.uniforms;if(u.id!==N&&(ue.useProgram(u.program),N=u.id,c=!0,h=!0,l=!0),r.id!==V&&(V=r.id,h=!0),c||e!==k){if(p.set(ue,e,"projectionMatrix"),fe.logarithmicDepthBuffer&&p.setValue(ue,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==k&&(k=e,h=!0,l=!0),r instanceof THREE.ShaderMaterial||r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshStandardMaterial||r.envMap){var f=p.map.cameraPosition;void 0!==f&&f.setValue(ue,ce.setFromMatrixPosition(e.matrixWorld))}(r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshLambertMaterial||r instanceof THREE.MeshBasicMaterial||r instanceof THREE.MeshStandardMaterial||r instanceof THREE.ShaderMaterial||r.skinning)&&p.setValue(ue,"viewMatrix",e.matrixWorldInverse),p.set(ue,F,"toneMappingExposure"),p.set(ue,F,"toneMappingWhitePoint")}if(r.skinning){p.setOptional(ue,i,"bindMatrix"),p.setOptional(ue,i,"bindMatrixInverse");var E=i.skeleton;E&&(fe.floatVertexTextures&&E.useVertexTexture?(p.set(ue,E,"boneTexture"),p.set(ue,E,"boneTextureWidth"),p.set(ue,E,"boneTextureHeight")):p.setOptional(ue,E,"boneMatrices"))}h&&(r.lights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(d,l),t&&r.fog&&function(e,t){e.fogColor.value=t.color,t instanceof THREE.Fog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t instanceof THREE.FogExp2&&(e.fogDensity.value=t.density)}(d,t),(r instanceof THREE.MeshBasicMaterial||r instanceof THREE.MeshLambertMaterial||r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshStandardMaterial||r instanceof THREE.MeshDepthMaterial)&&function(e,t){e.opacity.value=t.opacity,e.diffuse.value=t.color,t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity);e.map.value=t.map,e.specularMap.value=t.specularMap,e.alphaMap.value=t.alphaMap,t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var r;t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap);if(void 0!==r){r instanceof THREE.WebGLRenderTarget&&(r=r.texture);var i=r.offset,n=r.repeat;e.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap instanceof THREE.CubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio}(d,r),r instanceof THREE.LineBasicMaterial?g(d,r):r instanceof THREE.LineDashedMaterial?(g(d,r),function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(d,r)):r instanceof THREE.PointsMaterial?function(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*J,e.scale.value=.5*R.clientHeight,e.map.value=t.map,null!==t.map){var r=t.map.offset,i=t.map.repeat;e.offsetRepeat.value.set(r.x,r.y,i.x,i.y)}}(d,r):r instanceof THREE.MeshLambertMaterial?function(e,t){t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(d,r):r instanceof THREE.MeshPhongMaterial?function(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale);t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale));t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(d,r):r instanceof THREE.MeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,v(e,t)}(d,r):r instanceof THREE.MeshStandardMaterial?v(d,r):r instanceof THREE.MeshDepthMaterial?r.displacementMap&&(d.displacementMap.value=r.displacementMap,d.displacementScale.value=r.displacementScale,d.displacementBias.value=r.displacementBias):r instanceof THREE.MeshNormalMaterial&&(d.opacity.value=r.opacity),THREE.WebGLUniforms.upload(ue,n.uniformsList,d,F)),p.set(ue,i,"modelViewMatrix"),p.set(ue,i,"normalMatrix"),p.setValue(ue,"modelMatrix",i.matrixWorld);var m=n.dynamicUniforms;return null!==m&&(THREE.WebGLUniforms.evalDynamic(m,d,i,e),THREE.WebGLUniforms.upload(ue,m,d,F)),u}function g(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function v(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function T(e,t){var r,i,n,a,o,s,c,h=0,l=0,u=0,p=t.matrixWorldInverse,d=0,f=0,E=0,m=0;for(r=0,i=e.length;r8&&(p.length=8);for(var g=i.morphAttributes,d=0,f=p.length;d=0){var l=a[c];if(void 0!==l){var u=ue.FLOAT,p=l.array,d=l.normalized;p instanceof Float32Array?u=ue.FLOAT:p instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):p instanceof Uint16Array?u=ue.UNSIGNED_SHORT:p instanceof Int16Array?u=ue.SHORT:p instanceof Uint32Array?u=ue.UNSIGNED_INT:p instanceof Int32Array?u=ue.INT:p instanceof Int8Array?u=ue.BYTE:p instanceof Uint8Array&&(u=ue.UNSIGNED_BYTE);var f=l.itemSize,E=ve.getAttributeBuffer(l);if(l instanceof THREE.InterleavedBufferAttribute){var m=l.data,g=m.stride,v=l.offset;m instanceof THREE.InstancedInterleavedBuffer?(Ee.enableAttributeAndDivisor(h,m.meshPerAttribute,n),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):Ee.enableAttribute(h),ue.bindBuffer(ue.ARRAY_BUFFER,E),ue.vertexAttribPointer(h,f,u,d,g*m.array.BYTES_PER_ELEMENT,(i*g+v)*m.array.BYTES_PER_ELEMENT)}else l instanceof THREE.InstancedBufferAttribute?(Ee.enableAttributeAndDivisor(h,l.meshPerAttribute,n),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):Ee.enableAttribute(h),ue.bindBuffer(ue.ARRAY_BUFFER,E),ue.vertexAttribPointer(h,f,u,d,0,i*f*l.array.BYTES_PER_ELEMENT)}else if(void 0!==s){var T=s[c];if(void 0!==T)switch(T.length){case 2:ue.vertexAttrib2fv(h,T);break;case 3:ue.vertexAttrib3fv(h,T);break;case 4:ue.vertexAttrib4fv(h,T);break;default:ue.vertexAttrib1fv(h,T)}}}}Ee.disableUnusedAttributes()}}(n,s,i),null!==T&&ue.bindBuffer(ue.ELEMENT_ARRAY_BUFFER,ve.getAttributeBuffer(T)));var x=1/0;null!==T?x=T.count:void 0!==y&&(x=y.count);var H=i.drawRange.start,b=i.drawRange.count,_=null!==o?o.start:0,M=null!==o?o.count:1/0,w=Math.max(0,H,_),S=Math.min(0+x,H+b,_+M)-1,A=Math.max(0,S-w+1);if(a instanceof THREE.Mesh)if(!0===n.wireframe)Ee.setLineWidth(n.wireframeLinewidth*t()),R.setMode(ue.LINES);else switch(a.drawMode){case THREE.TrianglesDrawMode:R.setMode(ue.TRIANGLES);break;case THREE.TriangleStripDrawMode:R.setMode(ue.TRIANGLE_STRIP);break;case THREE.TriangleFanDrawMode:R.setMode(ue.TRIANGLE_FAN)}else if(a instanceof THREE.Line){var L=n.linewidth;void 0===L&&(L=1),Ee.setLineWidth(L*t()),a instanceof THREE.LineSegments?R.setMode(ue.LINES):R.setMode(ue.LINE_STRIP)}else a instanceof THREE.Points&&R.setMode(ue.POINTS);i instanceof THREE.InstancedBufferGeometry?i.maxInstancedCount>0&&R.renderInstances(i,w,A):R.render(w,A)},this.render=function(e,t,i,n){if(t instanceof THREE.Camera!=!1){var a=e.fog;z="",V=-1,k=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),se.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),re.setFromMatrix(se),A.length=0,C=-1,B=-1,D.length=0,I.length=0,ae=this.localClippingEnabled,ne=ie.init(this.clippingPlanes,ae,t),d(e,t),L.length=C+1,P.length=B+1,!0===F.sortObjects&&(L.sort(h),P.sort(l)),ne&&ie.beginShadows(),function(e){for(var t=0,r=0,i=e.length;r=fe.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+fe.maxTextures),q+=1,e},this.setTexture2D=function(){var e=!1;return function(t,r){t instanceof THREE.WebGLRenderTarget&&(e||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),ge.setTexture2D(t,r)}}(),this.setTexture=function(){var e=!1;return function(t,r){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),ge.setTexture2D(t,r)}}(),this.setTextureCube=function(){var e=!1;return function(t,r){t instanceof THREE.WebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t instanceof THREE.CubeTexture||Array.isArray(t.image)&&6===t.image.length?ge.setTextureCube(t,r):ge.setTextureCubeDynamic(t,r)}}(),this.getCurrentRenderTarget=function(){return O},this.setRenderTarget=function(e){O=e,e&&void 0===me.get(e).__webglFramebuffer&&ge.setupRenderTarget(e);var t,r=e instanceof THREE.WebGLRenderTargetCube;if(e){var i=me.get(e);t=r?i.__webglFramebuffer[e.activeCubeFace]:i.__webglFramebuffer,j.copy(e.scissor),W=e.scissorTest,X.copy(e.viewport)}else t=null,j.copy($).multiplyScalar(J),W=ee,X.copy(te).multiplyScalar(J);if(G!==t&&(ue.bindFramebuffer(ue.FRAMEBUFFER,t),G=t),Ee.scissor(j),Ee.setScissorTest(W),Ee.viewport(X),r){var n=me.get(e.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,n.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,r,i,n,a){if(e instanceof THREE.WebGLRenderTarget!=!1){var o=me.get(e).__webglFramebuffer;if(o){var s=!1;o!==G&&(ue.bindFramebuffer(ue.FRAMEBUFFER,o),s=!0);try{var c=e.texture;if(c.format!==THREE.RGBAFormat&&y(c.format)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c.type===THREE.UnsignedByteType||y(c.type)===ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)||c.type===THREE.FloatType&&de.get("WEBGL_color_buffer_float")||c.type===THREE.HalfFloatType&&de.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");ue.checkFramebufferStatus(ue.FRAMEBUFFER)===ue.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&r>=0&&r<=e.height-n&&ue.readPixels(t,r,i,n,y(c.format),y(c.type),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&ue.bindFramebuffer(ue.FRAMEBUFFER,G)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}},THREE.WebGLRenderTarget=function(e,t,r){this.uuid=THREE.Math.generateUUID(),this.width=e,this.height=t,this.scissor=new THREE.Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new THREE.Vector4(0,0,e,t),void 0===(r=r||{}).minFilter&&(r.minFilter=THREE.LinearFilter),this.texture=new THREE.Texture(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=null},Object.assign(THREE.WebGLRenderTarget.prototype,THREE.EventDispatcher.prototype,{setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),THREE.WebGLRenderTargetCube=function(e,t,r){THREE.WebGLRenderTarget.call(this,e,t,r),this.activeCubeFace=0,this.activeMipMapLevel=0},THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype),THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube,THREE.WebGLBufferRenderer=function(e,t,r){var i;this.setMode=function(e){i=e},this.render=function(t,n){e.drawArrays(i,t,n),r.calls++,r.vertices+=n,i===e.TRIANGLES&&(r.faces+=n/3)},this.renderInstances=function(n){var a=t.get("ANGLE_instanced_arrays");if(null!==a){var o=n.attributes.position,s=0;o instanceof THREE.InterleavedBufferAttribute?(s=o.data.count,a.drawArraysInstancedANGLE(i,0,s,n.maxInstancedCount)):(s=o.count,a.drawArraysInstancedANGLE(i,0,s,n.maxInstancedCount)),r.calls++,r.vertices+=s*n.maxInstancedCount,i===e.TRIANGLES&&(r.faces+=n.maxInstancedCount*s/3)}else console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}},THREE.WebGLClipping=function(){function e(){h.value!==i&&(h.value=i,h.needsUpdate=n>0),r.numPlanes=n}function t(e,t,i,n){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=h.value,!0!==n||null===o){var l=i+4*a,u=t.matrixWorldInverse;c.getNormalMatrix(u),(null===o||o.length0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var n;this.getMaxAnisotropy=function(){if(void 0!==n)return n;var r=t.get("EXT_texture_filter_anisotropic");return n=null!==r?e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},this.getMaxPrecision=i,this.precision=void 0!==r.precision?r.precision:"highp",this.logarithmicDepthBuffer=void 0!==r.logarithmicDepthBuffer&&r.logarithmicDepthBuffer,this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxCubemapSize=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxAttributes=e.getParameter(e.MAX_VERTEX_ATTRIBS),this.maxVertexUniforms=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this.maxVaryings=e.getParameter(e.MAX_VARYING_VECTORS),this.maxFragmentUniforms=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),this.vertexTextures=this.maxVertexTextures>0,this.floatFragmentTextures=!!t.get("OES_texture_float"),this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;var a=i(this.precision);a!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",a,"instead."),this.precision=a),this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!t.get("EXT_frag_depth"))},THREE.WebGLGeometries=function(e,t,r){function i(e){var o=e.target,s=a[o.id];null!==s.index&&n(s.index),function(e){for(var t in e)n(e[t])}(s.attributes),o.removeEventListener("dispose",i),delete a[o.id];var c=t.get(o);c.wireframe&&n(c.wireframe),t.delete(o);var h=t.get(s);h.wireframe&&n(h.wireframe),t.delete(s),r.memory.geometries--}function n(r){var i=function(e){return e instanceof THREE.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}(r);void 0!==i&&(e.deleteBuffer(i),function(e){e instanceof THREE.InterleavedBufferAttribute?t.delete(e.data):t.delete(e)}(r))}var a={};this.get=function(e){var t=e.geometry;if(void 0!==a[t.id])return a[t.id];t.addEventListener("dispose",i);var n;return t instanceof THREE.BufferGeometry?n=t:t instanceof THREE.Geometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new THREE.BufferGeometry).setFromObject(e)),n=t._bufferGeometry),a[t.id]=n,r.memory.geometries++,n}},THREE.WebGLLights=function(){var e={};this.get=function(t){if(void 0!==e[t.id])return e[t.id];var r;switch(t.type){case"DirectionalLight":r={direction:new THREE.Vector3,color:new THREE.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case"SpotLight":r={position:new THREE.Vector3,direction:new THREE.Vector3,color:new THREE.Color,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case"PointLight":r={position:new THREE.Vector3,color:new THREE.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case"HemisphereLight":r={direction:new THREE.Vector3,skyColor:new THREE.Color,groundColor:new THREE.Color}}return e[t.id]=r,r}},THREE.WebGLObjects=function(e,t,r){function i(r,i){var n=r instanceof THREE.InterleavedBufferAttribute?r.data:r,a=t.get(n);void 0===a.__webglBuffer?function(t,r,i){t.__webglBuffer=e.createBuffer(),e.bindBuffer(i,t.__webglBuffer);var n=r.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW;e.bufferData(i,r.array,n),t.version=r.version}(a,n,i):a.version!==n.version&&function(t,r,i){e.bindBuffer(i,t.__webglBuffer),!1===r.dynamic||-1===r.updateRange.count?e.bufferSubData(i,0,r.array):0===r.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(i,r.updateRange.offset*r.array.BYTES_PER_ELEMENT,r.array.subarray(r.updateRange.offset,r.updateRange.offset+r.updateRange.count)),r.updateRange.count=0);t.version=r.version}(a,n,i)}function n(e,t,r){if(t>r){var i=t;t=r,r=i}var n=e[t];return void 0===n?(e[t]=[r],!0):-1===n.indexOf(r)&&(n.push(r),!0)}var a=new THREE.WebGLGeometries(e,t,r);this.getAttributeBuffer=function(e){return e instanceof THREE.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer},this.getWireframeAttribute=function(r){var a=t.get(r);if(void 0!==a.wireframe)return a.wireframe;var o=[],s=r.index,c=r.attributes,h=c.position;if(null!==s)for(var l={},u=0,p=(m=s.array).length;u65535?Uint32Array:Uint16Array,v=new THREE.BufferAttribute(new g(o),1);return i(v,e.ELEMENT_ARRAY_BUFFER),a.wireframe=v,v},this.update=function(t){var r=a.get(t);t.geometry instanceof THREE.Geometry&&r.updateFromObject(t);var n=r.index,o=r.attributes;null!==n&&i(n,e.ELEMENT_ARRAY_BUFFER);for(var s in o)i(o[s],e.ARRAY_BUFFER);var c=r.morphAttributes;for(var s in c)for(var h=c[s],l=0,u=h.length;l/g,function(e,t){var r=THREE.ShaderChunk[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");return n(r)})}function a(e){return e.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,r,i){for(var n="",a=parseInt(t);a0?s.gammaFactor:1,H=function(e,t,i){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(r).join("\n")}(p,l,s.extensions),b=function(e){var t=[];for(var r in e){var i=e[r];!1!==i&&t.push("#define "+r+" "+i)}return t.join("\n")}(d),_=u.createProgram();h instanceof THREE.RawShaderMaterial?(y=["precision "+l.precision+" float;","precision "+l.precision+" int;","#define SHADER_NAME "+h.__webglShader.name,b,"\n"].filter(r).join("\n"),R=[H,"precision "+l.precision+" float;","precision "+l.precision+" int;","#define SHADER_NAME "+h.__webglShader.name,b,"\n"].filter(r).join("\n")):(y=["precision "+l.precision+" float;","precision "+l.precision+" int;","#define SHADER_NAME "+h.__webglShader.name,b,l.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+x,"#define MAX_BONES "+l.maxBones,l.map?"#define USE_MAP":"",l.envMap?"#define USE_ENVMAP":"",l.envMap?"#define "+v:"",l.lightMap?"#define USE_LIGHTMAP":"",l.aoMap?"#define USE_AOMAP":"",l.emissiveMap?"#define USE_EMISSIVEMAP":"",l.bumpMap?"#define USE_BUMPMAP":"",l.normalMap?"#define USE_NORMALMAP":"",l.displacementMap&&l.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",l.specularMap?"#define USE_SPECULARMAP":"",l.roughnessMap?"#define USE_ROUGHNESSMAP":"",l.metalnessMap?"#define USE_METALNESSMAP":"",l.alphaMap?"#define USE_ALPHAMAP":"",l.vertexColors?"#define USE_COLOR":"",l.flatShading?"#define FLAT_SHADED":"",l.skinning?"#define USE_SKINNING":"",l.useVertexTexture?"#define BONE_TEXTURE":"",l.morphTargets?"#define USE_MORPHTARGETS":"",l.morphNormals&&!1===l.flatShading?"#define USE_MORPHNORMALS":"",l.doubleSided?"#define DOUBLE_SIDED":"",l.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+l.numClippingPlanes,l.shadowMapEnabled?"#define USE_SHADOWMAP":"",l.shadowMapEnabled?"#define "+m:"",l.sizeAttenuation?"#define USE_SIZEATTENUATION":"",l.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",l.logarithmicDepthBuffer&&s.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(r).join("\n"),R=[H,"precision "+l.precision+" float;","precision "+l.precision+" int;","#define SHADER_NAME "+h.__webglShader.name,b,l.alphaTest?"#define ALPHATEST "+l.alphaTest:"","#define GAMMA_FACTOR "+x,l.useFog&&l.fog?"#define USE_FOG":"",l.useFog&&l.fogExp?"#define FOG_EXP2":"",l.map?"#define USE_MAP":"",l.envMap?"#define USE_ENVMAP":"",l.envMap?"#define "+g:"",l.envMap?"#define "+v:"",l.envMap?"#define "+T:"",l.lightMap?"#define USE_LIGHTMAP":"",l.aoMap?"#define USE_AOMAP":"",l.emissiveMap?"#define USE_EMISSIVEMAP":"",l.bumpMap?"#define USE_BUMPMAP":"",l.normalMap?"#define USE_NORMALMAP":"",l.specularMap?"#define USE_SPECULARMAP":"",l.roughnessMap?"#define USE_ROUGHNESSMAP":"",l.metalnessMap?"#define USE_METALNESSMAP":"",l.alphaMap?"#define USE_ALPHAMAP":"",l.vertexColors?"#define USE_COLOR":"",l.flatShading?"#define FLAT_SHADED":"",l.doubleSided?"#define DOUBLE_SIDED":"",l.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+l.numClippingPlanes,l.shadowMapEnabled?"#define USE_SHADOWMAP":"",l.shadowMapEnabled?"#define "+m:"",l.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",l.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",l.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",l.logarithmicDepthBuffer&&s.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",l.envMap&&s.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",l.toneMapping!==THREE.NoToneMapping?"#define TONE_MAPPING":"",l.toneMapping!==THREE.NoToneMapping?THREE.ShaderChunk.tonemapping_pars_fragment:"",l.toneMapping!==THREE.NoToneMapping?function(e,t){var r;switch(t){case THREE.LinearToneMapping:r="Linear";break;case THREE.ReinhardToneMapping:r="Reinhard";break;case THREE.Uncharted2ToneMapping:r="Uncharted2";break;case THREE.CineonToneMapping:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",l.toneMapping):"",l.outputEncoding||l.mapEncoding||l.envMapEncoding||l.emissiveMapEncoding?THREE.ShaderChunk.encodings_pars_fragment:"",l.mapEncoding?t("mapTexelToLinear",l.mapEncoding):"",l.envMapEncoding?t("envMapTexelToLinear",l.envMapEncoding):"",l.emissiveMapEncoding?t("emissiveMapTexelToLinear",l.emissiveMapEncoding):"",l.outputEncoding?function(t,r){var i=e(r);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}("linearToOutputTexel",l.outputEncoding):"",l.depthPacking?"#define DEPTH_PACKING "+h.depthPacking:"","\n"].filter(r).join("\n")),f=i(f=n(f),l),E=i(E=n(E),l),h instanceof THREE.ShaderMaterial==!1&&(f=a(f),E=a(E));var M=y+f,w=R+E,S=THREE.WebGLShader(u,u.VERTEX_SHADER,M),A=THREE.WebGLShader(u,u.FRAGMENT_SHADER,w);u.attachShader(_,S),u.attachShader(_,A),void 0!==h.index0AttributeName?u.bindAttribLocation(_,0,h.index0AttributeName):!0===l.morphTargets&&u.bindAttribLocation(_,0,"position"),u.linkProgram(_);var L=u.getProgramInfoLog(_),C=u.getShaderInfoLog(S),P=u.getShaderInfoLog(A),B=!0,U=!0;!1===u.getProgramParameter(_,u.LINK_STATUS)?(B=!1,console.error("THREE.WebGLProgram: shader error: ",u.getError(),"gl.VALIDATE_STATUS",u.getProgramParameter(_,u.VALIDATE_STATUS),"gl.getProgramInfoLog",L,C,P)):""!==L?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",L):""!==C&&""!==P||(U=!1),U&&(this.diagnostics={runnable:B,material:h,programLog:L,vertexShader:{log:C,prefix:y},fragmentShader:{log:P,prefix:R}}),u.deleteShader(S),u.deleteShader(A);var D;this.getUniforms=function(){return void 0===D&&(D=new THREE.WebGLUniforms(u,_,s)),D};var I;return this.getAttributes=function(){return void 0===I&&(I=function(e,t,r){for(var i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===THREE.DoubleSide,flipSided:i.side===THREE.BackSide,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(e,t){var r=[];if(t.shaderID?r.push(t.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var n=0;n0:a instanceof THREE.Geometry&&(h=a.morphTargets&&a.morphTargets.length>0));var l=t instanceof THREE.SkinnedMesh&&r.skinning,u=0;h&&(u|=m),l&&(u|=g),o=s[u]}if(e.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var p=o.uuid,d=r.uuid,f=R[p];void 0===f&&(f={},R[p]=f);var E=f[d];void 0===E&&(E=o.clone(),f[d]=E),o=E}o.visible=r.visible,o.wireframe=r.wireframe;var v=r.side;return B.renderSingleSided&&v==THREE.DoubleSide&&(v=THREE.FrontSide),B.renderReverseSided&&(v===THREE.FrontSide?v=THREE.BackSide:v===THREE.BackSide&&(v=THREE.FrontSide)),o.side=v,o.clipShadows=r.clipShadows,o.clippingPlanes=r.clippingPlanes,o.wireframeLinewidth=r.wireframeLinewidth,o.linewidth=r.linewidth,i&&void 0!==o.uniforms.lightPos&&o.uniforms.lightPos.value.copy(n),o}function a(e,t,r){if(!1!==e.visible){if(e.layers.test(t.layers)&&(e instanceof THREE.Mesh||e instanceof THREE.Line||e instanceof THREE.Points)&&e.castShadow&&(!1===e.frustumCulled||!0===c.intersectsObject(e))){!0===e.material.visible&&(e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),E.push(e))}for(var i=e.children,n=0,o=i.length;nt||e.height>t){var r=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=Math.floor(e.width*r),i.height=Math.floor(e.height*r);return i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function c(e){return THREE.Math.isPowerOfTwo(e.width)&&THREE.Math.isPowerOfTwo(e.height)}function h(t){return t===THREE.NearestFilter||t===THREE.NearestMipMapNearestFilter||t===THREE.NearestMipMapLinearFilter?e.NEAREST:e.LINEAR}function l(t){var r=t.target;r.removeEventListener("dispose",l),function(t){var r=i.get(t);if(t.image&&r.__image__webglTextureCube)e.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;e.deleteTexture(r.__webglTexture)}i.delete(t)}(r),g.textures--}function u(t){var r=t.target;r.removeEventListener("dispose",u),function(t){var r=i.get(t),n=i.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t instanceof THREE.WebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(r.__webglFramebuffer[a]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[a]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer);i.delete(t.texture),i.delete(t)}(r),g.textures--}function p(t,o){var h=i.get(t);if(t.version>0&&h.__version!==t.version){var u=t.image;if(void 0===u)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==u.complete)return void function(t,i,o){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",l),t.__webglTexture=e.createTexture(),g.textures++);r.activeTexture(e.TEXTURE0+o),r.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var h=s(i.image,n.maxTextureSize);(function(e){return e.wrapS!==THREE.ClampToEdgeWrapping||e.wrapT!==THREE.ClampToEdgeWrapping||e.minFilter!==THREE.NearestFilter&&e.minFilter!==THREE.LinearFilter})(i)&&!1===c(h)&&(h=function(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=THREE.Math.nearestPowerOfTwo(e.width),t.height=THREE.Math.nearestPowerOfTwo(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}(h));var u=c(h),p=a(i.format),f=a(i.type);d(e.TEXTURE_2D,i,u);var E,m=i.mipmaps;if(i instanceof THREE.DepthTexture){var T=e.DEPTH_COMPONENT;if(i.type===THREE.FloatType){if(!v)throw new Error("Float Depth Texture only supported in WebGL2.0");T=e.DEPTH_COMPONENT32F}else v&&(T=e.DEPTH_COMPONENT16);r.texImage2D(e.TEXTURE_2D,0,T,h.width,h.height,0,p,f,null)}else if(i instanceof THREE.DataTexture)if(m.length>0&&u){for(var y=0,R=m.length;y-1?r.compressedTexImage2D(e.TEXTURE_2D,y,p,E.width,E.height,0,E.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(e.TEXTURE_2D,y,p,E.width,E.height,0,p,f,E.data);else if(m.length>0&&u){for(var y=0,R=m.length;y1||i.get(o).__currentAnisotropy)&&(e.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function f(t,n,o,s){var c=a(n.texture.format),h=a(n.texture.type);r.texImage2D(s,0,c,n.width,n.height,0,c,h,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,o,s,i.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function E(t,r){e.bindRenderbuffer(e.RENDERBUFFER,t),r.depthBuffer&&!r.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):r.depthBuffer&&r.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,r.width,r.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function m(t){var r=i.get(t),n=t instanceof THREE.WebGLRenderTargetCube;if(t.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r instanceof THREE.WebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!(r.depthTexture instanceof THREE.DepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),p(r.depthTexture,0);var n=i.get(r.depthTexture).__webglTexture;e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,n,0)}(r.__webglFramebuffer,t)}else if(n){r.__webglDepthbuffer=[];for(var a=0;a<6;a++)e.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[a]),r.__webglDepthbuffer[a]=e.createRenderbuffer(),E(r.__webglDepthbuffer[a],t)}else e.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),E(r.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}var g=o.memory,v="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext;this.setTexture2D=p,this.setTextureCube=function(t,o){var h=i.get(t);if(6===t.image.length)if(t.version>0&&h.__version!==t.version){h.__image__webglTextureCube||(t.addEventListener("dispose",l),h.__image__webglTextureCube=e.createTexture(),g.textures++),r.activeTexture(e.TEXTURE0+o),r.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var u=t instanceof THREE.CompressedTexture,p=t.image[0]instanceof THREE.DataTexture,f=[],E=0;E<6;E++)f[E]=u||p?p?t.image[E].image:t.image[E]:s(t.image[E],n.maxCubemapSize);var m=c(f[0]),v=a(t.format),T=a(t.type);for(d(e.TEXTURE_CUBE_MAP,t,m),E=0;E<6;E++)if(u)for(var y,R=f[E].mipmaps,x=0,H=R.length;x-1?r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+E,x,v,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+E,x,v,y.width,y.height,0,v,T,y.data);else p?r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+E,0,v,f[E].width,f[E].height,0,v,T,f[E].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+E,0,v,v,T,f[E]);t.generateMipmaps&&m&&e.generateMipmap(e.TEXTURE_CUBE_MAP),h.__version=t.version,t.onUpdate&&t.onUpdate(t)}else r.activeTexture(e.TEXTURE0+o),r.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,n){r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)},this.setupRenderTarget=function(t){var n=i.get(t),a=i.get(t.texture);t.addEventListener("dispose",u),a.__webglTexture=e.createTexture(),g.textures++;var o=t instanceof THREE.WebGLRenderTargetCube,s=c(t);if(o)for(n.__webglFramebuffer=[],h=0;h<6;h++)n.__webglFramebuffer[h]=e.createFramebuffer();else n.__webglFramebuffer=e.createFramebuffer();if(o){r.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture),d(e.TEXTURE_CUBE_MAP,t.texture,s);for(var h=0;h<6;h++)f(n.__webglFramebuffer[h],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+h);t.texture.generateMipmaps&&s&&e.generateMipmap(e.TEXTURE_CUBE_MAP),r.bindTexture(e.TEXTURE_CUBE_MAP,null)}else r.bindTexture(e.TEXTURE_2D,a.__webglTexture),d(e.TEXTURE_2D,t.texture,s),f(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),t.texture.generateMipmaps&&s&&e.generateMipmap(e.TEXTURE_2D),r.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&m(t)},this.updateRenderTargetMipmap=function(t){var n=t.texture;if(n.generateMipmaps&&c(t)&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter){var a=t instanceof THREE.WebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,o=i.get(n).__webglTexture;r.bindTexture(a,o),e.generateMipmap(a),r.bindTexture(a,null)}}},THREE.WebGLUniforms=function(){var e=new THREE.Texture,t=new THREE.CubeTexture,r=function(){this.seq=[],this.map={}},i=[],n=[],a=function(e,t,r){var n=e[0];if(n<=0||n>0)return e;var a=t*r,o=i[a];if(void 0===o&&(o=new Float32Array(a),i[a]=o),0!==t){n.toArray(o,0);for(var s=1,c=0;s!==t;++s)c+=r,e[s].toArray(o,c)}return o},o=function(e,t){var r=n[t];void 0===r&&(r=new Int32Array(t),n[t]=r);for(var i=0;i!==t;++i)r[i]=e.allocTextureUnit();return r},s=function(e,t){e.uniform1f(this.addr,t)},c=function(e,t){e.uniform1i(this.addr,t)},h=function(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)},l=function(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)},u=function(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)},p=function(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)},d=function(e,t){e.uniformMatrix3fv(this.addr,!1,t.elements||t)},f=function(e,t){e.uniformMatrix4fv(this.addr,!1,t.elements||t)},E=function(t,r,i){var n=i.allocTextureUnit();t.uniform1i(this.addr,n),i.setTexture2D(r||e,n)},m=function(e,r,i){var n=i.allocTextureUnit();e.uniform1i(this.addr,n),i.setTextureCube(r||t,n)},g=function(e,t){e.uniform2iv(this.addr,t)},v=function(e,t){e.uniform3iv(this.addr,t)},T=function(e,t){e.uniform4iv(this.addr,t)},y=function(e,t){e.uniform1fv(this.addr,t)},R=function(e,t){e.uniform1iv(this.addr,t)},x=function(e,t){e.uniform2fv(this.addr,a(t,this.size,2))},H=function(e,t){e.uniform3fv(this.addr,a(t,this.size,3))},b=function(e,t){e.uniform4fv(this.addr,a(t,this.size,4))},_=function(e,t){e.uniformMatrix2fv(this.addr,!1,a(t,this.size,4))},M=function(e,t){e.uniformMatrix3fv(this.addr,!1,a(t,this.size,9))},w=function(e,t){e.uniformMatrix4fv(this.addr,!1,a(t,this.size,16))},S=function(t,r,i){var n=r.length,a=o(i,n);t.uniform1iv(this.addr,a);for(var s=0;s!==n;++s)i.setTexture2D(r[s]||e,a[s])},A=function(e,r,i){var n=r.length,a=o(i,n);e.uniform1iv(this.addr,a);for(var s=0;s!==n;++s)i.setTextureCube(r[s]||t,a[s])},L=function(e,t,r){this.id=e,this.addr=r,this.setValue=function(e){switch(e){case 5126:return s;case 35664:return h;case 35665:return l;case 35666:return u;case 35674:return p;case 35675:return d;case 35676:return f;case 35678:return E;case 35680:return m;case 5124:case 35670:return c;case 35667:case 35671:return g;case 35668:case 35672:return v;case 35669:case 35673:return T}}(t.type)},C=function(e,t,r){this.id=e,this.addr=r,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return y;case 35664:return x;case 35665:return H;case 35666:return b;case 35674:return _;case 35675:return M;case 35676:return w;case 35678:return S;case 35680:return A;case 5124:case 35670:return R;case 35667:case 35671:return g;case 35668:case 35672:return v;case 35669:case 35673:return T}}(t.type)},P=function(e){this.id=e,r.call(this)};P.prototype.setValue=function(e,t){for(var r=this.seq,i=0,n=r.length;i!==n;++i){var a=r[i];a.setValue(e,t[a.id])}};var B=/([\w\d_]+)(\])?(\[|\.)?/g,U=function(e,t){e.seq.push(t),e.map[t.id]=t},D=function(e,t,r){var i=e.name,n=i.length;for(B.lastIndex=0;;){var a=B.exec(i),o=B.lastIndex,s=a[1],c="]"===a[2],h=a[3];if(c&&(s|=0),void 0===h||"["===h&&o+2===n){U(r,void 0===h?new L(s,e,t):new C(s,e,t));break}var l=r.map[s];void 0===l&&(l=new P(s),U(r,l)),r=l}},I=function(e,t,i){r.call(this),this.renderer=i;for(var n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),a=0;a!==n;++a){var o=e.getActiveUniform(t,a),s=o.name,c=e.getUniformLocation(t,s);D(o,c,this)}};return I.prototype.setValue=function(e,t,r){var i=this.map[t];void 0!==i&&i.setValue(e,r,this.renderer)},I.prototype.set=function(e,t,r){var i=this.map[r];void 0!==i&&i.setValue(e,t[r],this.renderer)},I.prototype.setOptional=function(e,t,r){var i=t[r];void 0!==i&&this.setValue(e,r,i)},I.upload=function(e,t,r,i){for(var n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,i)}},I.seqWithValue=function(e,t){for(var r=[],i=0,n=e.length;i!==n;++i){var a=e[i];a.id in t&&r.push(a)}return r},I.splitDynamic=function(e,t){for(var r=null,i=e.length,n=0,a=0;a!==i;++a){var o=e[a],s=t[o.id];s&&!0===s.dynamic?(null===r&&(r=[]),r.push(o)):(n.001&&A.scale>.001&&(R.x=A.x,R.y=A.y,R.z=A.z,T=A.size*A.scale/f.w,y.x=T*m,y.y=T,u.uniform3f(c.screenPosition,R.x,R.y,R.z),u.uniform2f(c.scale,y.x,y.y),u.uniform1f(c.rotation,A.rotation),u.uniform1f(c.opacity,A.opacity),u.uniform3f(c.color,A.color.r,A.color.g,A.color.b),p.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst),e.setTexture2D(A.texture,1),u.drawElements(u.TRIANGLES,6,u.UNSIGNED_SHORT,0))}}}p.enable(u.CULL_FACE),p.enable(u.DEPTH_TEST),p.setDepthWrite(!0),e.resetGLState()}}},THREE.SpritePlugin=function(e,t){function r(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);n=l.createBuffer(),a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,n),l.bufferData(l.ARRAY_BUFFER,t,l.STATIC_DRAW),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,a),l.bufferData(l.ELEMENT_ARRAY_BUFFER,r,l.STATIC_DRAW),o=function(){var t=l.createProgram(),r=l.createShader(l.VERTEX_SHADER),i=l.createShader(l.FRAGMENT_SHADER);return l.shaderSource(r,["precision "+e.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")),l.shaderSource(i,["precision "+e.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")),l.compileShader(r),l.compileShader(i),l.attachShader(t,r),l.attachShader(t,i),l.linkProgram(t),t}(),s={position:l.getAttribLocation(o,"position"),uv:l.getAttribLocation(o,"uv")},c={uvOffset:l.getUniformLocation(o,"uvOffset"),uvScale:l.getUniformLocation(o,"uvScale"),rotation:l.getUniformLocation(o,"rotation"),scale:l.getUniformLocation(o,"scale"),color:l.getUniformLocation(o,"color"),map:l.getUniformLocation(o,"map"),opacity:l.getUniformLocation(o,"opacity"),modelViewMatrix:l.getUniformLocation(o,"modelViewMatrix"),projectionMatrix:l.getUniformLocation(o,"projectionMatrix"),fogType:l.getUniformLocation(o,"fogType"),fogDensity:l.getUniformLocation(o,"fogDensity"),fogNear:l.getUniformLocation(o,"fogNear"),fogFar:l.getUniformLocation(o,"fogFar"),fogColor:l.getUniformLocation(o,"fogColor"),alphaTest:l.getUniformLocation(o,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var u=i.getContext("2d");u.fillStyle="white",u.fillRect(0,0,8,8),(h=new THREE.Texture(i)).needsUpdate=!0}function i(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var n,a,o,s,c,h,l=e.context,u=e.state,p=new THREE.Vector3,d=new THREE.Quaternion,f=new THREE.Vector3;this.render=function(E,m){if(0!==t.length){void 0===o&&r(),l.useProgram(o),u.initAttributes(),u.enableAttribute(s.position),u.enableAttribute(s.uv),u.disableUnusedAttributes(),u.disable(l.CULL_FACE),u.enable(l.BLEND),l.bindBuffer(l.ARRAY_BUFFER,n),l.vertexAttribPointer(s.position,2,l.FLOAT,!1,16,0),l.vertexAttribPointer(s.uv,2,l.FLOAT,!1,16,8),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,a),l.uniformMatrix4fv(c.projectionMatrix,!1,m.projectionMatrix.elements),u.activeTexture(l.TEXTURE0),l.uniform1i(c.map,0);var g=0,v=0,T=E.fog;T?(l.uniform3f(c.fogColor,T.color.r,T.color.g,T.color.b),T instanceof THREE.Fog?(l.uniform1f(c.fogNear,T.near),l.uniform1f(c.fogFar,T.far),l.uniform1i(c.fogType,1),g=1,v=1):T instanceof THREE.FogExp2&&(l.uniform1f(c.fogDensity,T.density),l.uniform1i(c.fogType,2),g=2,v=2)):(l.uniform1i(c.fogType,0),g=0,v=0);for(var y=0,R=t.length;y(h-s)*(p-c)-(l-c)*(u-s))return!1;var E,m,g,v,T,y,R,x,H,b,_,M,w,S,A;for(E=u-h,m=p-l,g=s-u,v=c-p,T=h-s,y=l-c,o=0;o=-Number.EPSILON&&S>=-Number.EPSILON&&w>=-Number.EPSILON))return!1;return!0}return function(t,r){var i=t.length;if(i<3)return null;var n,a,o,s=[],c=[],h=[];if(THREE.ShapeUtils.area(t)>0)for(a=0;a2;){if(u--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),r?h:s;if(n=a,l<=n&&(n=0),a=n+1,l<=a&&(a=0),o=a+1,l<=o&&(o=0),e(t,n,a,o,l,c)){var p,d,f,E,m;for(p=c[n],d=c[a],f=c[o],s.push([t[p],t[d],t[f]]),h.push([c[n],c[a],c[o]]),E=a,m=a+1;m2&&e[t-1].equals(e[0])&&e.pop()}function i(e,t,r){return e.x!==t.x?e.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||f_?[]:y===_?a?[]:[v]:R<=_?[v,T]:[v,H]}function a(e,t,r,i){var n=t.x-e.x,a=t.y-e.y,o=r.x-e.x,s=r.y-e.y,c=i.x-e.x,h=i.y-e.y,l=n*s-a*o,u=n*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}r(e),t.forEach(r);for(var o,s,c,h,l,u,p={},d=e.concat(),f=0,E=t.length;fr&&(n=0);var o=a(v[e],v[i],v[n],s[t]);if(!o)return!1;var c=s.length-1,h=t-1;h<0&&(h=c);var l=t+1;return l>c&&(l=0),!!(o=a(s[t],s[h],s[l],v[e]))}function i(e,t){var r,i;for(r=0;r0)return!0;return!1}function o(e,r){var i,a,o,s;for(i=0;i0)return!0;return!1}for(var s,c,h,l,u,p,d,f,E,m,g,v=e.concat(),T=[],y=[],R=0,x=t.length;R0;){if(--b<0){console.log("Infinite Loop! Holes left:"+T.length+", Probably Hole outside Shape!");break}for(h=H;h=0)break;y[d]=!0}if(c>=0)break}}return v}(e,t),g=THREE.ShapeUtils.triangulate(m,!1);for(o=0,s=g.length;o0)){c=n;break}c=n-1}if(n=c,i[n]===r){return l=n/(a-1)}var h=i[n],l=(n+(r-h)/(i[n+1]-h))/(a-1);return l},getTangent:function(e){var t=e-1e-4,r=e+1e-4;t<0&&(t=0),r>1&&(r=1);var i=this.getPoint(t);return this.getPoint(r).clone().sub(i).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)}},THREE.Curve.create=function(e,t){return e.prototype=Object.create(THREE.Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},THREE.CurvePath=function(){this.curves=[],this.autoClose=!1},THREE.CurvePath.prototype=Object.assign(Object.create(THREE.Curve.prototype),{constructor:THREE.CurvePath,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new THREE.LineCurve(t,e))},getPoint:function(e){for(var t=e*this.getLength(),r=this.getCurveLengths(),i=0;i=t){var n=r[i]-t,a=this.curves[i],o=a.getLength(),s=0===o?0:1-n/o;return a.getPointAt(s)}i++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.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 e=[],t=0,r=0,i=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(e){var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){for(var t=new THREE.Geometry,r=0,i=e.length;r0){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)}}),THREE.ShapePath=function(){this.subPaths=[],this.currentPath=null},THREE.ShapePath.prototype={moveTo:function(e,t){this.currentPath=new THREE.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t)},lineTo:function(e,t){this.currentPath.lineTo(e,t)},quadraticCurveTo:function(e,t,r,i){this.currentPath.quadraticCurveTo(e,t,r,i)},bezierCurveTo:function(e,t,r,i,n,a){this.currentPath.bezierCurveTo(e,t,r,i,n,a)},splineThru:function(e){this.currentPath.splineThru(e)},toShapes:function(e,t){function r(e){for(var t=[],r=0,i=e.length;rNumber.EPSILON){if(h<0&&(o=t[a],c=-c,s=t[n],h=-h),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var l=h*(e.x-o.x)-c*(e.y-o.y);if(0===l)return!0;if(l<0)continue;i=!i}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return i}var n=THREE.ShapeUtils.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return r(a);var o,s,c,h=[];if(1===a.length)return s=a[0],c=new THREE.Shape,c.curves=s.curves,h.push(c),h;var l=!n(a[0].getPoints());l=e?!l:l;var u,p=[],d=[],f=[],E=0;d[E]=void 0,f[E]=[];for(var m=0,g=a.length;m1){for(var v=!1,T=[],y=0,R=d.length;y0&&(v||(f=p))}for(var w,m=0,S=d.length;mt.length-2?t.length-1:i+1],c=t[i>t.length-3?t.length-1:i+2],h=THREE.CurveUtils.interpolate;return new THREE.Vector2(h(a.x,o.x,s.x,c.x,n),h(a.y,o.y,s.y,c.y,n))},THREE.EllipseCurve=function(e,t,r,i,n,a,o,s){this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s||0},THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype),THREE.EllipseCurve.prototype.constructor=THREE.EllipseCurve,THREE.EllipseCurve.prototype.getPoint=function(e){for(var t=2*Math.PI,r=this.aEndAngle-this.aStartAngle,i=Math.abs(r)t;)r-=t;rt.length-2?t.length-1:i+1],c=t[i>t.length-3?t.length-1:i+2],h=THREE.CurveUtils.interpolate;return new THREE.Vector3(h(a.x,o.x,s.x,c.x,n),h(a.y,o.y,s.y,c.y,n),h(a.z,o.z,s.z,c.z,n))}),THREE.CatmullRomCurve3=function(){function e(){}var t=new THREE.Vector3,r=new e,i=new e,n=new e;return e.prototype.init=function(e,t,r,i){this.c0=e,this.c1=r,this.c2=-3*e+3*t-2*r-i,this.c3=2*e-2*t+r+i},e.prototype.initNonuniformCatmullRom=function(e,t,r,i,n,a,o){var s=(t-e)/n-(r-e)/(n+a)+(r-t)/a,c=(r-t)/a-(i-t)/(a+o)+(i-r)/o;s*=a,c*=a,this.init(t,r,s,c)},e.prototype.initCatmullRom=function(e,t,r,i,n){this.init(t,r,n*(r-e),n*(i-t))},e.prototype.calc=function(e){var t=e*e,r=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*r},THREE.Curve.create(function(e){this.points=e||[],this.closed=!1},function(e){var a,o,s,c,h=this.points;(c=h.length)<2&&console.log("duh, you need at least 2 points"),s=(a=(c-(this.closed?0:1))*e)-(o=Math.floor(a)),this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/h.length)+1)*h.length:0===s&&o===c-1&&(o=c-2,s=1);var l,u,p,d;if(this.closed||o>0?l=h[(o-1)%c]:(t.subVectors(h[0],h[1]).add(h[0]),l=t),u=h[o%c],p=h[(o+1)%c],this.closed||o+20?1:-1,p[f]=L.x,p[f+1]=L.y,p[f+2]=L.z,d[E]=B/h,d[E+1]=1-C/T,f+=3,E+=2,S+=1}for(C=0;C65535?Uint32Array:Uint16Array)(h),u=new Float32Array(3*c),p=new Float32Array(3*c),d=new Float32Array(2*c),f=0,E=0,m=0,g=0,v=0;o("z","y","x",-1,-1,r,t,e,a,n,0),o("z","y","x",1,-1,r,t,-e,a,n,1),o("x","z","y",1,1,e,r,t,i,a,2),o("x","z","y",1,-1,e,r,-t,i,a,3),o("x","y","z",1,-1,e,t,r,i,n,4),o("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(new THREE.BufferAttribute(l,1)),this.addAttribute("position",new THREE.BufferAttribute(u,3)),this.addAttribute("normal",new THREE.BufferAttribute(p,3)),this.addAttribute("uv",new THREE.BufferAttribute(d,2))},THREE.BoxBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.BoxBufferGeometry.prototype.constructor=THREE.BoxBufferGeometry,THREE.CircleGeometry=function(e,t,r,i){THREE.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:i},this.fromBufferGeometry(new THREE.CircleBufferGeometry(e,t,r,i))},THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CircleGeometry.prototype.constructor=THREE.CircleGeometry,THREE.CircleBufferGeometry=function(e,t,r,i){THREE.BufferGeometry.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:i},e=e||50,t=void 0!==t?Math.max(3,t):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var n=t+2,a=new Float32Array(3*n),o=new Float32Array(3*n),s=new Float32Array(2*n);o[2]=1,s[0]=.5,s[1]=.5;for(var c=0,h=3,l=2;c<=t;c++,h+=3,l+=2){var u=r+c/t*i;a[h]=e*Math.cos(u),a[h+1]=e*Math.sin(u),o[h+2]=1,s[l]=(a[h]/e+1)/2,s[l+1]=(a[h+1]/e+1)/2}for(var p=[],h=1;h<=t;h++)p.push(h,h+1,0);this.setIndex(new THREE.BufferAttribute(new Uint16Array(p),1)),this.addAttribute("position",new THREE.BufferAttribute(a,3)),this.addAttribute("normal",new THREE.BufferAttribute(o,3)),this.addAttribute("uv",new THREE.BufferAttribute(s,2)),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,e)},THREE.CircleBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.CircleBufferGeometry.prototype.constructor=THREE.CircleBufferGeometry,THREE.CylinderBufferGeometry=function(e,t,r,i,n,a,o,s){function c(r){var n,a,c,l=new THREE.Vector2,u=new THREE.Vector3,p=0,T=!0===r?e:t,x=!0===r?1:-1;for(a=g,n=1;n<=i;n++)f.setXYZ(g,0,y*x,0),E.setXYZ(g,0,x,0),l.x=.5,l.y=.5,m.setXY(g,l.x,l.y),g++;for(c=g,n=0;n<=i;n++){var H=n/i*s+o,b=Math.cos(H),_=Math.sin(H);u.x=T*_,u.y=y*x,u.z=T*b,f.setXYZ(g,u.x,u.y,u.z),E.setXYZ(g,0,x,0),l.x=.5*b+.5,l.y=.5*_*x+.5,m.setXY(g,l.x,l.y),g++}for(n=0;n0&&l++,t>0&&l++);var u=function(){var e=(i+1)*(n+1);return!1===a&&(e+=(i+1)*l+i*l),e}(),p=function(){var e=i*n*2*3;return!1===a&&(e+=i*l*3),e}(),d=new THREE.BufferAttribute(new(p>65535?Uint32Array:Uint16Array)(p),1),f=new THREE.BufferAttribute(new Float32Array(3*u),3),E=new THREE.BufferAttribute(new Float32Array(3*u),3),m=new THREE.BufferAttribute(new Float32Array(2*u),2),g=0,v=0,T=[],y=r/2,R=0;!function(){var a,c,l=new THREE.Vector3,u=new THREE.Vector3,p=0,x=(t-e)/r;for(c=0;c<=n;c++){var H=[],b=c/n,_=b*(t-e)+e;for(a=0;a<=i;a++){var M=a/i;u.x=_*Math.sin(M*s+o),u.y=-b*r+y,u.z=_*Math.cos(M*s+o),f.setXYZ(g,u.x,u.y,u.z),l.copy(u),(0===e&&0===c||0===t&&c===n)&&(l.x=Math.sin(M*s+o),l.z=Math.cos(M*s+o)),l.setY(Math.sqrt(l.x*l.x+l.z*l.z)*x).normalize(),E.setXYZ(g,l.x,l.y,l.z),m.setXY(g,M,1-b),H.push(g),g++}T.push(H)}for(a=0;a0&&c(!0),t>0&&c(!1)),this.setIndex(d),this.addAttribute("position",f),this.addAttribute("normal",E),this.addAttribute("uv",m)},THREE.CylinderBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.CylinderBufferGeometry.prototype.constructor=THREE.CylinderBufferGeometry,THREE.CylinderGeometry=function(e,t,r,i,n,a,o,s){THREE.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new THREE.CylinderBufferGeometry(e,t,r,i,n,a,o,s)),this.mergeVertices()},THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry,THREE.ConeBufferGeometry=function(e,t,r,i,n,a,o){THREE.CylinderBufferGeometry.call(this,0,e,t,r,i,n,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,thetaStart:a,thetaLength:o}},THREE.ConeBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.ConeBufferGeometry.prototype.constructor=THREE.ConeBufferGeometry,THREE.ConeGeometry=function(e,t,r,i,n,a,o){THREE.CylinderGeometry.call(this,0,e,t,r,i,n,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:a,thetaLength:o}},THREE.ConeGeometry.prototype=Object.create(THREE.CylinderGeometry.prototype),THREE.ConeGeometry.prototype.constructor=THREE.ConeGeometry,THREE.EdgesGeometry=function(e,t){function r(e,t){return e-t}THREE.BufferGeometry.call(this),t=void 0!==t?t:1;var i,n=Math.cos(THREE.Math.DEG2RAD*t),a=[0,0],o={},s=["a","b","c"];e instanceof THREE.BufferGeometry?(i=new THREE.Geometry).fromBufferGeometry(e):i=e.clone(),i.mergeVertices(),i.computeFaceNormals();for(var c=i.vertices,h=i.faces,l=0,u=h.length;lNumber.EPSILON){var p=Math.sqrt(l),d=Math.sqrt(c*c+h*h),f=t.x-s/p,E=t.y+o/p,m=((r.x-h/d-f)*h-(r.y+c/d-E)*c)/(o*h-s*c),g=(i=f+o*m-e.x)*i+(n=E+s*m-e.y)*n;if(g<=2)return new THREE.Vector2(i,n);a=Math.sqrt(g/2)}else{var v=!1;o>Number.EPSILON?c>Number.EPSILON&&(v=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(v=!0):Math.sign(s)===Math.sign(h)&&(v=!0),v?(i=-s,n=o,a=Math.sqrt(l)):(i=o,n=s,a=Math.sqrt(l/2))}return new THREE.Vector2(i/a,n/a)}function n(e,t){var r,i;for(z=e.length;--z>=0;){r=z,(i=z-1)<0&&(i=e.length-1);var n=0,a=v+2*E;for(n=0;n=0;B--){for(I=d*(1-(D=B/E)),U=f*Math.sin(D*Math.PI/2),z=0,k=P.length;z65535?Uint32Array:Uint16Array)(c),1),l=new THREE.BufferAttribute(new Float32Array(3*s),3),u=new THREE.BufferAttribute(new Float32Array(2*s),2),p=0,d=0,f=(e.length,1/t),E=new THREE.Vector3,m=new THREE.Vector2;for(a=0;a<=t;a++){var g=r+a*f*i,v=Math.sin(g),T=Math.cos(g);for(o=0;o<=e.length-1;o++)E.x=e[o].x*v,E.y=e[o].y,E.z=e[o].x*T,l.setXYZ(p,E.x,E.y,E.z),m.x=a/t,m.y=o/(e.length-1),u.setXY(p,m.x,m.y),p++}for(a=0;a65535?Uint32Array:Uint16Array)(o*s*6),g=0;g65535?Uint32Array:Uint16Array)(l),1),p=new THREE.BufferAttribute(new Float32Array(3*h),3),d=new THREE.BufferAttribute(new Float32Array(3*h),3),f=new THREE.BufferAttribute(new Float32Array(2*h),2),E=0,m=0,g=e,v=(t-e)/i,T=new THREE.Vector3,y=new THREE.Vector2;for(s=0;s<=i;s++){for(c=0;c<=r;c++)o=n+c/r*a,T.x=g*Math.cos(o),T.y=g*Math.sin(o),p.setXYZ(E,T.x,T.y,T.z),d.setXYZ(E,0,0,1),y.x=(T.x/t+1)/2,y.y=(T.y/t+1)/2,f.setXY(E,y.x,y.y),E++;g+=v}for(s=0;s0)&&H.push(b,_,w),(E!==r-1||s65535?THREE.Uint32Attribute:THREE.Uint16Attribute)(H,1)),this.addAttribute("position",h),this.addAttribute("normal",l),this.addAttribute("uv",u),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,e)},THREE.SphereBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.SphereBufferGeometry.prototype.constructor=THREE.SphereBufferGeometry,THREE.TextGeometry=function(e,t){var r=(t=t||{}).font;if(r instanceof THREE.Font==!1)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new THREE.Geometry;var i=r.generateShapes(e,t.size,t.curveSegments);t.amount=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),THREE.ExtrudeGeometry.call(this,i,t),this.type="TextGeometry"},THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype),THREE.TextGeometry.prototype.constructor=THREE.TextGeometry,THREE.TorusBufferGeometry=function(e,t,r,i,n){THREE.BufferGeometry.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},e=e||100,t=t||40,r=Math.floor(r)||8,i=Math.floor(i)||6,n=n||2*Math.PI;var a,o,s=(r+1)*(i+1),c=r*i*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,E=0,m=new THREE.Vector3,g=new THREE.Vector3,v=new THREE.Vector3;for(a=0;a<=r;a++)for(o=0;o<=i;o++){var T=o/i*n,y=a/r*Math.PI*2;g.x=(e+t*Math.cos(y))*Math.cos(T),g.y=(e+t*Math.cos(y))*Math.sin(T),g.z=t*Math.sin(y),l[d]=g.x,l[d+1]=g.y,l[d+2]=g.z,m.x=e*Math.cos(T),m.y=e*Math.sin(T),v.subVectors(g,m).normalize(),u[d]=v.x,u[d+1]=v.y,u[d+2]=v.z,p[f]=o/i,p[f+1]=a/r,d+=3,f+=2}for(a=1;a<=r;a++)for(o=1;o<=i;o++){var R=(i+1)*a+o-1,x=(i+1)*(a-1)+o-1,H=(i+1)*(a-1)+o,b=(i+1)*a+o;h[E]=R,h[E+1]=x,h[E+2]=b,h[E+3]=x,h[E+4]=H,h[E+5]=b,E+=6}this.setIndex(new THREE.BufferAttribute(h,1)),this.addAttribute("position",new THREE.BufferAttribute(l,3)),this.addAttribute("normal",new THREE.BufferAttribute(u,3)),this.addAttribute("uv",new THREE.BufferAttribute(p,2))},THREE.TorusBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.TorusBufferGeometry.prototype.constructor=THREE.TorusBufferGeometry,THREE.TorusGeometry=function(e,t,r,i,n){THREE.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},this.fromBufferGeometry(new THREE.TorusBufferGeometry(e,t,r,i,n))},THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry,THREE.TorusKnotBufferGeometry=function(e,t,r,i,n,a){function o(e,t,r,i,n){var a=Math.cos(e),o=Math.sin(e),s=r/t*e,c=Math.cos(s);n.x=i*(2+c)*.5*a,n.y=i*(2+c)*o*.5,n.z=i*Math.sin(s)*.5}THREE.BufferGeometry.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:i,p:n,q:a},e=e||100,t=t||40,r=Math.floor(r)||64,i=Math.floor(i)||8,n=n||2,a=a||3;var s,c,h=(i+1)*(r+1),l=i*r*2*3,u=new THREE.BufferAttribute(new(l>65535?Uint32Array:Uint16Array)(l),1),p=new THREE.BufferAttribute(new Float32Array(3*h),3),d=new THREE.BufferAttribute(new Float32Array(3*h),3),f=new THREE.BufferAttribute(new Float32Array(2*h),2),E=0,m=0,g=new THREE.Vector3,v=new THREE.Vector3,T=new THREE.Vector2,y=new THREE.Vector3,R=new THREE.Vector3,x=new THREE.Vector3,H=new THREE.Vector3,b=new THREE.Vector3;for(s=0;s<=r;++s){var _=s/r*n*Math.PI*2;for(o(_,n,a,e,y),o(_+.01,n,a,e,R),H.subVectors(R,y),b.addVectors(R,y),x.crossVectors(H,b),b.crossVectors(x,H),x.normalize(),b.normalize(),c=0;c<=i;++c){var M=c/i*Math.PI*2,w=-t*Math.cos(M),S=t*Math.sin(M);g.x=y.x+(w*b.x+S*x.x),g.y=y.y+(w*b.y+S*x.y),g.z=y.z+(w*b.z+S*x.z),p.setXYZ(E,g.x,g.y,g.z),v.subVectors(g,y).normalize(),d.setXYZ(E,v.x,v.y,v.z),T.x=s/r,T.y=c/i,f.setXY(E,T.x,T.y),E++}}for(c=1;c<=r;c++)for(s=1;s<=i;s++){var A=(i+1)*(c-1)+(s-1),L=(i+1)*c+(s-1),C=(i+1)*c+s,P=(i+1)*(c-1)+s;u.setX(m,A),m++,u.setX(m,L),m++,u.setX(m,P),m++,u.setX(m,L),m++,u.setX(m,C),m++,u.setX(m,P),m++}this.setIndex(u),this.addAttribute("position",p),this.addAttribute("normal",d),this.addAttribute("uv",f)},THREE.TorusKnotBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.TorusKnotBufferGeometry.prototype.constructor=THREE.TorusKnotBufferGeometry,THREE.TorusKnotGeometry=function(e,t,r,i,n,a,o){THREE.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:i,p:n,q:a},void 0!==o&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new THREE.TorusKnotBufferGeometry(e,t,r,i,n,a)),this.mergeVertices()},THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry,THREE.TubeGeometry=function(e,t,r,i,n,a){function o(e,t,r){return S.vertices.push(new THREE.Vector3(e,t,r))-1}THREE.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:e,segments:t,radius:r,radialSegments:i,closed:n,taper:a},t=t||64,r=r||1,i=i||8,n=n||!1,a=a||THREE.TubeGeometry.NoTaper;var s,c,h,l,u,p,d,f,E,m,g,v,T,y,R,x,H,b,_,M,w=[],S=this,A=t+1,L=new THREE.Vector3,C=new THREE.TubeGeometry.FrenetFrames(e,t,n),P=C.tangents,B=C.normals,U=C.binormals;for(this.tangents=P,this.normals=B,this.binormals=U,E=0;ENumber.EPSILON&&(f.normalize(),i=Math.acos(THREE.Math.clamp(u[c-1].dot(u[c]),-1,1)),p[c].applyMatrix4(E.makeRotationAxis(f,i))),d[c].crossVectors(u[c],p[c]);if(r)for(i=Math.acos(THREE.Math.clamp(p[0].dot(p[m-1]),-1,1)),i/=m-1,u[0].dot(f.crossVectors(p[0],p[m-1]))>0&&(i=-i),c=1;c.9&&H<.1&&(T<.2&&(v[0].x+=1),y<.2&&(v[1].x+=1),R<.2&&(v[2].x+=1))}for(var h=0,l=this.vertices.length;h.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(r.z,0,-r.x).normalize(),e=Math.acos(r.y),this.quaternion.setFromAxisAngle(t,e))}}(),THREE.ArrowHelper.prototype.setLength=function(e,t,r){void 0===t&&(t=.2*e),void 0===r&&(r=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()},THREE.ArrowHelper.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},THREE.BoxHelper=function(e,t){void 0===t&&(t=16776960);var r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),n=new THREE.BufferGeometry;n.setIndex(new THREE.BufferAttribute(r,1)),n.addAttribute("position",new THREE.BufferAttribute(i,3)),THREE.LineSegments.call(this,n,new THREE.LineBasicMaterial({color:t})),void 0!==e&&this.update(e)},THREE.BoxHelper.prototype=Object.create(THREE.LineSegments.prototype),THREE.BoxHelper.prototype.constructor=THREE.BoxHelper,THREE.BoxHelper.prototype.update=function(){var e=new THREE.Box3;return function(t){if(t instanceof THREE.Box3?e.copy(t):e.setFromObject(t),!e.isEmpty()){var r=e.min,i=e.max,n=this.geometry.attributes.position,a=n.array;a[0]=i.x,a[1]=i.y,a[2]=i.z,a[3]=r.x,a[4]=i.y,a[5]=i.z,a[6]=r.x,a[7]=r.y,a[8]=i.z,a[9]=i.x,a[10]=r.y,a[11]=i.z,a[12]=i.x,a[13]=i.y,a[14]=r.z,a[15]=r.x,a[16]=i.y,a[17]=r.z,a[18]=r.x,a[19]=r.y,a[20]=r.z,a[21]=i.x,a[22]=r.y,a[23]=r.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),THREE.BoundingBoxHelper=function(e,t){var r=void 0!==t?t:8947848;this.object=e,this.box=new THREE.Box3,THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:r,wireframe:!0}))},THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype),THREE.BoundingBoxHelper.prototype.constructor=THREE.BoundingBoxHelper,THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},THREE.CameraHelper=function(e){function t(e,t,i){r(e,i),r(t,i)}function r(e,t){i.vertices.push(new THREE.Vector3),i.colors.push(new THREE.Color(t)),void 0===a[e]&&(a[e]=[]),a[e].push(i.vertices.length-1)}var i=new THREE.Geometry,n=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),a={};t("n1","n2",16755200),t("n2","n4",16755200),t("n4","n3",16755200),t("n3","n1",16755200),t("f1","f2",16755200),t("f2","f4",16755200),t("f4","f3",16755200),t("f3","f1",16755200),t("n1","f1",16755200),t("n2","f2",16755200),t("n3","f3",16755200),t("n4","f4",16755200),t("p","n1",16711680),t("p","n2",16711680),t("p","n3",16711680),t("p","n4",16711680),t("u1","u2",43775),t("u2","u3",43775),t("u3","u1",43775),t("c","t",16777215),t("p","c",3355443),t("cn1","cn2",3355443),t("cn3","cn4",3355443),t("cf1","cf2",3355443),t("cf3","cf4",3355443),THREE.LineSegments.call(this,i,n),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()},THREE.CameraHelper.prototype=Object.create(THREE.LineSegments.prototype),THREE.CameraHelper.prototype.constructor=THREE.CameraHelper,THREE.CameraHelper.prototype.update=function(){function e(e,a,o,s){i.set(a,o,s).unproject(n);var c=r[e];if(void 0!==c)for(var h=0,l=c.length;h1){i[c=s[1]]||(i[c]={start:1/0,end:-1/0});a<(h=i[c]).start&&(h.start=a),a>h.end&&(h.end=a),t||(t=c)}}for(var c in i){var h=i[c];this.createAnimation(c,h.start,h.end,e)}this.firstAnimation=t},THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},THREE.MorphBlendMesh.prototype.setAnimationFPS=function(e,t){var r=this.animationsMap[e];r&&(r.fps=t,r.duration=(r.end-r.start)/r.fps)},THREE.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var r=this.animationsMap[e];r&&(r.duration=t,r.fps=(r.end-r.start)/r.duration)},THREE.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var r=this.animationsMap[e];r&&(r.weight=t)},THREE.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var r=this.animationsMap[e];r&&(r.time=t)},THREE.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0,r=this.animationsMap[e];return r&&(t=r.time),t},THREE.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1,r=this.animationsMap[e];return r&&(t=r.duration),t},THREE.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("THREE.MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},THREE.MorphBlendMesh.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},THREE.MorphBlendMesh.prototype.update=function(e){for(var t=0,r=this.animationsList.length;ti.duration||i.time<0)&&(i.direction*=-1,i.time>i.duration&&(i.time=i.duration,i.directionBackwards=!0),i.time<0&&(i.time=0,i.directionBackwards=!1)):(i.time=i.time%i.duration,i.time<0&&(i.time+=i.duration));var a=i.start+THREE.Math.clamp(Math.floor(i.time/n),0,i.length-1),o=i.weight;a!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*o,this.morphTargetInfluences[a]=0,i.lastFrame=i.currentFrame,i.currentFrame=a);var s=i.time%n/n;i.directionBackwards&&(s=1-s),i.currentFrame!==i.lastFrame?(this.morphTargetInfluences[i.currentFrame]=s*o,this.morphTargetInfluences[i.lastFrame]=(1-s)*o):this.morphTargetInfluences[i.currentFrame]=o}}};