// three.js (r79): https://github.com/mrdoob/three.js // Projector.js (r79, from three.js): https://github.com/mrdoob/three.js/tree/dev/examples/js/renderers // CanvasRenderer.js (r79, from three.js): https://github.com/mrdoob/three.js/tree/dev/examples/js/renderers // CSS3DRenderer.js (r79, from three.js): https://github.com/mrdoob/three.js/tree/dev/examples/js/renderers // Tween.js (v16.3.4): https://github.com/tweenjs/tween.js var THREE={REVISION:"79"};"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&&!function(){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=r[1],l=h.length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(e&&e.length>0){var h=THREE.ColorKeywords[e];void 0!==h?this.setHex(h):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,r=1e-6;return function(i,n){return void 0===e&&(e=new THREE.Vector3),t=i.dot(n)+1,tMath.abs(i.z)?e.set(-i.y,i.x,0):e.set(0,-i.z,i.y)):e.crossVectors(i,n),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,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=.01,o=.1,s=e.elements,c=s[0],h=s[4],l=s[8],u=s[1],p=s[5],d=s[9],f=s[2],E=s[6],m=s[10];if(Math.abs(h-u)v&&g>T?gT?vthis.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){var r=t||new THREE.Vector2;return r.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){var r=t||new THREE.Vector2;return r.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector2;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.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){var r=t||new THREE.Vector3;return r.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){var r=t||new THREE.Vector3;return r.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector3;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.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],M=i[1],_=i[5],w=i[9],S=i[13],L=i[2],A=i[6],C=i[10],P=i[14],B=i[3],I=i[7],D=i[11],U=i[15];return n[0]=a*R+o*M+s*L+c*B,n[4]=a*x+o*_+s*A+c*I,n[8]=a*H+o*w+s*C+c*D,n[12]=a*b+o*S+s*P+c*U,n[1]=h*R+l*M+u*L+p*B,n[5]=h*x+l*_+u*A+p*I,n[9]=h*H+l*w+u*C+p*D,n[13]=h*b+l*S+u*P+p*U,n[2]=d*R+f*M+E*L+m*B,n[6]=d*x+f*_+E*A+m*I,n[10]=d*H+f*w+E*C+m*D,n[14]=d*b+f*S+E*P+m*U,n[3]=g*R+v*M+T*L+y*B,n[7]=g*x+v*_+T*A+y*I,n[11]=g*H+v*w+T*C+y*D,n[15]=g*b+v*S+T*P+y*U,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;s*=g,c*=g,h=s*(s+p*c+2*d)+c*(p*s+c+2*f)+E}else c=u,s=Math.max(0,-(p*c+d)),h=-s*s+c*(c+2*f)+E;else c=-u,s=Math.max(0,-(p*c+d)),h=-s*s+c*(c+2*f)+E;else c<=-l?(s=Math.max(0,-(-p*u+d)),c=s>0?-u:Math.min(Math.max(-u,-f),u),h=-s*s+c*(c+2*f)+E):c<=l?(s=0,c=Math.min(Math.max(-u,-f),u),h=c*(c+2*f)+E):(s=Math.max(0,-(p*u+d)),c=s>0?u:Math.min(Math.max(-u,-f),u),h=-s*s+c*(c+2*f)+E);else c=p>0?-u:u,s=Math.max(0,-(p*c+d)),h=-s*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;var r=e.normal.dot(this.direction);return r*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++){var a=t[n].distanceToPoint(r);if(a0?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),i=t||new THREE.Vector3;return i.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){var t=e||new THREE.Vector3;return t.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(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,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*e*(3-2*e))},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*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++,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){var t=e||new THREE.Vector3;return t.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){var t=e||new THREE.Plane;return t.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),this.containsPoint(r)===!0)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 s=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)),t===!0)for(var r=0;r0)for(var 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)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);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 m=d[r];for(this.faces.splice(m,1),o=0,s=this.faceVertexUvs.length;o0,x=g.vertexNormals.length>0,H=1!==g.color.r||1!==g.color.g||1!==g.color.b,b=g.vertexColors.length>0,M=0;if(M=e(M,0,0),M=e(M,1,v),M=e(M,2,T),M=e(M,3,y),M=e(M,4,R),M=e(M,5,x),M=e(M,6,H),M=e(M,7,b),l.push(M),l.push(g.a,g.b,g.c),l.push(g.materialIndex),y){var _=this.faceVertexUvs[0][c];l.push(i(_[0]),i(_[1]),i(_[2]))}if(R&&l.push(t(g.normal)),x){var w=g.vertexNormals;l.push(t(w[0]),t(w[1]),t(w[2]))}if(H&&l.push(r(g.color)),b){var S=g.vertexColors;l.push(r(S[0]),r(S[1]),r(S[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(var h=0;h0){l=[];for(var h=0;h0){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=e.vertices.length>65535?Uint32Array:Uint16Array,s=new o(3*e.indices.length);this.setIndex(new THREE.BufferAttribute(s,1).copyIndicesArray(e.indices))}this.groups=e.groups;for(var c in e.morphTargets){for(var h=[],l=e.morphTargets[c],u=0,p=l.length;u0){var E=new THREE.Float32Attribute(4*e.skinIndices.length,4);this.addAttribute("skinIndex",E.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new THREE.Float32Attribute(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.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){var i=r.evaluate(e)[0];t*=i,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){n===-1&&(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(n===-1&&(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):(e?i.endingStart=this.zeroSlopeAtStart?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:i.endingStart=THREE.WrapAroundEnding,t?i.endingEnd=this.zeroSlopeAtEnd?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:i.endingEnd=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=this.tracks,t=0,r=0,i=e.length;r!==i;++r){var n=this.tracks[r];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var e=0;e1){var h=c[1],l=i[h];l||(i[h]=l=[]),l.push(s)}}var u=[];for(var h in i)u.push(THREE.AnimationClip.CreateFromMorphTargetSequence(h,i[h],t,r));return u},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],l=h.uuid,u=n[l];if(void 0!==u)if(delete n[l],ut;)--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],c=e[n+1];if(s!==c&&(1!==n||s!==s[0]))for(var h=n*r,l=h-r,u=h+r,p=0;p!==r;++p){var d=t[h+p];if(d!==t[l+p]||d!==t[u+p]){o=!0;break}}if(o){if(n!==i){e[i]=e[n];for(var f=n*r,E=i*r,p=0;p!==r;++p)t[E+p]=t[f+p]}++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)return void console.error(" trying to update node for track: "+this.path+" but it wasn't found.");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(var o=0;o=.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(this.isPlaying===!0)return void console.warn("THREE.Audio: Audio is already playing.");if(this.hasPlaybackControl===!1)return void console.warn("THREE.Audio: this Audio has no playback control.");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()},pause:function(){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this)},stop:function(){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=0,this.isPlaying=!1,this)},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[r+1]:0,s=t>2?e.skinWeights[r+2]:0,c=t>3?e.skinWeights[r+3]:0;o.skinWeights.push(new THREE.Vector4(n,a,s,c))}if(e.skinIndices)for(var r=0,i=e.skinIndices.length;r1?e.skinIndices[r+1]:0,u=t>2?e.skinIndices[r+2]:0,p=t>3?e.skinIndices[r+3]:0;o.skinIndices.push(new THREE.Vector4(h,l,u,p))}o.bones=e.bones,o.bones&&o.bones.length>0&&(o.skinWeights.length!==o.skinIndices.length||o.skinIndices.length!==o.vertices.length)&&console.warn("When skinning, number of vertices ("+o.vertices.length+"), skinIndices ("+o.skinIndices.length+"), and skinWeights ("+o.skinWeights.length+") should match.")}function n(t){if(void 0!==e.morphTargets)for(var r=0,i=e.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var l=o.faces,u=e.morphColors[0].colors,r=0,i=l.length;r0&&(o.animations=t)}var o=new THREE.Geometry,s=void 0!==e.scale?1/e.scale:1;if(r(s),i(),n(s),a(),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:o};var c=THREE.Loader.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:o,materials:c}}}),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++,n===!1&&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,a=new THREE.XHRLoader(n.manager);a.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){var n=new i[r.type](r.array);t.setIndex(new THREE.BufferAttribute(n,1))}var a=e.data.attributes;for(var o in a){var s=a[o],n=new i[s.type](s.array);t.addAttribute(o,new THREE.BufferAttribute(n,s.itemSize,s.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,a=new THREE.XHRLoader(n.manager);a.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.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;Array.isArray(r)===!1&&(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"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,s++,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),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(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")}if(void 0!==e.textures[this.uuid])return e.textures[this.uuid];var r={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;void 0===i.uuid&&(i.uuid=THREE.Math.generateUUID()),void 0===e.images[i.uuid]&&(e.images[i.uuid]={uuid:i.uuid,url:t(i)}),r.image=i.uuid}return e.textures[this.uuid]=r,r},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),i.ray.intersectsSphere(r)!==!1){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,E=f.position.array;if(null!==d)for(var m=d.array,g=0,v=m.length;go)){p.applyMatrix4(this.matrixWorld);var H=i.ray.origin.distanceTo(p);Hi.far||n.push({distance:H,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else for(var v=0,T=m.length/3-1;vo)){p.applyMatrix4(this.matrixWorld);var H=i.ray.origin.distanceTo(p);Hi.far||n.push({distance:H,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}else if(s instanceof THREE.Geometry)for(var b=s.vertices,M=b.length,v=0;vo)){p.applyMatrix4(this.matrixWorld);var H=i.ray.origin.distanceTo(p);Hi.far||n.push({distance:H,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),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:h,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),E.ray.intersectsSphere(a)!==!1&&(i.getInverse(y),n.copy(E.ray).applyMatrix4(i),null===v.boundingBox||n.intersectsBox(v.boundingBox)!==!1))){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!==_)for(var L=_.array,A=0,C=L.length;A0&&(R=N);for(var V=0,G=F.length;V1){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(;an||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){var l=a[c];if(void 0!==l){var u=_e.FLOAT,p=l.array,d=l.normalized;p instanceof Float32Array?u=_e.FLOAT:p instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):p instanceof Uint16Array?u=_e.UNSIGNED_SHORT:p instanceof Int16Array?u=_e.SHORT:p instanceof Uint32Array?u=_e.UNSIGNED_INT:p instanceof Int32Array?u=_e.INT:p instanceof Int8Array?u=_e.BYTE:p instanceof Uint8Array&&(u=_e.UNSIGNED_BYTE);var f=l.itemSize,E=Be.getAttributeBuffer(l);if(l instanceof THREE.InterleavedBufferAttribute){var m=l.data,g=m.stride,v=l.offset;m instanceof THREE.InstancedInterleavedBuffer?(Ae.enableAttributeAndDivisor(h,m.meshPerAttribute,n),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):Ae.enableAttribute(h),_e.bindBuffer(_e.ARRAY_BUFFER,E),_e.vertexAttribPointer(h,f,u,d,g*m.array.BYTES_PER_ELEMENT,(i*g+v)*m.array.BYTES_PER_ELEMENT)}else l instanceof THREE.InstancedBufferAttribute?(Ae.enableAttributeAndDivisor(h,l.meshPerAttribute,n),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):Ae.enableAttribute(h),_e.bindBuffer(_e.ARRAY_BUFFER,E),_e.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:_e.vertexAttrib2fv(h,T);break;case 3:_e.vertexAttrib3fv(h,T);break;case 4:_e.vertexAttrib4fv(h,T);break;default:_e.vertexAttrib1fv(h,T)}}}}Ae.disableUnusedAttributes()}function l(e,t){return Math.abs(t[0])-Math.abs(e[0])}function u(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.material.program&&t.material.program&&e.material.program!==t.material.program?e.material.program.id-t.material.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function p(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function d(e,t,r,i,n){var a,o;r.transparent?(a=q,o=++Y):(a=W,o=++X);var s=a[o];void 0!==s?(s.id=e.id,s.object=e,s.geometry=t,s.material=r,s.z=He.z,s.group=n):(s={id:e.id,object:e,geometry:t,material:r,z:He.z,group:n},a.push(s))}function f(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Re.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),m(Re)}function E(e){return Re.center.set(0,0,0),Re.radius=.7071067811865476,Re.applyMatrix4(e.matrixWorld),m(Re)}function m(e){if(!ge.intersectsSphere(e))return!1;var t=ve.numPlanes;if(0===t)return!0;var r=J.clippingPlanes,i=e.center,n=-e.radius,a=0;do if(r[a].distanceToPoint(i)=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)&&e.clipping!==!0||(i.numClippingPlanes=ve.numPlanes,d.clippingPlanes=ve.uniform),e.lights&&(i.lightsHash=be.hash,d.ambientLightColor.value=be.ambient,d.directionalLights.value=be.directional,d.spotLights.value=be.spot,d.pointLights.value=be.point,d.hemisphereLights.value=be.hemi,d.directionalShadowMap.value=be.directionalShadowMap,d.directionalShadowMatrix.value=be.directionalShadowMatrix,d.spotShadowMap.value=be.spotShadowMap,d.spotShadowMatrix.value=be.spotShadowMatrix,d.pointShadowMap.value=be.pointShadowMap,d.pointShadowMatrix.value=be.pointShadowMatrix);var f=i.program.getUniforms(),E=THREE.WebGLUniforms.seqWithValue(f.seq,d);i.uniformsList=E,i.dynamicUniforms=THREE.WebGLUniforms.splitDynamic(E,d)}function y(e){e.side!==THREE.DoubleSide?Ae.enable(_e.CULL_FACE):Ae.disable(_e.CULL_FACE),Ae.setFlipSided(e.side===THREE.BackSide),e.transparent===!0?Ae.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):Ae.setBlending(THREE.NoBlending),Ae.setDepthFunc(e.depthFunc),Ae.setDepthTest(e.depthTest),Ae.setDepthWrite(e.depthWrite),Ae.setColorWrite(e.colorWrite),Ae.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function R(e,t,r,i){ce=0;var n=Ce.get(r);if(Te){if(ye||e!==ne){var a=e===ne&&r.id===re;ve.setState(r.clippingPlanes,r.clipShadows,e,n,a)}void 0!==n.numClippingPlanes&&n.numClippingPlanes!==ve.numPlanes&&(r.needsUpdate=!0)}void 0===n.program&&(r.needsUpdate=!0),void 0!==n.lightsHash&&n.lightsHash!==be.hash&&(r.needsUpdate=!0),r.needsUpdate&&(T(r,t,i),r.needsUpdate=!1);var o=!1,s=!1,c=!1,h=n.program,l=h.getUniforms(),u=n.__webglShader.uniforms;if(h.id!==$&&(_e.useProgram(h.program),$=h.id,o=!0,s=!0,c=!0),r.id!==re&&(re=r.id,s=!0),o||e!==ne){if(l.set(_e,e,"projectionMatrix"),Le.logarithmicDepthBuffer&&l.setValue(_e,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==ne&&(ne=e,s=!0,c=!0),r instanceof THREE.ShaderMaterial||r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshStandardMaterial||r.envMap){var p=l.map.cameraPosition;void 0!==p&&p.setValue(_e,He.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)&&l.setValue(_e,"viewMatrix",e.matrixWorldInverse),l.set(_e,J,"toneMappingExposure"),l.set(_e,J,"toneMappingWhitePoint")}if(r.skinning){l.setOptional(_e,i,"bindMatrix"),l.setOptional(_e,i,"bindMatrixInverse");var d=i.skeleton;d&&(Le.floatVertexTextures&&d.useVertexTexture?(l.set(_e,d,"boneTexture"),l.set(_e,d,"boneTextureWidth"),l.set(_e,d,"boneTextureHeight")):l.setOptional(_e,d,"boneMatrices"))}s&&(r.lights&&C(u,c),t&&r.fog&&_(u,t),(r instanceof THREE.MeshBasicMaterial||r instanceof THREE.MeshLambertMaterial||r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshStandardMaterial||r instanceof THREE.MeshDepthMaterial)&&x(u,r),r instanceof THREE.LineBasicMaterial?H(u,r):r instanceof THREE.LineDashedMaterial?(H(u,r),b(u,r)):r instanceof THREE.PointsMaterial?M(u,r):r instanceof THREE.MeshLambertMaterial?w(u,r):r instanceof THREE.MeshPhongMaterial?S(u,r):r instanceof THREE.MeshPhysicalMaterial?A(u,r):r instanceof THREE.MeshStandardMaterial?L(u,r):r instanceof THREE.MeshDepthMaterial?r.displacementMap&&(u.displacementMap.value=r.displacementMap,u.displacementScale.value=r.displacementScale,u.displacementBias.value=r.displacementBias):r instanceof THREE.MeshNormalMaterial&&(u.opacity.value=r.opacity),THREE.WebGLUniforms.upload(_e,n.uniformsList,u,J)),l.set(_e,i,"modelViewMatrix"),l.set(_e,i,"normalMatrix"),l.setValue(_e,"modelMatrix",i.matrixWorld);var f=n.dynamicUniforms;return null!==f&&(THREE.WebGLUniforms.evalDynamic(f,u,i,e),THREE.WebGLUniforms.upload(_e,f,u,J)),h}function x(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;if(t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap),void 0!==r){r 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}function H(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function b(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function M(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*de,e.scale.value=.5*U.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)}}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)}function w(e,t){t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function S(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)}function L(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 A(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,L(e,t)}function C(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function P(e){for(var t=0,r=0,i=e.length;r=Le.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+Le.maxTextures),ce+=1,e}function D(e){var t;if(e===THREE.RepeatWrapping)return _e.REPEAT;if(e===THREE.ClampToEdgeWrapping)return _e.CLAMP_TO_EDGE;if(e===THREE.MirroredRepeatWrapping)return _e.MIRRORED_REPEAT;if(e===THREE.NearestFilter)return _e.NEAREST;if(e===THREE.NearestMipMapNearestFilter)return _e.NEAREST_MIPMAP_NEAREST;if(e===THREE.NearestMipMapLinearFilter)return _e.NEAREST_MIPMAP_LINEAR;if(e===THREE.LinearFilter)return _e.LINEAR;if(e===THREE.LinearMipMapNearestFilter)return _e.LINEAR_MIPMAP_NEAREST;if(e===THREE.LinearMipMapLinearFilter)return _e.LINEAR_MIPMAP_LINEAR;if(e===THREE.UnsignedByteType)return _e.UNSIGNED_BYTE;if(e===THREE.UnsignedShort4444Type)return _e.UNSIGNED_SHORT_4_4_4_4;if(e===THREE.UnsignedShort5551Type)return _e.UNSIGNED_SHORT_5_5_5_1;if(e===THREE.UnsignedShort565Type)return _e.UNSIGNED_SHORT_5_6_5;if(e===THREE.ByteType)return _e.BYTE;if(e===THREE.ShortType)return _e.SHORT;if(e===THREE.UnsignedShortType)return _e.UNSIGNED_SHORT;if(e===THREE.IntType)return _e.INT;if(e===THREE.UnsignedIntType)return _e.UNSIGNED_INT;if(e===THREE.FloatType)return _e.FLOAT;if(t=Se.get("OES_texture_half_float"),null!==t&&e===THREE.HalfFloatType)return t.HALF_FLOAT_OES;if(e===THREE.AlphaFormat)return _e.ALPHA;if(e===THREE.RGBFormat)return _e.RGB;if(e===THREE.RGBAFormat)return _e.RGBA;if(e===THREE.LuminanceFormat)return _e.LUMINANCE;if(e===THREE.LuminanceAlphaFormat)return _e.LUMINANCE_ALPHA;if(e===THREE.DepthFormat)return _e.DEPTH_COMPONENT;if(e===THREE.AddEquation)return _e.FUNC_ADD;if(e===THREE.SubtractEquation)return _e.FUNC_SUBTRACT;if(e===THREE.ReverseSubtractEquation)return _e.FUNC_REVERSE_SUBTRACT;if(e===THREE.ZeroFactor)return _e.ZERO;if(e===THREE.OneFactor)return _e.ONE;if(e===THREE.SrcColorFactor)return _e.SRC_COLOR;if(e===THREE.OneMinusSrcColorFactor)return _e.ONE_MINUS_SRC_COLOR;if(e===THREE.SrcAlphaFactor)return _e.SRC_ALPHA;if(e===THREE.OneMinusSrcAlphaFactor)return _e.ONE_MINUS_SRC_ALPHA;if(e===THREE.DstAlphaFactor)return _e.DST_ALPHA;if(e===THREE.OneMinusDstAlphaFactor)return _e.ONE_MINUS_DST_ALPHA;if(e===THREE.DstColorFactor)return _e.DST_COLOR;if(e===THREE.OneMinusDstColorFactor)return _e.ONE_MINUS_DST_COLOR;if(e===THREE.SrcAlphaSaturateFactor)return _e.SRC_ALPHA_SATURATE;if(t=Se.get("WEBGL_compressed_texture_s3tc"),null!==t){if(e===THREE.RGB_S3TC_DXT1_Format)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===THREE.RGBA_S3TC_DXT1_Format)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===THREE.RGBA_S3TC_DXT3_Format)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===THREE.RGBA_S3TC_DXT5_Format)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t=Se.get("WEBGL_compressed_texture_pvrtc"),null!==t){if(e===THREE.RGB_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===THREE.RGB_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===THREE.RGBA_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===THREE.RGBA_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t=Se.get("WEBGL_compressed_texture_etc1"),null!==t&&e===THREE.RGB_ETC1_Format)return t.COMPRESSED_RGB_ETC1_WEBGL;if(t=Se.get("EXT_blend_minmax"),null!==t){if(e===THREE.MinEquation)return t.MIN_EXT;if(e===THREE.MaxEquation)return t.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION),e=e||{};var U=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),O=void 0!==e.context?e.context:null,F=void 0!==e.alpha&&e.alpha,N=void 0===e.depth||e.depth,V=void 0===e.stencil||e.stencil,G=void 0!==e.antialias&&e.antialias,z=void 0===e.premultipliedAlpha||e.premultipliedAlpha,k=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,j=[],W=[],X=-1,q=[],Y=-1,Z=new Float32Array(8),K=[],Q=[];this.domElement=U,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=THREE.LinearToneMapping,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var J=this,$=null,ee=null,te=null,re=-1,ie="",ne=null,ae=new THREE.Vector4,oe=null,se=new THREE.Vector4,ce=0,he=new THREE.Color(0),le=0,ue=U.width,pe=U.height,de=1,fe=new THREE.Vector4(0,0,ue,pe),Ee=!1,me=new THREE.Vector4(0,0,ue,pe),ge=new THREE.Frustum,ve=new THREE.WebGLClipping,Te=!1,ye=!1,Re=new THREE.Sphere,xe=new THREE.Matrix4,He=new THREE.Vector3,be={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},Me={calls:0,vertices:0,faces:0,points:0};this.info={render:Me,memory:{geometries:0,textures:0},programs:null};var _e;try{var we={alpha:F,depth:N,stencil:V,antialias:G,premultipliedAlpha:z,preserveDrawingBuffer:k};if(_e=O||U.getContext("webgl",we)||U.getContext("experimental-webgl",we),null===_e)throw null!==U.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===_e.getShaderPrecisionFormat&&(_e.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),U.addEventListener("webglcontextlost",a,!1)}catch(e){console.error("THREE.WebGLRenderer: "+e)}var Se=new THREE.WebGLExtensions(_e);Se.get("WEBGL_depth_texture"),Se.get("OES_texture_float"),Se.get("OES_texture_float_linear"),Se.get("OES_texture_half_float"),Se.get("OES_texture_half_float_linear"),Se.get("OES_standard_derivatives"),Se.get("ANGLE_instanced_arrays"),Se.get("OES_element_index_uint")&&(THREE.BufferGeometry.MaxIndex=4294967296);var Le=new THREE.WebGLCapabilities(_e,Se,e),Ae=new THREE.WebGLState(_e,Se,D),Ce=new THREE.WebGLProperties,Pe=new THREE.WebGLTextures(_e,Se,Ae,Ce,Le,D,this.info),Be=new THREE.WebGLObjects(_e,Ce,this.info),Ie=new THREE.WebGLPrograms(this,Le),De=new THREE.WebGLLights;this.info.programs=Ie.programs;var Ue=new THREE.WebGLBufferRenderer(_e,Se,Me),Oe=new THREE.WebGLIndexedBufferRenderer(_e,Se,Me),Fe=new THREE.OrthographicCamera((-1),1,1,(-1),0,1),Ne=new THREE.PerspectiveCamera,Ve=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1})),Ge=THREE.ShaderLib.cube,ze=new THREE.Mesh(new THREE.BoxBufferGeometry(5,5,5),new THREE.ShaderMaterial({uniforms:Ge.uniforms,vertexShader:Ge.vertexShader,fragmentShader:Ge.fragmentShader,side:THREE.BackSide,depthTest:!1,depthWrite:!1,fog:!1}));i(),this.context=_e,this.capabilities=Le,this.extensions=Se,this.properties=Ce,this.state=Ae;var ke=new THREE.WebGLShadowMap(this,be,Be,Le);this.shadowMap=ke;var je=new THREE.SpritePlugin(this,K),We=new THREE.LensFlarePlugin(this,Q);this.getContext=function(){return _e},this.getContextAttributes=function(){return _e.getContextAttributes()},this.forceContextLoss=function(){Se.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return Le.getMaxAnisotropy()},this.getPrecision=function(){return Le.precision},this.getPixelRatio=function(){return de},this.setPixelRatio=function(e){void 0!==e&&(de=e,this.setSize(me.z,me.w,!1))},this.getSize=function(){return{width:ue,height:pe}},this.setSize=function(e,t,r){ue=e,pe=t,U.width=e*de,U.height=t*de,r!==!1&&(U.style.width=e+"px",U.style.height=t+"px"),this.setViewport(0,0,e,t)},this.setViewport=function(e,t,r,i){Ae.viewport(me.set(e,t,r,i))},this.setScissor=function(e,t,r,i){Ae.scissor(fe.set(e,t,r,i))},this.setScissorTest=function(e){Ae.setScissorTest(Ee=e)},this.getClearColor=function(){return he},this.setClearColor=function(e,t){he.set(e),le=void 0!==t?t:1,r(he.r,he.g,he.b,le)},this.getClearAlpha=function(){return le},this.setClearAlpha=function(e){le=e,r(he.r,he.g,he.b,le)},this.clear=function(e,t,r){var i=0;(void 0===e||e)&&(i|=_e.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=_e.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=_e.STENCIL_BUFFER_BIT),_e.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,r,i){this.setRenderTarget(e),this.clear(t,r,i)},this.resetGLState=n,this.dispose=function(){q=[],Y=-1,W=[],X=-1,U.removeEventListener("webglcontextlost",a,!1)},this.renderBufferImmediate=function(e,t,r){Ae.initAttributes();var i=Ce.get(e);e.hasPositions&&!i.position&&(i.position=_e.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=_e.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=_e.createBuffer()),e.hasColors&&!i.color&&(i.color=_e.createBuffer());var n=t.getAttributes();if(e.hasPositions&&(_e.bindBuffer(_e.ARRAY_BUFFER,i.position),_e.bufferData(_e.ARRAY_BUFFER,e.positionArray,_e.DYNAMIC_DRAW),Ae.enableAttribute(n.position),_e.vertexAttribPointer(n.position,3,_e.FLOAT,!1,0,0)),e.hasNormals){if(_e.bindBuffer(_e.ARRAY_BUFFER,i.normal),"MeshPhongMaterial"!==r.type&&"MeshStandardMaterial"!==r.type&&"MeshPhysicalMaterial"!==r.type&&r.shading===THREE.FlatShading)for(var a=0,o=3*e.count;a8&&(d.length=8);for(var g=i.morphAttributes,f=0,E=d.length;f0&&x.renderInstances(i,L,C):x.render(L,C)},this.render=function(e,t,i,n){if(t instanceof THREE.Camera==!1)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");var a=e.fog;ie="",re=-1,ne=null,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),xe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ge.setFromMatrix(xe),j.length=0,X=-1,Y=-1,K.length=0,Q.length=0,ye=this.localClippingEnabled,Te=ve.init(this.clippingPlanes,ye,t),g(e,t),W.length=X+1,q.length=Y+1,J.sortObjects===!0&&(W.sort(u),q.sort(p)),Te&&ve.beginShadows(),P(j),ke.render(e,t),B(j,t),Te&&ve.endShadows(),Me.calls=0,Me.vertices=0,Me.faces=0,Me.points=0,void 0===i&&(i=null),this.setRenderTarget(i);var o=e.background;if(null===o?r(he.r,he.g,he.b,le):o instanceof THREE.Color&&r(o.r,o.g,o.b,1),(this.autoClear||n)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),o instanceof THREE.CubeTexture?(Ne.projectionMatrix.copy(t.projectionMatrix),Ne.matrixWorld.extractRotation(t.matrixWorld),Ne.matrixWorldInverse.getInverse(Ne.matrixWorld),ze.material.uniforms.tCube.value=o,ze.modelViewMatrix.multiplyMatrices(Ne.matrixWorldInverse,ze.matrixWorld),Be.update(ze),J.renderBufferDirect(Ne,null,ze.geometry,ze.material,ze,null)):o instanceof THREE.Texture&&(Ve.material.map=o,Be.update(Ve),J.renderBufferDirect(Fe,null,Ve.geometry,Ve.material,Ve,null)),e.overrideMaterial){var s=e.overrideMaterial;v(W,t,a,s),v(q,t,a,s)}else Ae.setBlending(THREE.NoBlending),v(W,t,a),v(q,t,a);je.render(e,t),We.render(e,t,se),i&&Pe.updateRenderTargetMipmap(i),Ae.setDepthTest(!0),Ae.setDepthWrite(!0),Ae.setColorWrite(!0)},this.setFaceCulling=function(e,t){Ae.setCullFace(e),Ae.setFlipSided(t===THREE.FrontFaceDirectionCW)},this.allocTextureUnit=I,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),Pe.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),Pe.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?Pe.setTextureCube(t,r):Pe.setTextureCubeDynamic(t,r)}}(),this.getCurrentRenderTarget=function(){return ee},this.setRenderTarget=function(e){ee=e,e&&void 0===Ce.get(e).__webglFramebuffer&&Pe.setupRenderTarget(e);var t,r=e instanceof THREE.WebGLRenderTargetCube;if(e){var i=Ce.get(e);t=r?i.__webglFramebuffer[e.activeCubeFace]:i.__webglFramebuffer,ae.copy(e.scissor),oe=e.scissorTest,se.copy(e.viewport)}else t=null,ae.copy(fe).multiplyScalar(de),oe=Ee,se.copy(me).multiplyScalar(de);if(te!==t&&(_e.bindFramebuffer(_e.FRAMEBUFFER,t),te=t),Ae.scissor(ae),Ae.setScissorTest(oe),Ae.viewport(se),r){var n=Ce.get(e.texture);_e.framebufferTexture2D(_e.FRAMEBUFFER,_e.COLOR_ATTACHMENT0,_e.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)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var o=Ce.get(e).__webglFramebuffer;if(o){var s=!1;o!==te&&(_e.bindFramebuffer(_e.FRAMEBUFFER,o),s=!0);try{var c=e.texture;if(c.format!==THREE.RGBAFormat&&D(c.format)!==_e.getParameter(_e.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||D(c.type)===_e.getParameter(_e.IMPLEMENTATION_COLOR_READ_TYPE)||c.type===THREE.FloatType&&Se.get("WEBGL_color_buffer_float")||c.type===THREE.HalfFloatType&&Se.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");_e.checkFramebufferStatus(_e.FRAMEBUFFER)===_e.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&r>=0&&r<=e.height-n&&_e.readPixels(t,r,i,n,D(c.format),D(c.type),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&_e.bindFramebuffer(_e.FRAMEBUFFER,te)}}}},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),r=r||{},void 0===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){function i(e){o=e}function n(t,i){e.drawArrays(o,t,i),r.calls++,r.vertices+=i,o===e.TRIANGLES&&(r.faces+=i/3)}function a(i){var n=t.get("ANGLE_instanced_arrays");if(null===n)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");var a=i.attributes.position,s=0;a instanceof THREE.InterleavedBufferAttribute?(s=a.data.count,n.drawArraysInstancedANGLE(o,0,s,i.maxInstancedCount)):(s=a.count,n.drawArraysInstancedANGLE(o,0,s,i.maxInstancedCount)),r.calls++,r.vertices+=s*i.maxInstancedCount,o===e.TRIANGLES&&(r.faces+=i.maxInstancedCount*s/3)}var o;this.setMode=i,this.render=n,this.renderInstances=a},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,n!==!0||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 a;this.getMaxAnisotropy=i,this.getMaxPrecision=n,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 o=n(this.precision);o!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",o,"instead."),this.precision=o),this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!t.get("EXT_frag_depth"))},THREE.WebGLGeometries=function(e,t,r){function i(e){var t=e.geometry;if(void 0!==h[t.id])return h[t.id];t.addEventListener("dispose",n);var i;return t instanceof THREE.BufferGeometry?i=t:t instanceof THREE.Geometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new THREE.BufferGeometry).setFromObject(e)),i=t._bufferGeometry),h[t.id]=i,r.memory.geometries++,i}function n(e){var i=e.target,a=h[i.id];null!==a.index&&o(a.index),s(a.attributes),i.removeEventListener("dispose",n),delete h[i.id];var c=t.get(i);c.wireframe&&o(c.wireframe),t.delete(i);var l=t.get(a);l.wireframe&&o(l.wireframe),t.delete(a),r.memory.geometries--}function a(e){return e instanceof THREE.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}function o(t){var r=a(t);void 0!==r&&(e.deleteBuffer(r),c(t))}function s(e){for(var t in e)o(e[t])}function c(e){e instanceof THREE.InterleavedBufferAttribute?t.delete(e.data):t.delete(e)}var h={};this.get=i},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(t){var r=l.get(t);t.geometry instanceof THREE.Geometry&&r.updateFromObject(t);var i=r.index,a=r.attributes;null!==i&&n(i,e.ELEMENT_ARRAY_BUFFER);for(var o in a)n(a[o],e.ARRAY_BUFFER);var s=r.morphAttributes;for(var o in s)for(var c=s[o],h=0,u=c.length;h65535?Uint32Array:Uint16Array,v=new THREE.BufferAttribute(new g(a),1);return n(v,e.ELEMENT_ARRAY_BUFFER),i.wireframe=v,v}function h(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):n.indexOf(r)===-1&&(n.push(r),!0)}var l=new THREE.WebGLGeometries(e,t,r);this.getAttributeBuffer=s,this.getWireframeAttribute=c,this.update=i},THREE.WebGLProgram=function(){function e(e){switch(e){case THREE.LinearEncoding:return["Linear","( value )"];case THREE.sRGBEncoding:return["sRGB","( value )"];case THREE.RGBEEncoding:return["RGBE","( value )"];case THREE.RGBM7Encoding:return["RGBM","( value, 7.0 )"];case THREE.RGBM16Encoding:return["RGBM","( value, 16.0 )"];case THREE.RGBDEncoding:return["RGBD","( value, 256.0 )"];case THREE.GammaEncoding:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}}function t(t,r){var i=e(r);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function r(t,r){var i=e(r);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function i(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 ); }"}function n(e,t,r){e=e||{};var i=[e.derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""];return i.filter(s).join("\n")}function a(e){var t=[];for(var r in e){var i=e[r];i!==!1&&t.push("#define "+r+" "+i)}return t.join("\n")}function o(e,t,r){for(var i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a");return h(r)}var r=/#include +<([\w\d.]+)>/g;return e.replace(r,t)}function l(e){function t(e,t,r,i){for(var n="",a=parseInt(t);a0?e.gammaFactor:1,w=n(m,f,e.extensions),S=a(g),L=E.createProgram();d instanceof THREE.RawShaderMaterial?(b=[S].filter(s).join("\n"),M=[S].filter(s).join("\n")):(b=["precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+d.__webglShader.name,S,f.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+f.maxBones,f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+x:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.displacementMap&&f.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.flatShading?"#define FLAT_SHADED":"",f.skinning?"#define USE_SKINNING":"",f.useVertexTexture?"#define BONE_TEXTURE":"",f.morphTargets?"#define USE_MORPHTARGETS":"",f.morphNormals&&f.flatShading===!1?"#define USE_MORPHNORMALS":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+f.numClippingPlanes,f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+y:"",f.sizeAttenuation?"#define USE_SIZEATTENUATION":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&e.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(s).join("\n"),M=[w,"precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+d.__webglShader.name,S,f.alphaTest?"#define ALPHATEST "+f.alphaTest:"","#define GAMMA_FACTOR "+_,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+R:"",f.envMap?"#define "+x:"",f.envMap?"#define "+H:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.flatShading?"#define FLAT_SHADED":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+f.numClippingPlanes,f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+y:"",f.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",f.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",f.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",f.toneMapping!==THREE.NoToneMapping?"#define TONE_MAPPING":"",f.toneMapping!==THREE.NoToneMapping?THREE.ShaderChunk.tonemapping_pars_fragment:"",f.toneMapping!==THREE.NoToneMapping?i("toneMapping",f.toneMapping):"",f.outputEncoding||f.mapEncoding||f.envMapEncoding||f.emissiveMapEncoding?THREE.ShaderChunk.encodings_pars_fragment:"",f.mapEncoding?t("mapTexelToLinear",f.mapEncoding):"",f.envMapEncoding?t("envMapTexelToLinear",f.envMapEncoding):"",f.emissiveMapEncoding?t("emissiveMapTexelToLinear",f.emissiveMapEncoding):"",f.outputEncoding?r("linearToOutputTexel",f.outputEncoding):"",f.depthPacking?"#define DEPTH_PACKING "+d.depthPacking:"","\n"].filter(s).join("\n")),v=h(v,f),v=c(v,f),T=h(T,f),T=c(T,f),d instanceof THREE.ShaderMaterial==!1&&(v=l(v),T=l(T));var A=b+v,C=M+T,P=THREE.WebGLShader(E,E.VERTEX_SHADER,A),B=THREE.WebGLShader(E,E.FRAGMENT_SHADER,C);E.attachShader(L,P),E.attachShader(L,B),void 0!==d.index0AttributeName?E.bindAttribLocation(L,0,d.index0AttributeName):f.morphTargets===!0&&E.bindAttribLocation(L,0,"position"),E.linkProgram(L);var I=E.getProgramInfoLog(L),D=E.getShaderInfoLog(P),U=E.getShaderInfoLog(B),O=!0,F=!0;E.getProgramParameter(L,E.LINK_STATUS)===!1?(O=!1,console.error("THREE.WebGLProgram: shader error: ",E.getError(),"gl.VALIDATE_STATUS",E.getProgramParameter(L,E.VALIDATE_STATUS),"gl.getProgramInfoLog",I,D,U)):""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==D&&""!==U||(F=!1),F&&(this.diagnostics={runnable:O,material:d,programLog:I,vertexShader:{log:D,prefix:b},fragmentShader:{log:U,prefix:M}}),E.deleteShader(P),E.deleteShader(B);var N;this.getUniforms=function(){return void 0===N&&(N=new THREE.WebGLUniforms(E,L,e)),N};var V;return this.getAttributes=function(){return void 0===V&&(V=o(E,L)),V},this.destroy=function(){E.deleteProgram(L),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=u++,this.code=p,this.usedTimes=1,this.program=L,this.vertexShader=P,this.fragmentShader=B,this}}(),THREE.WebGLPrograms=function(e,t){function r(e){if(t.floatVertexTextures&&e&&e.skeleton&&e.skeleton.useVertexTexture)return 1024;var r=t.maxVertexUniforms,i=Math.floor((r-20)/4),n=i;return void 0!==e&&e instanceof THREE.SkinnedMesh&&(n=Math.min(e.skeleton.bones.length,n),n0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===THREE.DoubleSide,flipSided:n.side===THREE.BackSide,depthPacking:void 0!==n.depthPacking&&n.depthPacking};return f},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&&r.clipShadows===!0&&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(e.visible!==!1){if(e.layers.test(t.layers)&&(e instanceof THREE.Mesh||e instanceof THREE.Line||e instanceof THREE.Points)&&e.castShadow&&(e.frustumCulled===!1||c.intersectsObject(e)===!0)){var i=e.material;i.visible===!0&&(e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),E.push(e))}for(var n=e.children,o=0,s=n.length;ot||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);var n=i.getContext("2d");return n.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(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");t.width=THREE.Math.nearestPowerOfTwo(e.width),t.height=THREE.Math.nearestPowerOfTwo(e.height);var r=t.getContext("2d");return r.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}function l(e){return e.wrapS!==THREE.ClampToEdgeWrapping||e.wrapT!==THREE.ClampToEdgeWrapping||e.minFilter!==THREE.NearestFilter&&e.minFilter!==THREE.LinearFilter}function u(t){return t===THREE.NearestFilter||t===THREE.NearestMipMapNearestFilter||t===THREE.NearestMipMapLinearFilter?e.NEAREST:e.LINEAR}function p(e){var t=e.target;t.removeEventListener("dispose",p),f(t),w.textures--}function d(e){var t=e.target;t.removeEventListener("dispose",d),E(t),w.textures--}function f(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)}function E(t){var r=i.get(t),n=i.get(t.texture);if(t){if(void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),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)}}function m(t,n){var a=i.get(t);if(t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(o.complete!==!1)return void y(a,t,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function g(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",p),h.__image__webglTextureCube=e.createTexture(),w.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 l=t instanceof THREE.CompressedTexture,u=t.image[0]instanceof THREE.DataTexture,d=[],f=0;f<6;f++)l||u?d[f]=u?t.image[f].image:t.image[f]:d[f]=s(t.image[f],n.maxCubemapSize);var E=d[0],m=c(E),g=a(t.format),v=a(t.type);T(e.TEXTURE_CUBE_MAP,t,m);for(var f=0;f<6;f++)if(l)for(var y,R=d[f].mipmaps,x=0,H=R.length;x-1?r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+f,x,g,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+f,x,g,y.width,y.height,0,g,v,y.data);else u?r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,g,d[f].width,d[f].height,0,g,v,d[f].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,g,g,v,d[f]);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)}function v(t,n){r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)}function T(r,o,s){var c;if(s?(e.texParameteri(r,e.TEXTURE_WRAP_S,a(o.wrapS)),e.texParameteri(r,e.TEXTURE_WRAP_T,a(o.wrapT)),e.texParameteri(r,e.TEXTURE_MAG_FILTER,a(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a(o.minFilter))):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),o.wrapS===THREE.ClampToEdgeWrapping&&o.wrapT===THREE.ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",o),e.texParameteri(r,e.TEXTURE_MAG_FILTER,u(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,u(o.minFilter)),o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",o)),c=t.get("EXT_texture_filter_anisotropic")){if(o.type===THREE.FloatType&&null===t.get("OES_texture_float_linear"))return;if(o.type===THREE.HalfFloatType&&null===t.get("OES_texture_half_float_linear"))return;(o.anisotropy>1||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 y(t,i,o){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",p),t.__webglTexture=e.createTexture(),w.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 u=s(i.image,n.maxTextureSize);l(i)&&c(u)===!1&&(u=h(u));var d=c(u),f=a(i.format),E=a(i.type);T(e.TEXTURE_2D,i,d);var m,g=i.mipmaps;if(i instanceof THREE.DepthTexture){var v=e.DEPTH_COMPONENT;if(i.type===THREE.FloatType){if(!S)throw new Error("Float Depth Texture only supported in WebGL2.0");v=e.DEPTH_COMPONENT32F}else S&&(v=e.DEPTH_COMPONENT16);r.texImage2D(e.TEXTURE_2D,0,v,u.width,u.height,0,f,E,null)}else if(i instanceof THREE.DataTexture)if(g.length>0&&d){for(var y=0,R=g.length;y-1?r.compressedTexImage2D(e.TEXTURE_2D,y,f,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(e.TEXTURE_2D,y,f,m.width,m.height,0,f,E,m.data);else if(g.length>0&&d){for(var y=0,R=g.length;y0)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){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}},R=function(e,t){e.uniform1fv(this.addr,t)},x=function(e,t){e.uniform1iv(this.addr,t)},H=function(e,t){e.uniform2fv(this.addr,a(t,this.size,2))},b=function(e,t){e.uniform3fv(this.addr,a(t,this.size,3))},M=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))},w=function(e,t){e.uniformMatrix3fv(this.addr,!1,a(t,this.size,9))},S=function(e,t){e.uniformMatrix4fv(this.addr,!1,a(t,this.size,16))},L=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])},C=function(e){switch(e){case 5126:return R;case 35664:return H;case 35665:return b;case 35666:return M;case 35674:return _;case 35675:return w;case 35676:return S;case 35678:return L;case 35680:return A;case 5124:case 35670:return x;case 35667:case 35671:return g;case 35668:case 35672:return v;case 35669:case 35673:return T}},P=function(e,t,r){this.id=e,this.addr=r,this.setValue=y(t.type)},B=function(e,t,r){this.id=e,this.addr=r,this.size=t.size,this.setValue=C(t.type)},I=function(e){this.id=e,r.call(this)};I.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 D=/([\w\d_]+)(\])?(\[|\.)?/g,U=function(e,t){e.seq.push(t),e.map[t.id]=t},O=function(e,t,r){var i=e.name,n=i.length;for(D.lastIndex=0;;){var a=D.exec(i),o=D.lastIndex,s=a[1],c="]"===a[2],h=a[3];if(c&&(s=0|s),void 0===h||"["===h&&o+2===n){U(r,void 0===h?new P(s,e,t):new B(s,e,t));break}var l=r.map,u=l[s];void 0===u&&(u=new I(s),U(r,u)),r=u}},F=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);O(o,c,this)}};return F.prototype.setValue=function(e,t,r){var i=this.map[t];void 0!==i&&i.setValue(e,r,this.renderer)},F.prototype.set=function(e,t,r){var i=this.map[r];void 0!==i&&i.setValue(e,t[r],this.renderer)},F.prototype.setOptional=function(e,t,r){var i=t[r];void 0!==i&&this.setValue(e,r,i)},F.upload=function(e,t,r,i){for(var n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o.id];s.needsUpdate!==!1&&o.setValue(e,s.value,i)}},F.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},F.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&&s.dynamic===!0?(null===r&&(r=[]),r.push(o)):(n.001&&L.scale>.001&&(R.x=L.x,R.y=L.y,R.z=L.z,T=L.size*L.scale/f.w,y.x=T*m,y.y=T,p.uniform3f(h.screenPosition,R.x,R.y,R.z),p.uniform2f(h.scale,y.x,y.y),p.uniform1f(h.rotation,L.rotation),p.uniform1f(h.opacity,L.opacity),p.uniform3f(h.color,L.color.r,L.color.g,L.color.b),d.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst),e.setTexture2D(L.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}}d.enable(p.CULL_FACE),d.enable(p.DEPTH_TEST),d.setDepthWrite(!0),e.resetGLState()}}},THREE.SpritePlugin=function(e,t){function r(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),t=new Uint16Array([0,1,2,0,2,3]);a=u.createBuffer(),o=u.createBuffer(),u.bindBuffer(u.ARRAY_BUFFER,a),u.bufferData(u.ARRAY_BUFFER,e,u.STATIC_DRAW),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,o),u.bufferData(u.ELEMENT_ARRAY_BUFFER,t,u.STATIC_DRAW),s=i(),c={position:u.getAttribLocation(s,"position"),uv:u.getAttribLocation(s,"uv")},h={uvOffset:u.getUniformLocation(s,"uvOffset"),uvScale:u.getUniformLocation(s,"uvScale"),rotation:u.getUniformLocation(s,"rotation"),scale:u.getUniformLocation(s,"scale"),color:u.getUniformLocation(s,"color"),map:u.getUniformLocation(s,"map"),opacity:u.getUniformLocation(s,"opacity"),modelViewMatrix:u.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:u.getUniformLocation(s,"projectionMatrix"),fogType:u.getUniformLocation(s,"fogType"),fogDensity:u.getUniformLocation(s,"fogDensity"),fogNear:u.getUniformLocation(s,"fogNear"),fogFar:u.getUniformLocation(s,"fogFar"),fogColor:u.getUniformLocation(s,"fogColor"),alphaTest:u.getUniformLocation(s,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var n=r.getContext("2d");n.fillStyle="white",n.fillRect(0,0,8,8),l=new THREE.Texture(r),l.needsUpdate=!0}function i(){var t=u.createProgram(),r=u.createShader(u.VERTEX_SHADER),i=u.createShader(u.FRAGMENT_SHADER);return u.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")),u.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")),u.compileShader(r),u.compileShader(i),u.attachShader(t,r),u.attachShader(t,i),u.linkProgram(t),t}function n(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var a,o,s,c,h,l,u=e.context,p=e.state,d=new THREE.Vector3,f=new THREE.Quaternion,E=new THREE.Vector3;this.render=function(i,m){if(0!==t.length){void 0===s&&r(),u.useProgram(s),p.initAttributes(),p.enableAttribute(c.position),p.enableAttribute(c.uv),p.disableUnusedAttributes(),p.disable(u.CULL_FACE),p.enable(u.BLEND),u.bindBuffer(u.ARRAY_BUFFER,a),u.vertexAttribPointer(c.position,2,u.FLOAT,!1,16,0),u.vertexAttribPointer(c.uv,2,u.FLOAT,!1,16,8),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,o),u.uniformMatrix4fv(h.projectionMatrix,!1,m.projectionMatrix.elements),p.activeTexture(u.TEXTURE0),u.uniform1i(h.map,0);var g=0,v=0,T=i.fog;T?(u.uniform3f(h.fogColor,T.color.r,T.color.g,T.color.b),T instanceof THREE.Fog?(u.uniform1f(h.fogNear,T.near),u.uniform1f(h.fogFar,T.far),u.uniform1i(h.fogType,1),g=1,v=1):T instanceof THREE.FogExp2&&(u.uniform1f(h.fogDensity,T.density),u.uniform1i(h.fogType,2),g=2,v=2)):(u.uniform1i(h.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,L;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,f<0||f>p)return[]}else{if(d>0||d0||fM?[]:y===M?a?[]:[v]:R<=M?[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}function o(e,t){function r(e,t){var r=v.length-1,i=e-1;i<0&&(i=r);var n=e+1;n>r&&(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]),!!o}function i(e,t){var r,i,a;for(r=0;r0)return!0;return!1}function o(e,r){var i,a,o,s,c;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--,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}r(e),t.forEach(r);for(var s,c,h,l,u,p,d={},f=e.concat(),E=0,m=t.length;E0)){c=n;break}c=n-1}if(n=c,i[n]===r){var h=n/(a-1);return h}var l=i[n],u=i[n+1],p=u-l,d=(r-l)/p,h=(n+d)/(a-1);return h},getTangent:function(e){var t=1e-4,r=e-t,i=e+t;r<0&&(r=0),i>1&&(i=1);var n=this.getPoint(r),a=this.getPoint(i),o=a.clone().sub(n); return o.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(t===!0)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,c<2&&console.log("duh, you need at least 2 points"),a=(c-(this.closed?0:1))*e,o=Math.floor(a),s=a-o,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,f[m]=A.x,f[m+1]=A.y,f[m+2]=A.z,E[g]=B/c,E[g+1]=1-C/l,m+=3,g+=2,S+=1}for(C=0;C65535?Uint32Array:Uint16Array)(u),d=new Float32Array(3*l),f=new Float32Array(3*l),E=new Float32Array(2*l),m=0,g=0,v=0,T=0,y=0;c("z","y","x",-1,-1,r,t,e,a,n,0),c("z","y","x",1,-1,r,t,-e,a,n,1),c("x","z","y",1,1,e,r,t,i,a,2),c("x","z","y",1,-1,e,r,-t,i,a,3),c("x","y","z",1,-1,e,t,r,i,n,4),c("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(new THREE.BufferAttribute(p,1)),this.addAttribute("position",new THREE.BufferAttribute(d,3)),this.addAttribute("normal",new THREE.BufferAttribute(f,3)),this.addAttribute("uv",new THREE.BufferAttribute(E,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(){var e=(i+1)*(n+1);return a===!1&&(e+=(i+1)*d+i*d),e}function h(){var e=i*n*2*3;return a===!1&&(e+=i*d*3),e}function l(){var a,c,h=new THREE.Vector3,l=new THREE.Vector3,u=0,d=(t-e)/r;for(c=0;c<=n;c++){var f=[],E=c/n,M=E*(t-e)+e;for(a=0;a<=i;a++){var _=a/i;l.x=M*Math.sin(_*s+o),l.y=-E*r+H,l.z=M*Math.cos(_*s+o),g.setXYZ(y,l.x,l.y,l.z),h.copy(l),(0===e&&0===c||0===t&&c===n)&&(h.x=Math.sin(_*s+o),h.z=Math.cos(_*s+o)),h.setY(Math.sqrt(h.x*h.x+h.z*h.z)*d).normalize(),v.setXYZ(y,h.x,h.y,h.z),T.setXY(y,_,1-E),f.push(y),y++}x.push(f)}for(a=0;a0&&d++,t>0&&d++);var f=c(),E=h(),m=new THREE.BufferAttribute(new(E>65535?Uint32Array:Uint16Array)(E),1),g=new THREE.BufferAttribute(new Float32Array(3*f),3),v=new THREE.BufferAttribute(new Float32Array(3*f),3),T=new THREE.BufferAttribute(new Float32Array(2*f),2),y=0,R=0,x=[],H=r/2,b=0;l(),a===!1&&(e>0&&u(!0),t>0&&u(!1)),this.setIndex(m),this.addAttribute("position",g),this.addAttribute("normal",v),this.addAttribute("uv",T)},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,i.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,g=r.y+c/d,v=((m-f)*h-(g-E)*c)/(o*h-s*c);i=f+o*v-e.x,n=E+s*v-e.y;var T=i*i+n*n;if(T<=2)return new THREE.Vector2(i,n);a=Math.sqrt(T/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(h)&&(y=!0),y?(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(){if(T){var e=0,t=z*e;for(W=0;W=0;){r=W,i=W-1,i<0&&(i=e.length-1);var n=0,a=R+2*v;for(n=0;n=0;U--){for(F=U/v,N=m*(1-F),O=g*Math.sin(F*Math.PI/2),W=0,X=D.length;W65535?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=(1/(e.length-1),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,M,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){t=t||{};var r=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 M=s/r*n*Math.PI*2;for(o(M,n,a,e,y),o(M+.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 _=c/i*Math.PI*2,w=-t*Math.cos(_),S=t*Math.sin(_);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 L=(i+1)*(c-1)+(s-1),A=(i+1)*c+(s-1),C=(i+1)*c+s,P=(i+1)*(c-1)+s;u.setX(m,L),m++,u.setX(m,A),m++,u.setX(m,P),m++,u.setX(m,A),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 L.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=[],L=this,A=t+1,C=new THREE.Vector3,P=new THREE.TubeGeometry.FrenetFrames(e,t,n),B=P.tangents,I=P.normals,D=P.binormals;for(this.tangents=B,this.normals=I,this.binormals=D,m=0;mNumber.EPSILON&&(E.normalize(),n=Math.acos(THREE.Math.clamp(p[h-1].dot(p[h]),-1,1)),d[h].applyMatrix4(m.makeRotationAxis(E,n))),f[h].crossVectors(p[h],d[h]);if(r)for(n=Math.acos(THREE.Math.clamp(d[0].dot(d[g-1]),-1,1)),n/=g-1,p[0].dot(E.crossVectors(d[0],d[g-1]))>0&&(n=-n),h=1;h.9&&M<.1&&(R<.2&&(y[0].x+=1),x<.2&&(y[1].x+=1),H<.2&&(y[2].x+=1))}for(var u=0,p=this.vertices.length;u.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={},o=16755200,s=16711680,c=43775,h=16777215,l=3355443;t("n1","n2",o),t("n2","n4",o),t("n4","n3",o),t("n3","n1",o),t("f1","f2",o),t("f2","f4",o),t("f4","f3",o),t("f3","f1",o),t("n1","f1",o),t("n2","f2",o),t("n3","f3",o),t("n4","f4",o),t("p","n1",s),t("p","n2",s),t("p","n3",s),t("p","n4",s),t("u1","u2",c),t("u2","u3",c),t("u3","u1",c),t("c","t",h),t("p","c",l),t("cn1","cn2",l),t("cn3","cn4",l),t("cf1","cf2",l),t("cf3","cf4",l),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){var h=c[1];i[h]||(i[h]={start:1/0,end:-(1/0)});var l=i[h];al.end&&(l.end=a),t||(t=h)}}for(var h in i){var l=i[h];this.createAnimation(h,l.start,l.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}}},THREE.RenderableObject=function(){this.id=0,this.object=null,this.z=0,this.renderOrder=0},THREE.RenderableFace=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0,this.renderOrder=0},THREE.RenderableVertex=function(){this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0,this.renderOrder=0},THREE.RenderableSprite=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null,this.renderOrder=0},THREE.Projector=function(){function e(){if(c===T){var e=new THREE.RenderableObject;return v.push(e),T++,c++,e}return v[c++]}function t(){if(l===R){var e=new THREE.RenderableVertex;return y.push(e),R++,l++,e}return y[l++]}function r(){if(p===H){var e=new THREE.RenderableFace;return x.push(e),H++,p++,e}return x[p++]}function i(){if(f===M){var e=new THREE.RenderableLine;return b.push(e),M++,f++,e}return b[f++]}function n(){if(m===w){var e=new THREE.RenderableSprite;return _.push(e),w++,m++,e}return _[m++]}function a(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function o(e,t){var r=0,i=1,n=e.z+e.w,a=t.z+t.w,o=-e.z+e.w,s=-t.z+t.w;return n>=0&&a>=0&&o>=0&&s>=0||!(n<0&&a<0||o<0&&s<0)&&(n<0?r=Math.max(r,n/(n-a)):a<0&&(i=Math.min(i,n/(n-a))),o<0?r=Math.max(r,o/(o-s)):s<0&&(i=Math.min(i,o/(o-s))),!(i=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function a(e,r,i){h=t(),h.position.set(e,r,i),n(h)}function o(e,t,r){E.push(e,t,r)}function s(e,t){m.push(e,t)}function c(e,t,r){return e.visible===!0||t.visible===!0||r.visible===!0||(B[0]=e.positionScreen,B[1]=t.positionScreen,B[2]=r.positionScreen,C.intersectsBox(P.setFromPoints(B)))}function l(e,t,r){return(r.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(r.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}function p(e,t){var r=y[e],n=y[t];d=i(),d.id=v.id,d.v1.copy(r),d.v2.copy(n),d.z=(r.positionScreen.z+n.positionScreen.z)/2,d.renderOrder=v.renderOrder,d.material=v.material,S.elements.push(d)}function f(e,t,i){var n=y[e],a=y[t],o=y[i];if(c(n,a,o)!==!1&&(T.side===THREE.DoubleSide||l(n,a,o)===!0)){u=r(),u.id=v.id,u.v1.copy(n),u.v2.copy(a),u.v3.copy(o),u.z=(n.positionScreen.z+a.positionScreen.z+o.positionScreen.z)/3,u.renderOrder=v.renderOrder,u.normalModel.fromArray(E,3*e),u.normalModel.applyMatrix3(R).normalize();for(var s=0;s<3;s++){var h=u.vertexNormalsModel[s];h.fromArray(E,3*arguments[s]),h.applyMatrix3(R).normalize();var p=u.uvs[s];p.fromArray(m,2*arguments[s])}u.vertexNormalsLength=3,u.material=v.material,S.elements.push(u)}}var E=[],m=[],v=null,T=null,R=new THREE.Matrix3;return{setObject:e,projectVertex:n,checkTriangleVisibility:c,checkBackfaceCulling:l,pushVertex:a,pushNormal:o,pushUv:s,pushLine:p,pushTriangle:f}},z=new G;this.projectScene=function(h,v,T,R){function x(t){s=e(),s.id=t.id,s.object=t,L.setFromMatrixPosition(t.matrixWorld),L.applyProjection(D),s.z=L.z,s.renderOrder=t.renderOrder,S.objects.push(s)}p=0,f=0,m=0,S.elements.length=0,h.autoUpdate===!0&&h.updateMatrixWorld(),null===v.parent&&v.updateMatrixWorld(),I.copy(v.matrixWorldInverse.getInverse(v.matrixWorld)),D.multiplyMatrices(v.projectionMatrix,I),F.setFromMatrix(D),c=0,S.objects.length=0,S.lights.length=0,h.traverseVisible(function(e){if(e instanceof THREE.Light)S.lights.push(e);else if(e instanceof THREE.Mesh||e instanceof THREE.Line){if(e.material.visible===!1)return;if(e.frustumCulled===!0&&F.intersectsObject(e)===!1)return;x(e)}else if(e instanceof THREE.Sprite){if(e.material.visible===!1)return;if(e.frustumCulled===!0&&F.intersectsSprite(e)===!1)return;x(e)}}),T===!0&&S.objects.sort(a);for(var H=0,b=S.objects.length;H0)for(var H=0;H0||(fe=y[l-2],N.copy(de.positionScreen),V.copy(fe.positionScreen),o(N,V)===!0&&(N.multiplyScalar(1/N.w),V.multiplyScalar(1/V.w),d=i(),d.id=M.id,d.v1.positionScreen.copy(N),d.v2.positionScreen.copy(V),d.z=Math.max(N.z,V.z),d.renderOrder=M.renderOrder,d.material=M.material,M.material.vertexColors===THREE.VertexColors&&(d.vertexColors[0].copy(M.geometry.colors[$]),d.vertexColors[1].copy(M.geometry.colors[$-1])),S.elements.push(d)))}}else if(M instanceof THREE.Sprite){A.set(g.elements[12],g.elements[13],g.elements[14],1),A.applyMatrix4(D);var be=1/A.w;A.z*=be,A.z>=-1&&A.z<=1&&(E=n(),E.id=M.id,E.x=A.x*be,E.y=A.y*be,E.z=A.z,E.renderOrder=M.renderOrder,E.object=M,E.rotation=M.rotation,E.scale.x=M.scale.x*Math.abs(E.x-(A.x+v.projectionMatrix.elements[0])/(A.w+v.projectionMatrix.elements[12])),E.scale.y=M.scale.y*Math.abs(E.y-(A.y+v.projectionMatrix.elements[5])/(A.w+v.projectionMatrix.elements[13])),E.material=M.material,S.elements.push(E))}}return R===!0&&S.elements.sort(a),S}},THREE.SpriteCanvasMaterial=function(e){THREE.Material.call(this),this.type="SpriteCanvasMaterial",this.color=new THREE.Color(16777215),this.program=function(e,t){},this.setValues(e)},THREE.SpriteCanvasMaterial.prototype=Object.create(THREE.Material.prototype),THREE.SpriteCanvasMaterial.prototype.constructor=THREE.SpriteCanvasMaterial,THREE.SpriteCanvasMaterial.prototype.clone=function(){var e=new THREE.SpriteCanvasMaterial;return e.copy(this),e.color.copy(this.color),e.program=this.program,e},THREE.CanvasRenderer=function(e){function t(){ge.setRGB(0,0,0),ve.setRGB(0,0,0),Te.setRGB(0,0,0);for(var e=0,t=x.length;e0&&(d(THREE.NormalBlending),p(1),v("rgba("+Math.floor(255*$.r)+","+Math.floor(255*$.g)+","+Math.floor(255*$.b)+","+ee+")"),J.fillRect(0|Ee.min.x,0|Ee.max.y,Ee.max.x-Ee.min.x|0,Ee.min.y-Ee.max.y|0)),Ee.makeEmpty())},this.clearColor=function(){},this.clearDepth=function(){},this.clearStencil=function(){},this.render=function(e,r){if(r instanceof THREE.Camera==!1)return void console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");this.autoClear===!0&&this.clear(),V.info.render.vertices=0,V.info.render.faces=0,J.setTransform(Z/k,0,0,-K/j,q,j-Y),J.translate(W,X),y=G.projectScene(e,r,this.sortObjects,this.sortElements),R=y.elements,x=y.lights,H=r,He.getNormalMatrix(r.matrixWorldInverse),t();for(var o=0,s=R.length;o1)continue;if(M.positionScreen.z<-1||M.positionScreen.z>1)continue;if(_.positionScreen.z<-1||_.positionScreen.z>1)continue;b.positionScreen.x*=W,b.positionScreen.y*=X,M.positionScreen.x*=W,M.positionScreen.y*=X,_.positionScreen.x*=W,_.positionScreen.y*=X,h.overdraw>0&&(u(b.positionScreen,M.positionScreen,h.overdraw),u(M.positionScreen,_.positionScreen,h.overdraw),u(_.positionScreen,b.positionScreen,h.overdraw)),me.setFromPoints([b.positionScreen,M.positionScreen,_.positionScreen]),fe.intersectsBox(me)===!0&&a(b,M,_,0,1,2,c,h)}Ee.union(me)}}J.setTransform(1,0,0,1,0,0)}},THREE.CSS3DObject=function(e){THREE.Object3D.call(this),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",function(e){null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)})},THREE.CSS3DObject.prototype=Object.create(THREE.Object3D.prototype),THREE.CSS3DObject.prototype.constructor=THREE.CSS3DObject,THREE.CSS3DSprite=function(e){THREE.CSS3DObject.call(this,e)},THREE.CSS3DSprite.prototype=Object.create(THREE.CSS3DObject.prototype),THREE.CSS3DSprite.prototype.constructor=THREE.CSS3DSprite,THREE.CSS3DRenderer=function(){console.log("THREE.CSS3DRenderer",THREE.REVISION);var e,t,r,i,n=new THREE.Matrix4,a={camera:{fov:0,style:""},objects:{}},o=document.createElement("div");o.style.overflow="hidden",o.style.WebkitTransformStyle="preserve-3d",o.style.MozTransformStyle="preserve-3d",o.style.oTransformStyle="preserve-3d",o.style.transformStyle="preserve-3d",this.domElement=o;var s=document.createElement("div");s.style.WebkitTransformStyle="preserve-3d",s.style.MozTransformStyle="preserve-3d",s.style.oTransformStyle="preserve-3d",s.style.transformStyle="preserve-3d",o.appendChild(s),this.setClearColor=function(){},this.getSize=function(){return{width:e,height:t}},this.setSize=function(n,a){e=n,t=a,r=e/2,i=t/2,o.style.width=n+"px",o.style.height=a+"px",s.style.width=n+"px",s.style.height=a+"px"};var c=function(e){return Math.abs(e)1?1:T,y=p(T);for(c in i)if(void 0!==r[c]){var R=r[c]||0,x=i[c];x instanceof Array?t[c]=d(x,y):("string"==typeof x&&(x=x.startsWith("+")||x.startsWith("-")?R+parseFloat(x,10):parseFloat(x,10)),"number"==typeof x&&(t[c]=R+(x-R)*y))}if(null!==g&&g.call(t,y),1===T){if(o>0){isFinite(o)&&o--;for(c in n){if("string"==typeof i[c]&&(n[c]=n[c]+parseFloat(i[c],10)),s){var H=n[c];n[c]=i[c],i[c]=H}r[c]=n[c]}return s&&(h=!h),u=e+l,!0}null!==v&&v.call(t);for(var b=0,M=f.length;b1?a(e[r],e[r-1],r-i):a(e[n],e[n+1>r?r:n+1],i-n)},Bezier:function(e,t){for(var r=0,i=e.length-1,n=Math.pow,a=TWEEN.Interpolation.Utils.Bernstein,o=0;o<=i;o++)r+=n(1-t,i-o)*n(t,o)*e[o]*a(i,o);return r},CatmullRom:function(e,t){var r=e.length-1,i=r*t,n=Math.floor(i),a=TWEEN.Interpolation.Utils.CatmullRom;return e[0]===e[r]?(t<0&&(n=Math.floor(i=r*(1+t))),a(e[(n-1+r)%r],e[n],e[(n+1)%r],e[(n+2)%r],i-n)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[r]-(a(e[r],e[r],e[r-1],e[r-1],i-r)-e[r]):a(e[n?n-1:0],e[n],e[r1;i--)r*=i;return e[t]=r,r}}(),CatmullRom:function(e,t,r,i,n){var a=.5*(r-e),o=.5*(i-t),s=n*n,c=n*s;return(2*t-2*r+a+o)*c+(-3*t+3*r-2*a-o)*s+a*n+t}}},function(e){"function"==typeof define&&define.amd?define([],function(){return TWEEN}):"undefined"!=typeof module&&"object"==typeof exports?module.exports=TWEEN:void 0!==e&&(e.TWEEN=TWEEN)}(this);