var THREE=THREE||{REVISION:"59"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}},String.prototype.trim=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},THREE.extend=function(e,t){if(Object.keys)for(var i=Object.keys(t),r=0,o=i.length;r>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(e,t,i){if(0===t)this.r=this.g=this.b=i;else{var r=function(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e},o=i<=.5?i*(1+t):i+t-i*t,a=2*i-o;this.r=r(a,o,e+1/3),this.g=r(a,o,e),this.b=r(a,o,e-1/3)}return this},setStyle:function(e){if(/^rgb\((\d+),(\d+),(\d+)\)$/i.test(e)){var t=/^rgb\((\d+),(\d+),(\d+)\)$/i.exec(e);return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,this}if(/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.test(e)){var t=/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.exec(e);return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,this}if(/^\#([0-9a-f]{6})$/i.test(e)){var t=/^\#([0-9a-f]{6})$/i.exec(e);return this.setHex(parseInt(t[1],16)),this}if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(e)){var t=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);return this.setHex(parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3],16)),this}if(/^(\w+)$/i.test(e))return this.setHex(THREE.ColorKeywords[e]),this},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e){return this.r=e.r*e.r,this.g=e.g*e.g,this.b=e.b*e.b,this},copyLinearToGamma:function(e){return this.r=Math.sqrt(e.r),this.g=Math.sqrt(e.g),this.b=Math.sqrt(e.b),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(){var e={h:0,s:0,l:0};return function(){var t,i,r=this.r,o=this.g,a=this.b,n=Math.max(r,o,a),s=Math.min(r,o,a),h=(s+n)/2;if(s===n)t=0,i=0;else{var l=n-s;switch(i=h<=.5?l/(n+s):l/(2-n-s),n){case r:t=(o-a)/l+(o0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(c-h)*t,this._y=(a-l)*t,this._z=(n-o)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(c-h)/t,this._x=.25*t,this._y=(o+n)/t,this._z=(a+l)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(a-l)/t,this._x=(o+n)/t,this._y=.25*t,this._z=(h+c)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(n-o)/t,this._x=(a+l)/t,this._y=(h+c)/t,this._z=.25*t),this._updateEuler(),this},inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._updateEuler(),this},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},multiply:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,o=e._z,a=e._w,n=t._x,s=t._y,h=t._z,l=t._w;return this._x=i*l+a*n+r*h-o*s,this._y=r*l+a*s+o*n-i*h,this._z=o*l+a*h+i*s-r*n,this._w=a*l-i*n-r*s-o*h,this._updateEuler(),this},multiplyVector3:function(e){return console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},slerp:function(e,t){var i=this._x,r=this._y,o=this._z,a=this._w,n=a*e._w+i*e._x+r*e._y+o*e._z;if(n<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,n=-n):this.copy(e),n>=1)return this._w=a,this._x=i,this._y=r,this._z=o,this;var s=Math.acos(n),h=Math.sqrt(1-n*n);if(Math.abs(h)<.001)return this._w=.5*(a+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(o+this._z),this;var l=Math.sin((1-t)*s)/h,c=Math.sin(t*s)/h;return this._w=a*l+this._w*c,this._x=i*l+this._x*c,this._y=r*l+this._y*c,this._z=o*l+this._z*c,this._updateEuler(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],this._w=e[3],this._updateEuler(),this},toArray:function(){return[this._x,this._y,this._z,this._w]},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}},THREE.Quaternion.slerp=function(e,t,i,r){return i.copy(e).slerp(t,r)},THREE.Vector2=function(e,t){this.x=e||0,this.y=t||0},THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(e,t){return this.x=e,this.y=t,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)}},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScalar:function(e){return this.x+=e,this.y+=e,this},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t}else this.x=0,this.y=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this},negate:function(){return this.multiplyScalar(-1)},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)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e){return this.x=e[0],this.y=e[1],this},toArray:function(){return[this.x,this.y]},clone:function(){return new THREE.Vector2(this.x,this.y)}},THREE.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,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)}},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("DEPRECATED: Vector3's .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},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector3's .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)},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("DEPRECATED: Vector3's .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*i+o[6]*r,this.y=o[1]*t+o[4]*i+o[7]*r,this.z=o[2]*t+o[5]*i+o[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12],this.y=o[1]*t+o[5]*i+o[9]*r+o[13],this.z=o[2]*t+o[6]*i+o[10]*r+o[14],this},applyProjection:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements,a=1/(o[3]*t+o[7]*i+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*i+o[8]*r+o[12])*a,this.y=(o[1]*t+o[5]*i+o[9]*r+o[13])*a,this.z=(o[2]*t+o[6]*i+o[10]*r+o[14])*a,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,o=e.x,a=e.y,n=e.z,s=e.w,h=s*t+a*r-n*i,l=s*i+n*t-o*r,c=s*r+o*i-a*t,u=-o*t-a*i-n*r;return this.x=h*s+u*-o+l*-n-c*-a,this.y=l*s+u*-a+c*-o-h*-n,this.z=c*s+u*-n+h*-a-l*-o,this},transformDirection:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r,this.y=o[1]*t+o[5]*i+o[9]*r,this.z=o[2]*t+o[6]*i+o[10]*r,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t,this.z*=t}else this.x=0,this.y=0,this.z=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this},negate:function(){return this.multiplyScalar(-1)},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){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},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},cross:function(e,t){if(void 0!==t)return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var i=this.x,r=this.y,o=this.z;return this.x=r*e.z-o*e.y,this.y=o*e.x-i*e.z,this.z=i*e.y-r*e.x,this},crossVectors:function(e,t){return this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this},angleTo:function(e){var t=this.dot(e)/(this.length()*e.length());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,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},setEulerFromRotationMatrix:function(e,t){console.error("REMOVED: Vector3's setEulerFromRotationMatrix has been removed in favor of Euler.setFromRotationMatrix(), please update your code.")},setEulerFromQuaternion:function(e,t){console.error("REMOVED: Vector3's setEulerFromQuaternion: has been removed in favor of Euler.setFromQuaternion(), please update your code.")},getPositionFromMatrix:function(e){return this.x=e.elements[12],this.y=e.elements[13],this.z=e.elements[14],this},getScaleFromMatrix:function(e){var t=this.set(e.elements[0],e.elements[1],e.elements[2]).length(),i=this.set(e.elements[4],e.elements[5],e.elements[6]).length(),r=this.set(e.elements[8],e.elements[9],e.elements[10]).length();return this.x=t,this.y=i,this.z=r,this},getColumnFromMatrix:function(e,t){var i=4*e,r=t.elements;return this.x=r[i],this.y=r[i+1],this.z=r[i+2],this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e){return this.x=e[0],this.y=e[1],this.z=e[2],this},toArray:function(){return[this.x,this.y,this.z]},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}},THREE.extend(THREE.Vector3.prototype,{applyEuler:function(){var e=new THREE.Quaternion;return function(t){void 0===typeof t.order&&console.error("ERROR: Vector3's .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");var i=e.setFromEuler(t);return this.applyQuaternion(i),this}}(),applyAxisAngle:function(){var e=new THREE.Quaternion;return function(t,i){var r=e.setFromAxisAngle(t,i);return this.applyQuaternion(r),this}}(),projectOnVector:function(){var e=new THREE.Vector3;return function(t){e.copy(t).normalize();var i=this.dot(e);return this.copy(e).multiplyScalar(i)}}(),projectOnPlane:function(){var e=new THREE.Vector3;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new THREE.Vector3;return function(t){return e.copy(this).projectOnVector(t).multiplyScalar(2),this.subVectors(e,this)}}()}),THREE.Vector4=function(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1},THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,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)}},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("DEPRECATED: Vector4's .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},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector4's .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)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*o,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*o,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*o,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*o,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t,this.z*=t,this.w*=t}else this.x=0,this.y=0,this.z=0,this.w=1;return this},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,i,r,o,a=.01,n=.1,s=e.elements,h=s[0],l=s[4],c=s[8],u=s[1],p=s[5],d=s[9],f=s[2],E=s[6],m=s[10];if(Math.abs(l-u)v&&g>T?gT?ve.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this.w>e.w&&(this.w=e.w),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this.wt.w&&(this.w=t.w),this},negate:function(){return this.multiplyScalar(-1)},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e){return this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3],this},toArray:function(){return[this.x,this.y,this.z,this.w]},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}},THREE.Euler=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._order=r||THREE.Euler.DefaultOrder},THREE.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],THREE.Euler.DefaultOrder="XYZ",THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,_quaternion:void 0,_updateQuaternion:function(){void 0!==this._quaternion&&this._quaternion.setFromEuler(this,!1)},get x(){return this._x},set x(e){this._x=e,this._updateQuaternion()},get y(){return this._y},set y(e){this._y=e,this._updateQuaternion()},get z(){return this._z},set z(e){this._z=e,this._updateQuaternion()},get order(){return this._order},set order(e){this._order=e,this._updateQuaternion()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this._updateQuaternion(),this},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._updateQuaternion(),this},setFromRotationMatrix:function(e,t){function i(e){return Math.min(Math.max(e,-1),1)}var r=e.elements,o=r[0],a=r[4],n=r[8],s=r[1],h=r[5],l=r[9],c=r[2],u=r[6],p=r[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(i(n)),Math.abs(n)<.99999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(u,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(l)),Math.abs(l)<.99999?(this._y=Math.atan2(n,p),this._z=Math.atan2(s,h)):(this._y=Math.atan2(-c,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(u)),Math.abs(u)<.99999?(this._y=Math.atan2(-c,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(s,o))):"ZYX"===t?(this._y=Math.asin(-i(c)),Math.abs(c)<.99999?(this._x=Math.atan2(u,p),this._z=Math.atan2(s,o)):(this._x=0,this._z=Math.atan2(-a,h))):"YZX"===t?(this._z=Math.asin(i(s)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,o)):(this._x=0,this._y=Math.atan2(n,p))):"XZY"===t?(this._z=Math.asin(-i(a)),Math.abs(a)<.99999?(this._x=Math.atan2(u,h),this._y=Math.atan2(n,o)):(this._x=Math.atan2(-l,p),this._y=0)):console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+t),this._order=t,this._updateQuaternion(),this},setFromQuaternion:function(e,t,i){function r(e){return Math.min(Math.max(e,-1),1)}var o=e.x*e.x,a=e.y*e.y,n=e.z*e.z,s=e.w*e.w;return t=t||this._order,"XYZ"===t?(this._x=Math.atan2(2*(e.x*e.w-e.y*e.z),s-o-a+n),this._y=Math.asin(r(2*(e.x*e.z+e.y*e.w))),this._z=Math.atan2(2*(e.z*e.w-e.x*e.y),s+o-a-n)):"YXZ"===t?(this._x=Math.asin(r(2*(e.x*e.w-e.y*e.z))),this._y=Math.atan2(2*(e.x*e.z+e.y*e.w),s-o-a+n),this._z=Math.atan2(2*(e.x*e.y+e.z*e.w),s-o+a-n)):"ZXY"===t?(this._x=Math.asin(r(2*(e.x*e.w+e.y*e.z))),this._y=Math.atan2(2*(e.y*e.w-e.z*e.x),s-o-a+n),this._z=Math.atan2(2*(e.z*e.w-e.x*e.y),s-o+a-n)):"ZYX"===t?(this._x=Math.atan2(2*(e.x*e.w+e.z*e.y),s-o-a+n),this._y=Math.asin(r(2*(e.y*e.w-e.x*e.z))),this._z=Math.atan2(2*(e.x*e.y+e.z*e.w),s+o-a-n)):"YZX"===t?(this._x=Math.atan2(2*(e.x*e.w-e.z*e.y),s-o+a-n),this._y=Math.atan2(2*(e.y*e.w-e.x*e.z),s+o-a-n),this._z=Math.asin(r(2*(e.x*e.y+e.z*e.w)))):"XZY"===t?(this._x=Math.atan2(2*(e.x*e.w+e.y*e.z),s-o+a-n),this._y=Math.atan2(2*(e.x*e.z+e.y*e.w),s+o-a-n),this._z=Math.asin(r(2*(e.z*e.w-e.x*e.y)))):console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: "+t),this._order=t,i!==!1&&this._updateQuaternion(),this},reorder:function(){var e=new THREE.Quaternion;return function(t){e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._updateQuaternion(),this},toArray:function(){return[this._x,this._y,this._z,this._order]},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}},THREE.Line3=function(e,t){this.start=void 0!==e?e:new THREE.Vector3,this.end=void 0!==t?t:new THREE.Vector3},THREE.Line3.prototype={constructor:THREE.Line3,set:function(e,t){return this.start.copy(e),this.end.copy(t),this},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},center:function(e){var t=e||new THREE.Vector3;return t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){var t=e||new THREE.Vector3;return t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var i=t||new THREE.Vector3;return this.delta(i).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(i,r){e.subVectors(i,this.start),t.subVectors(this.end,this.start);var o=t.dot(t),a=t.dot(e),n=a/o;return r&&(n=THREE.Math.clamp(n,0,1)),n}}(),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t),o=i||new THREE.Vector3;return this.delta(o).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)},clone:function(){ return(new THREE.Line3).copy(this)}},THREE.Box2=function(e,t){this.min=void 0!==e?e:new THREE.Vector2(1/0,1/0),this.max=void 0!==t?t:new THREE.Vector2((-(1/0)),(-(1/0)))},THREE.Box2.prototype={constructor:THREE.Box2,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){if(e.length>0){var t=e[0];this.min.copy(t),this.max.copy(t);for(var i=1,r=e.length;ithis.max.x&&(this.max.x=t.x),t.ythis.max.y&&(this.max.y=t.y)}else this.makeEmpty();return this},setFromCenterAndSize:function(){var e=new THREE.Vector2;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-(1/0),this},empty:function(){return this.max.xthis.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){return new THREE.Vector2((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){var i=t||new THREE.Vector2;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector2;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.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)},clone:function(){return(new THREE.Box2).copy(this)}},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},setFromPoints:function(e){if(e.length>0){var t=e[0];this.min.copy(t),this.max.copy(t);for(var i=1,r=e.length;ithis.max.x&&(this.max.x=t.x),t.ythis.max.y&&(this.max.y=t.y),t.zthis.max.z&&(this.max.z=t.z)}else this.makeEmpty();return this},setFromCenterAndSize:function(){var e=new THREE.Vector3;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),setFromObject:function(){var e=new THREE.Vector3;return function(t){var i=this;return t.updateMatrixWorld(!0),this.makeEmpty(),t.traverse(function(t){if(void 0!==t.geometry&&void 0!==t.geometry.vertices)for(var r=t.geometry.vertices,o=0,a=r.length;othis.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){return new THREE.Vector3((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))},isIntersectionBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},clampPoint:function(e,t){var i=t||new THREE.Vector3;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector3;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.sub(t).length()}}(),getBoundingSphere:function(){var e=new THREE.Vector3;return function(t){var i=t||new THREE.Sphere;return i.center=this.center(),i.radius=.5*this.size(e).length(),i}}(),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},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 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.makeEmpty(),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)},clone:function(){return(new THREE.Box3).copy(this)}},THREE.Matrix3=function(e,t,i,r,o,a,n,s,h){this.elements=new Float32Array(9),this.set(void 0!==e?e:1,t||0,i||0,r||0,void 0!==o?o:1,a||0,n||0,s||0,void 0!==h?h:1)},THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(e,t,i,r,o,a,n,s,h){var l=this.elements;return l[0]=e,l[3]=t,l[6]=i,l[1]=r,l[4]=o,l[7]=a,l[2]=n,l[5]=s,l[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},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},multiplyVector3:function(e){return console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){var e=new THREE.Vector3;return function(t){for(var i=0,r=t.length;i=0)if(o=p*f-d,a=p*d-f,s=c*m,o>=0)if(a>=-s)if(a<=s){var g=1/m;o*=g,a*=g,n=o*(o+p*a+2*d)+a*(p*o+a+2*f)+E}else a=c,o=Math.max(0,-(p*a+d)),n=-o*o+a*(a+2*f)+E;else a=-c,o=Math.max(0,-(p*a+d)),n=-o*o+a*(a+2*f)+E;else a<=-s?(o=Math.max(0,-(-p*c+d)),a=o>0?-c:Math.min(Math.max(-c,-f),c),n=-o*o+a*(a+2*f)+E):a<=s?(o=0,a=Math.min(Math.max(-c,-f),c),n=a*(a+2*f)+E):(o=Math.max(0,-(p*c+d)),a=o>0?c:Math.min(Math.max(-c,-f),c),n=-o*o+a*(a+2*f)+E);else a=p>0?-c:c,o=Math.max(0,-(p*a+d)),n=-o*o+a*(a+2*f)+E;return i&&i.copy(this.direction.clone().multiplyScalar(o).add(this.origin)),r&&r.copy(l.clone().multiplyScalar(a).add(h)),n},isIntersectionSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},isIntersectionPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var i=e.normal.dot(this.direction);return i*t<0},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0==t)return 0==e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)},clone:function(){return(new THREE.Ray).copy(this)}},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(e){for(var t,i=0,r=0,o=e.length;rthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},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},clone:function(){return(new THREE.Sphere).copy(this)}},THREE.Frustum=function(e,t,i,r,o,a){this.planes=[void 0!==e?e:new THREE.Plane,void 0!==t?t:new THREE.Plane,void 0!==i?i:new THREE.Plane,void 0!==r?r:new THREE.Plane,void 0!==o?o:new THREE.Plane,void 0!==a?a:new THREE.Plane]},THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(e,t,i,r,o,a){var n=this.planes;return n[0].copy(e),n[1].copy(t),n[2].copy(i),n[3].copy(r),n[4].copy(o),n[5].copy(a),this},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],n=i[3],s=i[4],h=i[5],l=i[6],c=i[7],u=i[8],p=i[9],d=i[10],f=i[11],E=i[12],m=i[13],g=i[14],v=i[15];return t[0].setComponents(n-r,c-s,f-u,v-E).normalize(),t[1].setComponents(n+r,c+s,f+u,v+E).normalize(),t[2].setComponents(n+o,c+h,f+p,v+m).normalize(),t[3].setComponents(n-o,c-h,f-p,v-m).normalize(),t[4].setComponents(n-a,c-l,f-d,v-g).normalize(),t[5].setComponents(n+a,c+l,f+d,v+g).normalize(),this},intersectsObject:function(){var e=new THREE.Vector3;return function(t){var i=t.geometry,r=t.matrixWorld;null===i.boundingSphere&&i.computeBoundingSphere();var o=-i.boundingSphere.radius*r.getMaxScaleOnAxis();e.getPositionFromMatrix(r);for(var a=this.planes,n=0;n<6;n++){var s=a[n].distanceToPoint(e);if(s0?i.min.x:i.max.x,t.x=a.normal.x>0?i.max.x:i.min.x,e.y=a.normal.y>0?i.min.y:i.max.y,t.y=a.normal.y>0?i.max.y:i.min.y,e.z=a.normal.z>0?i.min.z:i.max.z,t.z=a.normal.z>0?i.max.z:i.min.z;var n=a.distanceToPoint(e),s=a.distanceToPoint(t);if(n<0&&s<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}},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,i,r){return this.normal.set(e,t,i),this.constant=r,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(i,r,o){var a=e.subVectors(o,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(a,i),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 i=this.distanceToPoint(e),r=t||new THREE.Vector3;return r.copy(this.normal).multiplyScalar(i)},isIntersectionLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectLine:function(){var e=new THREE.Vector3;return function(t,i){var r=i||new THREE.Vector3,o=t.delta(e),a=this.normal.dot(o);if(0!=a){var n=-(t.start.dot(this.normal)+this.constant)/a;if(!(n<0||n>1))return r.copy(o).multiplyScalar(n).add(t.start)}else if(0==this.distanceToPoint(t.start))return r.copy(t.start)}}(),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.Vector3;return function(i,r){r=r||(new THREE.Matrix3).getNormalMatrix(i);var o=e.copy(this.normal).applyMatrix3(r),a=this.coplanarPoint(t);return a.applyMatrix4(i),this.setFromNormalAndCoplanarPoint(o,a),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},clone:function(){return(new THREE.Plane).copy(this)}},THREE.Math={PI2:2*Math.PI,generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var o=0;o<36;o++)8==o||13==o||18==o||23==o?i[o]="-":14==o?i[o]="4":(r<=2&&(r=33554432+16777216*Math.random()|0),e=15&r,r>>=4,i[o]=t[19==o?3&e|8:e]);return i.join("")}}(),clamp:function(e,t,i){return ei?i:e},clampBottom:function(e,t){return e=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},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())},sign:function(e){return e<0?-1:e>0?1:0},degToRad:function(){var e=Math.PI/180;return function(t){return t*e}}(),radToDeg:function(){var e=180/Math.PI;return function(t){return t*e}}()},THREE.Spline=function(e){function t(e,t,i,r,o,a,n){var s=.5*(i-e),h=.5*(r-t);return(2*(t-i)+s+h)*n+(-3*(t-i)-2*s-h)*a+s*o+t}this.points=e;var i,r,o,a,n,s,h,l,c,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:r+1,u[3]=r>this.points.length-3?this.points.length-1:r+2,s=this.points[u[0]],h=this.points[u[1]],l=this.points[u[2]],c=this.points[u[3]],a=o*o,n=o*a,p.x=t(s.x,h.x,l.x,c.x,o,a,n),p.y=t(s.y,h.y,l.y,c.y,o,a,n),p.z=t(s.z,h.z,l.z,c.z,o,a,n),p},this.getControlPointsArray=function(){var e,t,i=this.points.length,r=[];for(e=0;e0?a.multiplyScalar(1/Math.sqrt(n)):a.set(0,0,0)}}(),THREE.Triangle.barycoordFromPoint=function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3;return function(r,o,a,n,s){e.subVectors(n,o),t.subVectors(a,o),i.subVectors(r,o);var h=e.dot(e),l=e.dot(t),c=e.dot(i),u=t.dot(t),p=t.dot(i),d=h*u-l*l,f=s||new THREE.Vector3;if(0==d)return f.set(-2,-1,-1);var E=1/d,m=(u*c-l*p)*E,g=(h*p-l*c)*E;return f.set(1-m-g,g,m)}}(),THREE.Triangle.containsPoint=function(){var e=new THREE.Vector3;return function(t,i,r,o){var a=THREE.Triangle.barycoordFromPoint(t,i,r,o,e);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]), this.c.copy(e[r]),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)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)},clone:function(){return(new THREE.Triangle).copy(this)}},THREE.Vertex=function(e){return console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead."),e},THREE.UV=function(e,t){return console.warn("THREE.UV has been DEPRECATED. Use THREE.Vector2 instead."),new THREE.Vector2(e,t)},THREE.Clock=function(e){this.autoStart=void 0===e||e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1},THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.startTime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running&&this.start(),this.running){var t=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now();e=.001*(t-this.oldTime),this.oldTime=t,this.elapsedTime+=e}return e}},THREE.EventDispatcher=function(){},THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(e){e.addEventListener=THREE.EventDispatcher.prototype.addEventListener,e.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener,e.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener,e.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&i[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(void 0!==this._listeners){var i=this._listeners,r=i[e].indexOf(t);r!==-1&&i[e].splice(r,1)}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners,i=t[e.type];if(void 0!==i){e.target=this;for(var r=0,o=i.length;r0&&this.ray.direction.normalize(),this.near=r||0,this.far=o||1/0};var t=new e.Sphere,i=new e.Ray,r=new e.Plane,o=new e.Vector3,a=new e.Vector3,n=new e.Matrix4,s=function(e,t){return e.distance-t.distance},h=function(s,l,c){if(s instanceof e.Particle){a.getPositionFromMatrix(s.matrixWorld);var u=l.ray.distanceToPoint(a);if(u>s.scale.x)return c;c.push({distance:u,point:s.position,face:null,object:s})}else if(s instanceof e.LOD){a.getPositionFromMatrix(s.matrixWorld);var u=l.ray.origin.distanceTo(a);h(s.getObjectForDistance(u),l,c)}else if(s instanceof e.Mesh){var p=s.geometry;if(a.getPositionFromMatrix(s.matrixWorld),null===p.boundingSphere&&p.computeBoundingSphere(),t.set(a,p.boundingSphere.radius*s.matrixWorld.getMaxScaleOnAxis()),l.ray.isIntersectionSphere(t)===!1)return c;var d=p.vertices;if(p instanceof e.BufferGeometry){var f=s.material;if(void 0===f)return c;if(p.dynamic===!1)return c;var E,m,g,v=s.material instanceof e.MeshFaceMaterial,T=v===!0?s.material.materials:null,y=s.material.side,R=l.precision;n.getInverse(s.matrixWorld),i.copy(l.ray).applyMatrix4(n);var x,H=!1;p.attributes.index?(H=!0,x=p.attributes.index.numItems/3):x=p.attributes.position.numItems/9;for(var w=new e.Vector3,_=new e.Vector3,b=new e.Vector3,M=(new e.Vector3,new e.Vector3,0);M0))continue}Dl.far||(o=i.at(D,o),e.Triangle.containsPoint(o,w,_,b)!==!1&&c.push({distance:D,point:l.ray.at(D),face:null,faceIndex:null,object:s}))}}}else if(p instanceof e.Geometry){var E,m,g,U,v=s.material instanceof e.MeshFaceMaterial,T=v===!0?s.material.materials:null,y=s.material.side,R=l.precision;n.getInverse(s.matrixWorld),i.copy(l.ray).applyMatrix4(n);for(var V=0,x=p.faces.length;V0))continue}if(!(Dl.far)){if(o=i.at(D,o),z instanceof e.Face3){if(E=d[z.a],m=d[z.b],g=d[z.c],e.Triangle.containsPoint(o,E,m,g)===!1)continue}else{if(!(z instanceof e.Face4))throw Error("face type not supported");if(E=d[z.a],m=d[z.b],g=d[z.c],U=d[z.d],e.Triangle.containsPoint(o,E,m,U)===!1&&e.Triangle.containsPoint(o,m,g,U)===!1)continue}c.push({distance:D,point:l.ray.at(D),face:z,faceIndex:V,object:s})}}}}}}else if(s instanceof e.Line){var R=l.linePrecision,N=R*R,p=s.geometry;if(null===p.boundingSphere&&p.computeBoundingSphere(),a.getPositionFromMatrix(s.matrixWorld),t.set(a,p.boundingSphere.radius*s.matrixWorld.getMaxScaleOnAxis()),l.ray.isIntersectionSphere(t)===!1)return c;n.getInverse(s.matrixWorld),i.copy(l.ray).applyMatrix4(n),i.direction.normalize();for(var d=p.vertices,B=d.length,O=new e.Vector3,I=new e.Vector3,k=s.type===e.LineStrip?1:2,L=0;L0&&this.ray.direction.normalize()},e.Raycaster.prototype.intersectObject=function(e,t){var i=[];return t===!0&&l(e,this,i),h(e,this,i),i.sort(s),i},e.Raycaster.prototype.intersectObjects=function(e,t){for(var i=[],r=0,o=e.length;r=0&&a>=0&&n>=0&&s>=0||!(o<0&&a<0||n<0&&s<0)&&(o<0?i=Math.max(i,o/(o-a)):a<0&&(r=Math.min(r,o/(o-a))),n<0?i=Math.max(i,n/(n-s)):s<0&&(r=Math.min(r,n/(n-s))),!(r1||c.positionScreen.y<-1||c.positionScreen.y>1||c.positionScreen.z<-1||c.positionScreen.z>1)}for(b=0,M=$.length;b0||(ae=x[u-2],X.copy(oe.positionScreen),Y.copy(ae.positionScreen),s(X,Y)===!0&&(X.multiplyScalar(1/X.w),Y.multiplyScalar(1/Y.w),E=o(),E.id=Q.id,E.v1.positionScreen.copy(X),E.v2.positionScreen.copy(Y),E.z=Math.max(X.z,Y.z),E.material=Q.material,Q.material.vertexColors===THREE.VertexColors&&(E.vertexColors[0].copy(Q.geometry.colors[w]),E.vertexColors[1].copy(Q.geometry.colors[w-1])),P.elements.push(E)))}for(R=0,H=P.sprites.length;R0&&F.z<1&&(g=a(),g.id=Q.id,g.x=F.x*ue,g.y=F.y*ue,g.z=F.z,g.object=Q,g.rotation=Q.rotation.z,g.scale.x=Q.scale.x*Math.abs(g.x-(F.x+h.projectionMatrix.elements[0])/(F.w+h.projectionMatrix.elements[12])),g.scale.y=Q.scale.y*Math.abs(g.y-(F.y+h.projectionMatrix.elements[5])/(F.w+h.projectionMatrix.elements[13])),g.material=Q.material,P.elements.push(g))}return y===!0&&P.elements.sort(n),P}},THREE.Face3=function(e,t,i,r,o,a){this.a=e,this.b=t,this.c=i,this.normal=r instanceof THREE.Vector3?r:new THREE.Vector3,this.vertexNormals=r instanceof Array?r:[],this.color=o instanceof THREE.Color?o:new THREE.Color,this.vertexColors=o instanceof Array?o:[],this.vertexTangents=[],this.materialIndex=void 0!==a?a:0,this.centroid=new THREE.Vector3},THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var e=new THREE.Face3(this.a,this.b,this.c);e.normal.copy(this.normal),e.color.copy(this.color),e.centroid.copy(this.centroid),e.materialIndex=this.materialIndex;var t,i;for(t=0,i=this.vertexNormals.length;t0&&(e+=t[i].distanceTo(t[i-1])),this.lineDistances[i]=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)},mergeVertices:function(){var e,t,i,r,o,a,n,s,h,l={},c=[],u=[],p=4,d=Math.pow(10,p);for(this.__tmpVertices=void 0,i=0,r=this.vertices.length;i=0&&f.push(i),E=m);if(E>=0){a.splice(E,1);var g=new THREE.Face3(a[0],a[1],a[2],o.normal,o.color,o.materialIndex);for(n=0,s=this.faceVertexUvs.length;n0&&(g.vertexNormals=o.vertexNormals,g.vertexNormals.splice(E,1)),o.vertexColors&&o.vertexColors.length>0&&(g.vertexColors=o.vertexColors,g.vertexColors.splice(E,1)),this.faces[i]=g}}for(i=f.length-1;i>=0;i--)for(this.faces.splice(i,1),n=0,s=this.faceVertexUvs.length;n=3&&(o.min.x=o.max.x=e[0],o.min.y=o.max.y=e[1],o.min.z=o.max.z=e[2]);for(var a=3,n=e.length;ao.max.x&&(o.max.x=t),io.max.y&&(o.max.y=i),ro.max.z&&(o.max.z=r)}void 0!==e&&0!==e.length||(this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0))},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere); var e=this.attributes.position.array;if(e){for(var t,i,r,o,a=0,n=0,s=e.length;na&&(a=t);this.boundingSphere.radius=Math.sqrt(a)}},computeVertexNormals:function(){if(this.attributes.position){var e,t,i,r,o=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemSize:3,array:new Float32Array(o)};else for(e=0,t=this.attributes.normal.array.length;e0){this.morphTargetBase=-1,this.morphTargetForcedOrder=[],this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,t=this.geometry.morphTargets.length;e256?64:l>64?32:l>16?16:8,this.boneTextureWidth=c,this.boneTextureHeight=c,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new THREE.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,THREE.RGBAFormat,THREE.FloatType),this.boneTexture.minFilter=THREE.NearestFilter,this.boneTexture.magFilter=THREE.NearestFilter,this.boneTexture.generateMipmaps=!1,this.boneTexture.flipY=!1}else this.boneMatrices=new Float32Array(16*l);this.pose()}},THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.SkinnedMesh.prototype.addBone=function(e){return void 0===e&&(e=new THREE.Bone(this)),this.bones.push(e),e},THREE.SkinnedMesh.prototype.updateMatrixWorld=function(){var e=new THREE.Matrix4;return function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent?this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var i=0,r=this.children.length;i1){var h=s[1];s[2];i[h]||(i[h]={start:1/0,end:-(1/0)});var l=i[h];ol.end&&(l.end=o),t||(t=h)}}e.firstAnimation=t},THREE.MorphAnimMesh.prototype.setAnimationLabel=function(e,t,i){this.geometry.animations||(this.geometry.animations={}),this.geometry.animations[e]={start:t,end:i}},THREE.MorphAnimMesh.prototype.playAnimation=function(e,t){var i=this.geometry.animations[e];i?(this.setFrameRange(i.start,i.end),this.duration=1e3*((i.end-i.start)/t),this.time=0):console.warn("animation["+e+"] undefined")},THREE.MorphAnimMesh.prototype.updateAnimation=function(e){var t=this.duration/this.length;this.time+=this.direction*e,this.mirroredLoop?(this.time>this.duration||this.time<0)&&(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),this.time<0&&(this.time=0,this.directionBackwards=!1)):(this.time=this.time%this.duration,this.time<0&&(this.time+=this.duration));var i=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/t),0,this.length-1);i!==this.currentKeyframe&&(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[i]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=i);var r=this.time%t/t;this.directionBackwards&&(r=1-r),this.morphTargetInfluences[this.currentKeyframe]=r,this.morphTargetInfluences[this.lastKeyframe]=1-r},THREE.MorphAnimMesh.prototype.clone=function(e){return void 0===e&&(e=new THREE.MorphAnimMesh(this.geometry,this.material)),e.duration=this.duration,e.mirroredLoop=this.mirroredLoop,e.time=this.time,e.lastKeyframe=this.lastKeyframe,e.currentKeyframe=this.currentKeyframe,e.direction=this.direction,e.directionBackwards=this.directionBackwards,THREE.Mesh.prototype.clone.call(this,e),e},THREE.Ribbon=function(e,t){THREE.Object3D.call(this),this.geometry=e,this.material=t},THREE.Ribbon.prototype=Object.create(THREE.Object3D.prototype),THREE.Ribbon.prototype.clone=function(e){return void 0===e&&(e=new THREE.Ribbon(this.geometry,this.material)),THREE.Object3D.prototype.clone.call(this,e),e},THREE.LOD=function(){THREE.Object3D.call(this),this.objects=[]},THREE.LOD.prototype=Object.create(THREE.Object3D.prototype),THREE.LOD.prototype.addLevel=function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var i=0;i1){e.getPositionFromMatrix(i.matrixWorld),t.getPositionFromMatrix(this.matrixWorld);var r=e.distanceTo(t);this.objects[0].object.visible=!0;for(var o=1,a=this.objects.length;o=this.objects[o].distance;o++)this.objects[o-1].object.visible=!1,this.objects[o].object.visible=!0;for(;o>1,l=s.height>>1,a=t.scale.x*C,n=t.scale.y*A,r=a*h,o=n*l,Be.min.set(e.x-r,e.y-o),Be.max.set(e.x+r,e.y+o),ze.isIntersectionBox(Be)===!1)return void Be.makeEmpty();de.save(),de.translate(e.x,e.y),de.rotate(-t.rotation),de.scale(a,-n),de.translate(-h,-l),de.drawImage(s,0,0),de.restore()}else if(i instanceof THREE.ParticleCanvasMaterial){if(r=t.scale.x*C,o=t.scale.y*A,Be.min.set(e.x-r,e.y-o),Be.max.set(e.x+r,e.y+o), ze.isIntersectionBox(Be)===!1)return void Be.makeEmpty();y(i.color.getStyle()),R(i.color.getStyle()),de.save(),de.translate(e.x,e.y),de.rotate(-t.rotation),de.scale(r,o),i.program(de),de.restore()}}function o(e,t,i,r){if(E(r.opacity),m(r.blending),de.beginPath(),de.moveTo(e.positionScreen.x,e.positionScreen.y),de.lineTo(t.positionScreen.x,t.positionScreen.y),r instanceof THREE.LineBasicMaterial){if(g(r.linewidth),v(r.linecap),T(r.linejoin),r.vertexColors!==THREE.VertexColors)y(r.color.getStyle());else{var o=i.vertexColors[0].getStyle(),a=i.vertexColors[1].getStyle();if(o===a)y(o);else{try{var n=de.createLinearGradient(e.positionScreen.x,e.positionScreen.y,t.positionScreen.x,t.positionScreen.y);n.addColorStop(0,o),n.addColorStop(1,a)}catch(e){n=o}y(n)}}de.stroke(),Be.expandByScalar(2*r.linewidth)}else r instanceof THREE.LineDashedMaterial&&(g(r.linewidth),v(r.linecap),T(r.linejoin),y(r.color.getStyle()),x(r.dashSize,r.gapSize),de.stroke(),Be.expandByScalar(2*r.linewidth),x(null,null))}function a(e,t,r,o,a,n,h,f){if(ce.info.render.vertices+=3,ce.info.render.faces++,E(f.opacity),m(f.blending),V=e.positionScreen.x,z=e.positionScreen.y,N=t.positionScreen.x,B=t.positionScreen.y,O=r.positionScreen.x,I=r.positionScreen.y,s(V,z,N,B,O,I),(f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)&&null===f.map)Pe.copy(f.color),De.copy(f.emissive),f.vertexColors===THREE.FaceColors&&Pe.multiply(h.color),f.wireframe===!1&&f.shading==THREE.SmoothShading&&3==h.vertexNormalsLength?(Se.copy(Oe),Ce.copy(Oe),Ae.copy(Oe),i(h.v1.positionWorld,h.vertexNormalsModel[0],Se),i(h.v2.positionWorld,h.vertexNormalsModel[1],Ce),i(h.v3.positionWorld,h.vertexNormalsModel[2],Ae),Se.multiply(Pe).add(De),Ce.multiply(Pe).add(De),Ae.multiply(Pe).add(De),Le.addColors(Ce,Ae).multiplyScalar(.5),K=d(Se,Ce,Ae,Le),p(V,z,N,B,O,I,0,0,1,0,0,1,K)):(Me.copy(Oe),i(h.centroidModel,h.normalModel,Me),Me.multiply(Pe).add(De),f.wireframe===!0?l(Me,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):c(Me));else if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)null!==f.map?f.map.mapping instanceof THREE.UVMapping&&(Z=h.uvs[0],u(V,z,N,B,O,I,Z[o].x,Z[o].y,Z[a].x,Z[a].y,Z[n].x,Z[n].y,f.map)):null!==f.envMap?f.envMap.mapping instanceof THREE.SphericalReflectionMapping&&(je.copy(h.vertexNormalsModelView[o]),J=.5*je.x+.5,$=.5*je.y+.5,je.copy(h.vertexNormalsModelView[a]),ee=.5*je.x+.5,te=.5*je.y+.5,je.copy(h.vertexNormalsModelView[n]),ie=.5*je.x+.5,re=.5*je.y+.5,u(V,z,N,B,O,I,J,$,ee,te,ie,re,f.envMap)):(Me.copy(f.color),f.vertexColors===THREE.FaceColors&&Me.multiply(h.color),f.wireframe===!0?l(Me,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):c(Me));else if(f instanceof THREE.MeshDepthMaterial)q=L.near,Q=L.far,Se.r=Se.g=Se.b=1-H(e.positionScreen.z*e.positionScreen.w,q,Q),Ce.r=Ce.g=Ce.b=1-H(t.positionScreen.z*t.positionScreen.w,q,Q),Ae.r=Ae.g=Ae.b=1-H(r.positionScreen.z*r.positionScreen.w,q,Q),Le.addColors(Ce,Ae).multiplyScalar(.5),K=d(Se,Ce,Ae,Le),p(V,z,N,B,O,I,0,0,1,0,0,1,K);else if(f instanceof THREE.MeshNormalMaterial){var g;f.shading==THREE.FlatShading?(g=h.normalModelView,Me.setRGB(g.x,g.y,g.z).multiplyScalar(.5).addScalar(.5),f.wireframe===!0?l(Me,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):c(Me)):f.shading==THREE.SmoothShading&&(g=h.vertexNormalsModelView[o],Se.setRGB(g.x,g.y,g.z).multiplyScalar(.5).addScalar(.5),g=h.vertexNormalsModelView[a],Ce.setRGB(g.x,g.y,g.z).multiplyScalar(.5).addScalar(.5),g=h.vertexNormalsModelView[n],Ae.setRGB(g.x,g.y,g.z).multiplyScalar(.5).addScalar(.5),Le.addColors(Ce,Ae).multiplyScalar(.5),K=d(Se,Ce,Ae,Le),p(V,z,N,B,O,I,0,0,1,0,0,1,K))}}function n(e,t,r,o,n,u,f,g){if(ce.info.render.vertices+=4,ce.info.render.faces++,E(g.opacity),m(g.blending),void 0!==g.map&&null!==g.map||void 0!==g.envMap&&null!==g.envMap)return a(e,t,o,0,1,3,f,g),void a(n,r,u,1,2,3,f,g);if(V=e.positionScreen.x,z=e.positionScreen.y,N=t.positionScreen.x,B=t.positionScreen.y,O=r.positionScreen.x,I=r.positionScreen.y,k=o.positionScreen.x,j=o.positionScreen.y,G=n.positionScreen.x,W=n.positionScreen.y,X=u.positionScreen.x,Y=u.positionScreen.y,g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial)Pe.copy(g.color),De.copy(g.emissive),g.vertexColors===THREE.FaceColors&&Pe.multiply(f.color),g.wireframe===!1&&g.shading==THREE.SmoothShading&&4==f.vertexNormalsLength?(Se.copy(Oe),Ce.copy(Oe),Ae.copy(Oe),Le.copy(Oe),i(f.v1.positionWorld,f.vertexNormalsModel[0],Se),i(f.v2.positionWorld,f.vertexNormalsModel[1],Ce),i(f.v4.positionWorld,f.vertexNormalsModel[3],Ae),i(f.v3.positionWorld,f.vertexNormalsModel[2],Le),Se.multiply(Pe).add(De),Ce.multiply(Pe).add(De),Ae.multiply(Pe).add(De),Le.multiply(Pe).add(De),K=d(Se,Ce,Ae,Le),s(V,z,N,B,k,j),p(V,z,N,B,k,j,0,0,1,0,0,1,K),s(G,W,O,I,X,Y),p(G,W,O,I,X,Y,1,0,1,1,0,1,K)):(Me.copy(Oe),i(f.centroidModel,f.normalModel,Me),Me.multiply(Pe).add(De),h(V,z,N,B,O,I,k,j),g.wireframe===!0?l(Me,g.wireframeLinewidth,g.wireframeLinecap,g.wireframeLinejoin):c(Me));else if(g instanceof THREE.MeshBasicMaterial)Me.copy(g.color),g.vertexColors===THREE.FaceColors&&Me.multiply(f.color),h(V,z,N,B,O,I,k,j),g.wireframe===!0?l(Me,g.wireframeLinewidth,g.wireframeLinecap,g.wireframeLinejoin):c(Me);else if(g instanceof THREE.MeshNormalMaterial){var v;g.shading==THREE.FlatShading?(v=f.normalModelView,Me.setRGB(v.x,v.y,v.z).multiplyScalar(.5).addScalar(.5),h(V,z,N,B,O,I,k,j),g.wireframe===!0?l(Me,g.wireframeLinewidth,g.wireframeLinecap,g.wireframeLinejoin):c(Me)):g.shading==THREE.SmoothShading&&(v=f.vertexNormalsModelView[0],Se.setRGB(v.x,v.y,v.z).multiplyScalar(.5).addScalar(.5),v=f.vertexNormalsModelView[1],Ce.setRGB(v.x,v.y,v.z).multiplyScalar(.5).addScalar(.5),v=f.vertexNormalsModelView[3],Ae.setRGB(v.x,v.y,v.z).multiplyScalar(.5).addScalar(.5),v=f.vertexNormalsModelView[2],Le.setRGB(v.x,v.y,v.z).multiplyScalar(.5).addScalar(.5),K=d(Se,Ce,Ae,Le),s(V,z,N,B,k,j),p(V,z,N,B,k,j,0,0,1,0,0,1,K),s(G,W,O,I,X,Y),p(G,W,O,I,X,Y,1,0,1,1,0,1,K))}else g instanceof THREE.MeshDepthMaterial&&(q=L.near,Q=L.far,Se.r=Se.g=Se.b=1-H(e.positionScreen.z*e.positionScreen.w,q,Q),Ce.r=Ce.g=Ce.b=1-H(t.positionScreen.z*t.positionScreen.w,q,Q),Ae.r=Ae.g=Ae.b=1-H(o.positionScreen.z*o.positionScreen.w,q,Q),Le.r=Le.g=Le.b=1-H(r.positionScreen.z*r.positionScreen.w,q,Q),K=d(Se,Ce,Ae,Le),s(V,z,N,B,k,j),p(V,z,N,B,k,j,0,0,1,0,0,1,K),s(G,W,O,I,X,Y),p(G,W,O,I,X,Y,1,0,1,1,0,1,K))}function s(e,t,i,r,o,a){de.beginPath(),de.moveTo(e,t),de.lineTo(i,r),de.lineTo(o,a),de.closePath()}function h(e,t,i,r,o,a,n,s){de.beginPath(),de.moveTo(e,t),de.lineTo(i,r),de.lineTo(o,a),de.lineTo(n,s),de.closePath()}function l(e,t,i,r){g(t),v(i),T(r),y(e.getStyle()),de.stroke(),Be.expandByScalar(2*t)}function c(e){R(e.getStyle()),de.fill()}function u(e,t,i,r,o,a,n,s,h,l,u,p,d){if(!(d instanceof THREE.DataTexture||void 0===d.image||0==d.image.width)){if(d.needsUpdate===!0){var f=d.wrapS==THREE.RepeatWrapping,E=d.wrapT==THREE.RepeatWrapping;Ue[d.id]=de.createPattern(d.image,f===!0&&E===!0?"repeat":f===!0&&E===!1?"repeat-x":f===!1&&E===!0?"repeat-y":"no-repeat"),d.needsUpdate=!1}R(void 0===Ue[d.id]?"rgba(0,0,0,1)":Ue[d.id]);var m,g,v,T,y,x,H,w,_=d.offset.x/d.repeat.x,b=d.offset.y/d.repeat.y,M=d.image.width*d.repeat.x,S=d.image.height*d.repeat.y;if(n=(n+_)*M,s=(1-s+b)*S,h=(h+_)*M,l=(1-l+b)*S,u=(u+_)*M,p=(1-p+b)*S,i-=e,r-=t,o-=e,a-=t,h-=n,l-=s,u-=n,p-=s,H=h*p-u*l,0===H){if(void 0===Ve[d.id]){var C=document.createElement("canvas");C.width=d.image.width,C.height=d.image.height;var A=C.getContext("2d");A.drawImage(d.image,0,0),Ve[d.id]=A.getImageData(0,0,d.image.width,d.image.height).data}var L=Ve[d.id],P=4*(Math.floor(n)+Math.floor(s)*d.image.width);return Me.setRGB(L[P]/255,L[P+1]/255,L[P+2]/255),void c(Me)}w=1/H,m=(p*i-l*o)*w,g=(p*r-l*a)*w,v=(h*o-u*i)*w,T=(h*a-u*r)*w,y=e-m*n-v*s,x=t-g*n-T*s,de.save(),de.transform(m,g,v,T,y,x),de.fill(),de.restore()}}function p(e,t,i,r,o,a,n,s,h,l,c,u,p){var d,f,E,m,g,v,T,y,R=p.width-1,x=p.height-1;n*=R,s*=x,h*=R,l*=x,c*=R,u*=x,i-=e,r-=t,o-=e,a-=t,h-=n,l-=s,c-=n,u-=s,T=h*u-c*l,y=1/T,d=(u*i-l*o)*y,f=(u*r-l*a)*y,E=(h*o-c*i)*y,m=(h*a-c*r)*y,g=e-d*n-E*s,v=t-f*n-m*s,de.save(),de.transform(d,f,E,m,g,v),de.clip(),de.drawImage(p,0,0),de.restore()}function d(e,t,i,r){return se[0]=255*e.r|0,se[1]=255*e.g|0,se[2]=255*e.b|0,se[4]=255*t.r|0,se[5]=255*t.g|0,se[6]=255*t.b|0,se[8]=255*i.r|0,se[9]=255*i.g|0,se[10]=255*i.b|0,se[12]=255*r.r|0,se[13]=255*r.g|0,se[14]=255*r.b|0,ae.putImageData(ne,0,0),le.drawImage(oe,0,0),he}function f(e,t,i){var r,o=t.x-e.x,a=t.y-e.y,n=o*o+a*a;0!==n&&(r=i/Math.sqrt(n),o*=r,a*=r,t.x+=o,t.y+=a,e.x-=o,e.y-=a)}function E(e){me!==e&&(de.globalAlpha=e,me=e)}function m(e){ge!==e&&(e===THREE.NormalBlending?de.globalCompositeOperation="source-over":e===THREE.AdditiveBlending?de.globalCompositeOperation="lighter":e===THREE.SubtractiveBlending&&(de.globalCompositeOperation="darker"),ge=e)}function g(e){ye!==e&&(de.lineWidth=e,ye=e)}function v(e){Re!==e&&(de.lineCap=e,Re=e)}function T(e){xe!==e&&(de.lineJoin=e,xe=e)}function y(e){ve!==e&&(de.strokeStyle=e,ve=e)}function R(e){Te!==e&&(de.fillStyle=e,Te=e)}function x(e,t){He===e&&we===t||(de.setLineDash([e,t]),He=e,we=t)}console.log("THREE.CanvasRenderer",THREE.REVISION);var H=THREE.Math.smoothstep;e=e||{};var w,_,b,M,S,C,A,L,P,D,F,U,V,z,N,B,O,I,k,j,G,W,X,Y,q,Q,K,Z,J,$,ee,te,ie,re,oe,ae,ne,se,he,le,ce=this,ue=new THREE.Projector,pe=void 0!==e.canvas?e.canvas:document.createElement("canvas"),de=pe.getContext("2d"),fe=new THREE.Color(0),Ee=0,me=1,ge=0,ve=null,Te=null,ye=null,Re=null,xe=null,He=null,we=0,_e=new THREE.RenderableVertex,be=new THREE.RenderableVertex,Me=new THREE.Color,Se=new THREE.Color,Ce=new THREE.Color,Ae=new THREE.Color,Le=new THREE.Color,Pe=new THREE.Color,De=new THREE.Color,Fe=new THREE.Color,Ue={},Ve={},ze=new THREE.Box2,Ne=new THREE.Box2,Be=new THREE.Box2,Oe=new THREE.Color,Ie=new THREE.Color,ke=new THREE.Color,je=new THREE.Vector3,Ge=16;oe=document.createElement("canvas"),oe.width=oe.height=2,ae=oe.getContext("2d"),ae.fillStyle="rgba(0,0,0,1)",ae.fillRect(0,0,2,2),ne=ae.getImageData(0,0,2,2),se=ne.data,he=document.createElement("canvas"),he.width=he.height=Ge,le=he.getContext("2d"),le.translate(-Ge/2,-Ge/2),le.scale(Ge,Ge),Ge--,void 0===de.setLineDash&&(void 0!==de.mozDash?de.setLineDash=function(e){de.mozDash=null!==e[0]?e:null}:de.setLineDash=function(){}),this.domElement=pe,this.devicePixelRatio=void 0!==e.devicePixelRatio?e.devicePixelRatio:void 0!==window.devicePixelRatio?window.devicePixelRatio:1,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.supportsVertexTextures=function(){},this.setFaceCulling=function(){},this.setSize=function(e,t,i){M=e*this.devicePixelRatio,S=t*this.devicePixelRatio,C=Math.floor(M/2),A=Math.floor(S/2),pe.width=M,pe.height=S,1!==this.devicePixelRatio&&i!==!1&&(pe.style.width=e+"px",pe.style.height=t+"px"),ze.set(new THREE.Vector2((-C),(-A)),new THREE.Vector2(C,A)),Ne.set(new THREE.Vector2((-C),(-A)),new THREE.Vector2(C,A)),me=1,ge=0,ve=null,Te=null,ye=null,Re=null,xe=null},this.setClearColor=function(e,t){fe.set(e),Ee=void 0!==t?t:1,Ne.set(new THREE.Vector2((-C),(-A)),new THREE.Vector2(C,A))},this.setClearColorHex=function(e,t){console.warn("DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(e,t)},this.getMaxAnisotropy=function(){return 0},this.clear=function(){de.setTransform(1,0,0,-1,C,A),Ne.empty()===!1&&(Ne.intersect(ze),Ne.expandByScalar(2),Ee<1&&de.clearRect(0|Ne.min.x,0|Ne.min.y,Ne.max.x-Ne.min.x|0,Ne.max.y-Ne.min.y|0),Ee>0&&(m(THREE.NormalBlending),E(1),R("rgba("+Math.floor(255*fe.r)+","+Math.floor(255*fe.g)+","+Math.floor(255*fe.b)+","+Ee+")"),de.fillRect(0|Ne.min.x,0|Ne.min.y,Ne.max.x-Ne.min.x|0,Ne.max.y-Ne.min.y|0)),Ne.makeEmpty())},this.render=function(e,i){if(i instanceof THREE.Camera==!1)return void console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");this.autoClear===!0&&this.clear(),de.setTransform(1,0,0,-1,C,A),ce.info.render.vertices=0,ce.info.render.faces=0,w=ue.projectScene(e,i,this.sortObjects,this.sortElements),_=w.elements,b=w.lights,L=i,t();for(var s=0,h=_.length;s1)continue;if(D.positionScreen.z<-1||D.positionScreen.z>1)continue;if(F.positionScreen.z<-1||F.positionScreen.z>1)continue;P.positionScreen.x*=C,P.positionScreen.y*=A,D.positionScreen.x*=C,D.positionScreen.y*=A,F.positionScreen.x*=C,F.positionScreen.y*=A,c.overdraw>0&&(f(P.positionScreen,D.positionScreen,c.overdraw),f(D.positionScreen,F.positionScreen,c.overdraw),f(F.positionScreen,P.positionScreen,c.overdraw)),Be.setFromPoints([P.positionScreen,D.positionScreen,F.positionScreen]),ze.isIntersectionBox(Be)===!0&&a(P,D,F,0,1,2,l,c)}else if(l instanceof THREE.RenderableFace4){if(P=l.v1,D=l.v2,F=l.v3,U=l.v4,P.positionScreen.z<-1||P.positionScreen.z>1)continue;if(D.positionScreen.z<-1||D.positionScreen.z>1)continue;if(F.positionScreen.z<-1||F.positionScreen.z>1)continue;if(U.positionScreen.z<-1||U.positionScreen.z>1)continue;P.positionScreen.x*=C,P.positionScreen.y*=A,D.positionScreen.x*=C,D.positionScreen.y*=A,F.positionScreen.x*=C,F.positionScreen.y*=A,U.positionScreen.x*=C,U.positionScreen.y*=A,_e.positionScreen.copy(D.positionScreen),be.positionScreen.copy(U.positionScreen),c.overdraw>0&&(f(P.positionScreen,D.positionScreen,c.overdraw),f(D.positionScreen,U.positionScreen,c.overdraw),f(U.positionScreen,P.positionScreen,c.overdraw),f(F.positionScreen,_e.positionScreen,c.overdraw),f(F.positionScreen,be.positionScreen,c.overdraw)),Be.setFromPoints([P.positionScreen,D.positionScreen,F.positionScreen,U.positionScreen]),ze.isIntersectionBox(Be)===!0&&n(P,D,F,U,_e,be,l,c)}Ne.union(Be)}}de.setTransform(1,0,0,1,0,0)}},THREE.ShaderChunk={fog_pars_fragment:["#ifdef USE_FOG","uniform vec3 fogColor;","#ifdef FOG_EXP2","uniform float fogDensity;","#else","uniform float fogNear;","uniform float fogFar;","#endif","#endif"].join("\n"),fog_fragment:["#ifdef USE_FOG","float depth = gl_FragCoord.z / gl_FragCoord.w;","#ifdef FOG_EXP2","const float LOG2 = 1.442695;","float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","#else","float fogFactor = smoothstep( fogNear, fogFar, depth );","#endif","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","#endif"].join("\n"),envmap_pars_fragment:["#ifdef USE_ENVMAP","uniform float reflectivity;","uniform samplerCube envMap;","uniform float flipEnvMap;","uniform int combine;","#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )","uniform bool useRefract;","uniform float refractionRatio;","#else","varying vec3 vReflect;","#endif","#endif"].join("\n"),envmap_fragment:["#ifdef USE_ENVMAP","vec3 reflectVec;","#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )","vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );","if ( useRefract ) {","reflectVec = refract( cameraToVertex, normal, refractionRatio );","} else { ","reflectVec = reflect( cameraToVertex, normal );","}","#else","reflectVec = vReflect;","#endif","#ifdef DOUBLE_SIDED","float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );","vec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );","#else","vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );","#endif","#ifdef GAMMA_INPUT","cubeColor.xyz *= cubeColor.xyz;","#endif","if ( combine == 1 ) {","gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );","} else if ( combine == 2 ) {","gl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;","} else {","gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );","}","#endif"].join("\n"),envmap_pars_vertex:["#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )","varying vec3 vReflect;","uniform float refractionRatio;","uniform bool useRefract;","#endif"].join("\n"),worldpos_vertex:["#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )","#ifdef USE_SKINNING","vec4 worldPosition = modelMatrix * skinned;","#endif","#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )","vec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );","#endif","#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","#endif","#endif"].join("\n"),envmap_vertex:["#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )","vec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;","worldNormal = normalize( worldNormal );","vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );","if ( useRefract ) {","vReflect = refract( cameraToVertex, worldNormal, refractionRatio );","} else {","vReflect = reflect( cameraToVertex, worldNormal );","}","#endif"].join("\n"),map_particle_pars_fragment:["#ifdef USE_MAP","uniform sampler2D map;","#endif"].join("\n"),map_particle_fragment:["#ifdef USE_MAP","gl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );","#endif"].join("\n"),map_pars_vertex:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","varying vec2 vUv;","uniform vec4 offsetRepeat;","#endif"].join("\n"),map_pars_fragment:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","varying vec2 vUv;","#endif","#ifdef USE_MAP","uniform sampler2D map;","#endif"].join("\n"),map_vertex:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","vUv = uv * offsetRepeat.zw + offsetRepeat.xy;","#endif"].join("\n"),map_fragment:["#ifdef USE_MAP","vec4 texelColor = texture2D( map, vUv );","#ifdef GAMMA_INPUT","texelColor.xyz *= texelColor.xyz;","#endif","gl_FragColor = gl_FragColor * texelColor;","#endif"].join("\n"),lightmap_pars_fragment:["#ifdef USE_LIGHTMAP","varying vec2 vUv2;","uniform sampler2D lightMap;","#endif"].join("\n"),lightmap_pars_vertex:["#ifdef USE_LIGHTMAP","varying vec2 vUv2;","#endif"].join("\n"),lightmap_fragment:["#ifdef USE_LIGHTMAP","gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );","#endif"].join("\n"),lightmap_vertex:["#ifdef USE_LIGHTMAP","vUv2 = uv2;","#endif"].join("\n"),bumpmap_pars_fragment:["#ifdef USE_BUMPMAP","uniform sampler2D bumpMap;","uniform float bumpScale;","vec2 dHdxy_fwd() {","vec2 dSTdx = dFdx( vUv );","vec2 dSTdy = dFdy( vUv );","float Hll = bumpScale * texture2D( bumpMap, vUv ).x;","float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;","float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;","return vec2( dBx, dBy );","}","vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {","vec3 vSigmaX = dFdx( surf_pos );","vec3 vSigmaY = dFdy( surf_pos );","vec3 vN = surf_norm;","vec3 R1 = cross( vSigmaY, vN );","vec3 R2 = cross( vN, vSigmaX );","float fDet = dot( vSigmaX, R1 );","vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );","return normalize( abs( fDet ) * surf_norm - vGrad );","}","#endif"].join("\n"),normalmap_pars_fragment:["#ifdef USE_NORMALMAP","uniform sampler2D normalMap;","uniform vec2 normalScale;","vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {","vec3 q0 = dFdx( eye_pos.xyz );","vec3 q1 = dFdy( eye_pos.xyz );","vec2 st0 = dFdx( vUv.st );","vec2 st1 = dFdy( vUv.st );","vec3 S = normalize( q0 * st1.t - q1 * st0.t );","vec3 T = normalize( -q0 * st1.s + q1 * st0.s );","vec3 N = normalize( surf_norm );","vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;","mapN.xy = normalScale * mapN.xy;","mat3 tsn = mat3( S, T, N );","return normalize( tsn * mapN );","}","#endif"].join("\n"),specularmap_pars_fragment:["#ifdef USE_SPECULARMAP","uniform sampler2D specularMap;","#endif"].join("\n"),specularmap_fragment:["float specularStrength;","#ifdef USE_SPECULARMAP","vec4 texelSpecular = texture2D( specularMap, vUv );","specularStrength = texelSpecular.r;","#else","specularStrength = 1.0;","#endif"].join("\n"),lights_lambert_pars_vertex:["uniform vec3 ambient;","uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif"].join("\n"),lights_lambert_vertex:["vLightFront = vec3( 0.0 );","#ifdef DOUBLE_SIDED","vLightBack = vec3( 0.0 );","#endif","transformedNormal = normalize( transformedNormal );","#if MAX_DIR_LIGHTS > 0","for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","float dotProduct = dot( transformedNormal, dirVector );","vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += directionalLightColor[ i ] * directionalLightWeighting;","#ifdef DOUBLE_SIDED","vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;","#endif","}","#endif","#if MAX_POINT_LIGHTS > 0","for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","float dotProduct = dot( transformedNormal, lVector );","vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;","#ifdef DOUBLE_SIDED","vLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","float dotProduct = dot( transformedNormal, lVector );","vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;","#ifdef DOUBLE_SIDED","vLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;","#endif","}","}","#endif","#if MAX_HEMI_LIGHTS > 0","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( transformedNormal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","float hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;","vLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","#ifdef DOUBLE_SIDED","vLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );","#endif","}","#endif","vLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;","#ifdef DOUBLE_SIDED","vLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;","#endif"].join("\n"),lights_phong_pars_vertex:["#ifndef PHONG_PER_PIXEL","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","varying vec4 vPointLight[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","varying vec3 vWorldPosition;","#endif"].join("\n"),lights_phong_vertex:["#ifndef PHONG_PER_PIXEL","#if MAX_POINT_LIGHTS > 0","for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","vPointLight[ i ] = vec4( lVector, lDistance );","}","#endif","#if MAX_SPOT_LIGHTS > 0","for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","vSpotLight[ i ] = vec4( lVector, lDistance );","}","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","vWorldPosition = worldPosition.xyz;","#endif"].join("\n"),lights_phong_pars_fragment:["uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","#ifdef PHONG_PER_PIXEL","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#else","varying vec4 vPointLight[ MAX_POINT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","#ifdef PHONG_PER_PIXEL","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","#else","varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","varying vec3 vWorldPosition;","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif","varying vec3 vViewPosition;","varying vec3 vNormal;"].join("\n"),lights_phong_fragment:["vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );","#ifdef DOUBLE_SIDED","normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );","#endif","#ifdef USE_NORMALMAP","normal = perturbNormal2Arb( -vViewPosition, normal );","#elif defined( USE_BUMPMAP )","normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );","#endif","#if MAX_POINT_LIGHTS > 0","vec3 pointDiffuse = vec3( 0.0 );","vec3 pointSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","#ifdef PHONG_PER_PIXEL","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz + vViewPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","#else","vec3 lVector = normalize( vPointLight[ i ].xyz );","float lDistance = vPointLight[ i ].w;","#endif","float dotProduct = dot( normal, lVector );","#ifdef WRAP_AROUND","float pointDiffuseWeightFull = max( dotProduct, 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );","#else","float pointDiffuseWeight = max( dotProduct, 0.0 );","#endif","pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;","vec3 pointHalfVector = normalize( lVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );","pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;","#else","pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","vec3 spotDiffuse = vec3( 0.0 );","vec3 spotSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","#ifdef PHONG_PER_PIXEL","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz + vViewPosition.xyz;","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","#else","vec3 lVector = normalize( vSpotLight[ i ].xyz );","float lDistance = vSpotLight[ i ].w;","#endif","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","float dotProduct = dot( normal, lVector );","#ifdef WRAP_AROUND","float spotDiffuseWeightFull = max( dotProduct, 0.0 );","float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );","#else","float spotDiffuseWeight = max( dotProduct, 0.0 );","#endif","spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;","vec3 spotHalfVector = normalize( lVector + viewPosition );","float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );","float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );","spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;","#else","spotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;","#endif","}","}","#endif","#if MAX_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, dirVector );","#ifdef WRAP_AROUND","float dirDiffuseWeightFull = max( dotProduct, 0.0 );","float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );","#else","float dirDiffuseWeight = max( dotProduct, 0.0 );","#endif","dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );","dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;","#else","dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;","#endif","}","#endif","#if MAX_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","hemiDiffuse += diffuse * hemiColor;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","float hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","float hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float dotProductGround = dot( normal, lVectorGround );","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );","vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );","hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );","#else","hemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;","#endif","}","#endif","vec3 totalDiffuse = vec3( 0.0 );","vec3 totalSpecular = vec3( 0.0 );","#if MAX_DIR_LIGHTS > 0","totalDiffuse += dirDiffuse;","totalSpecular += dirSpecular;","#endif","#if MAX_HEMI_LIGHTS > 0","totalDiffuse += hemiDiffuse;","totalSpecular += hemiSpecular;","#endif","#if MAX_POINT_LIGHTS > 0","totalDiffuse += pointDiffuse;","totalSpecular += pointSpecular;","#endif","#if MAX_SPOT_LIGHTS > 0","totalDiffuse += spotDiffuse;","totalSpecular += spotSpecular;","#endif","#ifdef METAL","gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );","#else","gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;","#endif"].join("\n"), color_pars_fragment:["#ifdef USE_COLOR","varying vec3 vColor;","#endif"].join("\n"),color_fragment:["#ifdef USE_COLOR","gl_FragColor = gl_FragColor * vec4( vColor, opacity );","#endif"].join("\n"),color_pars_vertex:["#ifdef USE_COLOR","varying vec3 vColor;","#endif"].join("\n"),color_vertex:["#ifdef USE_COLOR","#ifdef GAMMA_INPUT","vColor = color * color;","#else","vColor = color;","#endif","#endif"].join("\n"),skinning_pars_vertex:["#ifdef USE_SKINNING","#ifdef BONE_TEXTURE","uniform sampler2D boneTexture;","mat4 getBoneMatrix( const in float i ) {","float j = i * 4.0;","float x = mod( j, N_BONE_PIXEL_X );","float y = floor( j / N_BONE_PIXEL_X );","const float dx = 1.0 / N_BONE_PIXEL_X;","const float dy = 1.0 / N_BONE_PIXEL_Y;","y = dy * ( y + 0.5 );","vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );","vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );","vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );","vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );","mat4 bone = mat4( v1, v2, v3, v4 );","return bone;","}","#else","uniform mat4 boneGlobalMatrices[ MAX_BONES ];","mat4 getBoneMatrix( const in float i ) {","mat4 bone = boneGlobalMatrices[ int(i) ];","return bone;","}","#endif","#endif"].join("\n"),skinbase_vertex:["#ifdef USE_SKINNING","mat4 boneMatX = getBoneMatrix( skinIndex.x );","mat4 boneMatY = getBoneMatrix( skinIndex.y );","#endif"].join("\n"),skinning_vertex:["#ifdef USE_SKINNING","#ifdef USE_MORPHTARGETS","vec4 skinVertex = vec4( morphed, 1.0 );","#else","vec4 skinVertex = vec4( position, 1.0 );","#endif","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned \t += boneMatY * skinVertex * skinWeight.y;","#endif"].join("\n"),morphtarget_pars_vertex:["#ifdef USE_MORPHTARGETS","#ifndef USE_MORPHNORMALS","uniform float morphTargetInfluences[ 8 ];","#else","uniform float morphTargetInfluences[ 4 ];","#endif","#endif"].join("\n"),morphtarget_vertex:["#ifdef USE_MORPHTARGETS","vec3 morphed = vec3( 0.0 );","morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];","morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];","morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];","morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];","#ifndef USE_MORPHNORMALS","morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];","morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];","morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];","morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];","#endif","morphed += position;","#endif"].join("\n"),default_vertex:["vec4 mvPosition;","#ifdef USE_SKINNING","mvPosition = modelViewMatrix * skinned;","#endif","#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )","mvPosition = modelViewMatrix * vec4( morphed, 1.0 );","#endif","#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )","mvPosition = modelViewMatrix * vec4( position, 1.0 );","#endif","gl_Position = projectionMatrix * mvPosition;"].join("\n"),morphnormal_vertex:["#ifdef USE_MORPHNORMALS","vec3 morphedNormal = vec3( 0.0 );","morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];","morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];","morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];","morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];","morphedNormal += normal;","#endif"].join("\n"),skinnormal_vertex:["#ifdef USE_SKINNING","mat4 skinMatrix = skinWeight.x * boneMatX;","skinMatrix \t+= skinWeight.y * boneMatY;","#ifdef USE_MORPHNORMALS","vec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );","#else","vec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );","#endif","#endif"].join("\n"),defaultnormal_vertex:["vec3 objectNormal;","#ifdef USE_SKINNING","objectNormal = skinnedNormal.xyz;","#endif","#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )","objectNormal = morphedNormal;","#endif","#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )","objectNormal = normal;","#endif","#ifdef FLIP_SIDED","objectNormal = -objectNormal;","#endif","vec3 transformedNormal = normalMatrix * objectNormal;"].join("\n"),shadowmap_pars_fragment:["#ifdef USE_SHADOWMAP","uniform sampler2D shadowMap[ MAX_SHADOWS ];","uniform vec2 shadowMapSize[ MAX_SHADOWS ];","uniform float shadowDarkness[ MAX_SHADOWS ];","uniform float shadowBias[ MAX_SHADOWS ];","varying vec4 vShadowCoord[ MAX_SHADOWS ];","float unpackDepth( const in vec4 rgba_depth ) {","const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );","float depth = dot( rgba_depth, bit_shift );","return depth;","}","#endif"].join("\n"),shadowmap_fragment:["#ifdef USE_SHADOWMAP","#ifdef SHADOWMAP_DEBUG","vec3 frustumColors[3];","frustumColors[0] = vec3( 1.0, 0.5, 0.0 );","frustumColors[1] = vec3( 0.0, 1.0, 0.8 );","frustumColors[2] = vec3( 0.0, 0.5, 1.0 );","#endif","#ifdef SHADOWMAP_CASCADE","int inFrustumCount = 0;","#endif","float fDepth;","vec3 shadowColor = vec3( 1.0 );","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;","bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );","bool inFrustum = all( inFrustumVec );","#ifdef SHADOWMAP_CASCADE","inFrustumCount += int( inFrustum );","bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );","#else","bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );","#endif","bool frustumTest = all( frustumTestVec );","if ( frustumTest ) {","shadowCoord.z += shadowBias[ i ];","#if defined( SHADOWMAP_TYPE_PCF )","float shadow = 0.0;","const float shadowDelta = 1.0 / 9.0;","float xPixelOffset = 1.0 / shadowMapSize[ i ].x;","float yPixelOffset = 1.0 / shadowMapSize[ i ].y;","float dx0 = -1.25 * xPixelOffset;","float dy0 = -1.25 * yPixelOffset;","float dx1 = 1.25 * xPixelOffset;","float dy1 = 1.25 * yPixelOffset;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );","#elif defined( SHADOWMAP_TYPE_PCF_SOFT )","float shadow = 0.0;","float xPixelOffset = 1.0 / shadowMapSize[ i ].x;","float yPixelOffset = 1.0 / shadowMapSize[ i ].y;","float dx0 = -1.0 * xPixelOffset;","float dy0 = -1.0 * yPixelOffset;","float dx1 = 1.0 * xPixelOffset;","float dy1 = 1.0 * yPixelOffset;","mat3 shadowKernel;","mat3 depthKernel;","depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );","depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );","depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );","depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );","depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );","depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );","depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );","depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );","depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );","vec3 shadowZ = vec3( shadowCoord.z );","shadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));","shadowKernel[0] *= vec3(0.25);","shadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));","shadowKernel[1] *= vec3(0.25);","shadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));","shadowKernel[2] *= vec3(0.25);","vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );","shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );","shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );","vec4 shadowValues;","shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );","shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );","shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );","shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );","shadow = dot( shadowValues, vec4( 1.0 ) );","shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );","#else","vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );","float fDepth = unpackDepth( rgbaDepth );","if ( fDepth < shadowCoord.z )","shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );","#endif","}","#ifdef SHADOWMAP_DEBUG","#ifdef SHADOWMAP_CASCADE","if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];","#else","if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];","#endif","#endif","}","#ifdef GAMMA_OUTPUT","shadowColor *= shadowColor;","#endif","gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;","#endif"].join("\n"),shadowmap_pars_vertex:["#ifdef USE_SHADOWMAP","varying vec4 vShadowCoord[ MAX_SHADOWS ];","uniform mat4 shadowMatrix[ MAX_SHADOWS ];","#endif"].join("\n"),shadowmap_vertex:["#ifdef USE_SHADOWMAP","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;","}","#endif"].join("\n"),alphatest_fragment:["#ifdef ALPHATEST","if ( gl_FragColor.a < ALPHATEST ) discard;","#endif"].join("\n"),linear_to_gamma_fragment:["#ifdef GAMMA_OUTPUT","gl_FragColor.xyz = sqrt( gl_FragColor.xyz );","#endif"].join("\n")},THREE.UniformsUtils={merge:function(e){var t,i,r,o={};for(t=0;t dashSize ) {","discard;","}","gl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","uniform float opacity;","void main() {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float color = 1.0 - smoothstep( mNear, mFar, depth );","gl_FragColor = vec4( vec3( color ), opacity );","}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {","vNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;","varying vec3 vNormal;","void main() {","gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );","}"].join("\n")},normalmap:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null},tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new THREE.Vector2(1,1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",value:new THREE.Color(16777215)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(16777215)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1},useRefract:{type:"i",value:0},uRefractionRatio:{type:"f",value:.98},uReflectivity:{type:"f",value:.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 uAmbientColor;","uniform vec3 uDiffuseColor;","uniform vec3 uSpecularColor;","uniform float uShininess;","uniform float uOpacity;","uniform bool enableDiffuse;","uniform bool enableSpecular;","uniform bool enableAO;","uniform bool enableReflection;","uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tSpecular;","uniform sampler2D tAO;","uniform samplerCube tCube;","uniform vec2 uNormalScale;","uniform bool useRefract;","uniform float uRefractionRatio;","uniform float uReflectivity;","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {","gl_FragColor = vec4( vec3( 1.0 ), uOpacity );","vec3 specularTex = vec3( 1.0 );","vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","if( enableDiffuse ) {","#ifdef GAMMA_INPUT","vec4 texelColor = texture2D( tDiffuse, vUv );","texelColor.xyz *= texelColor.xyz;","gl_FragColor = gl_FragColor * texelColor;","#else","gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );","#endif","}","if( enableAO ) {","#ifdef GAMMA_INPUT","vec4 aoColor = texture2D( tAO, vUv );","aoColor.xyz *= aoColor.xyz;","gl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;","#else","gl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;","#endif","}","if( enableSpecular )","specularTex = texture2D( tSpecular, vUv ).xyz;","mat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );","vec3 finalNormal = tsb * normalTex;","#ifdef FLIP_SIDED","finalNormal = -finalNormal;","#endif","vec3 normal = normalize( finalNormal );","vec3 viewPosition = normalize( vViewPosition );","#if MAX_POINT_LIGHTS > 0","vec3 pointDiffuse = vec3( 0.0 );","vec3 pointSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 pointVector = lPosition.xyz + vViewPosition.xyz;","float pointDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","pointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );","pointVector = normalize( pointVector );","#ifdef WRAP_AROUND","float pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );","#else","float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );","#endif","pointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;","vec3 pointHalfVector = normalize( pointVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );","pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;","#else","pointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","vec3 spotDiffuse = vec3( 0.0 );","vec3 spotSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 spotVector = lPosition.xyz + vViewPosition.xyz;","float spotDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","spotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );","spotVector = normalize( spotVector );","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","#ifdef WRAP_AROUND","float spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );","float spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );","vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );","#else","float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );","#endif","spotDiffuse += spotDistance * spotLightColor[ i ] * uDiffuseColor * spotDiffuseWeight * spotEffect;","vec3 spotHalfVector = normalize( spotVector + viewPosition );","float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );","float spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );","spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;","#else","spotSpecular += spotDistance * spotLightColor[ i ] * uSpecularColor * spotSpecularWeight * spotDiffuseWeight * spotEffect;","#endif","}","}","#endif","#if MAX_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","#ifdef WRAP_AROUND","float directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );","float directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );","#else","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","#endif","dirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );","dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;","#else","dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;","#endif","}","#endif","#if MAX_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","hemiDiffuse += uDiffuseColor * hemiColor;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","float hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, uShininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","float hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float dotProductGround = dot( normal, lVectorGround );","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlickSky = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );","vec3 schlickGround = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );","hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );","#else","hemiSpecular += uSpecularColor * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;","#endif","}","#endif","vec3 totalDiffuse = vec3( 0.0 );","vec3 totalSpecular = vec3( 0.0 );","#if MAX_DIR_LIGHTS > 0","totalDiffuse += dirDiffuse;","totalSpecular += dirSpecular;","#endif","#if MAX_HEMI_LIGHTS > 0","totalDiffuse += hemiDiffuse;","totalSpecular += hemiSpecular;","#endif","#if MAX_POINT_LIGHTS > 0","totalDiffuse += pointDiffuse;","totalSpecular += pointSpecular;","#endif","#if MAX_SPOT_LIGHTS > 0","totalDiffuse += spotDiffuse;","totalSpecular += spotSpecular;","#endif","#ifdef METAL","gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor + totalSpecular );","#else","gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor ) + totalSpecular;","#endif","if ( enableReflection ) {","vec3 vReflect;","vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );","if ( useRefract ) {","vReflect = refract( cameraToVertex, normal, uRefractionRatio );","} else {","vReflect = reflect( cameraToVertex, normal );","}","vec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );","#ifdef GAMMA_INPUT","cubeColor.xyz *= cubeColor.xyz;","#endif","gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );","}",THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"), vertexShader:["attribute vec4 tangent;","uniform vec2 uOffset;","uniform vec2 uRepeat;","uniform bool enableDisplacement;","#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"#ifdef USE_SKINNING","vNormal = normalize( normalMatrix * skinnedNormal.xyz );","vec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );","vTangent = normalize( normalMatrix * skinnedTangent.xyz );","#else","vNormal = normalize( normalMatrix * normal );","vTangent = normalize( normalMatrix * tangent.xyz );","#endif","vBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );","vUv = uv * uRepeat + uOffset;","vec3 displacedPosition;","#ifdef VERTEX_TEXTURES","if ( enableDisplacement ) {","vec3 dv = texture2D( tDisplacement, uv ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","displacedPosition = position + normalize( normal ) * df;","} else {","#ifdef USE_SKINNING","vec4 skinVertex = vec4( position, 1.0 );","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned \t += boneMatY * skinVertex * skinWeight.y;","displacedPosition = skinned.xyz;","#else","displacedPosition = position;","#endif","}","#else","#ifdef USE_SKINNING","vec4 skinVertex = vec4( position, 1.0 );","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned \t += boneMatY * skinVertex * skinWeight.y;","displacedPosition = skinned.xyz;","#else","displacedPosition = position;","#endif","#endif","vec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );","vec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );","gl_Position = projectionMatrix * mvPosition;","vWorldPosition = worldPosition.xyz;","vViewPosition = -mvPosition.xyz;","#ifdef USE_SHADOWMAP","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;","}","#endif","}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;","void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vWorldPosition = worldPosition.xyz;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","uniform float tFlip;","varying vec3 vWorldPosition;","void main() {","gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );","}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:["vec4 pack_depth( const in float depth ) {","const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );","const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );","vec4 res = fract( depth * bit_shift );","res -= res.xxyz * bit_mask;","return res;","}","void main() {","gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );","}"].join("\n")}},THREE.WebGLRenderer=function(e){function t(e){e.__webglVertexBuffer=Ne.createBuffer(),e.__webglColorBuffer=Ne.createBuffer(),Ge.info.memory.geometries++}function i(e){e.__webglVertexBuffer=Ne.createBuffer(),e.__webglColorBuffer=Ne.createBuffer(),e.__webglLineDistanceBuffer=Ne.createBuffer(),Ge.info.memory.geometries++}function r(e){e.__webglVertexBuffer=Ne.createBuffer(),e.__webglColorBuffer=Ne.createBuffer(),e.__webglNormalBuffer=Ne.createBuffer(),Ge.info.memory.geometries++}function o(e){e.__webglVertexBuffer=Ne.createBuffer(),e.__webglNormalBuffer=Ne.createBuffer(),e.__webglTangentBuffer=Ne.createBuffer(),e.__webglColorBuffer=Ne.createBuffer(),e.__webglUVBuffer=Ne.createBuffer(),e.__webglUV2Buffer=Ne.createBuffer(),e.__webglSkinIndicesBuffer=Ne.createBuffer(),e.__webglSkinWeightsBuffer=Ne.createBuffer(),e.__webglFaceBuffer=Ne.createBuffer(),e.__webglLineBuffer=Ne.createBuffer();var t,i;if(e.numMorphTargets)for(e.__webglMorphTargetsBuffers=[],t=0,i=e.numMorphTargets;t0||i.faceVertexUvs.length>0)&&(e.__uvArray=new Float32Array(2*a)),(i.faceUvs.length>1||i.faceVertexUvs.length>1)&&(e.__uv2Array=new Float32Array(2*a))),t.geometry.skinWeights.length&&t.geometry.skinIndices.length&&(e.__skinIndexArray=new Float32Array(4*a),e.__skinWeightArray=new Float32Array(4*a)),e.__faceArray=new Uint16Array(3*n),e.__lineArray=new Uint16Array(2*s);var m,g;if(e.numMorphTargets)for(e.__morphTargetsArrays=[],m=0,g=e.numMorphTargets;m0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),Ne.bufferData(Ne.ARRAY_BUFFER,_e,i),Ne.bindBuffer(Ne.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),Ne.bufferData(Ne.ARRAY_BUFFER,be,i))}if(Be&&re){for(a=0,n=ke.length;a0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,e.__webglColorBuffer),Ne.bufferData(Ne.ARRAY_BUFFER,we,i))}if(ze&&Pe.hasTangents){for(a=0,n=ke.length;a0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,e.__webglUVBuffer),Ne.bufferData(Ne.ARRAY_BUFFER,ye,i))}if(Ue&&Xe&&oe){for(a=0,n=ke.length;a0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,e.__webglUV2Buffer),Ne.bufferData(Ne.ARRAY_BUFFER,Re,i))}if(Fe){for(a=0,n=ke.length;a=0?(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[i.morphTargetBase]),x(r.position),Ne.vertexAttribPointer(r.position,3,Ne.FLOAT,!1,0,0)):r.position>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglVertexBuffer),x(r.position),Ne.vertexAttribPointer(r.position,3,Ne.FLOAT,!1,0,0)),i.morphTargetForcedOrder.length)for(var o=0,a=i.morphTargetForcedOrder,n=i.morphTargetInfluences;o=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[a[o]]),x(r["morphTarget"+o]),Ne.vertexAttribPointer(r["morphTarget"+o],3,Ne.FLOAT,!1,0,0)),r["morphNormal"+o]>=0&&e.morphNormals&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglMorphNormalsBuffers[a[o]]),x(r["morphNormal"+o]),Ne.vertexAttribPointer(r["morphNormal"+o],3,Ne.FLOAT,!1,0,0)),i.__webglMorphTargetInfluences[o]=n[a[o]],o++;else{var s,h,l=[],n=i.morphTargetInfluences,c=n.length;for(h=0;h0&&l.push([s,h]);l.length>e.numSupportedMorphTargets?(l.sort(b),l.length=e.numSupportedMorphTargets):l.length>e.numSupportedMorphNormals?l.sort(b):0===l.length&&l.push([0,0]);for(var u,o=0;o=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[u]),x(r["morphTarget"+o]),Ne.vertexAttribPointer(r["morphTarget"+o],3,Ne.FLOAT,!1,0,0)),r["morphNormal"+o]>=0&&e.morphNormals&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,t.__webglMorphNormalsBuffers[u]),x(r["morphNormal"+o]),Ne.vertexAttribPointer(r["morphNormal"+o],3,Ne.FLOAT,!1,0,0)),i.__webglMorphTargetInfluences[o]=n[u]):i.__webglMorphTargetInfluences[o]=0,o++}null!==e.program.uniforms.morphTargetInfluences&&Ne.uniform1fv(e.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}function _(e,t){return e.z!==t.z?t.z-e.z:e.id-t.id}function b(e,t){return t[0]-e[0]}function M(e,t,i){if(e.length)for(var r=0,o=e.length;r65535&&(h[a].counter+=1,s=h[a].hash+"_"+h[a].counter,void 0===e.geometryGroups[s]&&(e.geometryGroups[s]={faces3:[],faces4:[],materialIndex:a,vertices:0,numMorphTargets:l,numMorphNormals:c})),o instanceof THREE.Face3?e.geometryGroups[s].faces3.push(i):e.geometryGroups[s].faces4.push(i),e.geometryGroups[s].vertices+=n;e.geometryGroupsList=[];for(var p in e.geometryGroups)e.geometryGroups[p].id=Je++,e.geometryGroupsList.push(e.geometryGroups[p])}function D(e,a){var n,u,p,d;if(void 0===e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrix=new THREE.Matrix3,void 0!==e.geometry&&void 0===e.geometry.__webglInit&&(e.geometry.__webglInit=!0,e.geometry.addEventListener("dispose",Nt)),u=e.geometry,void 0===u);else if(u instanceof THREE.BufferGeometry)m(u);else if(e instanceof THREE.Mesh){p=e.material,void 0===u.geometryGroups&&P(u,p);for(n in u.geometryGroups)d=u.geometryGroups[n],d.__webglVertexBuffer||(o(d),c(d,e),u.verticesNeedUpdate=!0,u.morphTargetsNeedUpdate=!0, u.elementsNeedUpdate=!0,u.uvsNeedUpdate=!0,u.normalsNeedUpdate=!0,u.tangentsNeedUpdate=!0,u.colorsNeedUpdate=!0)}else e instanceof THREE.Ribbon?u.__webglVertexBuffer||(r(u),l(u,e),u.verticesNeedUpdate=!0,u.colorsNeedUpdate=!0,u.normalsNeedUpdate=!0):e instanceof THREE.Line?u.__webglVertexBuffer||(i(u),h(u,e),u.verticesNeedUpdate=!0,u.colorsNeedUpdate=!0,u.lineDistancesNeedUpdate=!0):e instanceof THREE.ParticleSystem&&(u.__webglVertexBuffer||(t(u),s(u,e),u.verticesNeedUpdate=!0,u.colorsNeedUpdate=!0));if(void 0===e.__webglActive){if(e instanceof THREE.Mesh){if(u=e.geometry,u instanceof THREE.BufferGeometry)F(a.__webglObjects,u,e);else if(u instanceof THREE.Geometry)for(n in u.geometryGroups)d=u.geometryGroups[n],F(a.__webglObjects,d,e)}else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(u=e.geometry,F(a.__webglObjects,u,e)):e instanceof THREE.ImmediateRenderObject||e.immediateRenderCallback?U(a.__webglObjectsImmediate,e):e instanceof THREE.Sprite?a.__webglSprites.push(e):e instanceof THREE.LensFlare&&a.__webglFlares.push(e);e.__webglActive=!0}}function F(e,t,i){e.push({id:null,buffer:t,object:i,opaque:null,transparent:null,z:0})}function U(e,t){e.push({id:null,object:t,opaque:null,transparent:null,z:0})}function V(e){var t,i,r,o=e.geometry;if(o instanceof THREE.BufferGeometry)R(o,Ne.DYNAMIC_DRAW,!o.dynamic);else if(e instanceof THREE.Mesh){for(var a=0,n=o.geometryGroupsList.length;a=0;i--)e[i].object===t&&e.splice(i,1)}function I(e,t){for(var i=e.length-1;i>=0;i--)e[i]===t&&e.splice(i,1)}function k(e,t){e.uniforms=THREE.UniformsUtils.clone(t.uniforms),e.vertexShader=t.vertexShader,e.fragmentShader=t.fragmentShader}function j(e,t,i,r,o){$e=0,r.needsUpdate&&(r.program&&Wt(r),Ge.initMaterial(r,t,i,o),r.needsUpdate=!1),r.morphTargets&&(o.__webglMorphTargetInfluences||(o.__webglMorphTargetInfluences=new Float32Array(Ge.maxMorphTargets)));var a=!1,n=r.program,s=n.uniforms,h=r.uniforms;if(n!==Ye&&(Ne.useProgram(n),Ye=n,a=!0),r.id!==Qe&&(Qe=r.id,a=!0),(a||e!==Ze)&&(Ne.uniformMatrix4fv(s.projectionMatrix,!1,e.projectionMatrix.elements),e!==Ze&&(Ze=e)),r.skinning)if(Lt&&o.useVertexTexture){if(null!==s.boneTexture){var l=ee();Ne.uniform1i(s.boneTexture,l),Ge.setTexture(o.boneTexture,l)}}else null!==s.boneGlobalMatrices&&Ne.uniformMatrix4fv(s.boneGlobalMatrices,!1,o.boneMatrices);return a&&(i&&r.fog&&q(h,i),(r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshLambertMaterial||r.lights)&&(wt&&(ae(n,t),wt=!1),Z(h,_t)),(r instanceof THREE.MeshBasicMaterial||r instanceof THREE.MeshLambertMaterial||r instanceof THREE.MeshPhongMaterial)&&G(h,r),r instanceof THREE.LineBasicMaterial?W(h,r):r instanceof THREE.LineDashedMaterial?(W(h,r),X(h,r)):r instanceof THREE.ParticleBasicMaterial?Y(h,r):r instanceof THREE.MeshPhongMaterial?Q(h,r):r instanceof THREE.MeshLambertMaterial?K(h,r):r instanceof THREE.MeshDepthMaterial?(h.mNear.value=e.near,h.mFar.value=e.far,h.opacity.value=r.opacity):r instanceof THREE.MeshNormalMaterial&&(h.opacity.value=r.opacity),o.receiveShadow&&!r._shadowPass&&J(h,t),te(n,r.uniformsList),(r instanceof THREE.ShaderMaterial||r instanceof THREE.MeshPhongMaterial||r.envMap)&&null!==s.cameraPosition&&(xt.getPositionFromMatrix(e.matrixWorld),Ne.uniform3f(s.cameraPosition,xt.x,xt.y,xt.z)),(r instanceof THREE.MeshPhongMaterial||r instanceof THREE.MeshLambertMaterial||r instanceof THREE.ShaderMaterial||r.skinning)&&null!==s.viewMatrix&&Ne.uniformMatrix4fv(s.viewMatrix,!1,e.matrixWorldInverse.elements)),$(s,o),null!==s.modelMatrix&&Ne.uniformMatrix4fv(s.modelMatrix,!1,o.matrixWorld.elements),n}function G(e,t){e.opacity.value=t.opacity,Ge.gammaInput?e.diffuse.value.copyGammaToLinear(t.color):e.diffuse.value=t.color,e.map.value=t.map,e.lightMap.value=t.lightMap,e.specularMap.value=t.specularMap,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));var i;if(t.map?i=t.map:t.specularMap?i=t.specularMap:t.normalMap?i=t.normalMap:t.bumpMap&&(i=t.bumpMap),void 0!==i){var r=i.offset,o=i.repeat;e.offsetRepeat.value.set(r.x,r.y,o.x,o.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,Ge.gammaInput?e.reflectivity.value=t.reflectivity:e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.combine.value=t.combine,e.useRefract.value=t.envMap&&t.envMap.mapping instanceof THREE.CubeRefractionMapping}function W(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function X(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function Y(e,t){e.psColor.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size,e.scale.value=Ce.height/2,e.map.value=t.map}function q(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 Q(e,t){e.shininess.value=t.shininess,Ge.gammaInput?(e.ambient.value.copyGammaToLinear(t.ambient),e.emissive.value.copyGammaToLinear(t.emissive),e.specular.value.copyGammaToLinear(t.specular)):(e.ambient.value=t.ambient,e.emissive.value=t.emissive,e.specular.value=t.specular),t.wrapAround&&e.wrapRGB.value.copy(t.wrapRGB)}function K(e,t){Ge.gammaInput?(e.ambient.value.copyGammaToLinear(t.ambient),e.emissive.value.copyGammaToLinear(t.emissive)):(e.ambient.value=t.ambient,e.emissive.value=t.emissive),t.wrapAround&&e.wrapRGB.value.copy(t.wrapRGB)}function Z(e,t){e.ambientLightColor.value=t.ambient,e.directionalLightColor.value=t.directional.colors,e.directionalLightDirection.value=t.directional.positions,e.pointLightColor.value=t.point.colors,e.pointLightPosition.value=t.point.positions,e.pointLightDistance.value=t.point.distances,e.spotLightColor.value=t.spot.colors,e.spotLightPosition.value=t.spot.positions,e.spotLightDistance.value=t.spot.distances,e.spotLightDirection.value=t.spot.directions,e.spotLightAngleCos.value=t.spot.anglesCos,e.spotLightExponent.value=t.spot.exponents,e.hemisphereLightSkyColor.value=t.hemi.skyColors,e.hemisphereLightGroundColor.value=t.hemi.groundColors,e.hemisphereLightDirection.value=t.hemi.positions}function J(e,t){if(e.shadowMatrix)for(var i=0,r=0,o=t.length;r=bt&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+bt),$e+=1,e}function te(e,t){var i,r,o,a,n,s,h,l,c,u,p;for(c=0,u=t.length;c1||t.__oldAnisotropy)&&(Ne.texParameterf(e,ke.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,Ct)),t.__oldAnisotropy=t.anisotropy)}function me(e,t){if(e.width<=t&&e.height<=t)return e;var i=Math.max(e.width,e.height),r=Math.floor(e.width*t/i),o=Math.floor(e.height*t/i),a=document.createElement("canvas");a.width=r,a.height=o;var n=a.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,r,o),a}function ge(e,t){if(6===e.image.length)if(e.needsUpdate){e.image.__webglTextureCube||(e.addEventListener("dispose",Bt),e.image.__webglTextureCube=Ne.createTexture(),Ge.info.memory.textures++),Ne.activeTexture(Ne.TEXTURE0+t),Ne.bindTexture(Ne.TEXTURE_CUBE_MAP,e.image.__webglTextureCube),Ne.pixelStorei(Ne.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var i=e instanceof THREE.CompressedTexture,r=[],o=0;o<6;o++)Ge.autoScaleCubemaps&&!i?r[o]=me(e.image[o],St):r[o]=e.image[o];var a=r[0],n=fe(a.width)&&fe(a.height),s=He(e.format),h=He(e.type);Ee(Ne.TEXTURE_CUBE_MAP,e,n);for(var o=0;o<6;o++)if(i)for(var l,c=r[o].mipmaps,u=0,p=c.length;u0,Lt=At&&Be,Pt=(je?Ne.getParameter(Ne.COMPRESSED_TEXTURE_FORMATS):[],Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.HIGH_FLOAT)),Dt=Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.MEDIUM_FLOAT),Ft=(Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.LOW_FLOAT),Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.HIGH_FLOAT)),Ut=Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.MEDIUM_FLOAT),Vt=(Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.LOW_FLOAT),Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.HIGH_INT),Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.MEDIUM_INT),Ne.getShaderPrecisionFormat(Ne.VERTEX_SHADER,Ne.LOW_INT),Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.HIGH_INT),Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.MEDIUM_INT),Ne.getShaderPrecisionFormat(Ne.FRAGMENT_SHADER,Ne.LOW_INT),Pt.precision>0&&Ft.precision>0),zt=Dt.precision>0&&Ut.precision>0;"highp"!==Ae||Vt||(zt?(Ae="mediump",console.warn("WebGLRenderer: highp not supported, using mediump")):(Ae="lowp",console.warn("WebGLRenderer: highp and mediump not supported, using lowp"))),"mediump"!==Ae||zt||(Ae="lowp",console.warn("WebGLRenderer: mediump not supported, using lowp")),this.getContext=function(){return Ne},this.supportsVertexTextures=function(){return At},this.supportsFloatTextures=function(){return Be},this.supportsStandardDerivatives=function(){return Ie},this.supportsCompressedTextureS3TC=function(){return je},this.getMaxAnisotropy=function(){return Ct},this.getPrecision=function(){return Ae},this.setSize=function(e,t,i){Ce.width=e*this.devicePixelRatio,Ce.height=t*this.devicePixelRatio,1!==this.devicePixelRatio&&i!==!1&&(Ce.style.width=e+"px",Ce.style.height=t+"px"),this.setViewport(0,0,Ce.width,Ce.height)},this.setViewport=function(e,t,i,r){pt=void 0!==e?e:0,dt=void 0!==t?t:0,ft=void 0!==i?i:Ce.width,Et=void 0!==r?r:Ce.height,Ne.viewport(pt,dt,ft,Et)},this.setScissor=function(e,t,i,r){Ne.scissor(e,t,i,r)},this.enableScissorTest=function(e){e?Ne.enable(Ne.SCISSOR_TEST):Ne.disable(Ne.SCISSOR_TEST)},this.setClearColor=function(e,t){Ve.set(e),ze=void 0!==t?t:1,Ne.clearColor(Ve.r,Ve.g,Ve.b,ze)},this.setClearColorHex=function(e,t){console.warn("DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(e,t)},this.getClearColor=function(){return Ve},this.getClearAlpha=function(){return ze},this.clear=function(e,t,i){var r=0;(void 0===e||e)&&(r|=Ne.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=Ne.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=Ne.STENCIL_BUFFER_BIT),Ne.clear(r)},this.clearTarget=function(e,t,i,r){this.setRenderTarget(e),this.clear(t,i,r)},this.addPostPlugin=function(e){e.init(this),this.renderPluginsPost.push(e)},this.addPrePlugin=function(e){e.init(this),this.renderPluginsPre.push(e)},this.updateShadowMap=function(e,t){Ye=null,it=-1,nt=-1,st=-1,Ke=-1,Qe=-1,wt=!0,et=-1,tt=-1,this.shadowMapPlugin.update(e,t)};var Nt=function(e){var t=e.target;t.removeEventListener("dispose",Nt),kt(t),Ge.info.memory.geometries--; },Bt=function(e){var t=e.target;t.removeEventListener("dispose",Bt),jt(t),Ge.info.memory.textures--},Ot=function(e){var t=e.target;t.removeEventListener("dispose",Ot),Gt(t),Ge.info.memory.textures--},It=function(e){var t=e.target;t.removeEventListener("dispose",It),Wt(t)},kt=function(e){if(e.__webglInit=void 0,void 0!==e.__webglVertexBuffer&&Ne.deleteBuffer(e.__webglVertexBuffer),void 0!==e.__webglNormalBuffer&&Ne.deleteBuffer(e.__webglNormalBuffer),void 0!==e.__webglTangentBuffer&&Ne.deleteBuffer(e.__webglTangentBuffer),void 0!==e.__webglColorBuffer&&Ne.deleteBuffer(e.__webglColorBuffer),void 0!==e.__webglUVBuffer&&Ne.deleteBuffer(e.__webglUVBuffer),void 0!==e.__webglUV2Buffer&&Ne.deleteBuffer(e.__webglUV2Buffer),void 0!==e.__webglSkinIndicesBuffer&&Ne.deleteBuffer(e.__webglSkinIndicesBuffer),void 0!==e.__webglSkinWeightsBuffer&&Ne.deleteBuffer(e.__webglSkinWeightsBuffer),void 0!==e.__webglFaceBuffer&&Ne.deleteBuffer(e.__webglFaceBuffer),void 0!==e.__webglLineBuffer&&Ne.deleteBuffer(e.__webglLineBuffer),void 0!==e.__webglLineDistanceBuffer&&Ne.deleteBuffer(e.__webglLineDistanceBuffer),void 0!==e.geometryGroups)for(var t in e.geometryGroups){var i=e.geometryGroups[t];if(void 0!==i.numMorphTargets)for(var r=0,o=i.numMorphTargets;r1&&(d=!0);for(var v=0,T=g.length;v=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,n.buffer),x(h),Ne.vertexAttribPointer(h,l,Ne.FLOAT,!1,0,y*l*4)));Ne.bindBuffer(Ne.ELEMENT_ARRAY_BUFFER,m.buffer)}Ne.drawElements(Ne.TRIANGLES,g[v].count,Ne.UNSIGNED_SHORT,2*g[v].start),Ge.info.render.calls++,Ge.info.render.vertices+=g[v].count,Ge.info.render.faces+=g[v].count/3}}else{if(d)for(s in p)"index"!==s&&(h=u[s],n=p[s],l=n.itemSize,h>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,n.buffer),x(h),Ne.vertexAttribPointer(h,l,Ne.FLOAT,!1,0,0)));var R=o.attributes.position;Ne.drawArrays(Ne.TRIANGLES,0,R.numItems/3),Ge.info.render.calls++,Ge.info.render.vertices+=R.numItems/3,Ge.info.render.faces+=R.numItems/3/3}}else if(a instanceof THREE.ParticleSystem){if(d){for(s in p)h=u[s],n=p[s],l=n.itemSize,h>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,n.buffer),x(h),Ne.vertexAttribPointer(h,l,Ne.FLOAT,!1,0,0));var R=p.position;Ne.drawArrays(Ne.POINTS,0,R.numItems/3),Ge.info.render.calls++,Ge.info.render.points+=R.numItems/3}}else if(a instanceof THREE.Line&&d){for(s in p)h=u[s],n=p[s],l=n.itemSize,h>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,n.buffer),x(h),Ne.vertexAttribPointer(h,l,Ne.FLOAT,!1,0,0));var w=a.type===THREE.LineStrip?Ne.LINE_STRIP:Ne.LINES;ne(r.linewidth);var R=p.position;Ne.drawArrays(w,0,R.numItems/3),Ge.info.render.calls++,Ge.info.render.points+=R.numItems}}},this.renderBuffer=function(e,t,i,r,o,a){if(r.visible!==!1){var n,s,h,l=j(e,t,i,r,a),c=l.attributes,u=!1,p=r.wireframe?1:0,d=16777215*o.id+2*l.id+p;if(d!==Ke&&(Ke=d,u=!0),u&&H(),!r.morphTargets&&c.position>=0?u&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglVertexBuffer),x(c.position),Ne.vertexAttribPointer(c.position,3,Ne.FLOAT,!1,0,0)):a.morphTargetBase&&w(r,o,a),u){if(o.__webglCustomAttributesList)for(s=0,h=o.__webglCustomAttributesList.length;s=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,n.buffer),x(c[n.buffer.belongsToAttribute]),Ne.vertexAttribPointer(c[n.buffer.belongsToAttribute],n.size,Ne.FLOAT,!1,0,0));c.color>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglColorBuffer),x(c.color),Ne.vertexAttribPointer(c.color,3,Ne.FLOAT,!1,0,0)),c.normal>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglNormalBuffer),x(c.normal),Ne.vertexAttribPointer(c.normal,3,Ne.FLOAT,!1,0,0)),c.tangent>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglTangentBuffer),x(c.tangent),Ne.vertexAttribPointer(c.tangent,4,Ne.FLOAT,!1,0,0)),c.uv>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglUVBuffer),x(c.uv),Ne.vertexAttribPointer(c.uv,2,Ne.FLOAT,!1,0,0)),c.uv2>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglUV2Buffer),x(c.uv2),Ne.vertexAttribPointer(c.uv2,2,Ne.FLOAT,!1,0,0)),r.skinning&&c.skinIndex>=0&&c.skinWeight>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),x(c.skinIndex),Ne.vertexAttribPointer(c.skinIndex,4,Ne.FLOAT,!1,0,0),Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),x(c.skinWeight),Ne.vertexAttribPointer(c.skinWeight,4,Ne.FLOAT,!1,0,0)),c.lineDistance>=0&&(Ne.bindBuffer(Ne.ARRAY_BUFFER,o.__webglLineDistanceBuffer),x(c.lineDistance),Ne.vertexAttribPointer(c.lineDistance,1,Ne.FLOAT,!1,0,0))}if(a instanceof THREE.Mesh)r.wireframe?(ne(r.wireframeLinewidth),u&&Ne.bindBuffer(Ne.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),Ne.drawElements(Ne.LINES,o.__webglLineCount,Ne.UNSIGNED_SHORT,0)):(u&&Ne.bindBuffer(Ne.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer),Ne.drawElements(Ne.TRIANGLES,o.__webglFaceCount,Ne.UNSIGNED_SHORT,0)),Ge.info.render.calls++,Ge.info.render.vertices+=o.__webglFaceCount,Ge.info.render.faces+=o.__webglFaceCount/3;else if(a instanceof THREE.Line){var f=a.type===THREE.LineStrip?Ne.LINE_STRIP:Ne.LINES;ne(r.linewidth),Ne.drawArrays(f,0,o.__webglLineCount),Ge.info.render.calls++}else a instanceof THREE.ParticleSystem?(Ne.drawArrays(Ne.POINTS,0,o.__webglParticleCount),Ge.info.render.calls++,Ge.info.render.points+=o.__webglParticleCount):a instanceof THREE.Ribbon&&(Ne.drawArrays(Ne.TRIANGLE_STRIP,0,o.__webglVertexCount),Ge.info.render.calls++)}},this.render=function(e,t,i,r){if(t instanceof THREE.Camera==!1)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");var o,a,n,s,h,l=e.__lights,c=e.fog;for(Qe=-1,wt=!0,e.autoUpdate===!0&&e.updateMatrixWorld(),void 0===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),yt.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Tt.setFromMatrix(yt),this.autoUpdateObjects&&this.initWebGLObjects(e),M(this.renderPluginsPre,e,t),Ge.info.render.calls=0,Ge.info.render.vertices=0,Ge.info.render.faces=0,Ge.info.render.points=0,this.setRenderTarget(i),(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),h=e.__webglObjects,o=0,a=h.length;o=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;var p,d="morphNormal";for(a=0;a=0&&e.numSupportedMorphNormals++}e.uniformsList=[];for(o in e.uniforms)e.uniformsList.push([e.uniforms[o],o])},this.setFaceCulling=function(e,t){e===THREE.CullFaceNone?Ne.disable(Ne.CULL_FACE):(t===THREE.FrontFaceDirectionCW?Ne.frontFace(Ne.CW):Ne.frontFace(Ne.CCW),e===THREE.CullFaceBack?Ne.cullFace(Ne.BACK):e===THREE.CullFaceFront?Ne.cullFace(Ne.FRONT):Ne.cullFace(Ne.FRONT_AND_BACK),Ne.enable(Ne.CULL_FACE))},this.setMaterialFaces=function(e){var t=e.side===THREE.DoubleSide,i=e.side===THREE.BackSide;et!==t&&(t?Ne.disable(Ne.CULL_FACE):Ne.enable(Ne.CULL_FACE),et=t),tt!==i&&(i?Ne.frontFace(Ne.CW):Ne.frontFace(Ne.CCW),tt=i)},this.setDepthTest=function(e){nt!==e&&(e?Ne.enable(Ne.DEPTH_TEST):Ne.disable(Ne.DEPTH_TEST),nt=e)},this.setDepthWrite=function(e){st!==e&&(Ne.depthMask(e),st=e)},this.setBlending=function(e,t,i,r){e!==it&&(e===THREE.NoBlending?Ne.disable(Ne.BLEND):e===THREE.AdditiveBlending?(Ne.enable(Ne.BLEND),Ne.blendEquation(Ne.FUNC_ADD),Ne.blendFunc(Ne.SRC_ALPHA,Ne.ONE)):e===THREE.SubtractiveBlending?(Ne.enable(Ne.BLEND),Ne.blendEquation(Ne.FUNC_ADD),Ne.blendFunc(Ne.ZERO,Ne.ONE_MINUS_SRC_COLOR)):e===THREE.MultiplyBlending?(Ne.enable(Ne.BLEND),Ne.blendEquation(Ne.FUNC_ADD),Ne.blendFunc(Ne.ZERO,Ne.SRC_COLOR)):e===THREE.CustomBlending?Ne.enable(Ne.BLEND):(Ne.enable(Ne.BLEND),Ne.blendEquationSeparate(Ne.FUNC_ADD,Ne.FUNC_ADD),Ne.blendFuncSeparate(Ne.SRC_ALPHA,Ne.ONE_MINUS_SRC_ALPHA,Ne.ONE,Ne.ONE_MINUS_SRC_ALPHA)),it=e),e===THREE.CustomBlending?(t!==rt&&(Ne.blendEquation(He(t)),rt=t),i===ot&&r===at||(Ne.blendFunc(He(i),He(r)),ot=i,at=r)):(rt=null,ot=null,at=null)},this.setTexture=function(e,t){if(e.needsUpdate){e.__webglInit||(e.__webglInit=!0,e.addEventListener("dispose",Bt),e.__webglTexture=Ne.createTexture(),Ge.info.memory.textures++),Ne.activeTexture(Ne.TEXTURE0+t),Ne.bindTexture(Ne.TEXTURE_2D,e.__webglTexture),Ne.pixelStorei(Ne.UNPACK_FLIP_Y_WEBGL,e.flipY),Ne.pixelStorei(Ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Ne.pixelStorei(Ne.UNPACK_ALIGNMENT,e.unpackAlignment);var i=e.image,r=fe(i.width)&&fe(i.height),o=He(e.format),a=He(e.type);Ee(Ne.TEXTURE_2D,e,r);var n,s=e.mipmaps;if(e instanceof THREE.DataTexture)if(s.length>0&&r){for(var h=0,l=s.length;h0&&r){for(var h=0,l=s.length;h1&&(a=1-a,n=1-n);var s=1-a-n;return o.copy(t),o.multiplyScalar(a),e.copy(i),e.multiplyScalar(n),o.add(e),e.copy(r),e.multiplyScalar(s),o.add(e),o}}(),randomPointInFace:function(e,t,i){var r,o,a,n;if(e instanceof THREE.Face3)return r=t.vertices[e.a],o=t.vertices[e.b],a=t.vertices[e.c],THREE.GeometryUtils.randomPointInTriangle(r,o,a);if(e instanceof THREE.Face4){r=t.vertices[e.a],o=t.vertices[e.b],a=t.vertices[e.c],n=t.vertices[e.d];var s,h;i?e._area1&&e._area2?(s=e._area1,h=e._area2):(s=THREE.GeometryUtils.triangleArea(r,o,n),h=THREE.GeometryUtils.triangleArea(o,a,n),e._area1=s,e._area2=h):(s=THREE.GeometryUtils.triangleArea(r,o,n),h=THREE.GeometryUtils.triangleArea(o,a,n));var l=THREE.Math.random16()*(s+h);return le?t(i,o-1):d[o]>8&255,e>>16&255,e>>24&255)}var o={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},a=542327876,n=131072,s=512,h=4,l=i("DXT1"),c=i("DXT3"),u=i("DXT5"),p=31,d=0,f=1,E=2,m=3,g=4,v=7,T=20,y=21,R=28,x=new Int32Array(e,0,p);if(x[d]!==a)return console.error("ImageUtils.parseDDS(): Invalid magic number in DDS header"),o;if(!x[T]&h)return console.error("ImageUtils.parseDDS(): Unsupported format, must contain a FourCC code"),o;var H,w=x[y];switch(w){case l:H=8,o.format=THREE.RGB_S3TC_DXT1_Format;break;case c:H=16,o.format=THREE.RGBA_S3TC_DXT3_Format;break;case u:H=16,o.format=THREE.RGBA_S3TC_DXT5_Format;break;default:return console.error("ImageUtils.parseDDS(): Unsupported FourCC code: ",r(w)),o}o.mipmapCount=1,x[E]&n&&t!==!1&&(o.mipmapCount=Math.max(1,x[v])),o.isCubemap=!!(x[R]&s),o.width=x[g],o.height=x[m];for(var _=x[f]+4,b=o.width,M=o.height,S=o.isCubemap?6:1,C=0;Cn-1?n-1:d+1,m=p-1<0?0:p-1,g=p+1>a-1?a-1:p+1,v=[],T=[0,0,l[4*(d*a+p)]/255*t];v.push([-1,0,l[4*(d*a+m)]/255*t]),v.push([-1,-1,l[4*(f*a+m)]/255*t]),v.push([0,-1,l[4*(f*a+p)]/255*t]),v.push([1,-1,l[4*(f*a+g)]/255*t]),v.push([1,0,l[4*(d*a+g)]/255*t]),v.push([1,1,l[4*(E*a+g)]/255*t]),v.push([0,1,l[4*(E*a+p)]/255*t]),v.push([-1,1,l[4*(E*a+m)]/255*t]);for(var y=[],R=v.length,x=0;x0)for(n=0;n2;){if(p--<=0)return console.log("Warning, unable to triangulate polygon!"),t?c:h;if(a=n,u<=a&&(a=0),n=a+1,u<=n&&(n=0),s=n+1,u<=s&&(s=0),o(e,a,n,s,u,l)){var d,f,E,m,g;for(d=l[a],f=l[n],E=l[s],h.push([e[d],e[f],e[E]]),c.push([l[a],l[n],l[s]]),m=n,g=n+1;g(c-h)*(d-l)-(u-l)*(p-h))return!1;var m,g,v,T,y,R,x,H,w,_,b,M,S,C,A;for(m=p-c,g=d-u,v=h-p,T=l-d,y=c-h,R=u-l,s=0;s=0&&C>=0&&S>=0))return!1;return!0};return e.Triangulate=i,e.Triangulate.area=r,e}(THREE.FontUtils),self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace},THREE.typeface_js=self._typeface_js,THREE.Curve=function(){},THREE.Curve.prototype.getPoint=function(e){return console.log("Warning, getPoint() not implemented!"),null},THREE.Curve.prototype.getPointAt=function(e){var t=this.getUtoTmapping(e);return this.getPoint(t)},THREE.Curve.prototype.getPoints=function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i},THREE.Curve.prototype.getSpacedPoints=function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPointAt(t/e));return i},THREE.Curve.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},THREE.Curve.prototype.getLengths=function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length==e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,r=[],o=this.getPoint(0),a=0;for(r.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),a+=t.distanceTo(o),r.push(a),o=t;return this.cacheArcLengths=r,r},THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0,this.getLengths()},THREE.Curve.prototype.getUtoTmapping=function(e,t){var i,r=this.getLengths(),o=0,a=r.length;i=t?t:e*r[a-1];for(var n,s=0,h=a-1;s<=h;)if(o=Math.floor(s+(h-s)/2),n=r[o]-i,n<0)s=o+1;else{if(!(n>0)){h=o;break}h=o-1}if(o=h,r[o]==i){var l=o/(a-1);return l}var c=r[o],u=r[o+1],p=u-c,d=(i-c)/p,l=(o+d)/(a-1);return l},THREE.Curve.prototype.getTangent=function(e){var t=1e-4,i=e-t,r=e+t;i<0&&(i=0),r>1&&(r=1);var o=this.getPoint(i),a=this.getPoint(r),n=a.clone().sub(o);return n.normalize()},THREE.Curve.prototype.getTangentAt=function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},THREE.Curve.Utils={tangentQuadraticBezier:function(e,t,i,r){return 2*(1-e)*(i-t)+2*e*(r-i)},tangentCubicBezier:function(e,t,i,r,o){return-3*t*(1-e)*(1-e)+3*i*(1-e)*(1-e)-6*e*i*(1-e)+6*e*r*(1-e)-3*e*e*r+3*e*e*o},tangentSpline:function(e,t,i,r,o){var a=6*e*e-6*e,n=3*e*e-4*e+1,s=-6*e*e+6*e,h=3*e*e-2*e;return a+n+s+h},interpolate:function(e,t,i,r,o){var a=.5*(i-e),n=.5*(r-t),s=o*o,h=o*s;return(2*t-2*i+a+n)*h+(-3*t+3*i-2*a-n)*s+a*o+t}},THREE.Curve.create=function(e,t){return e.prototype=Object.create(THREE.Curve.prototype),e.prototype.getPoint=t,e},THREE.CurvePath=function(){this.curves=[],this.bends=[],this.autoClose=!1},THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype),THREE.CurvePath.prototype.add=function(e){this.curves.push(e)},THREE.CurvePath.prototype.checkConnection=function(){},THREE.CurvePath.prototype.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))},THREE.CurvePath.prototype.getPoint=function(e){for(var t,i,r=e*this.getLength(),o=this.getCurveLengths(),a=0;a=r){t=o[a]-r,i=this.curves[a];var n=1-t/i.getLength();return i.getPointAt(n)}a++}return null},THREE.CurvePath.prototype.getLength=function(){var e=this.getCurveLengths();return e[e.length-1]},THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var e,t=[],i=0,r=this.curves.length;for(e=0;ee?e=s.x:s.xt?t=s.y:s.yi?i=s.z:s.z0?(E=y[y.length-1],d=E.x,f=E.y):(E=this.actions[i-1].args,d=E[E.length-2],f=E[E.length-1]),m=1;m<=e;m++)g=m/e,v=THREE.Shape.Utils.b2(g,d,u,s),T=THREE.Shape.Utils.b2(g,f,p,h),y.push(new THREE.Vector2(v,T));break;case THREE.PathActions.BEZIER_CURVE_TO:for(s=n[4],h=n[5],u=n[0],p=n[1],l=n[2],c=n[3],y.length>0?(E=y[y.length-1],d=E.x,f=E.y):(E=this.actions[i-1].args,d=E[E.length-2],f=E[E.length-1]),m=1;m<=e;m++)g=m/e,v=THREE.Shape.Utils.b3(g,d,u,l,s),T=THREE.Shape.Utils.b3(g,f,p,c,h),y.push(new THREE.Vector2(v,T));break;case THREE.PathActions.CSPLINE_THRU:E=this.actions[i-1].args;var R=new THREE.Vector2(E[E.length-2],E[E.length-1]),x=[R],H=e*n[0].length;x=x.concat(n[0]);var w=new THREE.SplineCurve(x);for(m=1;m<=H;m++)y.push(w.getPointAt(m/H));break;case THREE.PathActions.ARC:var _,b=n[0],M=n[1],S=n[2],C=n[3],A=n[4],L=!!n[5],P=A-C,D=2*e;for(m=1;m<=D;m++)g=m/D,L||(g=1-g),_=C+g*P,v=b+S*Math.cos(_),T=M+S*Math.sin(_),y.push(new THREE.Vector2(v,T));break;case THREE.PathActions.ELLIPSE:var _,b=n[0],M=n[1],F=n[2],U=n[3],C=n[4],A=n[5],L=!!n[6],P=A-C,D=2*e;for(m=1;m<=D;m++)g=m/D,L||(g=1-g),_=C+g*P,v=b+F*Math.cos(_),T=M+U*Math.sin(_),y.push(new THREE.Vector2(v,T))}var V=y[y.length-1],z=1e-10;return Math.abs(V.x-y[0].x)=0?a-1:v.length-1,r=o-1>=0?o-1:h.length-1;var x=[h[o],v[a],v[i]],H=THREE.FontUtils.Triangulate.area(x),w=[h[o],h[r],v[a]],_=THREE.FontUtils.Triangulate.area(w),b=1,M=-1,S=a,C=o;a+=b,o+=M,a<0&&(a+=v.length),a%=v.length,o<0&&(o+=h.length),o%=h.length,i=a-1>=0?a-1:v.length-1,r=o-1>=0?o-1:h.length-1,x=[h[o],v[a],v[i]];var A=THREE.FontUtils.Triangulate.area(x);w=[h[o],h[r],v[a]];var L=THREE.FontUtils.Triangulate.area(w);H+_>A+L&&(a=S,o=C,a<0&&(a+=v.length),a%=v.length,o<0&&(o+=h.length),o%=h.length,i=a-1>=0?a-1:v.length-1,r=o-1>=0?o-1:h.length-1),f=v.slice(0,a),E=v.slice(a),m=h.slice(o),g=h.slice(0,o);var P=[h[o],v[a],v[i]],D=[h[o],h[r],v[a]];y.push(P),y.push(D),v=f.concat(m).concat(g).concat(E)}return{shape:v,isolatedPts:y,allpoints:T}},triangulateShape:function(e,t){var i,r,o,a,n,s,h=THREE.Shape.Utils.removeHoles(e,t),l=h.shape,c=h.allpoints,u=h.isolatedPts,p=THREE.FontUtils.Triangulate(l,!1),d={};for(i=0,r=c.length;in.length-2?n.length-1:i+1,a[3]=i>n.length-3?n.length-1:i+2,o.x=THREE.Curve.Utils.interpolate(n[a[0]].x,n[a[1]].x,n[a[2]].x,n[a[3]].x,r),o.y=THREE.Curve.Utils.interpolate(n[a[0]].y,n[a[1]].y,n[a[2]].y,n[a[3]].y,r),o},THREE.EllipseCurve=function(e,t,i,r,o,a,n){this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=n},THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype),THREE.EllipseCurve.prototype.getPoint=function(e){var t=this.aEndAngle-this.aStartAngle;this.aClockwise||(e=1-e);var i=this.aStartAngle+e*t,r=this.aX+this.xRadius*Math.cos(i),o=this.aY+this.yRadius*Math.sin(i);return new THREE.Vector2(r,o)},THREE.ArcCurve=function(e,t,i,r,o,a){THREE.EllipseCurve.call(this,e,t,i,i,r,o,a)},THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype),THREE.LineCurve3=THREE.Curve.create(function(e,t){this.v1=e,this.v2=t},function(e){var t=new THREE.Vector3;return t.subVectors(this.v2,this.v1),t.multiplyScalar(e),t.add(this.v1),t}),THREE.QuadraticBezierCurve3=THREE.Curve.create(function(e,t,i){this.v0=e,this.v1=t,this.v2=i},function(e){var t,i,r;return t=THREE.Shape.Utils.b2(e,this.v0.x,this.v1.x,this.v2.x),i=THREE.Shape.Utils.b2(e,this.v0.y,this.v1.y,this.v2.y),r=THREE.Shape.Utils.b2(e,this.v0.z,this.v1.z,this.v2.z),new THREE.Vector3(t,i,r)}),THREE.CubicBezierCurve3=THREE.Curve.create(function(e,t,i,r){this.v0=e,this.v1=t,this.v2=i,this.v3=r},function(e){var t,i,r;return t=THREE.Shape.Utils.b3(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),i=THREE.Shape.Utils.b3(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),r=THREE.Shape.Utils.b3(e,this.v0.z,this.v1.z,this.v2.z,this.v3.z),new THREE.Vector3(t,i,r)}),THREE.SplineCurve3=THREE.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t,i,r,o=new THREE.Vector3,a=[],n=this.points;t=(n.length-1)*e,i=Math.floor(t),r=t-i,a[0]=0==i?i:i-1,a[1]=i,a[2]=i>n.length-2?n.length-1:i+1,a[3]=i>n.length-3?n.length-1:i+2;var s=n[a[0]],h=n[a[1]],l=n[a[2]],c=n[a[3]];return o.x=THREE.Curve.Utils.interpolate(s.x,h.x,l.x,c.x,r),o.y=THREE.Curve.Utils.interpolate(s.y,h.y,l.y,c.y,r),o.z=THREE.Curve.Utils.interpolate(s.z,h.z,l.z,c.z,r),o}),THREE.ClosedSplineCurve3=THREE.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t,i,r,o=new THREE.Vector3,a=[],n=this.points;return t=(n.length-0)*e,i=Math.floor(t),r=t-i,i+=i>0?0:(Math.floor(Math.abs(i)/n.length)+1)*n.length,a[0]=(i-1)%n.length,a[1]=i%n.length,a[2]=(i+1)%n.length,a[3]=(i+2)%n.length,o.x=THREE.Curve.Utils.interpolate(n[a[0]].x,n[a[1]].x,n[a[2]].x,n[a[3]].x,r),o.y=THREE.Curve.Utils.interpolate(n[a[0]].y,n[a[1]].y,n[a[2]].y,n[a[3]].y,r),o.z=THREE.Curve.Utils.interpolate(n[a[0]].z,n[a[1]].z,n[a[2]].z,n[a[3]].z,r),o}),THREE.AnimationHandler=function(){var e=[],t={},i={};i.update=function(t){for(var i=0;i1)&&(console.log("THREE.Animation.update: Warning! Scale out of bounds:"+i+" on bone "+g),i=i<0?0:1),"pos"===t?(r=h.position,this.interpolationType===THREE.AnimationHandler.LINEAR?(r.x=o[0]+(a[0]-o[0])*i,r.y=o[1]+(a[1]-o[1])*i,r.z=o[2]+(a[2]-o[2])*i):this.interpolationType!==THREE.AnimationHandler.CATMULLROM&&this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD||(this.points[0]=this.getPrevKeyWith("pos",g,n.index-1).pos,this.points[1]=o,this.points[2]=a,this.points[3]=this.getNextKeyWith("pos",g,s.index+1).pos,i=.33*i+.33,d=this.interpolateCatmullRom(this.points,i),r.x=d[0],r.y=d[1],r.z=d[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD&&(f=this.interpolateCatmullRom(this.points,1.01*i),this.target.set(f[0],f[1],f[2]),this.target.sub(r),this.target.y=0,this.target.normalize(),E=Math.atan2(this.target.x,this.target.z),h.rotation.set(0,E,0)))):"rot"===t?THREE.Quaternion.slerp(o,a,h.quaternion,i):"scl"===t&&(r=h.scale,r.x=o[0]+(a[0]-o[0])*i,r.y=o[1]+(a[1]-o[1])*i,r.z=o[2]+(a[2]-o[2])*i)}}}},THREE.Animation.prototype.interpolateCatmullRom=function(e,t){var i,r,o,a,n,s,h,l,c,u=[],p=[];return i=(e.length-1)*t,r=Math.floor(i),o=i-r,u[0]=0===r?r:r-1,u[1]=r,u[2]=r>e.length-2?r:r+1,u[3]=r>e.length-3?r:r+2,s=e[u[0]],h=e[u[1]],l=e[u[2]],c=e[u[3]],a=o*o,n=o*a,p[0]=this.interpolate(s[0],h[0],l[0],c[0],o,a,n),p[1]=this.interpolate(s[1],h[1],l[1],c[1],o,a,n),p[2]=this.interpolate(s[2],h[2],l[2],c[2],o,a,n),p},THREE.Animation.prototype.interpolate=function(e,t,i,r,o,a,n){var s=.5*(i-e),h=.5*(r-t);return(2*(t-i)+s+h)*n+(-3*(t-i)-2*s-h)*a+s*o+t},THREE.Animation.prototype.getNextKeyWith=function(e,t,i){var r=this.data.hierarchy[t].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?i=i0?i:0:i>=0?i:i+r.length;i>=0;i--)if(void 0!==r[i][e])return r[i];return this.data.hierarchy[t].keys[r.length-1]},THREE.KeyFrameAnimation=function(e,t,i){this.root=e,this.data=THREE.AnimationHandler.get(t),this.hierarchy=THREE.AnimationHandler.parse(e),this.currentTime=0,this.timeScale=.001,this.isPlaying=!1,this.isPaused=!0,this.loop=!0,this.JITCompile=void 0===i||i;for(var r=0,o=this.hierarchy.length;r=n?t.interpolate(i,n):t.interpolate(i,i.time)}this.data.hierarchy[c].node.updateMatrix(),r.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===l[0][a]){this.hierarchy[0].updateMatrixWorld(!0);for(var c=0;c=0?i:i+r.length;i>=0;i--)if(r[i].hasTarget(e))return r[i];return r[r.length-1]},THREE.CubeCamera=function(e,t,i){THREE.Object3D.call(this);var r=90,o=1,a=new THREE.PerspectiveCamera(r,o,e,t);a.up.set(0,-1,0),a.lookAt(new THREE.Vector3(1,0,0)),this.add(a);var n=new THREE.PerspectiveCamera(r,o,e,t);n.up.set(0,-1,0),n.lookAt(new THREE.Vector3((-1),0,0)),this.add(n);var s=new THREE.PerspectiveCamera(r,o,e,t);s.up.set(0,0,1),s.lookAt(new THREE.Vector3(0,1,0)),this.add(s);var h=new THREE.PerspectiveCamera(r,o,e,t);h.up.set(0,0,-1),h.lookAt(new THREE.Vector3(0,(-1),0)),this.add(h);var l=new THREE.PerspectiveCamera(r,o,e,t);l.up.set(0,-1,0),l.lookAt(new THREE.Vector3(0,0,1)),this.add(l);var c=new THREE.PerspectiveCamera(r,o,e,t);c.up.set(0,-1,0),c.lookAt(new THREE.Vector3(0,0,(-1))),this.add(c),this.renderTarget=new THREE.WebGLRenderTargetCube(i,i,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter}),this.updateCubeMap=function(e,t){var i=this.renderTarget,r=i.generateMipmaps;i.generateMipmaps=!1,i.activeCubeFace=0,e.render(t,a,i),i.activeCubeFace=1,e.render(t,n,i),i.activeCubeFace=2,e.render(t,s,i),i.activeCubeFace=3,e.render(t,h,i),i.activeCubeFace=4,e.render(t,l,i),i.generateMipmaps=r,i.activeCubeFace=5,e.render(t,c,i)}},THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype),THREE.CombinedCamera=function(e,t,i,r,o,a,n){THREE.Camera.call(this),this.fov=i,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2,this.cameraO=new THREE.OrthographicCamera(e/-2,e/2,t/2,t/-2,a,n),this.cameraP=new THREE.PerspectiveCamera(i,e/t,r,o),this.zoom=1,this.toPerspective()},THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype),THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near,this.far=this.cameraP.far,this.cameraP.fov=this.fov/this.zoom,this.cameraP.updateProjectionMatrix(),this.projectionMatrix=this.cameraP.projectionMatrix,this.inPerspectiveMode=!0,this.inOrthographicMode=!1},THREE.CombinedCamera.prototype.toOrthographic=function(){var e=this.fov,t=this.cameraP.aspect,i=this.cameraP.near,r=this.cameraP.far,o=(i+r)/2,a=Math.tan(e/2)*o,n=2*a,s=n*t,h=s/2;a/=this.zoom,h/=this.zoom,this.cameraO.left=-h,this.cameraO.right=h,this.cameraO.top=a,this.cameraO.bottom=-a,this.cameraO.updateProjectionMatrix(),this.near=this.cameraO.near,this.far=this.cameraO.far,this.projectionMatrix=this.cameraO.projectionMatrix,this.inPerspectiveMode=!1,this.inOrthographicMode=!0},THREE.CombinedCamera.prototype.setSize=function(e,t){this.cameraP.aspect=e/t,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2},THREE.CombinedCamera.prototype.setFov=function(e){this.fov=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){this.inPerspectiveMode?this.toPerspective():(this.toPerspective(),this.toOrthographic())},THREE.CombinedCamera.prototype.setLens=function(e,t){void 0===t&&(t=24);var i=2*THREE.Math.radToDeg(Math.atan(t/(2*e)));return this.setFov(i),i},THREE.CombinedCamera.prototype.setZoom=function(e){this.zoom=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0,this.rotation.y=Math.PI,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0,this.rotation.y=-Math.PI/2,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0,this.rotation.y=Math.PI/2,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},THREE.CircleGeometry=function(e,t,i,r){THREE.Geometry.call(this),e=e||50,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI,t=void 0!==t?Math.max(3,t):8;var o,a=[],n=new THREE.Vector3,s=new THREE.Vector2(.5,.5);for(this.vertices.push(n),a.push(s),o=0;o<=t;o++){var h=new THREE.Vector3,l=i+o/t*r;h.x=e*Math.cos(l),h.y=e*Math.sin(l),this.vertices.push(h),a.push(new THREE.Vector2((h.x/e+1)/2,(h.y/e+1)/2))}var c=new THREE.Vector3(0,0,1);for(o=1;o<=t;o++){var u=o,p=o+1,d=0;this.faces.push(new THREE.Face3(u,p,d,[c,c,c])),this.faceVertexUvs[0].push([a[o],a[o+1],s])}this.computeCentroids(),this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,e)},THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CubeGeometry=function(e,t,i,r,o,a){function n(e,t,i,r,o,a,n,h){var l,c,u,p=s.widthSegments,d=s.heightSegments,f=o/2,E=a/2,m=s.vertices.length;"x"===e&&"y"===t||"y"===e&&"x"===t?l="z":"x"===e&&"z"===t||"z"===e&&"x"===t?(l="y",d=s.depthSegments):("z"===e&&"y"===t||"y"===e&&"z"===t)&&(l="x",p=s.depthSegments);var g=p+1,v=d+1,T=o/p,y=a/d,R=new THREE.Vector3;for(R[l]=n>0?1:-1,u=0;u0)for(this.vertices.push(new THREE.Vector3(0,h,0)),n=0;n0)for(this.vertices.push(new THREE.Vector3(0,(-h),0)),n=0;no&&(o+=2*Math.PI);var a=(r+o)/2,n=-Math.cos(a),s=-Math.sin(a),h=new THREE.Vector2(n,s);return h}function a(e,t,i){var r,a,n,s,h,l,c=THREE.ExtrudeGeometry.__v1,u=THREE.ExtrudeGeometry.__v2,p=THREE.ExtrudeGeometry.__v3,d=THREE.ExtrudeGeometry.__v4,f=THREE.ExtrudeGeometry.__v5,E=THREE.ExtrudeGeometry.__v6;return c.set(e.x-t.x,e.y-t.y),u.set(e.x-i.x,e.y-i.y),r=c.normalize(),a=u.normalize(),p.set(-r.y,r.x),d.set(a.y,-a.x),f.copy(e).add(p),E.copy(e).add(d),f.equals(E)?d.clone():(f.copy(t).add(p),E.copy(i).add(d),n=r.dot(d),s=E.sub(f).dot(d),0===n&&(console.log("Either infinite or no solutions!"),0===s?console.log("Its finite solutions."):console.log("Too bad, no solutions.")),h=s/n,h<0?o(e,t,i):(l=r.multiplyScalar(h).add(f),l.sub(e).clone()))}function n(){if(R){var e=0,t=X*e;for(Q=0;Q=0;){i=Q,r=Q-1,r<0&&(r=e.length-1);var o=0,a=H+2*y;for(o=0;o=0;O--){for(k=O/y,j=v*(1-k),I=T*Math.sin(k*Math.PI/2),Q=0,K=B.length;Qv&&(E.normalize(),o=Math.acos(THREE.Math.clamp(p[l-1].dot(p[l]),-1,1)),d[l].applyMatrix4(m.makeRotationAxis(E,o))),f[l].crossVectors(p[l],d[l]);if(i)for(o=Math.acos(THREE.Math.clamp(d[0].dot(d[g-1]),-1,1)),o/=g-1,p[0].dot(E.crossVectors(d[0],d[g-1]))>0&&(o=-o),l=1;l.9&&H<.1&&(T<.2&&(v[0].x+=1),y<.2&&(v[1].x+=1),R<.2&&(v[2].x+=1))}for(var u=0,p=this.vertices.length;u.99999?this.quaternion.set(0,0,0,1):i.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(i.z,0,-i.x).normalize(),e=Math.acos(i.y),this.quaternion.setFromAxisAngle(t,e))}}(),THREE.ArrowHelper.prototype.setLength=function(e){this.scale.set(e,e,e)},THREE.ArrowHelper.prototype.setColor=function(e){this.line.material.color.setHex(e),this.cone.material.color.setHex(e)},THREE.BoxHelper=function(e){var t=[new THREE.Vector3(1,1,1),new THREE.Vector3((-1),1,1),new THREE.Vector3((-1),(-1),1),new THREE.Vector3(1,(-1),1),new THREE.Vector3(1,1,(-1)),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3((-1),(-1),(-1)),new THREE.Vector3(1,(-1),(-1))];this.vertices=t;var i=new THREE.Geometry;i.vertices.push(t[0],t[1],t[1],t[2],t[2],t[3],t[3],t[0],t[4],t[5],t[5],t[6],t[6],t[7],t[7],t[4],t[0],t[4],t[1],t[5],t[2],t[6],t[3],t[7]),THREE.Line.call(this,i,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces),void 0!==e&&this.update(e)},THREE.BoxHelper.prototype=Object.create(THREE.Line.prototype),THREE.BoxHelper.prototype.update=function(e){var t=e.geometry;null===t.boundingBox&&t.computeBoundingBox();var i=t.boundingBox.min,r=t.boundingBox.max,o=this.vertices;o[0].set(r.x,r.y,r.z),o[1].set(i.x,r.y,r.z),o[2].set(i.x,i.y,r.z),o[3].set(r.x,i.y,r.z),o[4].set(r.x,r.y,i.z),o[5].set(i.x,r.y,i.z),o[6].set(i.x,i.y,i.z),o[7].set(r.x,i.y,i.z),this.geometry.computeBoundingSphere(),this.geometry.verticesNeedUpdate=!0,this.matrixAutoUpdate=!1,this.matrixWorld=e.matrixWorld},THREE.BoundingBoxHelper=function(e,t){var i=t||8947848;this.object=e,this.box=new THREE.Box3,THREE.Mesh.call(this,new THREE.CubeGeometry(1,1,1),new THREE.MeshBasicMaterial({color:i,wireframe:!0}))},THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype), 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,r){i(e,r),i(t,r)}function i(e,t){r.vertices.push(new THREE.Vector3),r.colors.push(new THREE.Color(t)),void 0===a[e]&&(a[e]=[]),a[e].push(r.vertices.length-1)}var r=new THREE.Geometry,o=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),a={},n=16755200,s=16711680,h=43775,l=16777215,c=3355443;t("n1","n2",n),t("n2","n4",n),t("n4","n3",n),t("n3","n1",n),t("f1","f2",n),t("f2","f4",n),t("f4","f3",n),t("f3","f1",n),t("n1","f1",n),t("n2","f2",n),t("n3","f3",n),t("n4","f4",n),t("p","n1",s),t("p","n2",s),t("p","n3",s),t("p","n4",s),t("u1","u2",h),t("u2","u3",h),t("u3","u1",h),t("c","t",l),t("p","c",c),t("cn1","cn2",c),t("cn3","cn4",c),t("cf1","cf2",c),t("cf3","cf4",c),THREE.Line.call(this,r,o,THREE.LinePieces),this.camera=e,this.matrixWorld=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()},THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype),THREE.CameraHelper.prototype.update=function(){var e=new THREE.Vector3,t=new THREE.Camera,i=new THREE.Projector;return function(){function r(r,a,n,s){e.set(a,n,s),i.unprojectVector(e,t);var h=o.pointMap[r];if(void 0!==h)for(var l=0,c=h.length;l1){var l=h[1];h[2];r[l]||(r[l]={start:1/0,end:-(1/0)});var c=r[l];ac.end&&(c.end=a),t||(t=l)}}for(var l in r){var c=r[l];this.createAnimation(l,c.start,c.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 i=this.animationsMap[e];i&&(i.fps=t,i.duration=(i.end-i.start)/i.fps)},THREE.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var i=this.animationsMap[e];i&&(i.duration=t,i.fps=(i.end-i.start)/i.duration)},THREE.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var i=this.animationsMap[e];i&&(i.weight=t)},THREE.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var i=this.animationsMap[e];i&&(i.time=t)},THREE.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0,i=this.animationsMap[e];return i&&(t=i.time),t},THREE.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1,i=this.animationsMap[e];return i&&(t=i.duration),t},THREE.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("animation["+e+"] undefined")},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,i=this.animationsList.length;tr.duration||r.time<0)&&(r.direction*=-1,r.time>r.duration&&(r.time=r.duration,r.directionBackwards=!0),r.time<0&&(r.time=0,r.directionBackwards=!1)):(r.time=r.time%r.duration,r.time<0&&(r.time+=r.duration));var a=r.startFrame+THREE.Math.clamp(Math.floor(r.time/o),0,r.length-1),n=r.weight;a!==r.currentFrame&&(this.morphTargetInfluences[r.lastFrame]=0,this.morphTargetInfluences[r.currentFrame]=1*n,this.morphTargetInfluences[a]=0,r.lastFrame=r.currentFrame,r.currentFrame=a);var s=r.time%o/o;r.directionBackwards&&(s=1-s),this.morphTargetInfluences[r.currentFrame]=s*n,this.morphTargetInfluences[r.lastFrame]=(1-s)*n}}},THREE.LensFlarePlugin=function(){function e(e,i){var r=t.createProgram(),o=t.createShader(t.FRAGMENT_SHADER),a=t.createShader(t.VERTEX_SHADER),n="precision "+i+" float;\n";return t.shaderSource(o,n+e.fragmentShader),t.shaderSource(a,n+e.vertexShader),t.compileShader(o),t.compileShader(a),t.attachShader(r,o),t.attachShader(r,a),t.linkProgram(r),r}var t,i,r,o={};this.init=function(a){t=a.context,i=a,r=a.getPrecision(),o.vertices=new Float32Array(16),o.faces=new Uint16Array(6);var n=0;o.vertices[n++]=-1,o.vertices[n++]=-1,o.vertices[n++]=0,o.vertices[n++]=0,o.vertices[n++]=1,o.vertices[n++]=-1,o.vertices[n++]=1,o.vertices[n++]=0,o.vertices[n++]=1,o.vertices[n++]=1,o.vertices[n++]=1,o.vertices[n++]=1,o.vertices[n++]=-1,o.vertices[n++]=1,o.vertices[n++]=0,o.vertices[n++]=1,n=0,o.faces[n++]=0,o.faces[n++]=1,o.faces[n++]=2,o.faces[n++]=0,o.faces[n++]=2,o.faces[n++]=3,o.vertexBuffer=t.createBuffer(),o.elementBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,o.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,o.vertices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o.elementBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,o.faces,t.STATIC_DRAW),o.tempTexture=t.createTexture(),o.occlusionTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,o.tempTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGB,16,16,0,t.RGB,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.bindTexture(t.TEXTURE_2D,o.occlusionTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,16,16,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(o.hasVertexTexture=!1,o.program=e(THREE.ShaderFlares.lensFlare,r)):(o.hasVertexTexture=!0,o.program=e(THREE.ShaderFlares.lensFlareVertexTexture,r)),o.attributes={},o.uniforms={},o.attributes.vertex=t.getAttribLocation(o.program,"position"),o.attributes.uv=t.getAttribLocation(o.program,"uv"),o.uniforms.renderType=t.getUniformLocation(o.program,"renderType"),o.uniforms.map=t.getUniformLocation(o.program,"map"),o.uniforms.occlusionMap=t.getUniformLocation(o.program,"occlusionMap"),o.uniforms.opacity=t.getUniformLocation(o.program,"opacity"),o.uniforms.color=t.getUniformLocation(o.program,"color"),o.uniforms.scale=t.getUniformLocation(o.program,"scale"),o.uniforms.rotation=t.getUniformLocation(o.program,"rotation"),o.uniforms.screenPosition=t.getUniformLocation(o.program,"screenPosition")},this.render=function(e,r,a,n){var s=e.__webglFlares,h=s.length;if(h){var l=new THREE.Vector3,c=n/a,u=.5*a,p=.5*n,d=16/n,f=new THREE.Vector2(d*c,d),E=new THREE.Vector3(1,1,0),m=new THREE.Vector2(1,1),g=o.uniforms,v=o.attributes;t.useProgram(o.program),t.enableVertexAttribArray(o.attributes.vertex),t.enableVertexAttribArray(o.attributes.uv),t.uniform1i(g.occlusionMap,0),t.uniform1i(g.map,1),t.bindBuffer(t.ARRAY_BUFFER,o.vertexBuffer),t.vertexAttribPointer(v.vertex,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(v.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o.elementBuffer),t.disable(t.CULL_FACE),t.depthMask(!1);var T,y,R,x,H;for(T=0;T0&&m.x0&&m.y.001&&H.scale>.001&&(E.x=H.x,E.y=H.y,E.z=H.z,d=H.size*H.scale/n,f.x=d*c,f.y=d,t.uniform3f(g.screenPosition,E.x,E.y,E.z),t.uniform2f(g.scale,f.x,f.y),t.uniform1f(g.rotation,H.rotation),t.uniform1f(g.opacity,H.opacity),t.uniform3f(g.color,H.color.r,H.color.g,H.color.b),i.setBlending(H.blending,H.blendEquation,H.blendSrc,H.blendDst),i.setTexture(H.texture,1),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0));t.enable(t.CULL_FACE),t.enable(t.DEPTH_TEST),t.depthMask(!0)}}},THREE.ShadowMapPlugin=function(){function e(e,t){var i=new THREE.DirectionalLight;i.isVirtual=!0,i.onlyShadow=!0,i.castShadow=!0,i.shadowCameraNear=e.shadowCameraNear,i.shadowCameraFar=e.shadowCameraFar,i.shadowCameraLeft=e.shadowCameraLeft,i.shadowCameraRight=e.shadowCameraRight,i.shadowCameraBottom=e.shadowCameraBottom,i.shadowCameraTop=e.shadowCameraTop,i.shadowCameraVisible=e.shadowCameraVisible,i.shadowDarkness=e.shadowDarkness,i.shadowBias=e.shadowCascadeBias[t],i.shadowMapWidth=e.shadowCascadeWidth[t],i.shadowMapHeight=e.shadowCascadeHeight[t],i.pointsWorld=[],i.pointsFrustum=[];for(var r=i.pointsWorld,o=i.pointsFrustum,a=0;a<8;a++)r[a]=new THREE.Vector3,o[a]=new THREE.Vector3;var n=e.shadowCascadeNearZ[t],s=e.shadowCascadeFarZ[t];return o[0].set(-1,-1,n),o[1].set(1,-1,n),o[2].set(-1,1,n),o[3].set(1,1,n),o[4].set(-1,-1,s),o[5].set(1,-1,s),o[6].set(-1,1,s),o[7].set(1,1,s),i}function t(e,t){var i=e.shadowCascadeArray[t];i.position.copy(e.position),i.target.position.copy(e.target.position),i.lookAt(i.target),i.shadowCameraVisible=e.shadowCameraVisible,i.shadowDarkness=e.shadowDarkness,i.shadowBias=e.shadowCascadeBias[t];var r=e.shadowCascadeNearZ[t],o=e.shadowCascadeFarZ[t],a=i.pointsFrustum;a[0].z=r,a[1].z=r,a[2].z=r,a[3].z=r,a[4].z=o,a[5].z=o,a[6].z=o,a[7].z=o}function i(e,t){var i=t.shadowCamera,r=t.pointsFrustum,o=t.pointsWorld;p.set(1/0,1/0,1/0),d.set(-(1/0),-(1/0),-(1/0));for(var a=0;a<8;a++){var n=o[a];n.copy(r[a]),THREE.ShadowMapPlugin.__projector.unprojectVector(n,e),n.applyMatrix4(i.matrixWorldInverse),n.xd.x&&(d.x=n.x),n.yd.y&&(d.y=n.y),n.zd.z&&(d.z=n.z)}i.left=p.x,i.right=d.x,i.top=d.y,i.bottom=p.y,i.updateProjectionMatrix()}function r(e){return e.material instanceof THREE.MeshFaceMaterial?e.material.materials[0]:e.material}var o,a,n,s,h,l,c=new THREE.Frustum,u=new THREE.Matrix4,p=new THREE.Vector3,d=new THREE.Vector3,f=new THREE.Vector3;this.init=function(e){o=e.context,a=e;var t=THREE.ShaderLib.depthRGBA,i=THREE.UniformsUtils.clone(t.uniforms);n=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:i}),s=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:i,morphTargets:!0}),h=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:i,skinning:!0}),l=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:i,morphTargets:!0,skinning:!0}),n._shadowPass=!0,s._shadowPass=!0,h._shadowPass=!0,l._shadowPass=!0},this.render=function(e,t){a.shadowMapEnabled&&a.shadowMapAutoUpdate&&this.update(e,t)},this.update=function(p,d){var E,m,g,v,T,y,R,x,H,w,_,b,M,S,C=[],A=0,L=null;for(o.clearColor(1,1,1,1),o.disable(o.BLEND),o.enable(o.CULL_FACE),o.frontFace(o.CCW),a.shadowMapCullFace===THREE.CullFaceFront?o.cullFace(o.FRONT):o.cullFace(o.BACK),a.setDepthTest(!0),E=0,m=p.__lights.length;E0&&V.morphTargets,N=b instanceof THREE.SkinnedMesh&&V.skinning,w=b.customDepthMaterial?b.customDepthMaterial:N?z?l:h:z?s:n,H instanceof THREE.BufferGeometry?a.renderBufferDirect(x,p.__lights,L,w,H,b):a.renderBuffer(x,p.__lights,L,w,H,b));for(S=p.__webglObjectsImmediate,g=0,v=S.length;g0&&T.morphTargets, R=m instanceof THREE.SkinnedMesh&&T.skinning,f=m.customDepthMaterial?m.customDepthMaterial:R?y?n:a:y?o:r,d instanceof THREE.BufferGeometry?i.renderBufferDirect(c,l.__lights,v,f,d,m):i.renderBuffer(c,l.__lights,v,f,d,m)}for(g=l.__webglObjectsImmediate,u=0,p=g.length;u 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;","float 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")}},Detector={canvas:!!window.CanvasRenderingContext2D,webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(e){return!1}}(),workers:!!window.Worker,fileapi:window.File&&window.FileReader&&window.FileList&&window.Blob,getWebGLErrorMessage:function(){var e=document.createElement("div");return e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support WebGL.
','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.'].join("\n")),e},addGetWebGLMessage:function(e){var t,i,r;e=e||{},t=void 0!==e.parent?e.parent:document.body,i=void 0!==e.id?e.id:"oldie",r=Detector.getWebGLErrorMessage(),r.id=i,t.appendChild(r)}},THREE.OrbitControls=function(e,t){function i(){return 2*Math.PI/60/60*c.autoRotateSpeed}function r(){return Math.pow(.95,c.userZoomSpeed)}function o(e){c.enabled!==!1&&c.userRotate!==!1&&(e.preventDefault(),w===H.NONE&&(0===e.button&&(w=H.ROTATE),1===e.button&&(w=H.ZOOM),2===e.button&&(w=H.PAN)),w===H.ROTATE?d.set(e.clientX,e.clientY):w===H.ZOOM?m.set(e.clientX,e.clientY):w===H.PAN,document.addEventListener("mousemove",a,!1),document.addEventListener("mouseup",n,!1))}function a(e){if(c.enabled!==!1)if(e.preventDefault(),w===H.ROTATE)f.set(e.clientX,e.clientY),E.subVectors(f,d),c.rotateLeft(2*Math.PI*E.x/p*c.userRotateSpeed),c.rotateUp(2*Math.PI*E.y/p*c.userRotateSpeed),d.copy(f);else if(w===H.ZOOM)g.set(e.clientX,e.clientY),v.subVectors(g,m),v.y>0?c.zoomIn():c.zoomOut(),m.copy(g);else if(w===H.PAN){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||0;c.pan(new THREE.Vector3((-t),i,0))}}function n(e){c.enabled!==!1&&c.userRotate!==!1&&(document.removeEventListener("mousemove",a,!1),document.removeEventListener("mouseup",n,!1),w=H.NONE)}function s(e){if(c.enabled!==!1&&c.userZoom!==!1){var t=0;e.wheelDelta?t=e.wheelDelta:e.detail&&(t=-e.detail),t>0?c.zoomOut():c.zoomIn()}}function h(e){if(c.enabled!==!1&&c.userPan!==!1)switch(e.keyCode){case c.keys.ROTATE:w=H.ROTATE;break;case c.keys.ZOOM:w=H.ZOOM;break;case c.keys.PAN:w=H.PAN}}function l(e){switch(e.keyCode){case c.keys.ROTATE:case c.keys.ZOOM:case c.keys.PAN:w=H.NONE}}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.center=new THREE.Vector3,this.userZoom=!0,this.userZoomSpeed=1,this.userRotate=!0,this.userRotateSpeed=1,this.userPan=!0,this.userPanSpeed=.02,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minDistance=0,this.maxDistance=1/0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40,ROTATE:65,ZOOM:83,PAN:68};var c=this,u=1e-6,p=1800,d=new THREE.Vector2,f=new THREE.Vector2,E=new THREE.Vector2,m=new THREE.Vector2,g=new THREE.Vector2,v=new THREE.Vector2,T=0,y=0,R=1,x=new THREE.Vector3,H={NONE:-1,ROTATE:0,ZOOM:1,PAN:2},w=H.NONE,_={type:"change"};this.rotateLeft=function(e){void 0===e&&(e=i()),y-=e},this.rotateRight=function(e){void 0===e&&(e=i()),y+=e},this.rotateUp=function(e){void 0===e&&(e=i()),T-=e},this.rotateDown=function(e){void 0===e&&(e=i()),T+=e},this.zoomIn=function(e){void 0===e&&(e=r()),R/=e},this.zoomOut=function(e){void 0===e&&(e=r()),R*=e},this.pan=function(e){e.transformDirection(this.object.matrix),e.multiplyScalar(c.userPanSpeed),this.object.position.add(e),this.center.add(e)},this.update=function(){var e=this.object.position,t=e.clone().sub(this.center),r=Math.atan2(t.x,t.z),o=Math.atan2(Math.sqrt(t.x*t.x+t.z*t.z),t.y);this.autoRotate&&this.rotateLeft(i()),r+=y,o+=T,o=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,o)),o=Math.max(u,Math.min(Math.PI-u,o));var a=t.length()*R;a=Math.max(this.minDistance,Math.min(this.maxDistance,a)),t.x=a*Math.sin(o)*Math.sin(r),t.y=a*Math.cos(o),t.z=a*Math.sin(o)*Math.cos(r),e.copy(this.center).add(t),this.object.lookAt(this.center),y=0,T=0,R=1,x.distanceTo(this.object.position)>0&&(this.dispatchEvent(_),x.copy(this.object.position))},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1),window.addEventListener("keydown",h,!1),window.addEventListener("keyup",l,!1)},THREE.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype);var VENUE3D=VENUE3D||{REVISION:"1"};VENUE3D.Engine=function(e){return this.parseConfig(),this},VENUE3D.Engine.prototype={data:null,items:[],relations:[],categories:[],constructor:VENUE3D.Engine,selectedColor:"#ff9900",unavailableColor:"#ff0000",highlightColor:"#5EBA4E",mediaURL:"",debug:!1,highlightedItems:[],highlighted:[],init:function(){void 0!=this.data&&null!=this.data||(this.addTemplates(),this.loadFromURL(this.url))},loadFromURL:function(e){var t=this;jQuery.ajax({dataType:"json",url:this.url,success:function(e){t.data=e,t.loadConfig(),t.build(),t.hideTooltip()}})},loadConfig:function(e){},build:function(e){this.drawItems(),this.addEventListeners()},drawItems:function(){},addEventListeners:function(){},removeEventListeners:function(){},highlightItems:function(e){},removeHighlights:function(){},showTooltip:function(e){var t,i,r=!1;if(void 0!=this.mouseX){if(e){if(t=this.relations[e],!t)return this.hideTooltip(),void(this["info-visible"]=!1);t.num=e,this.num=e,this["info-visible"]=!0,void 0!==t&&(t.image_url=t.image_url,"type"in t&&"available"==t.type?html=_.template(jQuery("#template-tooltip-tile").html(),t):"type"in t&&"stand"==t.type?html=_.template(jQuery("#template-tooltip-sponsor").html(),t):(r=!0,html=_.template(jQuery("#template-tooltip-section").html(),t)),jQuery(".tooltip-wrapper").html(html),r&&jQuery(".tooltip-wrapper #html").html(jQuery("
").html(t.html).text()),jQuery(".tooltip-wrapper").css("display","block"))}else e=this.num;t=this.relations[e],i=document.body.scrollTop,t&&(e&&"num"in t&&(t.num=e),"stand"==t.type?(jQuery(".tooltip-wrapper").css("left",this.mouseX-65+"px"),jQuery(".tooltip-wrapper").css("top",this.mouseY-170+i+"px")):(jQuery(".tooltip-wrapper").css("left",this.mouseX-50+"px"),jQuery(".tooltip-wrapper").css("top",this.mouseY-125+i+"px")))}},hideTooltip:function(){this["info-visible"]=!1,jQuery(".tooltip-wrapper").css("display","none")},getTiles:function(){var e,t,i=[];for(e in this.data.items)t=this.data.items[e],void 0!==t&&"type"in t&&"available"==t.type&&i.push(t);return i},getItems:function(){var e,t,i={};for(e in this.data.items)t=this.data.items[e],void 0!==t&&"type"in t&&("section"==t.type||"stand"==t.type)&&(i[t.id]=t);return i},parseConfig:function(e){if(void 0!==e)for(key in e)this[key]=e[key]},destroy:function(){},whoAmI:function(){console.log("base")},addTemplates:function(){jQuery("#template-tooltip-sponsor").length||jQuery("body").append(''),jQuery("#template-tooltip-tile").length||jQuery("body").append(''),jQuery("#template-tooltip-section").length||jQuery("body").append(''),jQuery("#tooltip-wrapper").length||jQuery("body").append('')}},VENUE3D.Engine2d=function(e){if(void 0!==e)for(key in e)this[key]=e[key];return this},VENUE3D.Engine2d.prototype=new VENUE3D.Engine,VENUE3D.Engine2d.prototype.constructor=VENUE3D.Engine2d,VENUE3D.Engine2d.prototype.loadConfig=function(e){jQuery(this.wrapper).css("width",this.width),jQuery(this.wrapper).css("height",this.height),this.mouse=new THREE.Vector2;for(key in e)void 0!==this[key]&&(this[key]=e[key])},VENUE3D.Engine2d.prototype.build=function(){var e,t;for(e in this.data.categories)this.categories[this.data.categories[e].id]=this.data.categories[e];jQuery(this.wrapper).html('
'),jQuery(this.wrapper+" #wrapper").css("width","100%"),jQuery(this.wrapper+" #wrapper").css("height","100%"),jQuery(this.wrapper+" #wrapper").css("overflow","hidden"),void 0!==this.backgroundColor&&jQuery(this.wrapper+" #wrapper").css("backgroundColor",this.backgroundColor),t=this.backgroundImage,""!=this.mediaURL&&(t=this.mediaURL+this.backgroundImage),jQuery(this.wrapper+" #plan").attr("src",t),this.drawItems(),this.addEventListeners(),this.hideTooltip(),this.highlightItems()},VENUE3D.Engine2d.prototype.drawItems=function(){var e,t,i,r,o,a,n,s,h,l,c,u,p;if(e="",t=this.getTiles(),this.debug)for(a=0;a<=this.columns;a++)for(n=0;n<=this.rows;n++)s="#333333",e+='
',this.relations[a+":"+n]={},this.relations[a+":"+n].type="available",this.relations[a+":"+n].color=s,this.relations[a+":"+n].category="A";for(i in t)for(r=t[i].start.split(":"),o=t[i].end.split(":"),a=parseInt(r[0],10);a<=parseInt(o[0],10);a++)for(n=parseInt(r[1],10);n<=parseInt(o[1],10);n++)s="#333333",void 0!==this.categories[t[i].category]&&(s=this.categories[t[i].category].color),e+='
',this.relations[a+":"+n]=t[i],this.relations[a+":"+n].type="available",this.relations[a+":"+n].color=this.categories[t[i].category].color;jQuery(this.wrapper+" #tiles").html(e),e="",l=this.getItems();for(p in l)h=l[p],r=h.start.split(":"),o=h.end.split(":"),c=Math.abs(parseInt(o[0],10)-parseInt(r[0],10))*this.tileSize,u=Math.abs(parseInt(o[1],10)-parseInt(r[1],10))*this.tileSize,e+="stand"==h.type?'
':"image_url"in h?'
':'
',h.mouseEnabled&&(this.relations[h.id]=h);jQuery(this.wrapper+" #sections").html(e)},VENUE3D.Engine2d.prototype.highlightItems=function(e){var t,i,r;if(void 0==this.data)return void(this.highlighted=e);this.removeHighlights(),void 0==e&&this.highlighted.length?e=this.highlighted:this.highlighted=e;for(r in e)t=e[r],i=this.highlightColor,"color"in t&&(i=t.color),this.highlighted[r].previousColor=jQuery(".venue3d-section#"+t.id).css("backgroundColor"),jQuery(".venue3d-section#"+t.id).css("backgroundColor",i)},VENUE3D.Engine2d.prototype.removeHighlights=function(){for(key in this.highlighted)item=this.highlighted[key],"previousColor"in item&&jQuery(".venue3d-section#"+item.id).css("backgroundColor",item.previousColor)},VENUE3D.Engine2d.prototype.removeEventListeners=function(){jQuery(this.wrapper+" #draggable img").unbind("dragstart"),jQuery(this.wrapper+" #draggable").unbind("mousedown"),jQuery(this.wrapper+" #draggable").unbind("mouseup"),jQuery(this.wrapper+" #draggable").unbind("mousemove"),jQuery(this.wrapper+" .tile").unbind("click"),jQuery(this.wrapper+" .tile,"+this.wrapper+" .venue3d-section").unbind("mouseenter"),jQuery(this.wrapper+" .venue3d-section").unbind("click"),jQuery(this.wrapper).unbind("mousemove")},VENUE3D.Engine2d.prototype.destroy=function(){this.relations=null,this.categories=null,this.removeEventListeners()},VENUE3D.Engine2d.prototype.addEventListeners=function(){var e,t,i,r=this;jQuery(this.wrapper+" #draggable img").on("dragstart",function(e){e.preventDefault()}),jQuery(this.wrapper+" #draggable").mousedown(function(e){r.dragging=!0,r.initialX=e.pageX}),jQuery(this.wrapper+" #draggable").mouseup(function(){r.dragging=!1}),jQuery(this.wrapper+" #draggable").mousemove(function(i){r.dragging&&(e=parseInt(jQuery(r.wrapper+" #draggable").css("left"),10),t=i.pageX-r.initialX,jQuery(r.wrapper+" #draggable").css("left",t))}),jQuery(this.wrapper+" .tile,"+this.wrapper+" .venue3d-section").mouseenter(function(){i=jQuery(this).attr("id"),previousColor=jQuery(this).css("backgroundColor"),jQuery(this).hasClass("section-image")||jQuery(this).css("backgroundColor",r.selectedColor),r.showTooltip(i)}).mouseleave(function(){jQuery(this).css("backgroundColor",previousColor),r.hideTooltip()}),jQuery(this.wrapper+" .venue3d-section, "+this.wrapper+" .tile").click(function(){if(i=jQuery(this).attr("id"),void 0!==r.relations[i]){var e=r.relations[i];"url"in e&&(r.hideTooltip(),""!=e.url&&window.open(e.url,"_blank"))}}),jQuery(this.wrapper).mousemove(function(e){e.preventDefault(),r.mouseX=e.clientX,r.mouseY=e.clientY,r.showTooltip()})},VENUE3D.Engine2d.prototype.whoAmI=function(){console.log("2d")},jQuery(document).on("mousewheel","#venue-wrapper",function(e){e.preventDefault(),e.stopPropagation()}),VENUE3D.Engine3d=function(e){if(void 0!==e)for(key in e)this[key]=e[key];return this},VENUE3D.Engine3d.prototype=new VENUE3D.Engine,VENUE3D.Engine3d.prototype.constructor=VENUE3D.Engine3d,VENUE3D.Engine3d.prototype.loadConfig=function(e){this.mouse=new THREE.Vector2,this.intersects=[],this.textures=[],jQuery(this.wrapper).css("width",this.width),jQuery(this.wrapper).css("height",this.height);for(key in e)void 0!==this[key]&&(this[key]=e[key])},VENUE3D.Engine3d.prototype.build=function(){var e,t,i,r,o=45,a=this.width/this.height,n=.1,s=2e4;if(!Detector.webgl)return jQuery(this.wrapper).css("background","#111"),jQuery(this.wrapper).html('
WebGL is not enabled
'),r=.5*this.width,jQuery(".venue3d-error").css("width",r),jQuery(".venue3d-error").css("position","absolute"),jQuery(".venue3d-error").css("left",.5*this.width-.5*r),jQuery(".venue3d-error").css("top",.5*this.height-20),jQuery(".venue3d-error").css("text-align","center"),jQuery(".venue3d-error").css("font-family","helvetica"),jQuery(".venue3d-error").css("padding","20"),void jQuery(".venue3d-error").css("background","rgb(214, 73, 32)");for(e in this.data.categories)this.categories[this.data.categories[e].id]=this.data.categories[e];this.scene=new THREE.Scene,this.camera=new THREE.PerspectiveCamera(o,a,n,s),this.scene.add(this.camera),this.camera.position.set(0,3.6,2.9),this.raycaster=new THREE.Raycaster,this.projector=new THREE.Projector,this.renderer=new THREE.WebGLRenderer({antialias:!0}),this.renderer.setSize(this.width,this.height),t=new THREE.Color,t.setStyle(this.backgroundColor),this.renderer.setClearColor(t,1),this.container=jQuery(this.wrapper),jQuery(this.wrapper).html(this.renderer.domElement),i=this,this.controls=new THREE.OrbitControls(this.camera,this.renderer.domElement),this.controls.addEventListener("change",i.render.bind(i)),jQuery.ajax({dataType:"json",url:this.geometryURL,success:function(e){var t,r,o,a,n,s;i.data.models=e.models;for(t in i.data.models)if(o=i.data.models[t],i.textures[o.id]=new THREE.ImageUtils.loadTexture(i.mediaURL+o.texture,{},function(){i.renderer.render(i.scene,i.camera)}),t=o.data.substring(o.data.lastIndexOf("/")+1,o.data.lastIndexOf(".")),loader=new THREE.JSONLoader,r=loader.parse(e.geometry[t]),a=new THREE.MeshBasicMaterial({map:i.textures[o.id]}),"positions"in o)for(n in o.positions)s=new THREE.Mesh(r.geometry,a),s.position.set(o.positions[n].x,o.positions[n].y,o.positions[n].z),i.scene.add(s);else s=new THREE.Mesh(r.geometry,a),i.scene.add(s);i.drawItems(),i.addEventListeners(),i.hideTooltip(),i.running=!0,i.animate(),i.highlightItems()}})},VENUE3D.Engine3d.prototype.drawItems=function(){var e,t,i,r,o,a,n,s,h,l,c,u,p,d,f,E,m,g,v=this.getTiles(),T=THREE.NormalBlending,y=.5;for(e in v)for(t=v[e].start.split(":"),i=v[e].end.split(":"),r=parseInt(t[0],10);r<=parseInt(i[0],10);r++)for(o=parseInt(t[1],10);o<=parseInt(i[1],10);o++)a=new THREE.PlaneGeometry(this.tileSize,this.tileSize),n="#333333",void 0!==this.categories[v[e].category]&&(n=this.categories[v[e].category].color),s=new THREE.MeshBasicMaterial({color:n,opacity:y,blending:T,transparent:!0}),mesh=new THREE.Mesh(a,s),mesh.rotation.x=Math.PI*-.5,mesh.position.set(r*this.tileSize-3.215,.091,o*this.tileSize-.85),mesh.mouseEnabled=!0,this.relations[r+":"+o]=v[e],this.relations[r+":"+o].type="available",this.relations[r+":"+o].color=this.categories[v[e].category].color,mesh.num=r+":"+o,this.scene.add(mesh);h=this.getItems();for(l in h)c=h[l],t=c.start.split(":"),i=c.end.split(":"),f=Math.abs(parseInt(i[0],10)-parseInt(t[0],10))*this.tileSize,d=Math.abs(parseInt(i[1],10)-parseInt(t[1],10))*this.tileSize,u=parseInt(t[0],10)*this.tileSize-3.235+.5*f,p=parseInt(t[1],10)*this.tileSize-.85+.5*d,a=new THREE.PlaneGeometry(f,d),n=new THREE.Color,n.getHexString("0xeeeeee"),"color"in c&&n.setStyle(c.color),m=this,g=.091,parseInt(t[0],10)>=170&&(g=.41),"stand"==c.type?s=new THREE.MeshBasicMaterial({color:n.setStyle(m.unavailableColor),opacity:y,blending:T,transparent:!0}):"image_url"in c?(E=new THREE.ImageUtils.loadTexture(c.image_url,{},function(){m.renderer.render(m.scene,m.camera)}),s=new THREE.MeshBasicMaterial({map:E,transparent:!0})):(g=.09,parseInt(t[0],10)>=170&&(g=.4),s=new THREE.MeshBasicMaterial({color:n,opacity:y,blending:T,transparent:!0})),mesh=new THREE.Mesh(a,s),mesh.rotation.x=Math.PI*-.5,mesh.position.set(u,g,p),mesh.mouseEnabled=c.mouseEnabled,mesh.available=c.available,mesh.num=c.id,c.mouseEnabled&&(this.relations[c.id]=c),this.scene.add(mesh)},VENUE3D.Engine3d.prototype.addEventListeners=function(){var e,t,i=this;jQuery(this.wrapper).mousemove(function(r){r.preventDefault(),i.mouseX=r.clientX,i.mouseY=r.clientY,void 0==r.offsetX?(e=r.pageX-jQuery(i.wrapper).offset().left,t=r.pageY-jQuery(i.wrapper).offset().top):(e=r.offsetX,t=r.offsetY),i.mouse.x=e/i.width*2-1,i.mouse.y=2*-(t/i.height)+1,i.showTooltip()}),jQuery(this.wrapper).mouseup(function(){i.isMouseDown=!1}),jQuery(this.wrapper).mousedown(function(){var e,t=i.findIntesections();i.isMouseDown=!0,null!==t&&void 0!==t&&"num"in t&&i.relations[t.num]&&(e=i.relations[t.num],"url"in e&&(i.hideTooltip(),""!=e.url&&window.open(e.url,"_blank")))})},VENUE3D.Engine3d.prototype.highlightItems=function(e){var t,i,r,o,a,n,s;if(void 0==this.data)return void(this.highlighted=e);this.removeHighlights(),void 0==e&&this.highlighted.length&&(e=this.highlighted);for(s in e){if(t=e[s],n=new THREE.Color,n.setStyle(this.highlightColor),"color"in t&&n.setStyle(t.color),sections=this.getItems(),section=sections[t.id],void 0==section)return;rangeStart=section.start.split(":"),rangeEnd=section.end.split(":"),width=Math.abs(parseInt(rangeEnd[0],10)-parseInt(rangeStart[0],10))*this.tileSize,height=Math.abs(parseInt(rangeEnd[1],10)-parseInt(rangeStart[1],10))*this.tileSize,x=parseInt(rangeStart[0],10)*this.tileSize-3.235+.5*width,y=parseInt(rangeStart[1],10)*this.tileSize-.85+.5*height,a=.3,"stand"==section.type&&(a=.1),i=new THREE.CubeGeometry(width,a,height),r=new THREE.MeshBasicMaterial({color:n,opacity:1,blending:THREE.MultiplyBlending,transparent:!0}),o=new THREE.Mesh(i,r),o.highlighted=!0,o.mouseEnabled=!0,o.num=t.id,this.relations[t.id]=section,z=.091,parseInt(rangeStart[0],10)>=170&&(z=.41),o.position.set(x,z+.5*a,y),this.scene.add(o),this.highlightedItems.push(o)}},VENUE3D.Engine3d.prototype.removeHighlights=function(e){for(item in this.highlightedItems)this.scene.remove(this.highlightedItems[item])},VENUE3D.Engine3d.prototype.removeEventListeners=function(){jQuery(this.wrapper).unbind("mousedown"),jQuery(this.wrapper).unbind("mousemove")},VENUE3D.Engine3d.prototype.destroy=function(){this.relations=null,this.categories=null,this.removeEventListeners(),this.running=!1},VENUE3D.Engine3d.prototype.animate=function(){this.running&&(requestAnimationFrame(this.animate.bind(this)),this.render(),this.update())},VENUE3D.Engine3d.prototype.update=function(){this.controls.update()},VENUE3D.Engine3d.prototype.render=function(){this.findIntesections(),this.renderer.render(this.scene,this.camera)},VENUE3D.Engine3d.prototype.findIntesections=function(){var e,t,i;return e=new THREE.Vector3(this.mouse.x,this.mouse.y,1),this.projector.unprojectVector(e,this.camera),this.raycaster.set(this.camera.position,e.sub(this.camera.position).normalize()),t=this.raycaster.intersectObjects(this.scene.children,!0),!this.isMouseDown&&t.length>0&&t[0].object.mouseEnabled?this.intersected!=t[0].object&&(this.intersected&&(this.setTileColor(this.intersected,this.intersected.currentHex),this.hideTooltip()),t[0].object.mouseEnabled&&(this.intersected=t[0].object,this.intersected.currentHex=this.getTileColor(this.intersected),i=new THREE.Color,i.setStyle(this.selectedColor),this.setTileColor(this.intersected,i.getHex()),jQuery(this.wrapper).css("cursor","pointer"),this.showTooltip(this.intersected.num))):(this.intersected&&(this.setTileColor(this.intersected,this.intersected.currentHex),this.hideTooltip(),jQuery(this.wrapper).css("cursor","default")),this.intersected=null),this.intersected},VENUE3D.Engine3d.prototype.getTileColor=function(e){return e.material.color.getHex()},VENUE3D.Engine3d.prototype.setTileColor=function(e,t){e.material.color.setHex(t)},VENUE3D.Engine3d.prototype.whoAmI=function(){console.log("3d")},VENUE3D.Collection=function(e){return this.parseConfig(e),this.build(),this},VENUE3D.Collection.prototype={items:[],constructor:VENUE3D.Collection,build:function(e){this["first-run"]=!0;var t,i,r="";if(r+='
    ',void 0!==this.items)for(t in this.items)r+='
  • '+this.items[t].name+"
  • ";r+="
",r+='
Highlight Area
',r+='
Highlight Stands
',r+='
UnHighlight All
',r+="
",jQuery(this["toolbar-wrapper"]).html(r),jQuery(this["toolbar-wrapper"]).css("width",this.width),i=this,jQuery(".tab").click(function(){if(jQuery(this).attr("id").indexOf("-")!==-1){var e=parseInt(jQuery(this).attr("id").split("-")[1],10);i.showIndex(e)}else"highlight_retro"===jQuery(this).attr("id")?venue3d.highlightItems([{id:4001,color:"#ffab00"}]):"highlight_stand"===jQuery(this).attr("id")?venue3d.highlightItems([{id:400101,color:"#bb00ff"},{id:400102,color:"#bb00ff"}]):venue3d.highlightItems([])}),this.showIndex(0)},showIndex:function(e){if(this["last-index"]!=e){void 0!==this.engine&&this.engine.destroy();var t=this.items[e];if("mode"in t){if("3D"==t.mode&&!Detector.webgl&&this.items.length>e+1&&this["first-run"])return void this.showIndex(e+1);if(this["first-run"]=!1,void 0!==this.config)for(key in this.config)t[key]=this.config[key];t.wrapper=this["view-wrapper"],"2D"==t.mode?this.engine=new VENUE3D.Engine2d(t):this.engine=new VENUE3D.Engine3d(t),this.engine.init()}jQuery(".tab.selected").toggleClass("selected"),jQuery(".tab#view-"+e).toggleClass("selected"),this["last-index"]=e}},highlightItems:function(e){this.engine.highlightItems(e)},removeHighlights:function(e){this.engine.removeHighlights()},parseConfig:function(e){if(void 0!==e)for(key in e)this[key]=e[key];this.config=e}};