three.min.js 397 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. // three.min.js - http://github.com/mrdoob/three.js
  2. 'use strict';var THREE=THREE||{REVISION:"52dev"};void 0===self.console&&(self.console={info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}});void 0===self.Int32Array&&(self.Int32Array=Array,self.Float32Array=Array);void 0===String.prototype.startsWith&&(String.prototype.startsWith=function(a){return this.slice(0,a.length)===a});
  3. void 0===String.prototype.endsWith&&(String.prototype.endsWith=function(a){var a=String(a),b=this.lastIndexOf(a);return b>=0&&b===this.length-a.length});void 0===!String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});
  4. (function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c){window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"]}if(window.requestAnimationFrame===void 0)window.requestAnimationFrame=function(b){var c=Date.now(),e=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+e)},e);a=c+e;return g};if(window.cancelAnimationFrame===void 0)window.cancelAnimationFrame=
  5. function(a){clearTimeout(a)}})();THREE.FrontSide=0;THREE.BackSide=1;THREE.DoubleSide=2;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;THREE.CustomBlending=5;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;
  6. THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};
  7. THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.UnsignedShort4444Type=1016;
  8. THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.Clock=function(a){this.autoStart=a!==void 0?a:true;this.elapsedTime=this.oldTime=this.startTime=0;this.running=false};
  9. THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=true};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=false};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime=this.elapsedTime+this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime=this.elapsedTime+a}return a};
  10. THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
  11. THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
  12. this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,e;if(c===0)this.r=this.g=this.b=0;else{d=Math.floor(a*6);f=a*6-d;a=c*(1-b);e=c*(1-b*f);b=c*(1-b*(1-f));if(d===0){this.r=c;this.g=b;this.b=a}else if(d===1){this.r=e;this.g=c;this.b=a}else if(d===2){this.r=a;this.g=c;this.b=b}else if(d===3){this.r=a;this.g=e;this.b=c}else if(d===4){this.r=b;this.g=a;this.b=c}else if(d===5){this.r=c;this.g=a;this.b=e}}return this},setHex:function(a){a=
  13. Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r=this.r+(a.r-this.r)*b;this.g=this.g+(a.g-this.g)*b;this.b=this.b+(a.b-this.b)*b;return this},getHex:function(){return this.r*255<<16^this.g*255<<8^this.b*255<<0},getContextStyle:function(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
  14. THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
  15. THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;return this},divideScalar:function(a){if(a){this.x=
  16. this.x/a;this.y=this.y/a}else this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
  17. lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},isZero:function(a){return this.lengthSq()<(a!==void 0?a:1E-4)},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
  18. THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;return this},addScalar:function(a){this.x=this.x+a;this.y=this.y+
  19. a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y=
  20. this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},
  21. setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,
  22. a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],g=d[8],h=d[1],i=d[5],j=d[9],l=d[2],n=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-j,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(n,i);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(j));if(Math.abs(j)<
  23. 0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(h,i)}else{this.y=Math.atan2(-l,f);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(n));if(Math.abs(n)<0.99999){this.y=Math.atan2(-l,d);this.z=Math.atan2(-e,i)}else{this.y=0;this.z=Math.atan2(h,f)}}else if(b==="ZYX"){this.y=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(n,d);this.z=Math.atan2(h,f)}else{this.x=0;this.z=Math.atan2(-e,i)}}else if(b==="YZX"){this.z=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-j,i);this.y=Math.atan2(-l,
  24. f)}else{this.x=0;this.y=Math.atan2(g,d)}}else if(b==="XZY"){this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(n,i);this.y=Math.atan2(g,f)}else{this.x=Math.atan2(-j,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,g=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-f+e);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-f-e)}else if(b===
  25. "YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+f-e)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-f+e);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+f-e)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-f+e);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-f-e)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z*
  26. a.y),g-d+f-e);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-f-e);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-d+f-e);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-f-e);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=
  27. b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},isZero:function(a){return this.lengthSq()<(a!==void 0?a:1E-4)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
  28. THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x=
  29. this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{this.z=this.y=this.x=0;this.w=1}return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
  30. 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(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*
  31. Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y=a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(Math.abs(d-g)<0.01&&Math.abs(e-c)<0.01&&Math.abs(i-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(e+c)<0.1&&Math.abs(i+b)<0.1&&Math.abs(f+h+j-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;e=
  32. (e+c)/4;i=(i+b)/4;if(f>h&&f>j)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(h>j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=e/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.001&&(a=1);this.x=(b-i)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
  33. THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*f;l[4]=b*e;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this},
  34. transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,g,h,i,j,l,n,m,q,o,p){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,h||0,i||0,j||0,l!==void 0?l:1,n||0,m||0,q||0,o||0,p!==void 0?p:1)};
  35. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,i,j,l,n,m,q,o,p){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=g;r[13]=h;r[2]=i;r[6]=j;r[10]=l;r[14]=n;r[3]=m;r[7]=q;r[11]=o;r[15]=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
  36. f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;f.cross(c,g).normalize();if(f.length()===0){g.x=g.x+1E-4;f.cross(c,g).normalize()}e.cross(g,f);d[0]=f.x;d[4]=e.x;d[8]=g.x;d[1]=f.y;d[5]=e.y;d[9]=g.y;d[2]=f.z;d[6]=e.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],g=c[4],h=c[8],i=c[12],j=c[1],l=c[5],n=c[9],m=c[13],q=c[2],o=c[6],p=c[10],r=c[14],t=c[3],u=c[7],v=c[11],c=c[15],s=d[0],z=d[4],
  37. w=d[8],A=d[12],J=d[1],D=d[5],F=d[9],B=d[13],E=d[2],H=d[6],Q=d[10],L=d[14],K=d[3],I=d[7],M=d[11],d=d[15];f[0]=e*s+g*J+h*E+i*K;f[4]=e*z+g*D+h*H+i*I;f[8]=e*w+g*F+h*Q+i*M;f[12]=e*A+g*B+h*L+i*d;f[1]=j*s+l*J+n*E+m*K;f[5]=j*z+l*D+n*H+m*I;f[9]=j*w+l*F+n*Q+m*M;f[13]=j*A+l*B+n*L+m*d;f[2]=q*s+o*J+p*E+r*K;f[6]=q*z+o*D+p*H+r*I;f[10]=q*w+o*F+p*Q+r*M;f[14]=q*A+o*B+p*L+r*d;f[3]=t*s+u*J+v*E+c*K;f[7]=t*z+u*D+v*H+c*I;f[11]=t*w+u*F+v*Q+c*M;f[15]=t*A+u*B+v*L+c*d;return this},multiplySelf:function(a){return this.multiply(this,
  38. a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]=
  39. b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=1/(b[3]*c+b[7]*d+b[11]*f+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*f+b[12])*e;a.y=(b[1]*c+b[5]*d+b[9]*f+b[13])*e;a.z=(b[2]*c+b[6]*d+b[10]*f+b[14])*e;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w;a.x=b[0]*c+b[4]*d+b[8]*f+b[12]*e;a.y=b[1]*c+b[5]*d+b[9]*f+b[13]*e;a.z=b[2]*c+b[6]*d+b[10]*f+b[14]*e;a.w=b[3]*c+b[7]*d+b[11]*f+b[15]*e;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1,
  40. c=0,d=a.length;c<d;c=c+3){b.x=a[c];b.y=a[c+1];b.z=a[c+2];this.multiplyVector3(b);a[c]=b.x;a[c+1]=b.y;a[c+2]=b.z}return a},rotateAxis:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z;a.x=c*b[0]+d*b[4]+f*b[8];a.y=c*b[1]+d*b[5]+f*b[9];a.z=c*b[2]+d*b[6]+f*b[10];a.normalize();return a},crossVector:function(a){var b=this.elements,c=new THREE.Vector4;c.x=b[0]*a.x+b[4]*a.y+b[8]*a.z+b[12]*a.w;c.y=b[1]*a.x+b[5]*a.y+b[9]*a.z+b[13]*a.w;c.z=b[2]*a.x+b[6]*a.y+b[10]*a.z+b[14]*a.w;c.w=a.w?b[3]*a.x+b[7]*a.y+b[11]*
  41. a.z+b[15]*a.w:1;return c},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],f=a[12],e=a[1],g=a[5],h=a[9],i=a[13],j=a[2],l=a[6],n=a[10],m=a[14],q=a[3],o=a[7],p=a[11],a=a[15];return f*h*l*q-d*i*l*q-f*g*n*q+c*i*n*q+d*g*m*q-c*h*m*q-f*h*j*o+d*i*j*o+f*e*n*o-b*i*n*o-d*e*m*o+b*h*m*o+f*g*j*p-c*i*j*p-f*e*l*p+b*i*l*p+c*e*m*p-b*g*m*p-d*g*j*a+c*h*j*a+d*e*l*a-b*h*l*a-c*e*n*a+b*g*n*a},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;
  42. b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},flattenToArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=
  43. c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a},getPosition:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[12],a[13],a[14])},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getColumnX:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[0],a[1],a[2])},getColumnY:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[4],a[5],a[6])},getColumnZ:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[8],
  44. a[9],a[10])},getInverse:function(a){var b=this.elements,c=a.elements,d=c[0],f=c[4],e=c[8],g=c[12],h=c[1],i=c[5],j=c[9],l=c[13],n=c[2],m=c[6],q=c[10],o=c[14],p=c[3],r=c[7],t=c[11],c=c[15];b[0]=j*o*r-l*q*r+l*m*t-i*o*t-j*m*c+i*q*c;b[4]=g*q*r-e*o*r-g*m*t+f*o*t+e*m*c-f*q*c;b[8]=e*l*r-g*j*r+g*i*t-f*l*t-e*i*c+f*j*c;b[12]=g*j*m-e*l*m-g*i*q+f*l*q+e*i*o-f*j*o;b[1]=l*q*p-j*o*p-l*n*t+h*o*t+j*n*c-h*q*c;b[5]=e*o*p-g*q*p+g*n*t-d*o*t-e*n*c+d*q*c;b[9]=g*j*p-e*l*p-g*h*t+d*l*t+e*h*c-d*j*c;b[13]=e*l*n-g*j*n+g*h*q-d*
  45. l*q-e*h*o+d*j*o;b[2]=i*o*p-l*m*p+l*n*r-h*o*r-i*n*c+h*m*c;b[6]=g*m*p-f*o*p-g*n*r+d*o*r+f*n*c-d*m*c;b[10]=f*l*p-g*i*p+g*h*r-d*l*r-f*h*c+d*i*c;b[14]=g*i*n-f*l*n-g*h*m+d*l*m+f*h*o-d*i*o;b[3]=j*m*p-i*q*p-j*n*r+h*q*r+i*n*t-h*m*t;b[7]=f*q*p-e*m*p+e*n*r-d*q*r-f*n*t+d*m*t;b[11]=e*i*p-f*j*p-e*h*r+d*j*r+f*h*t-d*i*t;b[15]=f*j*n-e*i*n+e*h*m-d*j*m-f*h*q+d*i*q;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=this.elements,d=a.x,f=a.y,e=a.z,g=Math.cos(d),d=Math.sin(d),
  46. h=Math.cos(f),f=Math.sin(f),i=Math.cos(e),e=Math.sin(e);if(b===void 0||b==="XYZ"){var j=g*i,l=g*e,n=d*i,m=d*e;c[0]=h*i;c[4]=-h*e;c[8]=f;c[1]=l+n*f;c[5]=j-m*f;c[9]=-d*h;c[2]=m-j*f;c[6]=n+l*f;c[10]=g*h}else if(b==="YXZ"){j=h*i;l=h*e;n=f*i;m=f*e;c[0]=j+m*d;c[4]=n*d-l;c[8]=g*f;c[1]=g*e;c[5]=g*i;c[9]=-d;c[2]=l*d-n;c[6]=m+j*d;c[10]=g*h}else if(b==="ZXY"){j=h*i;l=h*e;n=f*i;m=f*e;c[0]=j-m*d;c[4]=-g*e;c[8]=n+l*d;c[1]=l+n*d;c[5]=g*i;c[9]=m-j*d;c[2]=-g*f;c[6]=d;c[10]=g*h}else if(b==="ZYX"){j=g*i;l=g*e;n=d*i;
  47. m=d*e;c[0]=h*i;c[4]=n*f-l;c[8]=j*f+m;c[1]=h*e;c[5]=m*f+j;c[9]=l*f-n;c[2]=-f;c[6]=d*h;c[10]=g*h}else if(b==="YZX"){j=g*h;l=g*f;n=d*h;m=d*f;c[0]=h*i;c[4]=m-j*e;c[8]=n*e+l;c[1]=e;c[5]=g*i;c[9]=-d*i;c[2]=-f*i;c[6]=l*e+n;c[10]=j-m*e}else if(b==="XZY"){j=g*h;l=g*f;n=d*h;m=d*f;c[0]=h*i;c[4]=-e;c[8]=f*i;c[1]=j*e+m;c[5]=g*i;c[9]=l*e-n;c[2]=n*e-l;c[6]=d*i;c[10]=m*e+j}return this},setRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w,g=c+c,h=d+d,i=f+f,a=c*g,j=c*h,c=c*i,l=d*h,d=d*
  48. i,f=f*i,g=e*g,h=e*h,e=e*i;b[0]=1-(l+f);b[4]=j-e;b[8]=c+h;b[1]=j+e;b[5]=1-(a+f);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);return this},compose:function(a,b,c){var d=this.elements,f=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;f.identity();f.setRotationFromQuaternion(b);e.makeScale(c.x,c.y,c.z);this.multiply(f,e);d[12]=a.x;d[13]=a.y;d[14]=a.z;return this},decompose:function(a,b,c){var d=this.elements,f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;f.set(d[0],d[1],d[2]);e.set(d[4],d[5],d[6]);
  49. g.set(d[8],d[9],d[10]);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=f.length();c.y=e.length();c.z=g.length();a.x=d[12];a.y=d[13];a.z=d[14];d=THREE.Matrix4.__m1;d.copy(this);d.elements[0]=d.elements[0]/c.x;d.elements[1]=d.elements[1]/c.x;d.elements[2]=d.elements[2]/c.x;d.elements[4]=d.elements[4]/c.y;d.elements[5]=d.elements[5]/c.y;d.elements[6]=d.elements[6]/c.y;d.elements[8]=d.elements[8]/
  50. c.z;d.elements[9]=d.elements[9]/c.z;d.elements[10]=d.elements[10]/c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){var b=this.elements,a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractRotation:function(a){var b=this.elements,a=a.elements,c=THREE.Matrix4.__v1,d=1/c.set(a[0],a[1],a[2]).length(),f=1/c.set(a[4],a[5],a[6]).length(),c=1/c.set(a[8],a[9],a[10]).length();b[0]=a[0]*d;b[1]=a[1]*d;b[2]=a[2]*d;b[4]=a[4]*f;b[5]=a[5]*f;b[6]=a[6]*f;b[8]=a[8]*c;b[9]=a[9]*
  51. c;b[10]=a[10]*c;return this},translate:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[12]=b[0]*c+b[4]*d+b[8]*a+b[12];b[13]=b[1]*c+b[5]*d+b[9]*a+b[13];b[14]=b[2]*c+b[6]*d+b[10]*a+b[14];b[15]=b[3]*c+b[7]*d+b[11]*a+b[15];return this},rotateX:function(a){var b=this.elements,c=b[4],d=b[5],f=b[6],e=b[7],g=b[8],h=b[9],i=b[10],j=b[11],l=Math.cos(a),a=Math.sin(a);b[4]=l*c+a*g;b[5]=l*d+a*h;b[6]=l*f+a*i;b[7]=l*e+a*j;b[8]=l*g-a*c;b[9]=l*h-a*d;b[10]=l*i-a*f;b[11]=l*j-a*e;return this},rotateY:function(a){var b=
  52. this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[8],h=b[9],i=b[10],j=b[11],l=Math.cos(a),a=Math.sin(a);b[0]=l*c-a*g;b[1]=l*d-a*h;b[2]=l*f-a*i;b[3]=l*e-a*j;b[8]=l*g+a*c;b[9]=l*h+a*d;b[10]=l*i+a*f;b[11]=l*j+a*e;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[4],h=b[5],i=b[6],j=b[7],l=Math.cos(a),a=Math.sin(a);b[0]=l*c+a*g;b[1]=l*d+a*h;b[2]=l*f+a*i;b[3]=l*e+a*j;b[4]=l*g-a*c;b[5]=l*h-a*d;b[6]=l*i-a*f;b[7]=l*j-a*e;return this},rotateByAxis:function(a,b){var c=this.elements;
  53. if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);if(a.x===0&&a.y===0&&a.z===1)return this.rotateZ(b);var d=a.x,f=a.y,e=a.z,g=Math.sqrt(d*d+f*f+e*e),d=d/g,f=f/g,e=e/g,g=d*d,h=f*f,i=e*e,j=Math.cos(b),l=Math.sin(b),n=1-j,m=d*f*n,q=d*e*n,n=f*e*n,d=d*l,o=f*l,l=e*l,e=g+(1-g)*j,g=m+l,f=q-o,m=m-l,h=h+(1-h)*j,l=n+d,q=q+o,n=n-d,i=i+(1-i)*j,j=c[0],d=c[1],o=c[2],p=c[3],r=c[4],t=c[5],u=c[6],v=c[7],s=c[8],z=c[9],w=c[10],A=c[11];c[0]=e*j+g*r+f*s;c[1]=e*d+g*
  54. t+f*z;c[2]=e*o+g*u+f*w;c[3]=e*p+g*v+f*A;c[4]=m*j+h*r+l*s;c[5]=m*d+h*t+l*z;c[6]=m*o+h*u+l*w;c[7]=m*p+h*v+l*A;c[8]=q*j+n*r+i*s;c[9]=q*d+n*t+i*z;c[10]=q*o+n*u+i*w;c[11]=q*p+n*v+i*A;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[0]=b[0]*c;b[4]=b[4]*d;b[8]=b[8]*a;b[1]=b[1]*c;b[5]=b[5]*d;b[9]=b[9]*a;b[2]=b[2]*c;b[6]=b[6]*d;b[10]=b[10]*a;b[3]=b[3]*c;b[7]=b[7]*d;b[11]=b[11]*a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+
  55. a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);
  56. return this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,h=a.z,i=f*e,j=f*g;this.set(i*e+c,i*g-d*h,i*h+d*g,0,i*g+d*h,j*g+c,j*h-d*e,0,i*h-d*g,j*h+d*e,f*h*h+c,0,0,0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeFrustum:function(a,b,c,d,f,e){var g=this.elements;g[0]=2*f/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*f/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(e+f)/(e-f);g[14]=-2*e*f/(e-f);g[3]=
  57. 0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){var a=c*Math.tan(a*Math.PI/360),f=-a;return this.makeFrustum(f*b,a*b,f,a,c,d)},makeOrthographic:function(a,b,c,d,f,e){var g=this.elements,h=b-a,i=c-d,j=e-f;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/i;g[9]=0;g[13]=-((c+d)/i);g[2]=0;g[6]=0;g[10]=-2/j;g[14]=-((e+f)/j);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},clone:function(){var a=this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],
  58. a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
  59. THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
  60. THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],f=c[2],e=c[3],g=c[4],h=c[5],i=c[6],j=c[7],l=c[8],n=c[9],m=c[10],q=c[11],o=c[12],p=c[13],r=c[14],c=c[15];b[0].set(e-a,j-g,q-l,c-o);b[1].set(e+a,j+g,q+l,c+o);b[2].set(e+d,j+h,q+n,c+p);b[3].set(e-d,j-h,q-n,c-p);b[4].set(e-f,j-i,q-m,c-r);b[5].set(e+f,j+i,q+m,c+r);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}};
  61. THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),f=0;f<6;f++){b=c[f].x*d[12]+c[f].y*d[13]+c[f].z*d[14]+c[f].w;if(b<=a)return false}return true};THREE.Frustum.__v1=new THREE.Vector3;
  62. (function(a){a.Ray=function(b,c,d,f){this.origin=b||new a.Vector3;this.direction=c||new a.Vector3;this.near=d||0;this.far=f||Infinity};var b=new a.Vector3,c=new a.Vector3,d=new a.Vector3,f=new a.Vector3,e=new a.Vector3,g=new a.Vector3,h=new a.Matrix4,i=function(a,b){return a.distance-b.distance},j=new a.Vector3,l=new a.Vector3,n=new a.Vector3,m=function(a,b,c){j.sub(c,a);var d=j.dot(b),a=l.add(a,n.copy(b).multiplyScalar(d));return c.distanceTo(a)},q=function(a,b,c,d){j.sub(d,b);l.sub(c,b);n.sub(a,
  63. b);var a=j.dot(j),b=j.dot(l),c=j.dot(n),f=l.dot(l),d=l.dot(n),e=1/(a*f-b*b),f=(f*c-b*d)*e,a=(a*d-b*c)*e;return f>=0&&a>=0&&f+a<1},o=function(i,j,l){var n,p;if(i instanceof a.Particle){n=m(j.origin,j.direction,i.matrixWorld.getPosition());if(n>i.scale.x)return l;p={distance:n,point:i.position,face:null,object:i};l.push(p)}else if(i instanceof a.Mesh){var o=i.geometry.boundingSphere.radius*i.matrixWorld.getMaxScaleOnAxis();n=m(j.origin,j.direction,i.matrixWorld.getPosition());if(n>o)return l;var w,
  64. A,J=i.geometry,D=J.vertices,F,B,E;F=i.geometry.materials;B=i.material instanceof a.MeshFaceMaterial;var H,Q=j.precision;i.matrixRotationWorld.extractRotation(i.matrixWorld);b.copy(j.origin);h.getInverse(i.matrixWorld);c.copy(b);h.multiplyVector3(c);d.copy(j.direction);h.rotateAxis(d).normalize();o=0;for(w=J.faces.length;o<w;o++){p=J.faces[o];n=B===true?F[p.materialIndex]:i.material;if(n!==void 0){E=n.side;f.sub(p.centroid,c);e=p.normal;n=d.dot(e);if(!(Math.abs(n)<Q)){A=e.dot(f)/n;if(!(A<0)&&(E===
  65. a.DoubleSide||(E===a.FrontSide?n<0:n>0))){g.add(c,d.multiplyScalar(A));if(p instanceof a.Face3){n=D[p.a];A=D[p.b];E=D[p.c];if(q(g,n,A,E)){A=i.matrixWorld.multiplyVector3(g.clone());n=b.distanceTo(A);if(!(n<j.near||n>j.far)){p={distance:n,point:A,face:p,faceIndex:o,object:i};l.push(p)}}}else if(p instanceof a.Face4){n=D[p.a];A=D[p.b];E=D[p.c];H=D[p.d];if(q(g,n,A,H)||q(g,A,E,H)){A=i.matrixWorld.multiplyVector3(g.clone());n=b.distanceTo(A);if(!(n<j.near||n>j.far)){p={distance:n,point:A,face:p,faceIndex:o,
  66. object:i};l.push(p)}}}}}}}}},p=function(a,b,c){for(var a=a.getDescendants(),d=0,f=a.length;d<f;d++)o(a[d],b,c)};a.Ray.prototype.precision=1E-4;a.Ray.prototype.set=function(a,b){this.origin=a;this.direction=b};a.Ray.prototype.intersectObject=function(a,b){var c=[];b===true&&p(a,this,c);o(a,this,c);c.sort(i);return c};a.Ray.prototype.intersectObjects=function(a,b){for(var c=[],d=0,f=a.length;d<f;d++){o(a[d],this,c);b===true&&p(a[d],this,c)}c.sort(i);return c}})(THREE);
  67. THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b=0,c=0,d=0,f=0,e=0,g=0,h=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,l,n){h=false;b=e;c=g;d=l;f=n;a()};this.addPoint=function(e,g){if(h===true){h=false;b=e;c=g;d=e;f=g}else{b=b<e?b:e;c=c<g?c:
  68. g;d=d>e?d:e;f=f>g?f:g}a()};this.add3Points=function(e,g,l,n,m,q){if(h===true){h=false;b=e<l?e<m?e:m:l<m?l:m;c=g<n?g<q?g:q:n<q?n:q;d=e>l?e>m?e:m:l>m?l:m;f=g>n?g>q?g:q:n>q?n:q}else{b=e<l?e<m?e<b?e:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b;c=g<n?g<q?g<c?g:c:q<c?q:c:n<q?n<c?n:c:q<c?q:c;d=e>l?e>m?e>d?e:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;f=g>n?g>q?g>f?g:f:q>f?q:f:n>q?n>f?n:f:q>f?q:f}a()};this.addRectangle=function(e){if(h===true){h=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();
  69. c=c<e.getTop()?c:e.getTop();d=d>e.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||f<a.getTop()||c>a.getBottom()?false:true};this.empty=function(){h=true;f=d=c=b=0;a()};this.isEmpty=function(){return h}};
  70. THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,f){return d+(a-b)*(f-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())},sign:function(a){return a<0?-1:a>0?1:0}};
  71. THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.properties={};this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder=THREE.Object3D.defaultEulerOrder;this.scale=new THREE.Vector3(1,1,1);this.renderDepth=null;this.rotationAutoUpdate=true;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
  72. true;this.quaternion=new THREE.Quaternion;this.useQuaternion=false;this.boundRadius=0;this.boundRadiusScale=1;this.visible=true;this.receiveShadow=this.castShadow=false;this.frustumCulled=true;this._vector=new THREE.Vector3};
  73. THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiply(a,this.matrix);this.scale.getScaleFromMatrix(this.matrix);a=(new THREE.Matrix4).extractRotation(this.matrix);this.rotation.setEulerFromRotationMatrix(a,this.eulerOrder);this.position.getPositionFromMatrix(this.matrix)},translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,
  74. this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},localToWorld:function(a){return this.matrixWorld.multiplyVector3(a)},worldToLocal:function(a){return THREE.Object3D.__m1.getInverse(this.matrixWorld).multiplyVector3(a)},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)},add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");
  75. else if(a instanceof THREE.Object3D){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=void 0;this.children.splice(b,1);for(b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.__removeObject(a)}},traverse:function(a){a(this);for(var b=0,c=this.children.length;b<c;b++)this.children[b].traverse(a)},
  76. getChildByName:function(a,b){for(var c=0,d=this.children.length;c<d;c++){var f=this.children[c];if(f.name===a)return f;if(b===true){f=f.getChildByName(a,b);if(f!==void 0)return f}}},getDescendants:function(a){a===void 0&&(a=[]);Array.prototype.push.apply(a,this.children);for(var b=0,c=this.children.length;b<c;b++)this.children[b].getDescendants(a);return a},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion===false?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):
  77. this.matrix.setRotationFromQuaternion(this.quaternion);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=true},updateMatrixWorld:function(a){this.matrixAutoUpdate===true&&this.updateMatrix();if(this.matrixWorldNeedsUpdate===true||a===true){this.parent===void 0?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix);
  78. this.matrixWorldNeedsUpdate=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},clone:function(){}};THREE.Object3D.__m1=new THREE.Matrix4;THREE.Object3D.defaultEulerOrder="XYZ";THREE.Object3DCount=0;
  79. THREE.Projector=function(){function a(){if(e===h){var a=new THREE.RenderableObject;g.push(a);h++;e++;return a}return g[e++]}function b(){if(j===n){var a=new THREE.RenderableVertex;l.push(a);n++;j++;return a}return l[j++]}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(f>=0&&e>=0&&g>=0&&h>=0)return true;if(f<0&&e<0||g<0&&h<0)return false;f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h)));
  80. if(d<c)return false;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return true}var f,e,g=[],h=0,i,j,l=[],n=0,m,q,o=[],p=0,r,t=[],u=0,v,s,z=[],w=0,A,J,D=[],F=0,B={objects:[],sprites:[],lights:[],elements:[]},E=new THREE.Vector3,H=new THREE.Vector4,Q=new THREE.Matrix4,L=new THREE.Matrix4,K=new THREE.Frustum,I=new THREE.Vector4,M=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);Q.multiply(b.projectionMatrix,b.matrixWorldInverse);Q.multiplyVector3(a);return a};this.unprojectVector=
  81. function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);Q.multiply(b.matrixWorld,b.projectionMatrixInverse);Q.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectScene=function(g,h,n,N){var fa=h.near,S=h.far,ra=false,wa,O,ga,P,X,ia,$,ca,Ja,ua,La,Wa,oa,Xa,kb,Ta;J=s=r=q=0;B.elements.length=0;g.updateMatrixWorld();h.parent===
  82. void 0&&h.updateMatrixWorld();h.matrixWorldInverse.getInverse(h.matrixWorld);Q.multiply(h.projectionMatrix,h.matrixWorldInverse);K.setFromMatrix(Q);e=0;B.objects.length=0;B.sprites.length=0;B.lights.length=0;var gb=function(b){for(var c=0,d=b.children.length;c<d;c++){var e=b.children[c];if(e.visible!==false){if(e instanceof THREE.Light)B.lights.push(e);else if(e instanceof THREE.Mesh||e instanceof THREE.Line){if(e.frustumCulled===false||K.contains(e)===true){f=a();f.object=e;if(e.renderDepth!==null)f.z=
  83. e.renderDepth;else{E.copy(e.matrixWorld.getPosition());Q.multiplyVector3(E);f.z=E.z}B.objects.push(f)}}else if(e instanceof THREE.Sprite||e instanceof THREE.Particle){f=a();f.object=e;if(e.renderDepth!==null)f.z=e.renderDepth;else{E.copy(e.matrixWorld.getPosition());Q.multiplyVector3(E);f.z=E.z}B.sprites.push(f)}else{f=a();f.object=e;if(e.renderDepth!==null)f.z=e.renderDepth;else{E.copy(e.matrixWorld.getPosition());Q.multiplyVector3(E);f.z=E.z}B.objects.push(f)}gb(e)}}};gb(g);n===true&&B.objects.sort(c);
  84. g=0;for(n=B.objects.length;g<n;g++){ca=B.objects[g].object;Ja=ca.matrixWorld;j=0;if(ca instanceof THREE.Mesh){ua=ca.geometry;La=ca.geometry.materials;ga=ua.vertices;Wa=ua.faces;Xa=ua.faceVertexUvs;ua=ca.matrixRotationWorld.extractRotation(Ja);kb=ca.material instanceof THREE.MeshFaceMaterial;wa=0;for(O=ga.length;wa<O;wa++){i=b();i.positionWorld.copy(ga[wa]);Ja.multiplyVector3(i.positionWorld);i.positionScreen.copy(i.positionWorld);Q.multiplyVector4(i.positionScreen);i.positionScreen.x=i.positionScreen.x/
  85. i.positionScreen.w;i.positionScreen.y=i.positionScreen.y/i.positionScreen.w;i.visible=i.positionScreen.z>fa&&i.positionScreen.z<S}ga=0;for(wa=Wa.length;ga<wa;ga++){O=Wa[ga];Ta=kb===true?La[O.materialIndex]:ca.material;if(Ta!==void 0){ia=Ta.side;if(O instanceof THREE.Face3){P=l[O.a];X=l[O.b];$=l[O.c];if(P.visible===true&&X.visible===true&&$.visible===true){ra=($.positionScreen.x-P.positionScreen.x)*(X.positionScreen.y-P.positionScreen.y)-($.positionScreen.y-P.positionScreen.y)*(X.positionScreen.x-
  86. P.positionScreen.x)<0;if(ia===THREE.DoubleSide||ra===(ia===THREE.FrontSide)){if(q===p){oa=new THREE.RenderableFace3;o.push(oa);p++;q++;m=oa}else m=o[q++];m.v1.copy(P);m.v2.copy(X);m.v3.copy($)}else continue}else continue}else if(O instanceof THREE.Face4){P=l[O.a];X=l[O.b];$=l[O.c];oa=l[O.d];if(P.visible===true&&X.visible===true&&$.visible===true&&oa.visible===true){ra=(oa.positionScreen.x-P.positionScreen.x)*(X.positionScreen.y-P.positionScreen.y)-(oa.positionScreen.y-P.positionScreen.y)*(X.positionScreen.x-
  87. P.positionScreen.x)<0||(X.positionScreen.x-$.positionScreen.x)*(oa.positionScreen.y-$.positionScreen.y)-(X.positionScreen.y-$.positionScreen.y)*(oa.positionScreen.x-$.positionScreen.x)<0;if(ia===THREE.DoubleSide||ra===(ia===THREE.FrontSide)){if(r===u){var rb=new THREE.RenderableFace4;t.push(rb);u++;r++;m=rb}else m=t[r++];m.v1.copy(P);m.v2.copy(X);m.v3.copy($);m.v4.copy(oa)}else continue}else continue}m.normalWorld.copy(O.normal);ra===false&&(ia===THREE.BackSide||ia===THREE.DoubleSide)&&m.normalWorld.negate();
  88. ua.multiplyVector3(m.normalWorld);m.centroidWorld.copy(O.centroid);Ja.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);Q.multiplyVector3(m.centroidScreen);$=O.vertexNormals;P=0;for(X=$.length;P<X;P++){oa=m.vertexNormalsWorld[P];oa.copy($[P]);ra===false&&(ia===THREE.BackSide||ia===THREE.DoubleSide)&&oa.negate();ua.multiplyVector3(oa)}m.vertexNormalsLength=$.length;P=0;for(X=Xa.length;P<X;P++){oa=Xa[P][ga];if(oa!==void 0){ia=0;for($=oa.length;ia<$;ia++)m.uvs[P][ia]=oa[ia]}}m.color=
  89. O.color;m.material=Ta;m.z=m.centroidScreen.z;B.elements.push(m)}}}else if(ca instanceof THREE.Line){L.multiply(Q,Ja);ga=ca.geometry.vertices;P=b();P.positionScreen.copy(ga[0]);L.multiplyVector4(P.positionScreen);Ja=ca.type===THREE.LinePieces?2:1;wa=1;for(O=ga.length;wa<O;wa++){P=b();P.positionScreen.copy(ga[wa]);L.multiplyVector4(P.positionScreen);if(!((wa+1)%Ja>0)){X=l[j-2];I.copy(P.positionScreen);M.copy(X.positionScreen);if(d(I,M)===true){I.multiplyScalar(1/I.w);M.multiplyScalar(1/M.w);if(s===
  90. w){La=new THREE.RenderableLine;z.push(La);w++;s++;v=La}else v=z[s++];v.v1.positionScreen.copy(I);v.v2.positionScreen.copy(M);v.z=Math.max(I.z,M.z);v.material=ca.material;B.elements.push(v)}}}}}g=0;for(n=B.sprites.length;g<n;g++){ca=B.sprites[g].object;Ja=ca.matrixWorld;if(ca instanceof THREE.Particle){H.set(Ja.elements[12],Ja.elements[13],Ja.elements[14],1);Q.multiplyVector4(H);H.z=H.z/H.w;if(H.z>0&&H.z<1){if(J===F){fa=new THREE.RenderableParticle;D.push(fa);F++;J++;A=fa}else A=D[J++];A.object=ca;
  91. A.x=H.x/H.w;A.y=H.y/H.w;A.z=H.z;A.rotation=ca.rotation.z;A.scale.x=ca.scale.x*Math.abs(A.x-(H.x+h.projectionMatrix.elements[0])/(H.w+h.projectionMatrix.elements[12]));A.scale.y=ca.scale.y*Math.abs(A.y-(H.y+h.projectionMatrix.elements[5])/(H.w+h.projectionMatrix.elements[13]));A.material=ca.material;B.elements.push(A)}}}N===true&&B.elements.sort(c);return B}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
  92. THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),f=Math.cos(a.z/2),e=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=e*d*f+c*g*h;this.y=c*g*f-e*d*h;this.z=c*d*h+e*g*f;this.w=c*d*f-e*g*h}else if(b==="YXZ"){this.x=e*d*f+c*g*h;this.y=c*g*f-e*d*h;this.z=
  93. c*d*h-e*g*f;this.w=c*d*f+e*g*h}else if(b==="ZXY"){this.x=e*d*f-c*g*h;this.y=c*g*f+e*d*h;this.z=c*d*h+e*g*f;this.w=c*d*f-e*g*h}else if(b==="ZYX"){this.x=e*d*f-c*g*h;this.y=c*g*f+e*d*h;this.z=c*d*h-e*g*f;this.w=c*d*f+e*g*h}else if(b==="YZX"){this.x=e*d*f+c*g*h;this.y=c*g*f+e*d*h;this.z=c*d*h-e*g*f;this.w=c*d*f-e*g*h}else if(b==="XZY"){this.x=e*d*f-c*g*h;this.y=c*g*f-e*d*h;this.z=c*d*h+e*g*f;this.w=c*d*f+e*g*h}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*
  94. d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+e+b;if(j>0){c=0.5/Math.sqrt(j+1);this.w=0.25/c;this.x=(i-g)*c;this.y=(d-h)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(i-g)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+h)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-h)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(g+i)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
  95. (d+h)/c;this.y=(g+i)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=
  96. this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){var c=a.x,d=a.y,f=a.z,e=a.w,g=b.x,h=b.y,i=b.z,j=b.w;this.x=c*j+d*i-f*h+e*g;this.y=-c*i+d*j+f*g+e*h;this.z=c*h-d*g+f*j+e*i;this.w=-c*g-d*h-f*i+e*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=
  97. this.y,h=this.z,i=this.w,j=i*c+g*f-h*d,l=i*d+h*c-e*f,n=i*f+e*d-g*c,c=-e*c-g*d-h*f;b.x=j*i+c*-e+l*-h-n*-g;b.y=l*i+c*-g+n*-e-j*-h;b.z=n*i+c*-h+j*-g-l*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.001){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);this.y=0.5*
  98. (d+this.y);this.z=0.5*(f+this.z);return this}g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=e*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+this.y*h;this.z=f*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
  99. THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};
  100. THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
  101. THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
  102. return a}};THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
  103. THREE.Face4.prototype={constructor:THREE.Face4,clone:function(){var a=new THREE.Face4(this.a,this.b,this.c,this.d);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
  104. return a}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},lerpSelf:function(a,b){this.u=this.u+(a.u-this.u)*b;this.v=this.v+(a.v-this.v)*b;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
  105. THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.name="";this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.dynamic=true};
  106. THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a);for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c]);c=0;for(d=this.faces.length;c<d;c++){var f=this.faces[c];b.multiplyVector3(f.normal);for(var e=0,g=f.vertexNormals.length;e<g;e++)b.multiplyVector3(f.vertexNormals[e]);a.multiplyVector3(f.centroid)}},computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,
  107. 0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a]);c.centroid.addSelf(this.vertices[c.b]);c.centroid.addSelf(this.vertices[c.c]);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a]);c.centroid.addSelf(this.vertices[c.b]);c.centroid.addSelf(this.vertices[c.c]);c.centroid.addSelf(this.vertices[c.d]);c.centroid.divideScalar(4)}}},computeFaceNormals:function(){var a,b,c,d,f,e,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a<
  108. b;a++){c=this.faces[a];d=this.vertices[c.a];f=this.vertices[c.b];e=this.vertices[c.c];g.sub(e,f);h.sub(d,f);g.crossSelf(h);g.isZero()||g.normalize();c.normal.copy(g)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices===void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];
  109. else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;
  110. for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeMorphNormals:function(){var a,b,c,d,f;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.__originalFaceNormal?
  111. f.__originalFaceNormal.copy(f.normal):f.__originalFaceNormal=f.normal.clone();if(!f.__originalVertexNormals)f.__originalVertexNormals=[];a=0;for(b=f.vertexNormals.length;a<b;a++)f.__originalVertexNormals[a]?f.__originalVertexNormals[a].copy(f.vertexNormals[a]):f.__originalVertexNormals[a]=f.vertexNormals[a].clone()}var e=new THREE.Geometry;e.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=
  112. [];var g=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,i,j;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];i=new THREE.Vector3;j=f instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3};g.push(i);h.push(j)}}g=this.morphNormals[a];e.vertices=this.morphTargets[a].vertices;e.computeFaceNormals();e.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];
  113. i=g.faceNormals[c];j=g.vertexNormals[c];i.copy(f.normal);if(f instanceof THREE.Face3){j.a.copy(f.vertexNormals[0]);j.b.copy(f.vertexNormals[1]);j.c.copy(f.vertexNormals[2])}else{j.a.copy(f.vertexNormals[0]);j.b.copy(f.vertexNormals[1]);j.c.copy(f.vertexNormals[2]);j.d.copy(f.vertexNormals[3])}}}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.normal=f.__originalFaceNormal;f.vertexNormals=f.__originalVertexNormals}},computeTangents:function(){function a(a,b,c,d,f,e,H){h=a.vertices[b];i=a.vertices[c];
  114. j=a.vertices[d];l=g[f];n=g[e];m=g[H];q=i.x-h.x;o=j.x-h.x;p=i.y-h.y;r=j.y-h.y;t=i.z-h.z;u=j.z-h.z;v=n.u-l.u;s=m.u-l.u;z=n.v-l.v;w=m.v-l.v;A=1/(v*w-s*z);B.set((w*q-z*o)*A,(w*p-z*r)*A,(w*t-z*u)*A);E.set((v*o-s*q)*A,(v*r-s*p)*A,(v*u-s*t)*A);D[b].addSelf(B);D[c].addSelf(B);D[d].addSelf(B);F[b].addSelf(E);F[c].addSelf(E);F[d].addSelf(E)}var b,c,d,f,e,g,h,i,j,l,n,m,q,o,p,r,t,u,v,s,z,w,A,J,D=[],F=[],B=new THREE.Vector3,E=new THREE.Vector3,H=new THREE.Vector3,Q=new THREE.Vector3,L=new THREE.Vector3;b=0;for(c=
  115. this.vertices.length;b<c;b++){D[b]=new THREE.Vector3;F[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.faceVertexUvs[0][b];if(e instanceof THREE.Face3)a(this,e.a,e.b,e.c,0,1,2);else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.d,0,1,3);a(this,e.b,e.c,e.d,1,2,3)}}var K=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];for(d=0;d<e.vertexNormals.length;d++){L.copy(e.vertexNormals[d]);f=e[K[d]];J=D[f];H.copy(J);H.subSelf(L.multiplyScalar(L.dot(J))).normalize();
  116. Q.cross(e.vertexNormals[d],J);f=Q.dot(F[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(H.x,H.y,H.z,f)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;d<f;d++){a=this.vertices[d];if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=
  117. a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){var a=0;if(this.boundingSphere===null)this.boundingSphere={radius:0};for(var b=0,c=this.vertices.length;b<c;b++){var d=this.vertices[b].lengthSq();d>a&&(a=d)}this.boundingSphere.radius=Math.sqrt(a)},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g,h,i;e=0;for(g=this.vertices.length;e<g;e++){d=
  118. this.vertices[e];d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_");if(a[d]===void 0){a[d]=e;b.push(this.vertices[e]);c[e]=b.length-1}else c[e]=c[a[d]]}e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c]}else if(a instanceof THREE.Face4){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c];a.d=c[a.d];d=[a.a,a.b,a.c,a.d];for(f=3;f>0;f--)if(d.indexOf(a["abcd"[f]])!==f){d.splice(f,1);this.faces[e]=new THREE.Face3(d[0],d[1],d[2],a.normal,a.color,
  119. a.materialIndex);d=0;for(h=this.faceVertexUvs.length;d<h;d++)(i=this.faceVertexUvs[d][e])&&i.splice(f,1);this.faces[e].vertexColors=a.vertexColors;break}}}c=this.vertices.length-b.length;this.vertices=b;return c},clone:function(){}};THREE.GeometryCount=0;THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]};
  120. THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;if(this.attributes.position)b=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(b!==void 0){a.multiplyVector3Array(b);this.verticesNeedUpdate=true}if(c!==void 0){b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,
  121. Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,f,e=0,g=a.length;e<g;e=e+3){c=a[e];d=a[e+1];f=a[e+2];if(c<b.min.x)b.min.x=c;else if(c>b.max.x)b.max.x=c;if(d<b.min.y)b.min.y=d;else if(d>b.max.y)b.max.y=d;if(f<b.min.z)b.min.z=f;else if(f>b.max.z)b.max.z=f}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere=
  122. {radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,f,e=0,g=a.length;e<g;e=e+3){b=a[e];d=a[e+1];f=a[e+2];b=b*b+d*d+f*f;b>c&&(c=b)}this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]=
  123. 0}var f=this.offsets,e=this.attributes.index.array,g=this.attributes.position.array,h=this.attributes.normal.array,i,j,l,n,m,q,o=new THREE.Vector3,p=new THREE.Vector3,r=new THREE.Vector3,t=new THREE.Vector3,u=new THREE.Vector3;c=0;for(d=f.length;c<d;++c){b=f[c].start;i=f[c].count;var v=f[c].index;a=b;for(b=b+i;a<b;a=a+3){i=v+e[a];j=v+e[a+1];l=v+e[a+2];n=g[i*3];m=g[i*3+1];q=g[i*3+2];o.set(n,m,q);n=g[j*3];m=g[j*3+1];q=g[j*3+2];p.set(n,m,q);n=g[l*3];m=g[l*3+1];q=g[l*3+2];r.set(n,m,q);t.sub(r,p);u.sub(o,
  124. p);t.crossSelf(u);h[i*3]=h[i*3]+t.x;h[i*3+1]=h[i*3+1]+t.y;h[i*3+2]=h[i*3+2]+t.z;h[j*3]=h[j*3]+t.x;h[j*3+1]=h[j*3+1]+t.y;h[j*3+2]=h[j*3+2]+t.z;h[l*3]=h[l*3]+t.x;h[l*3+1]=h[l*3+1]+t.y;h[l*3+2]=h[l*3+2]+t.z}}a=0;for(b=h.length;a<b;a=a+3){n=h[a];m=h[a+1];q=h[a+2];c=1/Math.sqrt(n*n+m*m+q*q);h[a]=h[a]*c;h[a+1]=h[a+1]*c;h[a+2]=h[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a){Z.x=d[a*3];Z.y=d[a*3+1];Z.z=d[a*3+2];ea.copy(Z);fa=i[a];M.copy(fa);M.subSelf(Z.multiplyScalar(Z.dot(fa))).normalize();
  125. T.cross(ea,fa);S=T.dot(j[a]);N=S<0?-1:1;h[a*4]=M.x;h[a*4+1]=M.y;h[a*4+2]=M.z;h[a*4+3]=N}if(this.attributes.index===void 0||this.attributes.position===void 0||this.attributes.normal===void 0||this.attributes.uv===void 0)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,f=this.attributes.uv.array,e=c.length/3;if(this.attributes.tangent===
  126. void 0){var g=4*e;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array,i=[],j=[],g=0;g<e;g++){i[g]=new THREE.Vector3;j[g]=new THREE.Vector3}var l,n,m,q,o,p,r,t,u,v,s,z,w,A,J,e=new THREE.Vector3,g=new THREE.Vector3,D,F,B,E,H,Q,L,K=this.offsets;B=0;for(E=K.length;B<E;++B){F=K[B].start;H=K[B].count;var I=K[B].index;D=F;for(F=F+H;D<F;D=D+3){H=I+b[D];Q=I+b[D+1];L=I+b[D+2];l=c[H*3];n=c[H*3+1];m=c[H*3+2];q=c[Q*3];o=c[Q*3+1];p=c[Q*3+2];r=c[L*3];
  127. t=c[L*3+1];u=c[L*3+2];v=f[H*2];s=f[H*2+1];z=f[Q*2];w=f[Q*2+1];A=f[L*2];J=f[L*2+1];q=q-l;l=r-l;o=o-n;n=t-n;p=p-m;m=u-m;z=z-v;v=A-v;w=w-s;s=J-s;J=1/(z*s-v*w);e.set((s*q-w*l)*J,(s*o-w*n)*J,(s*p-w*m)*J);g.set((z*l-v*q)*J,(z*n-v*o)*J,(z*m-v*p)*J);i[H].addSelf(e);i[Q].addSelf(e);i[L].addSelf(e);j[H].addSelf(g);j[Q].addSelf(g);j[L].addSelf(g)}}var M=new THREE.Vector3,T=new THREE.Vector3,Z=new THREE.Vector3,ea=new THREE.Vector3,N,fa,S;B=0;for(E=K.length;B<E;++B){F=K[B].start;H=K[B].count;I=K[B].index;D=F;
  128. for(F=F+H;D<F;D=D+3){H=I+b[D];Q=I+b[D+1];L=I+b[D+2];a(H);a(Q);a(L)}}this.tangentsNeedUpdate=this.hasTangents=true}}};
  129. THREE.Spline=function(a){function b(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b}this.points=a;var c=[],d={x:0,y:0,z:0},f,e,g,h,i,j,l,n,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;e=Math.floor(f);g=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>this.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1:
  130. e+2;j=this.points[c[0]];l=this.points[c[1]];n=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,n.x,m.x,g,h,i);d.y=b(j.y,l.y,n.y,m.y,g,h,i);d.z=b(j.z,l.z,n.z,m.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++){b=this.points[a];d[a]=[b.x,b.y,b.z]}return d};this.getLength=function(a){var b,c,d,f=b=b=0,e=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;e.copy(this.points[0]);for(a=1;a<c;a++){b=
  131. a/c;d=this.getPoint(b);g.copy(d);i=i+g.distanceTo(e);e.copy(d);b=(this.points.length-1)*b;b=Math.floor(b);if(b!=f){h[b]=i;f=b}}h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,f,e,g,h=[],i=new THREE.Vector3,l=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];g=Math.ceil(a*c/l.total);f=(b-1)/(this.points.length-1);e=b/(this.points.length-1);for(c=1;c<g-1;c++){d=f+c*(1/g)*(e-f);d=this.getPoint(d);
  132. h.push(i.copy(d).clone())}h.push(i.copy(this.points[b]).clone())}this.points=h}};THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate===true&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};
  133. THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far)};
  134. THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);THREE.PerspectiveCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);this.fov=2*Math.atan(b/(a*2))*(180/Math.PI);this.updateProjectionMatrix()};
  135. THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
  136. THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far)};
  137. THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);
  138. THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0;this.onlyShadow=this.castShadow=false;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=false;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;
  139. this.shadowCascade=false;this.shadowCascadeOffset=new THREE.Vector3(0,0,-1E3);this.shadowCascadeCount=2;this.shadowCascadeBias=[0,0,0];this.shadowCascadeWidth=[512,512,512];this.shadowCascadeHeight=[512,512,512];this.shadowCascadeNearZ=[-1,0.99,0.998];this.shadowCascadeFarZ=[0.99,0.998,1];this.shadowCascadeArray=[];this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);
  140. THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a);this.groundColor=new THREE.Color(b);this.position=new THREE.Vector3(0,100,0);this.intensity=c!==void 0?c:1};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);
  141. THREE.SpotLight=function(a,b,c,d,f){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0;this.angle=d!==void 0?d:Math.PI/2;this.exponent=f!==void 0?f:10;this.onlyShadow=this.castShadow=false;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=false;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=
  142. this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
  143. THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
  144. a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(a.length<1?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++){b=a.materials[c];if(b instanceof THREE.ShaderMaterial)return true}return false},createMaterial:function(a,b){function c(a){a=
  145. Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function f(a,f,e,h,i,j,r){var t=e.toLowerCase().endsWith(".dds"),u=b+"/"+e;if(t){var v=THREE.ImageUtils.loadCompressedTexture(u);a[f]=v}else{v=document.createElement("canvas");a[f]=new THREE.Texture(v)}a[f].sourceFile=e;if(h){a[f].repeat.set(h[0],h[1]);if(h[0]!==1)a[f].wrapS=THREE.RepeatWrapping;if(h[1]!==1)a[f].wrapT=THREE.RepeatWrapping}i&&a[f].offset.set(i[0],i[1]);if(j){e={repeat:THREE.RepeatWrapping,
  146. mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[f].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[f].wrapT=e[j[1]]}if(r)a[f].anisotropy=r;if(!t){var s=a[f],a=new Image;a.onload=function(){if(!c(this.width)||!c(this.height)){var a=d(this.width),b=d(this.height);s.image.width=a;s.image.height=b;s.image.getContext("2d").drawImage(this,0,0,a,b)}else s.image=this;s.needsUpdate=true};a.crossOrigin=g.crossOrigin;a.src=u}}function e(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var g=this,h="MeshLambertMaterial",
  147. i={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:false};if(a.shading){var j=a.shading.toLowerCase();j==="phong"?h="MeshPhongMaterial":j==="basic"&&(h="MeshBasicMaterial")}if(a.blending!==void 0&&THREE[a.blending]!==void 0)i.blending=THREE[a.blending];if(a.transparent!==void 0||a.opacity<1)i.transparent=a.transparent;if(a.depthTest!==void 0)i.depthTest=a.depthTest;if(a.depthWrite!==void 0)i.depthWrite=a.depthWrite;if(a.visible!==void 0)i.visible=a.visible;if(a.flipSided!==
  148. void 0)i.side=THREE.BackSide;if(a.doubleSided!==void 0)i.side=THREE.DoubleSide;if(a.wireframe!==void 0)i.wireframe=a.wireframe;if(a.vertexColors!==void 0)if(a.vertexColors==="face")i.vertexColors=THREE.FaceColors;else if(a.vertexColors)i.vertexColors=THREE.VertexColors;if(a.colorDiffuse)i.color=e(a.colorDiffuse);else if(a.DbgColor)i.color=a.DbgColor;if(a.colorSpecular)i.specular=e(a.colorSpecular);if(a.colorAmbient)i.ambient=e(a.colorAmbient);if(a.transparency)i.opacity=a.transparency;if(a.specularCoef)i.shininess=
  149. a.specularCoef;a.mapDiffuse&&b&&f(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&f(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&f(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&f(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&f(i,"specularMap",
  150. a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);if(a.mapBumpScale)i.bumpScale=a.mapBumpScale;if(a.mapNormal){h=THREE.ShaderUtils.lib.normal;j=THREE.UniformsUtils.clone(h.uniforms);j.tNormal.value=i.normalMap;a.mapNormalFactor&&j.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor);if(i.map){j.tDiffuse.value=i.map;j.enableDiffuse.value=true}if(i.specularMap){j.tSpecular.value=i.specularMap;j.enableSpecular.value=true}if(i.lightMap){j.tAO.value=
  151. i.lightMap;j.enableAO.value=true}j.uDiffuseColor.value.setHex(i.color);j.uSpecularColor.value.setHex(i.specular);j.uAmbientColor.value.setHex(i.ambient);j.uShininess.value=i.shininess;if(i.opacity!==void 0)j.uOpacity.value=i.opacity;i=new THREE.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:j,lights:true,fog:true})}else i=new THREE[h](i);if(a.DbgName!==void 0)i.name=a.DbgName;return i}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
  152. THREE.BinaryLoader.prototype=Object.create(THREE.Loader.prototype);THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),f=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,f)};
  153. THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,e){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0){var h=JSON.parse(g.responseText);a.loadAjaxBuffers(h,c,f,d,e)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,true);g.send(null)};
  154. THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var e=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;e.onreadystatechange=function(){if(e.readyState==4)if(e.status==200||e.status==0){var c=e.response;if(c===void 0)c=(new Uint8Array(e.responseBody)).buffer;THREE.BinaryLoader.prototype.createBinModel(c,b,d,a.materials)}else console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+e.status+"]");else if(e.readyState==3){if(f){h==0&&(h=e.getResponseHeader("Content-Length"));f({total:h,loaded:e.responseText.length})}}else e.readyState==
  155. 2&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",g,true);e.responseType="arraybuffer";e.send(null)};
  156. THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,i,j,l,n,m,q,o,p,r,t,u,v,s;function z(a){return a%4?4-a%4:0}function w(a,b){return(new Uint8Array(a,b,1))[0]}function A(a,b){return(new Uint32Array(a,b,1))[0]}function J(b,c){var d,f,e,g,h,i,j,l,n=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){f=n[d*3];e=n[d*3+1];g=n[d*3+2];h=I[f*2];f=I[f*2+1];i=I[e*2];j=I[e*2+1];e=I[g*2];l=I[g*2+1];g=Q.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,f));m.push(new THREE.UV(i,j));m.push(new THREE.UV(e,
  157. l));g.push(m)}}function D(b,c){var d,f,e,g,h,i,j,l,n,m,p=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){f=p[d*4];e=p[d*4+1];g=p[d*4+2];h=p[d*4+3];i=I[f*2];f=I[f*2+1];j=I[e*2];n=I[e*2+1];l=I[g*2];m=I[g*2+1];g=I[h*2];e=I[h*2+1];h=Q.faceVertexUvs[0];var o=[];o.push(new THREE.UV(i,f));o.push(new THREE.UV(j,n));o.push(new THREE.UV(l,m));o.push(new THREE.UV(g,e));h.push(o)}}function F(b,c,d){for(var f,e,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++){f=c[d*3];e=c[d*3+1];g=c[d*3+2];h=i[d];
  158. Q.faces.push(new THREE.Face3(f,e,g,null,null,h))}}function B(b,c,d){for(var f,e,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++){f=c[d*4];e=c[d*4+1];g=c[d*4+2];h=c[d*4+3];i=j[d];Q.faces.push(new THREE.Face4(f,e,g,h,null,null,i))}}function E(b,c,d,f){for(var e,g,h,i,j,l,n,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),m=new Uint16Array(a,f,b),f=0;f<b;f++){e=c[f*3];g=c[f*3+1];h=c[f*3+2];j=d[f*3];l=d[f*3+1];n=d[f*3+2];i=m[f];var p=K[l*3],o=K[l*3+1];l=K[l*3+2];var q=K[n*3],
  159. r=K[n*3+1];n=K[n*3+2];Q.faces.push(new THREE.Face3(e,g,h,[new THREE.Vector3(K[j*3],K[j*3+1],K[j*3+2]),new THREE.Vector3(p,o,l),new THREE.Vector3(q,r,n)],null,i))}}function H(b,c,d,f){for(var e,g,h,i,j,l,n,m,p,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,f,b),f=0;f<b;f++){e=c[f*4];g=c[f*4+1];h=c[f*4+2];i=c[f*4+3];l=d[f*4];n=d[f*4+1];m=d[f*4+2];p=d[f*4+3];j=o[f];var q=K[n*3],r=K[n*3+1];n=K[n*3+2];var s=K[m*3],t=K[m*3+1];m=K[m*3+2];var u=K[p*3],v=K[p*3+1];p=K[p*3+2];Q.faces.push(new THREE.Face4(e,
  160. g,h,i,[new THREE.Vector3(K[l*3],K[l*3+1],K[l*3+2]),new THREE.Vector3(q,r,n),new THREE.Vector3(s,t,m),new THREE.Vector3(u,v,p)],null,j))}}var Q=this,L=0,K=[],I=[],M,T,Z;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(Q,d,b);s=a;T=L;b=new Uint8Array(s,T,12);p="";for(u=0;u<12;u++)p=p+String.fromCharCode(b[T+u]);c=w(s,T+12);w(s,T+13);w(s,T+14);w(s,T+15);f=w(s,T+16);i=w(s,T+17);j=w(s,T+18);l=w(s,T+19);n=A(s,T+20);m=A(s,T+20+4);q=A(s,T+20+8);o=A(s,T+20+12);p=A(s,T+20+16);r=A(s,T+20+20);t=
  161. A(s,T+20+24);u=A(s,T+20+28);b=A(s,T+20+32);v=A(s,T+20+36);s=A(s,T+20+40);L=L+c;T=f*3+l;Z=f*4+l;M=o*T;c=p*(T+i*3);f=r*(T+j*3);l=t*(T+i*3+j*3);T=u*Z;i=b*(Z+i*4);j=v*(Z+j*4);Z=L;var L=new Float32Array(a,L,n*3),ea,N,fa,S;for(ea=0;ea<n;ea++){N=L[ea*3];fa=L[ea*3+1];S=L[ea*3+2];Q.vertices.push(new THREE.Vector3(N,fa,S))}n=L=Z+n*3*Float32Array.BYTES_PER_ELEMENT;if(m){L=new Int8Array(a,L,m*3);for(Z=0;Z<m;Z++){ea=L[Z*3];N=L[Z*3+1];fa=L[Z*3+2];K.push(ea/127,N/127,fa/127)}}L=n+m*3*Int8Array.BYTES_PER_ELEMENT;
  162. m=L=L+z(m*3);if(q){L=new Float32Array(a,L,q*2);for(n=0;n<q;n++){Z=L[n*2];ea=L[n*2+1];I.push(Z,ea)}}q=L=m+q*2*Float32Array.BYTES_PER_ELEMENT;M=q+M+z(o*2);m=M+c+z(p*2);c=m+f+z(r*2);f=c+l+z(t*2);T=f+T+z(u*2);l=T+i+z(b*2);i=l+j+z(v*2);if(r){j=m+r*Uint32Array.BYTES_PER_ELEMENT*3;F(r,m,j+r*Uint32Array.BYTES_PER_ELEMENT*3);J(r,j)}if(t){r=c+t*Uint32Array.BYTES_PER_ELEMENT*3;j=r+t*Uint32Array.BYTES_PER_ELEMENT*3;E(t,c,r,j+t*Uint32Array.BYTES_PER_ELEMENT*3);J(t,j)}if(v){t=l+v*Uint32Array.BYTES_PER_ELEMENT*
  163. 4;B(v,l,t+v*Uint32Array.BYTES_PER_ELEMENT*4);D(v,t)}if(s){v=i+s*Uint32Array.BYTES_PER_ELEMENT*4;t=v+s*Uint32Array.BYTES_PER_ELEMENT*4;H(s,i,v,t+s*Uint32Array.BYTES_PER_ELEMENT*4);D(s,t)}o&&F(o,q,q+o*Uint32Array.BYTES_PER_ELEMENT*3);if(p){o=M+p*Uint32Array.BYTES_PER_ELEMENT*3;E(p,M,o,o+p*Uint32Array.BYTES_PER_ELEMENT*3)}u&&B(u,f,f+u*Uint32Array.BYTES_PER_ELEMENT*4);if(b){p=T+b*Uint32Array.BYTES_PER_ELEMENT*4;H(b,T,p,p+b*Uint32Array.BYTES_PER_ELEMENT*4)}this.computeCentroids();this.computeFaceNormals();
  164. THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=Object.create(THREE.Geometry.prototype);b(new f(c))};THREE.ImageLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
  165. THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b){var c=this;b===void 0&&(b=new Image);b.addEventListener("load",function(){c.dispatchEvent({type:"load",content:b})},false);b.addEventListener("error",function(){c.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(c.crossOrigin)b.crossOrigin=c.crossOrigin;b.src=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);
  166. THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
  167. THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,f){var e=new XMLHttpRequest,g=0;e.onreadystatechange=function(){if(e.readyState===e.DONE)if(e.status===200||e.status===0){if(e.responseText){var h=JSON.parse(e.responseText);a.createModel(h,c,d)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+e.status+"]");else if(e.readyState===e.LOADING){if(f){g===0&&(g=e.getResponseHeader("Content-Length"));
  168. f({total:g,loaded:e.responseText.length})}}else e.readyState===e.HEADERS_RECEIVED&&(g=e.getResponseHeader("Content-Length"))};e.open("GET",b,true);e.send(null)};
  169. THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);var e,g,h,i,j,l,n,m,q,o,p,r,t,u,v=a.faces;q=a.vertices;var s=a.normals,z=a.colors,w=0;for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&w++;for(e=0;e<w;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}c=0;for(i=q.length;c<i;){j=new THREE.Vector3;j.x=q[c++]*f;j.y=q[c++]*f;j.z=q[c++]*f;d.vertices.push(j)}c=0;for(i=v.length;c<i;){q=v[c++];j=q&1;h=q&2;e=q&4;g=q&8;n=q&
  170. 16;l=q&32;o=q&64;q=q&128;if(j){p=new THREE.Face4;p.a=v[c++];p.b=v[c++];p.c=v[c++];p.d=v[c++];j=4}else{p=new THREE.Face3;p.a=v[c++];p.b=v[c++];p.c=v[c++];j=3}if(h){h=v[c++];p.materialIndex=h}h=d.faces.length;if(e)for(e=0;e<w;e++){r=a.uvs[e];m=v[c++];u=r[m*2];m=r[m*2+1];d.faceUvs[e][h]=new THREE.UV(u,m)}if(g)for(e=0;e<w;e++){r=a.uvs[e];t=[];for(g=0;g<j;g++){m=v[c++];u=r[m*2];m=r[m*2+1];t[g]=new THREE.UV(u,m)}d.faceVertexUvs[e][h]=t}if(n){n=v[c++]*3;g=new THREE.Vector3;g.x=s[n++];g.y=s[n++];g.z=s[n];
  171. p.normal=g}if(l)for(e=0;e<j;e++){n=v[c++]*3;g=new THREE.Vector3;g.x=s[n++];g.y=s[n++];g.z=s[n];p.vertexNormals.push(g)}if(o){l=v[c++];l=new THREE.Color(z[l]);p.color=l}if(q)for(e=0;e<j;e++){l=v[c++];l=new THREE.Color(z[l]);p.vertexColors.push(l)}d.faces.push(p)}if(a.skinWeights){c=0;for(i=a.skinWeights.length;c<i;c=c+2){v=a.skinWeights[c];s=a.skinWeights[c+1];d.skinWeights.push(new THREE.Vector4(v,s,0,0))}}if(a.skinIndices){c=0;for(i=a.skinIndices.length;c<i;c=c+2){v=a.skinIndices[c];s=a.skinIndices[c+
  172. 1];d.skinIndices.push(new THREE.Vector4(v,s,0,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets!==void 0){c=0;for(i=a.morphTargets.length;c<i;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];z=d.morphTargets[c].vertices;w=a.morphTargets[c].vertices;v=0;for(s=w.length;v<s;v=v+3){q=new THREE.Vector3;q.x=w[v]*f;q.y=w[v+1]*f;q.z=w[v+2]*f;z.push(q)}}}if(a.morphColors!==void 0){c=0;for(i=a.morphColors.length;c<i;c++){d.morphColors[c]={};
  173. d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];s=d.morphColors[c].colors;z=a.morphColors[c].colors;f=0;for(v=z.length;f<v;f=f+3){w=new THREE.Color(16755200);w.setRGB(z[f],z[f+1],z[f+2]);s.push(w)}}}d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
  174. THREE.GeometryLoader.prototype={constructor:THREE.GeometryLoader,load:function(a){var b=this,c=null;if(b.path===null){var d=a.split("/");d.pop();b.path=d.length<1?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),f):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},false);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);d.open("GET",
  175. a,true);d.send(null);var f=new THREE.LoadingMonitor;f.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});f.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;if(a.materials){d.materials=[];for(var e=0;e<a.materials.length;++e){var g=a.materials[e],h=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},i=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},j=function(a,d,f,e,g,j){a[d]=new THREE.Texture;a[d].sourceFile=
  176. f;if(e){a[d].repeat.set(e[0],e[1]);if(e[0]!==1)a[d].wrapS=THREE.RepeatWrapping;if(e[1]!==1)a[d].wrapT=THREE.RepeatWrapping}g&&a[d].offset.set(g[0],g[1]);if(j){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[d].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[d].wrapT=e[j[1]]}var l=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!h(a.width)||!h(a.height)){var b=i(a.width),c=i(a.height);l.image=document.createElement("canvas");l.image.width=
  177. b;l.image.height=c;l.image.getContext("2d").drawImage(a,0,0,b,c)}else l.image=a;l.needsUpdate=true});a.crossOrigin=c.crossOrigin;a.load(c.path+"/"+f);b&&b.add(a)},l=function(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255},n="MeshLambertMaterial",m={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:false};if(g.shading){var q=g.shading.toLowerCase();q==="phong"?n="MeshPhongMaterial":q==="basic"&&(n="MeshBasicMaterial")}if(g.blending!==void 0&&THREE[g.blending]!==
  178. void 0)m.blending=THREE[g.blending];if(g.transparent!==void 0||g.opacity<1)m.transparent=g.transparent;if(g.depthTest!==void 0)m.depthTest=g.depthTest;if(g.depthWrite!==void 0)m.depthWrite=g.depthWrite;if(g.vertexColors!==void 0)if(g.vertexColors=="face")m.vertexColors=THREE.FaceColors;else if(g.vertexColors)m.vertexColors=THREE.VertexColors;if(g.colorDiffuse)m.color=l(g.colorDiffuse);else if(g.DbgColor)m.color=g.DbgColor;if(g.colorSpecular)m.specular=l(g.colorSpecular);if(g.colorAmbient)m.ambient=
  179. l(g.colorAmbient);if(g.transparency)m.opacity=g.transparency;if(g.specularCoef)m.shininess=g.specularCoef;if(g.visible!==void 0)m.visible=g.visible;if(g.flipSided!==void 0)m.side=THREE.BackSide;if(g.doubleSided!==void 0)m.side=THREE.DoubleSide;if(g.wireframe!==void 0)m.wireframe=g.wireframe;g.mapDiffuse&&j(m,"map",g.mapDiffuse,g.mapDiffuseRepeat,g.mapDiffuseOffset,g.mapDiffuseWrap);g.mapLight&&j(m,"lightMap",g.mapLight,g.mapLightRepeat,g.mapLightOffset,g.mapLightWrap);g.mapBump&&j(m,"bumpMap",g.mapBump,
  180. g.mapBumpRepeat,g.mapBumpOffset,g.mapBumpWrap);g.mapNormal&&j(m,"normalMap",g.mapNormal,g.mapNormalRepeat,g.mapNormalOffset,g.mapNormalWrap);g.mapSpecular&&j(m,"specularMap",g.mapSpecular,g.mapSpecularRepeat,g.mapSpecularOffset,g.mapSpecularWrap);if(g.mapNormal){j=THREE.ShaderUtils.lib.normal;l=THREE.UniformsUtils.clone(j.uniforms);l.tNormal.value=m.normalMap;g.mapNormalFactor&&l.uNormalScale.value.set(g.mapNormalFactor,g.mapNormalFactor);if(m.map){l.tDiffuse.value=m.map;l.enableDiffuse.value=true}if(m.specularMap){l.tSpecular.value=
  181. m.specularMap;l.enableSpecular.value=true}if(m.lightMap){l.tAO.value=m.lightMap;l.enableAO.value=true}l.uDiffuseColor.value.setHex(m.color);l.uSpecularColor.value.setHex(m.specular);l.uAmbientColor.value.setHex(m.ambient);l.uShininess.value=m.shininess;if(m.opacity!==void 0)l.uOpacity.value=m.opacity;m=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:l,lights:true,fog:true})}else m=new THREE[n](m);if(g.DbgName!==void 0)m.name=g.DbgName;d.materials[e]=
  182. m}}var g=a.faces,o=a.vertices,m=a.normals,j=a.colors,l=0;if(a.uvs)for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&l++;for(e=0;e<l;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}n=0;for(q=o.length;n<q;){var p=new THREE.Vector3;p.x=o[n++]*f;p.y=o[n++]*f;p.z=o[n++]*f;d.vertices.push(p)}n=0;for(q=g.length;n<q;){var r=g[n++],t=r&2,e=r&4,u=r&8,v=r&16,o=r&32,s=r&64,p=r&128;if(r&1){r=new THREE.Face4;r.a=g[n++];r.b=g[n++];r.c=g[n++];r.d=g[n++];var z=4}else{r=new THREE.Face3;r.a=g[n++];r.b=g[n++];r.c=g[n++];z=3}if(t){t=
  183. g[n++];r.materialIndex=t}var w=d.faces.length;if(e)for(e=0;e<l;e++){var A=a.uvs[e],t=g[n++],J=A[t*2],t=A[t*2+1];d.faceUvs[e][w]=new THREE.UV(J,t)}if(u)for(e=0;e<l;e++){for(var A=a.uvs[e],u=[],D=0;D<z;D++){t=g[n++];J=A[t*2];t=A[t*2+1];u[D]=new THREE.UV(J,t)}d.faceVertexUvs[e][w]=u}if(v){v=g[n++]*3;t=new THREE.Vector3;t.x=m[v++];t.y=m[v++];t.z=m[v];r.normal=t}if(o)for(e=0;e<z;e++){v=g[n++]*3;t=new THREE.Vector3;t.x=m[v++];t.y=m[v++];t.z=m[v];r.vertexNormals.push(t)}if(s){o=g[n++];r.color=new THREE.Color(j[o])}if(p)for(e=
  184. 0;e<z;e++){o=g[n++];r.vertexColors.push(new THREE.Color(j[o]))}d.faces.push(r)}if(a.skinWeights){e=0;for(g=a.skinWeights.length;e<g;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(g=a.skinIndices.length;e<g;e=e+2){m=0;d.skinIndices.push(new THREE.Vector4(a.skinIndices[e],a.skinIndices[e+1],m,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){e=0;for(g=a.morphTargets.length;e<g;e++){d.morphTargets[e]={};d.morphTargets[e].name=
  185. a.morphTargets[e].name;d.morphTargets[e].vertices=[];m=d.morphTargets[e].vertices;j=a.morphTargets[e].vertices;t=0;for(l=j.length;t<l;t=t+3){p=new THREE.Vector3;p.x=j[t]*f;p.y=j[t+1]*f;p.z=j[t+2]*f;m.push(p)}}}if(a.morphColors){e=0;for(g=a.morphColors.length;e<g;e++){d.morphColors[e]={};d.morphColors[e].name=a.morphColors[e].name;d.morphColors[e].colors=[];f=d.morphColors[e].colors;j=a.morphColors[e].colors;m=0;for(l=j.length;m<l;m=m+3){n=new THREE.Color(16755200);n.setRGB(j[m],j[m+1],j[m+2]);f.push(n)}}}d.computeCentroids();
  186. d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){};this.geometryHandlerMap={};this.addGeometryHandler("ascii",THREE.JSONLoader);this.addGeometryHandler("binary",THREE.BinaryLoader)};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
  187. THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState===4)if(d.status===200||d.status===0){var f=JSON.parse(d.responseText);c.parse(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,true);d.send(null)};THREE.SceneLoader.prototype.addGeometryHandler=function(a,b){this.geometryHandlerMap[a]={loaderClass:b}};
  188. THREE.SceneLoader.prototype.parse=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:j+"/"+a}function f(a,b){for(var c in b)if(I.objects[c]===void 0){var d=b[c],e=null;if(d.geometry!==void 0){if(J=I.geometries[d.geometry]){e=false;D=I.materials[d.materials[0]];(e=D instanceof THREE.ShaderMaterial)&&J.computeTangents();u=d.position;v=d.rotation;s=d.quaternion;z=d.scale;r=d.matrix;s=0;d.materials.length===0&&(D=new THREE.MeshFaceMaterial);d.materials.length>1&&(D=new THREE.MeshFaceMaterial);
  189. if(d.morph){e=new THREE.MorphAnimMesh(J,D);if(d.duration!==void 0)e.duration=d.duration;if(d.time!==void 0)e.time=d.time;if(d.mirroredLoop!==void 0)e.mirroredLoop=d.mirroredLoop;D.morphNormals&&J.computeMorphNormals()}else e=new THREE.Mesh(J,D);e.name=c;if(r){e.matrixAutoUpdate=false;e.matrix.set(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])}else{e.position.set(u[0],u[1],u[2]);if(s){e.quaternion.set(s[0],s[1],s[2],s[3]);e.useQuaternion=true}else e.rotation.set(v[0],
  190. v[1],v[2]);e.scale.set(z[0],z[1],z[2])}e.visible=d.visible;e.castShadow=d.castShadow;e.receiveShadow=d.receiveShadow;a.add(e);I.objects[c]=e}}else{u=d.position;v=d.rotation;s=d.quaternion;z=d.scale;s=0;e=new THREE.Object3D;e.name=c;e.position.set(u[0],u[1],u[2]);if(s){e.quaternion.set(s[0],s[1],s[2],s[3]);e.useQuaternion=true}else e.rotation.set(v[0],v[1],v[2]);e.scale.set(z[0],z[1],z[2]);e.visible=d.visible!==void 0?d.visible:false;a.add(e);I.objects[c]=e;I.empties[c]=e}if(e){if(d.properties!==void 0)for(var g in d.properties)e.properties[g]=
  191. d.properties[g];d.children!==void 0&&f(e,d.children)}}}function e(a){return function(b){I.geometries[a]=b;f(I.scene,M.objects);H=H-1;i.onLoadComplete();h()}}function g(a){return function(b){I.geometries[a]=b}}function h(){i.callbackProgress({totalModels:L,totalTextures:K,loadedModels:L-H,loadedTextures:K-Q},I);i.onLoadProgress();H===0&&Q===0&&b(I)}var i=this,j=THREE.Loader.prototype.extractUrlBase(c),l,n,m,q,o,p,r,t,u,v,s,z,w,A,J,D,F,B,E,H,Q,L,K,I,M=a;for(w in this.geometryHandlerMap)this.geometryHandlerMap[w].loaderObject=
  192. new this.geometryHandlerMap[w].loaderClass;Q=H=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(M.transform){a=M.transform.position;c=M.transform.rotation;w=M.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);c&&I.scene.rotation.set(c[0],c[1],c[2]);w&&I.scene.scale.set(w[0],w[1],w[2]);if(a||c||w){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(a){return function(){Q=Q-a;h();i.onLoadComplete()}};for(q in M.cameras){w=
  193. M.cameras[q];w.type==="perspective"?F=new THREE.PerspectiveCamera(w.fov,w.aspect,w.near,w.far):w.type==="ortho"&&(F=new THREE.OrthographicCamera(w.left,w.right,w.top,w.bottom,w.near,w.far));u=w.position;c=w.target;w=w.up;F.position.set(u[0],u[1],u[2]);F.target=new THREE.Vector3(c[0],c[1],c[2]);w&&F.up.set(w[0],w[1],w[2]);I.cameras[q]=F}for(m in M.lights){c=M.lights[m];q=c.color!==void 0?c.color:16777215;F=c.intensity!==void 0?c.intensity:1;if(c.type==="directional"){u=c.direction;t=new THREE.DirectionalLight(q,
  194. F);t.position.set(u[0],u[1],u[2]);t.position.normalize()}else if(c.type==="point"){u=c.position;t=c.distance;t=new THREE.PointLight(q,F,t);t.position.set(u[0],u[1],u[2])}else c.type==="ambient"&&(t=new THREE.AmbientLight(q));I.scene.add(t);I.lights[m]=t}for(o in M.fogs){m=M.fogs[o];m.type==="linear"?B=new THREE.Fog(0,m.near,m.far):m.type==="exp2"&&(B=new THREE.FogExp2(0,m.density));w=m.color;B.color.setRGB(w[0],w[1],w[2]);I.fogs[o]=B}if(I.cameras&&M.defaults.camera)I.currentCamera=I.cameras[M.defaults.camera];
  195. if(I.fogs&&M.defaults.fog)I.scene.fog=I.fogs[M.defaults.fog];w=M.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(w[0],w[1],w[2]);I.bgColorAlpha=M.defaults.bgalpha;for(l in M.geometries){o=M.geometries[l];if(o.type in this.geometryHandlerMap){H=H+1;i.onLoadStart()}}L=H;for(l in M.geometries){o=M.geometries[l];if(o.type==="cube"){J=new THREE.CubeGeometry(o.width,o.height,o.depth,o.segmentsWidth,o.segmentsHeight,o.segmentsDepth,null,o.flipped,o.sides);I.geometries[l]=J}else if(o.type==="plane"){J=
  196. new THREE.PlaneGeometry(o.width,o.height,o.segmentsWidth,o.segmentsHeight);I.geometries[l]=J}else if(o.type==="sphere"){J=new THREE.SphereGeometry(o.radius,o.segmentsWidth,o.segmentsHeight);I.geometries[l]=J}else if(o.type==="cylinder"){J=new THREE.CylinderGeometry(o.topRad,o.botRad,o.height,o.radSegs,o.heightSegs);I.geometries[l]=J}else if(o.type==="torus"){J=new THREE.TorusGeometry(o.radius,o.tube,o.segmentsR,o.segmentsT);I.geometries[l]=J}else if(o.type==="icosahedron"){J=new THREE.IcosahedronGeometry(o.radius,
  197. o.subdivisions);I.geometries[l]=J}else if(o.type in this.geometryHandlerMap){B={};for(E in o)E!=="type"&&E!=="url"&&(B[E]=o[E]);this.geometryHandlerMap[o.type].loaderObject.load(d(o.url,M.urlBaseType),e(l),B)}else if(o.type==="embedded"){o=M.embeds[o.id];o.metadata=M.metadata;o&&this.geometryHandlerMap.ascii.loaderObject.createModel(o,g(l),"")}}for(p in M.textures){l=M.textures[p];if(l.url instanceof Array){Q=Q+l.url.length;for(E=0;E<l.url.length;E++)i.onLoadStart()}else{Q=Q+1;i.onLoadStart()}}K=
  198. Q;for(p in M.textures){l=M.textures[p];if(l.mapping!==void 0&&THREE[l.mapping]!==void 0)l.mapping=new THREE[l.mapping];if(l.url instanceof Array){o=l.url.length;B=[];for(E=0;E<o;E++)B[E]=d(l.url[E],M.urlBaseType);E=(E=B[0].endsWith(".dds"))?THREE.ImageUtils.loadCompressedTextureCube(B,l.mapping,a(o)):THREE.ImageUtils.loadTextureCube(B,l.mapping,a(o))}else{E=l.url.toLowerCase().endsWith(".dds");o=d(l.url,M.urlBaseType);B=a(1);E=E?THREE.ImageUtils.loadCompressedTexture(o,l.mapping,B):THREE.ImageUtils.loadTexture(o,
  199. l.mapping,B);if(THREE[l.minFilter]!==void 0)E.minFilter=THREE[l.minFilter];if(THREE[l.magFilter]!==void 0)E.magFilter=THREE[l.magFilter];if(l.anisotropy)E.anisotropy=l.anisotropy;if(l.repeat){E.repeat.set(l.repeat[0],l.repeat[1]);if(l.repeat[0]!==1)E.wrapS=THREE.RepeatWrapping;if(l.repeat[1]!==1)E.wrapT=THREE.RepeatWrapping}l.offset&&E.offset.set(l.offset[0],l.offset[1]);if(l.wrap){o={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(o[l.wrap[0]]!==void 0)E.wrapS=o[l.wrap[0]];if(o[l.wrap[1]]!==
  200. void 0)E.wrapT=o[l.wrap[1]]}}I.textures[p]=E}for(n in M.materials){r=M.materials[n];for(A in r.parameters)if(A==="envMap"||A==="map"||A==="lightMap"||A==="bumpMap")r.parameters[A]=I.textures[r.parameters[A]];else if(A==="shading")r.parameters[A]=r.parameters[A]==="flat"?THREE.FlatShading:THREE.SmoothShading;else if(A==="side")r.parameters[A]=r.parameters[A]=="double"?THREE.DoubleSide:r.parameters[A]=="back"?THREE.BackSide:THREE.FrontSide;else if(A==="blending")r.parameters[A]=r.parameters[A]in THREE?
  201. THREE[r.parameters[A]]:THREE.NormalBlending;else if(A==="combine")r.parameters[A]=r.parameters[A]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(A==="vertexColors")if(r.parameters[A]=="face")r.parameters[A]=THREE.FaceColors;else{if(r.parameters[A])r.parameters[A]=THREE.VertexColors}else if(A==="wrapRGB"){p=r.parameters[A];r.parameters[A]=new THREE.Vector3(p[0],p[1],p[2])}if(r.parameters.opacity!==void 0&&r.parameters.opacity<1)r.parameters.transparent=true;if(r.parameters.normalMap){p=
  202. THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(p.uniforms);l=r.parameters.color;E=r.parameters.specular;o=r.parameters.ambient;B=r.parameters.shininess;a.tNormal.value=I.textures[r.parameters.normalMap];r.parameters.normalScale&&a.uNormalScale.value.set(r.parameters.normalScale[0],r.parameters.normalScale[1]);if(r.parameters.map){a.tDiffuse.value=r.parameters.map;a.enableDiffuse.value=true}if(r.parameters.envMap){a.tCube.value=r.parameters.envMap;a.enableReflection.value=true;a.uReflectivity.value=
  203. r.parameters.reflectivity}if(r.parameters.lightMap){a.tAO.value=r.parameters.lightMap;a.enableAO.value=true}if(r.parameters.specularMap){a.tSpecular.value=I.textures[r.parameters.specularMap];a.enableSpecular.value=true}if(r.parameters.displacementMap){a.tDisplacement.value=I.textures[r.parameters.displacementMap];a.enableDisplacement.value=true;a.uDisplacementBias.value=r.parameters.displacementBias;a.uDisplacementScale.value=r.parameters.displacementScale}a.uDiffuseColor.value.setHex(l);a.uSpecularColor.value.setHex(E);
  204. a.uAmbientColor.value.setHex(o);a.uShininess.value=B;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;D=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:a,lights:true,fog:true})}else D=new THREE[r.type](r.parameters);I.materials[n]=D}f(I.scene,M.objects);i.callbackSync(I);h()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
  205. THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
  206. THREE.Material=function(){this.id=THREE.MaterialCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=false;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=true;this.polygonOffset=false;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=false;this.needsUpdate=this.visible=true};
  207. THREE.Material.prototype.setValues=function(a){if(a!==void 0)for(var b in a){var c=a[b];if(c===void 0)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if(b in this){var d=this[b];d instanceof THREE.Color&&c instanceof THREE.Color?d.copy(c):d instanceof THREE.Color&&typeof c==="number"?d.setHex(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):this[b]=c}}};
  208. THREE.Material.prototype.clone=function(a){a===void 0&&(a=new THREE.Material);a.name=this.name;a.side=this.side;a.opacity=this.opacity;a.transparent=this.transparent;a.blending=this.blending;a.blendSrc=this.blendSrc;a.blendDst=this.blendDst;a.blendEquation=this.blendEquation;a.depthTest=this.depthTest;a.depthWrite=this.depthWrite;a.polygonOffset=this.polygonOffset;a.polygonOffsetFactor=this.polygonOffsetFactor;a.polygonOffsetUnits=this.polygonOffsetUnits;a.alphaTest=this.alphaTest;a.overdraw=this.overdraw;
  209. a.visible=this.visible;return a};THREE.MaterialCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=false;this.fog=true;this.setValues(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  210. THREE.LineBasicMaterial.prototype.clone=function(){var a=new THREE.LineBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.linewidth=this.linewidth;a.linecap=this.linecap;a.linejoin=this.linejoin;a.vertexColors=this.vertexColors;a.fog=this.fog;return a};
  211. THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.envMap=this.specularMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=false;this.setValues(a)};
  212. THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  213. THREE.MeshBasicMaterial.prototype.clone=function(){var a=new THREE.MeshBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.map=this.map;a.lightMap=this.lightMap;a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=
  214. this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;return a};
  215. THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.wrapAround=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.specularMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap=
  216. "round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setValues(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
  217. THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.ambient.copy(this.ambient);a.emissive.copy(this.emissive);a.wrapAround=this.wrapAround;a.wrapRGB.copy(this.wrapRGB);a.map=this.map;a.lightMap=this.lightMap;a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;
  218. a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals=this.morphNormals;return a};
  219. THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.specular=new THREE.Color(1118481);this.shininess=30;this.wrapAround=this.perPixel=this.metal=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.bumpMap=this.lightMap=this.map=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.envMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;
  220. this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setValues(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);
  221. THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.ambient.copy(this.ambient);a.emissive.copy(this.emissive);a.specular.copy(this.specular);a.shininess=this.shininess;a.metal=this.metal;a.perPixel=this.perPixel;a.wrapAround=this.wrapAround;a.wrapRGB.copy(this.wrapRGB);a.map=this.map;a.lightMap=this.lightMap;a.bumpMap=this.bumpMap;a.bumpScale=this.bumpScale;a.normalMap=this.normalMap;a.normalScale.copy(this.normalScale);
  222. a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals=this.morphNormals;return a};
  223. THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.wireframe=false;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.clone=function(){var a=new THREE.LineBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;return a};
  224. THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.shading=THREE.FlatShading;this.wireframe=false;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.clone=function(){var a=new THREE.MeshNormalMaterial;THREE.Material.prototype.clone.call(this,a);a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;return a};THREE.MeshFaceMaterial=function(){};
  225. THREE.MeshFaceMaterial.prototype.clone=function(){return new THREE.MeshFaceMaterial};THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=true;this.vertexColors=false;this.fog=true;this.setValues(a)};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  226. THREE.ParticleBasicMaterial.prototype.clone=function(){var a=new THREE.ParticleBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.map=this.map;a.size=this.size;a.sizeAttenuation=this.sizeAttenuation;a.vertexColors=this.vertexColors;a.fog=this.fog;return a};THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.program=function(){};this.setValues(a)};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);
  227. THREE.ParticleCanvasMaterial.prototype.clone=function(){var a=new THREE.ParticleCanvasMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.program=this.program;return a};THREE.ParticleDOMMaterial=function(a){this.element=a};THREE.ParticleDOMMaterial.prototype.clone=function(){return new THREE.ParticleDOMMaterial(this.element)};
  228. THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.defines={};this.attributes=null;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.lights=this.fog=false;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setValues(a)};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);
  229. THREE.ShaderMaterial.prototype.clone=function(){var a=new THREE.ShaderMaterial;THREE.Material.prototype.clone.call(this,a);a.fragmentShader=this.fragmentShader;a.vertexShader=this.vertexShader;a.uniforms=this.uniforms;a.attributes=this.attributes;a.defines=this.defines;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.fog=this.fog;a.lights=this.lights;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals=
  230. this.morphNormals;return a};
  231. THREE.Texture=function(a,b,c,d,f,e,g,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.anisotropy=i!==void 0?i:1;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=h!==void 0?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
  232. new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};
  233. THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture;a.image=this.image;a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.format=this.format;a.type=this.type;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};THREE.TextureCount=0;
  234. THREE.CompressedTexture=function(a,b,c,d,f,e,g,h,i,j){THREE.Texture.call(this,null,e,g,h,i,j,d,f);this.image={width:b,height:c};this.mipmaps=a};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);
  235. THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;a.image=this.image;a.mipmaps=this.mipmaps;a.format=this.format;a.type=this.type;a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.DataTexture=function(a,b,c,d,f,e,g,h,i,j){THREE.Texture.call(this,null,e,g,h,i,j,d,f);this.image={data:a,width:b,height:c}};
  236. THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=Object.create(THREE.Object3D.prototype);
  237. THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.ParticleBasicMaterial({color:Math.random()*16777215});this.sortParticles=false;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}this.frustumCulled=false};THREE.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);
  238. THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.LineBasicMaterial({color:Math.random()*16777215});this.type=c!==void 0?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=Object.create(THREE.Object3D.prototype);
  239. THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.MeshBasicMaterial({color:Math.random()*16777215,wireframe:true});if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius;if(this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<this.geometry.morphTargets.length;c++){this.morphTargetInfluences.push(0);
  240. this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}}}};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype);
  241. THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b=b|this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=false;b=true}var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
  242. THREE.SkinnedMesh=function(a,b,c){THREE.Mesh.call(this,a,b);this.useVertexTexture=c!==void 0?c:true;this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,f,e;if(this.geometry.bones!==void 0){for(a=0;a<this.geometry.bones.length;a++){c=this.geometry.bones[a];d=c.pos;f=c.rotq;e=c.scl;b=this.addBone();b.name=c.name;b.position.set(d[0],d[1],d[2]);b.quaternion.set(f[0],f[1],f[2],f[3]);b.useQuaternion=true;e!==void 0?b.scale.set(e[0],e[1],e[2]):b.scale.set(1,1,1)}for(a=0;a<this.bones.length;a++){c=
  243. this.geometry.bones[a];b=this.bones[a];c.parent===-1?this.add(b):this.bones[c.parent].add(b)}a=this.bones.length;if(this.useVertexTexture){this.boneTextureHeight=this.boneTextureWidth=a=a>256?64:a>64?32:a>16?16:8;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=
  244. THREE.NearestFilter;this.boneTexture.generateMipmaps=false;this.boneTexture.flipY=false}else this.boneMatrices=new Float32Array(16*a);this.pose()}};THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  245. THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a){this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=false}for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,false):c.updateMatrixWorld(true)}if(this.boneInverses==void 0){this.boneInverses=[];a=0;for(b=this.bones.length;a<
  246. b;a++){c=new THREE.Matrix4;c.getInverse(this.bones[a].skinMatrix);this.boneInverses.push(c)}}a=0;for(b=this.bones.length;a<b;a++){THREE.SkinnedMesh.offsetMatrix.multiply(this.bones[a].skinMatrix,this.boneInverses[a]);THREE.SkinnedMesh.offsetMatrix.flattenToArrayOffset(this.boneMatrices,a*16)}if(this.useVertexTexture)this.boneTexture.needsUpdate=true};
  247. THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(true);for(var a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();c!==Infinity?b.multiplyScalar(c):b.set(1)}};THREE.SkinnedMesh.offsetMatrix=new THREE.Matrix4;
  248. THREE.MorphAnimMesh=function(a,b){THREE.Mesh.call(this,a,b);this.duration=1E3;this.mirroredLoop=false;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=false;this.setFrameRange(0,this.geometry.morphTargets.length-1)};THREE.MorphAnimMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.MorphAnimMesh.prototype.setFrameRange=function(a,b){this.startKeyframe=a;this.endKeyframe=b;this.length=this.endKeyframe-this.startKeyframe+1};
  249. THREE.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1;this.directionBackwards=false};THREE.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1;this.directionBackwards=true};
  250. THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;if(!a.animations)a.animations={};for(var b,c=a.animations,d=/([a-z]+)(\d+)/,f=0,e=a.morphTargets.length;f<e;f++){var g=a.morphTargets[f].name.match(d);if(g&&g.length>1){g=g[1];c[g]||(c[g]={start:Infinity,end:-Infinity});var h=c[g];if(f<h.start)h.start=f;if(f>h.end)h.end=f;b||(b=g)}}a.firstAnimation=b};
  251. THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){if(!this.geometry.animations)this.geometry.animations={};this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];if(c){this.setFrameRange(c.start,c.end);this.duration=1E3*((c.end-c.start)/b);this.time=0}else console.warn("animation["+a+"] undefined")};
  252. THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time=this.time+this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction=this.direction*-1;if(this.time>this.duration){this.time=this.duration;this.directionBackwards=true}if(this.time<0){this.time=0;this.directionBackwards=false}}}else{this.time=this.time%this.duration;if(this.time<0)this.time=this.time+this.duration}a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/
  253. b),0,this.length-1);if(a!==this.currentKeyframe){this.morphTargetInfluences[this.lastKeyframe]=0;this.morphTargetInfluences[this.currentKeyframe]=1;this.morphTargetInfluences[a]=0;this.lastKeyframe=this.currentKeyframe;this.currentKeyframe=a}b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
  254. THREE.Ribbon.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD.prototype.addLevel=function(a,b){b===void 0&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length;c++)if(b<this.LODs[c].visibleAtDistance)break;this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
  255. THREE.LOD.prototype.update=function(a){if(this.LODs.length>1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.elements[2]*this.matrixWorld.elements[12]+a.elements[6]*this.matrixWorld.elements[13]+a.elements[10]*this.matrixWorld.elements[14]+a.elements[14]);this.LODs[0].object3D.visible=true;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance){this.LODs[b-1].object3D.visible=false;this.LODs[b].object3D.visible=true}else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=
  256. false}};
  257. THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:new THREE.Texture;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;this.useScreenCoordinates=a.useScreenCoordinates!==void 0?
  258. a.useScreenCoordinates:true;this.mergeWith3D=a.mergeWith3D!==void 0?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=a.affectedByDistance!==void 0?a.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=a.scaleByViewport!==void 0?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=
  259. new THREE.Vector2(1,1)};THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype);THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,this.scale.y)}this.matrixWorldNeedsUpdate=true};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);
  260. THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
  261. THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=false;this.__objects=[];this.__lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=Object.create(THREE.Object3D.prototype);
  262. THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light){this.__lights.indexOf(a)===-1&&this.__lights.push(a);a.target&&a.target.parent===void 0&&this.add(a.target)}else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.__objects.indexOf(a)===-1){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);b!==-1&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.__addObject(a.children[b])};
  263. THREE.Scene.prototype.__removeObject=function(a){if(a instanceof THREE.Light){var b=this.__lights.indexOf(a);b!==-1&&this.__lights.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.__objects.indexOf(a);if(b!==-1){this.__objects.splice(b,1);this.__objectsRemoved.push(a);b=this.__objectsAdded.indexOf(a);b!==-1&&this.__objectsAdded.splice(b,1)}}for(b=0;b<a.children.length;b++)this.__removeObject(a.children[b])};
  264. THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b!==void 0?b:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==void 0?b:2.5E-4};
  265. THREE.CanvasRenderer=function(a){function b(a){if(u!==a)u=p.globalAlpha=a}function c(a){if(v!==a){if(a===THREE.NormalBlending)p.globalCompositeOperation="source-over";else if(a===THREE.AdditiveBlending)p.globalCompositeOperation="lighter";else if(a===THREE.SubtractiveBlending)p.globalCompositeOperation="darker";v=a}}function d(a){if(s!==a)s=p.strokeStyle=a}function f(a){if(z!==a)z=p.fillStyle=a}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},e=this,g,h,i,j=new THREE.Projector,l=a.canvas!==
  266. void 0?a.canvas:document.createElement("canvas"),n,m,q,o,p=l.getContext("2d"),r=new THREE.Color(0),t=0,u=1,v=0,s=null,z=null,w=null,A=null,J=null,D,F,B,E,H=new THREE.RenderableVertex,Q=new THREE.RenderableVertex,L,K,I,M,T,Z,ea,N,fa,S,ra,wa,O=new THREE.Color,ga=new THREE.Color,P=new THREE.Color,X=new THREE.Color,ia=new THREE.Color,$=new THREE.Color,ca=new THREE.Color,Ja={},ua={},La,Wa,oa,Xa,kb,Ta,gb,rb,Qb,fb,bb=new THREE.Rectangle,Ma=new THREE.Rectangle,za=new THREE.Rectangle,xb=false,Ga=new THREE.Color,
  267. sb=new THREE.Color,hb=new THREE.Color,xa=new THREE.Vector3,ib,ab,Ya,Ha,yb,k,a=16;ib=document.createElement("canvas");ib.width=ib.height=2;ab=ib.getContext("2d");ab.fillStyle="rgba(0,0,0,1)";ab.fillRect(0,0,2,2);Ya=ab.getImageData(0,0,2,2);Ha=Ya.data;yb=document.createElement("canvas");yb.width=yb.height=a;k=yb.getContext("2d");k.translate(-a/2,-a/2);k.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,
  268. b){n=a;m=b;q=Math.floor(n/2);o=Math.floor(m/2);l.width=n;l.height=m;bb.set(-q,-o,q,o);Ma.set(-q,-o,q,o);u=1;v=0;J=A=w=z=s=null};this.setClearColor=function(a,b){r.copy(a);t=b!==void 0?b:1;Ma.set(-q,-o,q,o)};this.setClearColorHex=function(a,b){r.setHex(a);t=b!==void 0?b:1;Ma.set(-q,-o,q,o)};this.getMaxAnisotropy=function(){return 0};this.clear=function(){p.setTransform(1,0,0,-1,q,o);if(Ma.isEmpty()===false){Ma.minSelf(bb);Ma.inflate(2);t<1&&p.clearRect(Math.floor(Ma.getX()),Math.floor(Ma.getY()),Math.floor(Ma.getWidth()),
  269. Math.floor(Ma.getHeight()));if(t>0){c(THREE.NormalBlending);b(1);f("rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+t+")");p.fillRect(Math.floor(Ma.getX()),Math.floor(Ma.getY()),Math.floor(Ma.getWidth()),Math.floor(Ma.getHeight()))}Ma.empty()}};this.render=function(a,l){function n(a,b,c){for(var d=0,f=i.length;d<f;d++){var e=i[d],g=e.color;if(e instanceof THREE.DirectionalLight){var h=e.matrixWorld.getPosition().normalize(),k=b.dot(h);if(!(k<=0)){k=k*e.intensity;c.r=
  270. c.r+g.r*k;c.g=c.g+g.g*k;c.b=c.b+g.b*k}}else if(e instanceof THREE.PointLight){h=e.matrixWorld.getPosition();k=b.dot(xa.sub(h,a).normalize());if(!(k<=0)){k=k*(e.distance==0?1:1-Math.min(a.distanceTo(h)/e.distance,1));if(k!=0){k=k*e.intensity;c.r=c.r+g.r*k;c.g=c.g+g.g*k;c.b=c.b+g.b*k}}}}}function m(a,d,f,g,h,i,k,j){e.info.render.vertices=e.info.render.vertices+3;e.info.render.faces++;b(j.opacity);c(j.blending);L=a.positionScreen.x;K=a.positionScreen.y;I=d.positionScreen.x;M=d.positionScreen.y;T=f.positionScreen.x;
  271. Z=f.positionScreen.y;r(L,K,I,M,T,Z);if((j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)&&j.map===null&&j.map===null){$.copy(j.color);ca.copy(j.emissive);if(j.vertexColors===THREE.FaceColors){$.r=$.r*k.color.r;$.g=$.g*k.color.g;$.b=$.b*k.color.b}if(xb===true)if(j.wireframe===false&&j.shading==THREE.SmoothShading&&k.vertexNormalsLength==3){ga.r=P.r=X.r=Ga.r;ga.g=P.g=X.g=Ga.g;ga.b=P.b=X.b=Ga.b;n(k.v1.positionWorld,k.vertexNormalsWorld[0],ga);n(k.v2.positionWorld,k.vertexNormalsWorld[1],
  272. P);n(k.v3.positionWorld,k.vertexNormalsWorld[2],X);ga.r=ga.r*$.r+ca.r;ga.g=ga.g*$.g+ca.g;ga.b=ga.b*$.b+ca.b;P.r=P.r*$.r+ca.r;P.g=P.g*$.g+ca.g;P.b=P.b*$.b+ca.b;X.r=X.r*$.r+ca.r;X.g=X.g*$.g+ca.g;X.b=X.b*$.b+ca.b;ia.r=(P.r+X.r)*0.5;ia.g=(P.g+X.g)*0.5;ia.b=(P.b+X.b)*0.5;oa=Ec(ga,P,X,ia);ic(L,K,I,M,T,Z,0,0,1,0,0,1,oa)}else{O.r=Ga.r;O.g=Ga.g;O.b=Ga.b;n(k.centroidWorld,k.normalWorld,O);O.r=O.r*$.r+ca.r;O.g=O.g*$.g+ca.g;O.b=O.b*$.b+ca.b;j.wireframe===true?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):
  273. u(O)}else j.wireframe===true?t(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(j.color)}else if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)if(j.map!==null){if(j.map.mapping instanceof THREE.UVMapping){Xa=k.uvs[0];Ea(L,K,I,M,T,Z,Xa[g].u,Xa[g].v,Xa[h].u,Xa[h].v,Xa[i].u,Xa[i].v,j.map)}}else if(j.envMap!==null){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=l.matrixWorldInverse;xa.copy(k.vertexNormalsWorld[g]);
  274. kb=(xa.x*a.elements[0]+xa.y*a.elements[4]+xa.z*a.elements[8])*0.5+0.5;Ta=(xa.x*a.elements[1]+xa.y*a.elements[5]+xa.z*a.elements[9])*0.5+0.5;xa.copy(k.vertexNormalsWorld[h]);gb=(xa.x*a.elements[0]+xa.y*a.elements[4]+xa.z*a.elements[8])*0.5+0.5;rb=(xa.x*a.elements[1]+xa.y*a.elements[5]+xa.z*a.elements[9])*0.5+0.5;xa.copy(k.vertexNormalsWorld[i]);Qb=(xa.x*a.elements[0]+xa.y*a.elements[4]+xa.z*a.elements[8])*0.5+0.5;fb=(xa.x*a.elements[1]+xa.y*a.elements[5]+xa.z*a.elements[9])*0.5+0.5;Ea(L,K,I,M,T,Z,
  275. kb,Ta,gb,rb,Qb,fb,j.envMap)}}else{O.copy(j.color);if(j.vertexColors===THREE.FaceColors){O.r=O.r*k.color.r;O.g=O.g*k.color.g;O.b=O.b*k.color.b}j.wireframe===true?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(O)}else if(j instanceof THREE.MeshDepthMaterial){La=l.near;Wa=l.far;ga.r=ga.g=ga.b=1-fc(a.positionScreen.z,La,Wa);P.r=P.g=P.b=1-fc(d.positionScreen.z,La,Wa);X.r=X.g=X.b=1-fc(f.positionScreen.z,La,Wa);ia.r=(P.r+X.r)*0.5;ia.g=(P.g+X.g)*0.5;ia.b=(P.b+X.b)*0.5;oa=Ec(ga,P,X,ia);
  276. ic(L,K,I,M,T,Z,0,0,1,0,0,1,oa)}else if(j instanceof THREE.MeshNormalMaterial){O.r=v(k.normalWorld.x);O.g=v(k.normalWorld.y);O.b=v(k.normalWorld.z);j.wireframe===true?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(O)}}function r(a,b,c,d,f,e){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(f,e);p.closePath()}function s(a,b,c,d,f,e,g,h){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(f,e);p.lineTo(g,h);p.closePath()}function t(a,b,c,f){if(w!==b)w=p.lineWidth=b;if(A!==c)A=p.lineCap=
  277. c;if(J!==f)J=p.lineJoin=f;d(a.getContextStyle());p.stroke();za.inflate(b*2)}function u(a){f(a.getContextStyle());p.fill()}function Ea(a,b,c,d,e,g,h,i,k,j,l,n,m){if(!(m instanceof THREE.DataTexture||m.image===void 0||m.image.width==0)){if(m.needsUpdate===true){var Ea=m.wrapS==THREE.RepeatWrapping,o=m.wrapT==THREE.RepeatWrapping;Ja[m.id]=p.createPattern(m.image,Ea===true&&o===true?"repeat":Ea===true&&o===false?"repeat-x":Ea===false&&o===true?"repeat-y":"no-repeat");m.needsUpdate=false}Ja[m.id]===void 0?
  278. f("rgba(0,0,0,1)"):f(Ja[m.id]);var Ea=m.offset.x/m.repeat.x,o=m.offset.y/m.repeat.y,q=m.image.width*m.repeat.x,r=m.image.height*m.repeat.y,h=(h+Ea)*q,i=(1-i+o)*r,c=c-a,d=d-b,e=e-a,g=g-b,k=(k+Ea)*q-h,j=(1-j+o)*r-i,l=(l+Ea)*q-h,n=(1-n+o)*r-i,Ea=k*n-l*j;if(Ea===0){if(ua[m.id]===void 0){b=document.createElement("canvas");b.width=m.image.width;b.height=m.image.height;b=b.getContext("2d");b.drawImage(m.image,0,0);ua[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data}b=ua[m.id];h=(Math.floor(h)+
  279. Math.floor(i)*m.image.width)*4;O.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);u(O)}else{Ea=1/Ea;m=(n*c-j*e)*Ea;j=(n*d-j*g)*Ea;c=(k*e-l*c)*Ea;d=(k*g-l*d)*Ea;a=a-m*h-c*i;h=b-j*h-d*i;p.save();p.transform(m,j,c,d,a,h);p.fill();p.restore()}}}function ic(a,b,c,d,f,e,g,h,i,k,j,l,n){var m,Ea;m=n.width-1;Ea=n.height-1;g=g*m;h=h*Ea;c=c-a;d=d-b;f=f-a;e=e-b;i=i*m-g;k=k*Ea-h;j=j*m-g;l=l*Ea-h;Ea=1/(i*l-j*k);m=(l*c-k*f)*Ea;k=(l*d-k*e)*Ea;c=(i*f-j*c)*Ea;d=(i*e-j*d)*Ea;a=a-m*g-c*h;b=b-k*g-d*h;p.save();p.transform(m,k,c,
  280. d,a,b);p.clip();p.drawImage(n,0,0);p.restore()}function Ec(a,b,c,d){Ha[0]=a.r*255|0;Ha[1]=a.g*255|0;Ha[2]=a.b*255|0;Ha[4]=b.r*255|0;Ha[5]=b.g*255|0;Ha[6]=b.b*255|0;Ha[8]=c.r*255|0;Ha[9]=c.g*255|0;Ha[10]=c.b*255|0;Ha[12]=d.r*255|0;Ha[13]=d.g*255|0;Ha[14]=d.b*255|0;ab.putImageData(Ya,0,0);k.drawImage(ib,0,0);return yb}function fc(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function v(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function z(a,b){var c=b.x-a.x,d=b.y-a.y,f=c*c+d*d;if(f!==0){f=1/Math.sqrt(f);c=c*f;d=
  281. d*f;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}if(l instanceof THREE.Camera===false)console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");else{var Xb,Gc,ka,aa;this.autoClear===true?this.clear():p.setTransform(1,0,0,-1,q,o);e.info.render.vertices=0;e.info.render.faces=0;g=j.projectScene(a,l,this.sortObjects,this.sortElements);h=g.elements;i=g.lights;xb=i.length>0;if(xb===true){Ga.setRGB(0,0,0);sb.setRGB(0,0,0);hb.setRGB(0,0,0);Xb=0;for(Gc=i.length;Xb<Gc;Xb++){aa=i[Xb];
  282. var la=aa.color;if(aa instanceof THREE.AmbientLight){Ga.r=Ga.r+la.r;Ga.g=Ga.g+la.g;Ga.b=Ga.b+la.b}else if(aa instanceof THREE.DirectionalLight){sb.r=sb.r+la.r;sb.g=sb.g+la.g;sb.b=sb.b+la.b}else if(aa instanceof THREE.PointLight){hb.r=hb.r+la.r;hb.g=hb.g+la.g;hb.b=hb.b+la.b}}}Xb=0;for(Gc=h.length;Xb<Gc;Xb++){ka=h[Xb];aa=ka.material;if(!(aa===void 0||aa.visible===false)){za.empty();if(ka instanceof THREE.RenderableParticle){D=ka;D.x=D.x*q;D.y=D.y*o;var la=D,Za=ka;b(aa.opacity);c(aa.blending);var tb=
  283. void 0,ub=void 0,lb=void 0,mb=void 0,lc=ka=void 0,Vc=void 0;if(aa instanceof THREE.ParticleBasicMaterial)if(aa.map===null){lb=Za.object.scale.x;mb=Za.object.scale.y;lb=lb*Za.scale.x*q;mb=mb*Za.scale.y*o;za.set(la.x-lb,la.y-mb,la.x+lb,la.y+mb);if(bb.intersects(za)!==false){f(aa.color.getContextStyle());p.save();p.translate(la.x,la.y);p.rotate(-Za.rotation);p.scale(lb,mb);p.fillRect(-1,-1,2,2);p.restore()}}else{ka=aa.map.image;lc=ka.width>>1;Vc=ka.height>>1;lb=Za.scale.x*q;mb=Za.scale.y*o;tb=lb*lc;
  284. ub=mb*Vc;za.set(la.x-tb,la.y-ub,la.x+tb,la.y+ub);if(bb.intersects(za)!==false){p.save();p.translate(la.x,la.y);p.rotate(-Za.rotation);p.scale(lb,-mb);p.translate(-lc,-Vc);p.drawImage(ka,0,0);p.restore()}}else if(aa instanceof THREE.ParticleCanvasMaterial){tb=Za.scale.x*q;ub=Za.scale.y*o;za.set(la.x-tb,la.y-ub,la.x+tb,la.y+ub);if(bb.intersects(za)!==false){d(aa.color.getContextStyle());f(aa.color.getContextStyle());p.save();p.translate(la.x,la.y);p.rotate(-Za.rotation);p.scale(tb,ub);aa.program(p);
  285. p.restore()}}}else if(ka instanceof THREE.RenderableLine){D=ka.v1;F=ka.v2;D.positionScreen.x=D.positionScreen.x*q;D.positionScreen.y=D.positionScreen.y*o;F.positionScreen.x=F.positionScreen.x*q;F.positionScreen.y=F.positionScreen.y*o;za.addPoint(D.positionScreen.x,D.positionScreen.y);za.addPoint(F.positionScreen.x,F.positionScreen.y);if(bb.intersects(za)===true){la=D;Za=F;b(aa.opacity);c(aa.blending);p.beginPath();p.moveTo(la.positionScreen.x,la.positionScreen.y);p.lineTo(Za.positionScreen.x,Za.positionScreen.y);
  286. if(aa instanceof THREE.LineBasicMaterial){la=aa.linewidth;if(w!==la)w=p.lineWidth=la;la=aa.linecap;if(A!==la)A=p.lineCap=la;la=aa.linejoin;if(J!==la)J=p.lineJoin=la;d(aa.color.getContextStyle());p.stroke();za.inflate(aa.linewidth*2)}}}else if(ka instanceof THREE.RenderableFace3){D=ka.v1;F=ka.v2;B=ka.v3;D.positionScreen.x=D.positionScreen.x*q;D.positionScreen.y=D.positionScreen.y*o;F.positionScreen.x=F.positionScreen.x*q;F.positionScreen.y=F.positionScreen.y*o;B.positionScreen.x=B.positionScreen.x*
  287. q;B.positionScreen.y=B.positionScreen.y*o;if(aa.overdraw===true){z(D.positionScreen,F.positionScreen);z(F.positionScreen,B.positionScreen);z(B.positionScreen,D.positionScreen)}za.add3Points(D.positionScreen.x,D.positionScreen.y,F.positionScreen.x,F.positionScreen.y,B.positionScreen.x,B.positionScreen.y);bb.intersects(za)===true&&m(D,F,B,0,1,2,ka,aa,a)}else if(ka instanceof THREE.RenderableFace4){D=ka.v1;F=ka.v2;B=ka.v3;E=ka.v4;D.positionScreen.x=D.positionScreen.x*q;D.positionScreen.y=D.positionScreen.y*
  288. o;F.positionScreen.x=F.positionScreen.x*q;F.positionScreen.y=F.positionScreen.y*o;B.positionScreen.x=B.positionScreen.x*q;B.positionScreen.y=B.positionScreen.y*o;E.positionScreen.x=E.positionScreen.x*q;E.positionScreen.y=E.positionScreen.y*o;H.positionScreen.copy(F.positionScreen);Q.positionScreen.copy(E.positionScreen);if(aa.overdraw===true){z(D.positionScreen,F.positionScreen);z(F.positionScreen,E.positionScreen);z(E.positionScreen,D.positionScreen);z(B.positionScreen,H.positionScreen);z(B.positionScreen,
  289. Q.positionScreen)}za.addPoint(D.positionScreen.x,D.positionScreen.y);za.addPoint(F.positionScreen.x,F.positionScreen.y);za.addPoint(B.positionScreen.x,B.positionScreen.y);za.addPoint(E.positionScreen.x,E.positionScreen.y);if(bb.intersects(za)===true){la=D;Za=F;tb=B;ub=E;lb=H;mb=Q;lc=a;e.info.render.vertices=e.info.render.vertices+4;e.info.render.faces++;b(aa.opacity);c(aa.blending);if(aa.map!==void 0&&aa.map!==null||aa.envMap!==void 0&&aa.envMap!==null){m(la,Za,ub,0,1,3,ka,aa,lc);m(lb,tb,mb,1,2,3,
  290. ka,aa,lc)}else{L=la.positionScreen.x;K=la.positionScreen.y;I=Za.positionScreen.x;M=Za.positionScreen.y;T=tb.positionScreen.x;Z=tb.positionScreen.y;ea=ub.positionScreen.x;N=ub.positionScreen.y;fa=lb.positionScreen.x;S=lb.positionScreen.y;ra=mb.positionScreen.x;wa=mb.positionScreen.y;if(aa instanceof THREE.MeshLambertMaterial||aa instanceof THREE.MeshPhongMaterial){$.copy(aa.color);ca.copy(aa.emissive);if(aa.vertexColors===THREE.FaceColors){$.r=$.r*ka.color.r;$.g=$.g*ka.color.g;$.b=$.b*ka.color.b}if(xb===
  291. true)if(aa.wireframe===false&&aa.shading==THREE.SmoothShading&&ka.vertexNormalsLength==4){ga.r=P.r=X.r=ia.r=Ga.r;ga.g=P.g=X.g=ia.g=Ga.g;ga.b=P.b=X.b=ia.b=Ga.b;n(ka.v1.positionWorld,ka.vertexNormalsWorld[0],ga);n(ka.v2.positionWorld,ka.vertexNormalsWorld[1],P);n(ka.v4.positionWorld,ka.vertexNormalsWorld[3],X);n(ka.v3.positionWorld,ka.vertexNormalsWorld[2],ia);ga.r=ga.r*$.r+ca.r;ga.g=ga.g*$.g+ca.g;ga.b=ga.b*$.b+ca.b;P.r=P.r*$.r+ca.r;P.g=P.g*$.g+ca.g;P.b=P.b*$.b+ca.b;X.r=X.r*$.r+ca.r;X.g=X.g*$.g+ca.g;
  292. X.b=X.b*$.b+ca.b;ia.r=ia.r*$.r+ca.r;ia.g=ia.g*$.g+ca.g;ia.b=ia.b*$.b+ca.b;oa=Ec(ga,P,X,ia);r(L,K,I,M,ea,N);ic(L,K,I,M,ea,N,0,0,1,0,0,1,oa);r(fa,S,T,Z,ra,wa);ic(fa,S,T,Z,ra,wa,1,0,1,1,0,1,oa)}else{O.r=Ga.r;O.g=Ga.g;O.b=Ga.b;n(ka.centroidWorld,ka.normalWorld,O);O.r=O.r*$.r+ca.r;O.g=O.g*$.g+ca.g;O.b=O.b*$.b+ca.b;s(L,K,I,M,T,Z,ea,N);aa.wireframe===true?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)}else{O.r=$.r+ca.r;O.g=$.g+ca.g;O.b=$.b+ca.b;s(L,K,I,M,T,Z,ea,N);aa.wireframe===
  293. true?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)}}else if(aa instanceof THREE.MeshBasicMaterial){O.copy(aa.color);if(aa.vertexColors===THREE.FaceColors){O.r=O.r*ka.color.r;O.g=O.g*ka.color.g;O.b=O.b*ka.color.b}s(L,K,I,M,T,Z,ea,N);aa.wireframe===true?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)}else if(aa instanceof THREE.MeshNormalMaterial){O.r=v(ka.normalWorld.x);O.g=v(ka.normalWorld.y);O.b=v(ka.normalWorld.z);s(L,K,I,M,T,Z,ea,N);aa.wireframe===
  294. true?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)}else if(aa instanceof THREE.MeshDepthMaterial){La=l.near;Wa=l.far;ga.r=ga.g=ga.b=1-fc(la.positionScreen.z,La,Wa);P.r=P.g=P.b=1-fc(Za.positionScreen.z,La,Wa);X.r=X.g=X.b=1-fc(ub.positionScreen.z,La,Wa);ia.r=ia.g=ia.b=1-fc(tb.positionScreen.z,La,Wa);oa=Ec(ga,P,X,ia);r(L,K,I,M,ea,N);ic(L,K,I,M,ea,N,0,0,1,0,0,1,oa);r(fa,S,T,Z,ra,wa);ic(fa,S,T,Z,ra,wa,1,0,1,1,0,1,oa)}}}}Ma.addRectangle(za)}}p.setTransform(1,0,0,1,0,0)}}};
  295. THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
  296. envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nuniform bool useRefract;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec3 reflectVec;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nreflectVec = refract( cameraToVertex, normal, refractionRatio );\n} else { \nreflectVec = reflect( cameraToVertex, normal );\n}\n#else\nreflectVec = vReflect;\n#endif\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#endif\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n} else {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n}\n#endif",
  297. envmap_pars_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n#ifdef USE_SKINNING\nvec4 mPosition = modelMatrix * skinned;\n#endif\n#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( morphed, 1.0 );\n#endif\n#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\n#endif\n#endif",
  298. envmap_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvec3 nWorld = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  299. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif",map_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  300. map_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
  301. lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx( vUv );\nvec2 dSTdy = dFdy( vUv );\nfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\nfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\nfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\nreturn vec2( dBx, dBy );\n}\nvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\nvec3 vSigmaX = dFdx( surf_pos );\nvec3 vSigmaY = dFdy( surf_pos );\nvec3 vN = surf_norm;\nvec3 R1 = cross( vSigmaY, vN );\nvec3 R2 = cross( vN, vSigmaX );\nfloat fDet = dot( vSigmaX, R1 );\nvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\nreturn normalize( abs( fDet ) * surf_norm - vGrad );\n}\n#endif",
  302. normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\nvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\nvec3 q0 = dFdx( eye_pos.xyz );\nvec3 q1 = dFdy( eye_pos.xyz );\nvec2 st0 = dFdx( vUv.st );\nvec2 st1 = dFdy( vUv.st );\nvec3 S = normalize( q0 * st1.t - q1 * st0.t );\nvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\nvec3 N = normalize( surf_norm );\nvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\nmapN.xy = normalScale * mapN.xy;\nmat3 tsn = mat3( S, T, N );\nreturn normalize( tsn * mapN );\n}\n#endif",
  303. specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D( specularMap, vUv );\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",lights_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
  304. lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nlVector = normalize( lVector );\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - mPosition.xyz ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\nspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\nspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n#ifdef DOUBLE_SIDED\nvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\nvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n#ifdef DOUBLE_SIDED\nvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
  305. lights_phong_pars_vertex:"#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif",
  306. lights_phong_vertex:"#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nvSpotLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvWorldPosition = mPosition.xyz;\n#endif",
  307. lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#else\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  308. lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#ifdef USE_NORMALMAP\nnormal = perturbNormal2Arb( -viewPosition, normal );\n#elif defined( USE_BUMPMAP )\nnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vSpotLight[ i ].xyz );\nfloat lDistance = vSpotLight[ i ].w;\n#endif\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n#endif\nspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\nvec3 spotHalfVector = normalize( lVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = normalize( lPosition.xyz + vViewPosition.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += diffuse * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );\nvec3 lVectorGround = normalize( -lPosition.xyz + vViewPosition.xyz );\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
  309. color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n#ifdef BONE_TEXTURE\nuniform sampler2D boneTexture;\nmat4 getBoneMatrix( const in float i ) {\nfloat j = i * 4.0;\nfloat x = mod( j, N_BONE_PIXEL_X );\nfloat y = floor( j / N_BONE_PIXEL_X );\nconst float dx = 1.0 / N_BONE_PIXEL_X;\nconst float dy = 1.0 / N_BONE_PIXEL_Y;\ny = dy * ( y + 0.5 );\nvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\nvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\nvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\nvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\nmat4 bone = mat4( v1, v2, v3, v4 );\nreturn bone;\n}\n#else\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\nmat4 getBoneMatrix( const in float i ) {\nmat4 bone = boneGlobalMatrices[ int(i) ];\nreturn bone;\n}\n#endif\n#endif",
  310. skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix( skinIndex.x );\nmat4 boneMatY = getBoneMatrix( skinIndex.y );\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n#ifdef USE_MORPHTARGETS\nvec4 skinVertex = vec4( morphed, 1.0 );\n#else\nvec4 skinVertex = vec4( position, 1.0 );\n#endif\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",
  311. morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\n#endif",
  312. default_vertex:"vec4 mvPosition;\n#ifdef USE_SKINNING\nmvPosition = modelViewMatrix * skinned;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( position, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\n#endif",
  313. skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = skinWeight.x * boneMatX;\nskinMatrix \t+= skinWeight.y * boneMatY;\n#ifdef USE_MORPHNORMALS\nvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n#else\nvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n#endif\n#endif",defaultnormal_vertex:"vec3 objectNormal;\n#ifdef USE_SKINNING\nobjectNormal = skinnedNormal.xyz;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\nobjectNormal = morphedNormal;\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\nobjectNormal = normal;\n#endif\n#ifdef FLIP_SIDED\nobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;",
  314. shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
  315. shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * mPosition;\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
  316. THREE.UniformsUtils={merge:function(a){var b,c,d,f={};for(b=0;b<a.length;b++){d=this.clone(a[b]);for(c in d)f[c]=d[c]}return f},clone:function(a){var b,c,d,f={};for(b in a){f[b]={};for(c in a[b]){d=a[b][c];f[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector2||d instanceof THREE.Vector3||d instanceof THREE.Vector4||d instanceof THREE.Matrix4||d instanceof THREE.Texture?d.clone():d instanceof Array?d.slice():d}}return f}};
  317. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:null},specularMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},bump:{bumpMap:{type:"t",
  318. value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new THREE.Vector2(1,1)}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},hemisphereLightPosition:{type:"fv",value:[]},hemisphereLightSkyColor:{type:"fv",
  319. value:[]},hemisphereLightGroundColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]},spotLightColor:{type:"fv",value:[]},spotLightPosition:{type:"fv",value:[]},spotLightDirection:{type:"fv",value:[]},spotLightDistance:{type:"fv1",value:[]},spotLightAngle:{type:"fv1",value:[]},spotLightExponent:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",
  320. value:1},scale:{type:"f",value:1},map:{type:"t",value:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}};
  321. THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}"},normal:{uniforms:{opacity:{type:"f",
  322. value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalMatrix * normal;\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,
  323. THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,"#ifdef USE_ENVMAP",THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,
  324. "#endif",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
  325. THREE.ShaderChunk.specularmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,
  326. THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,
  327. THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.worldpos_vertex,
  328. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,
  329. "void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,"#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,
  330. THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.bump,THREE.UniformsLib.normalmap,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define PHONG\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  331. THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,
  332. THREE.ShaderChunk.defaultnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,"vViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;",
  333. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,
  334. THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,
  335. THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
  336. THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",
  337. 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 ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
  338. THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(a.__webglCustomAttributesList===void 0)a.__webglCustomAttributesList=[];for(var f in d.attributes){var e=d.attributes[f];if(!e.__webglInitialized||e.createUniqueBuffers){e.__webglInitialized=true;var g=1;e.type==="v2"?g=2:e.type==="v3"?g=3:e.type==="v4"?g=4:e.type==="c"&&(g=3);e.size=g;e.array=new Float32Array(c*g);e.buffer=k.createBuffer();e.buffer.belongsToAttribute=f;e.needsUpdate=true}a.__webglCustomAttributesList.push(e)}}}
  339. function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){return a.map||a.lightMap||a.bumpMap||a.normalMap||a.specularMap||a instanceof THREE.ShaderMaterial?true:false}function e(a){var b,
  340. c,d;for(b in a.attributes){d=b==="index"?k.ELEMENT_ARRAY_BUFFER:k.ARRAY_BUFFER;c=a.attributes[b];c.buffer=k.createBuffer();k.bindBuffer(d,c.buffer);k.bufferData(d,c.array,k.STATIC_DRAW)}}function g(a,b,c){var d,f,e,g,h=a.vertices;g=h.length;var i=a.colors,j=i.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,p=a.verticesNeedUpdate,o=a.colorsNeedUpdate,q=a.__webglCustomAttributesList;if(c.sortParticles){ib.copy(xa);ib.multiplySelf(c.matrixWorld);for(d=0;d<g;d++){f=h[d];ab.copy(f);ib.multiplyVector3(ab);
  341. n[d]=[ab.z,d]}n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++){f=h[n[d][1]];e=d*3;l[e]=f.x;l[e+1]=f.y;l[e+2]=f.z}for(d=0;d<j;d++){e=d*3;f=i[n[d][1]];m[e]=f.r;m[e+1]=f.g;m[e+2]=f.b}if(q){i=0;for(j=q.length;i<j;i++){h=q[i];if(h.boundTo===void 0||h.boundTo==="vertices"){e=0;f=h.value.length;if(h.size===1)for(d=0;d<f;d++){g=n[d][1];h.array[d]=h.value[g]}else if(h.size===2)for(d=0;d<f;d++){g=n[d][1];g=h.value[g];h.array[e]=g.x;h.array[e+1]=g.y;e=e+2}else if(h.size===3)if(h.type==="c")for(d=0;d<
  342. f;d++){g=n[d][1];g=h.value[g];h.array[e]=g.r;h.array[e+1]=g.g;h.array[e+2]=g.b;e=e+3}else for(d=0;d<f;d++){g=n[d][1];g=h.value[g];h.array[e]=g.x;h.array[e+1]=g.y;h.array[e+2]=g.z;e=e+3}else if(h.size===4)for(d=0;d<f;d++){g=n[d][1];g=h.value[g];h.array[e]=g.x;h.array[e+1]=g.y;h.array[e+2]=g.z;h.array[e+3]=g.w;e=e+4}}}}}else{if(p)for(d=0;d<g;d++){f=h[d];e=d*3;l[e]=f.x;l[e+1]=f.y;l[e+2]=f.z}if(o)for(d=0;d<j;d++){f=i[d];e=d*3;m[e]=f.r;m[e+1]=f.g;m[e+2]=f.b}if(q){i=0;for(j=q.length;i<j;i++){h=q[i];if(h.needsUpdate&&
  343. (h.boundTo===void 0||h.boundTo==="vertices")){f=h.value.length;e=0;if(h.size===1)for(d=0;d<f;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<f;d++){g=h.value[d];h.array[e]=g.x;h.array[e+1]=g.y;e=e+2}else if(h.size===3)if(h.type==="c")for(d=0;d<f;d++){g=h.value[d];h.array[e]=g.r;h.array[e+1]=g.g;h.array[e+2]=g.b;e=e+3}else for(d=0;d<f;d++){g=h.value[d];h.array[e]=g.x;h.array[e+1]=g.y;h.array[e+2]=g.z;e=e+3}else if(h.size===4)for(d=0;d<f;d++){g=h.value[d];h.array[e]=g.x;h.array[e+1]=g.y;h.array[e+
  344. 2]=g.z;h.array[e+3]=g.w;e=e+4}}}}}if(p||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,l,b)}if(o||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,m,b)}if(q){i=0;for(j=q.length;i<j;i++){h=q[i];if(h.needsUpdate||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.bufferData(k.ARRAY_BUFFER,h.array,b)}}}}function h(a,b,c){var d=a.attributes,e=d.index,f=d.position,g=d.normal,h=d.uv,i=d.color,d=d.tangent;
  345. if(a.elementsNeedUpdate&&e!==void 0){k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.buffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,e.array,b)}if(a.verticesNeedUpdate&&f!==void 0){k.bindBuffer(k.ARRAY_BUFFER,f.buffer);k.bufferData(k.ARRAY_BUFFER,f.array,b)}if(a.normalsNeedUpdate&&g!==void 0){k.bindBuffer(k.ARRAY_BUFFER,g.buffer);k.bufferData(k.ARRAY_BUFFER,g.array,b)}if(a.uvsNeedUpdate&&h!==void 0){k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.bufferData(k.ARRAY_BUFFER,h.array,b)}if(a.colorsNeedUpdate&&i!==void 0){k.bindBuffer(k.ARRAY_BUFFER,
  346. i.buffer);k.bufferData(k.ARRAY_BUFFER,i.array,b)}if(a.tangentsNeedUpdate&&d!==void 0){k.bindBuffer(k.ARRAY_BUFFER,d.buffer);k.bufferData(k.ARRAY_BUFFER,d.array,b)}if(c)for(var j in a.attributes)delete a.attributes[j].array}function i(a,b){return b.z-a.z}function j(a,b){return b[1]-a[1]}function l(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++){ia=O=null;P=X=ua=Ja=Ta=kb=La=-1;Ha=true;a[d].render(b,c,Ga,sb);ia=O=null;P=X=ua=Ja=Ta=kb=La=-1;Ha=true}}function n(a,b,c,d,e,f,g,h){var i,k,j,l;if(b){k=
  347. a.length-1;l=b=-1}else{k=0;b=a.length;l=1}for(var m=k;m!==b;m=m+l){i=a[m];if(i.render){k=i.object;j=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&S.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);S.setDepthTest(i.depthTest);S.setDepthWrite(i.depthWrite);A(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}S.setMaterialFaces(i);j instanceof THREE.BufferGeometry?S.renderBufferDirect(d,e,f,i,j,k):S.renderBuffer(d,e,f,i,j,k)}}}function m(a,b,c,d,e,f,g){for(var h,i,k=0,j=a.length;k<
  348. j;k++){h=a[k];i=h.object;if(i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&S.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);S.setDepthTest(h.depthTest);S.setDepthWrite(h.depthWrite);A(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}S.renderImmediateObject(c,d,e,h,i)}}}function q(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function o(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=
  349. false}function r(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function t(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function u(a,b,c,d,e){ca=0;if(d.needsUpdate){d.program&&S.deallocateMaterial(d);S.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(S.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,i=d.uniforms;if(g!==O){k.useProgram(g);O=g;f=true}if(d.id!==P){P=d.id;
  350. f=true}if(f||a!==ia){k.uniformMatrix4fv(h.projectionMatrix,false,a._projectionMatrixArray);a!==ia&&(ia=a)}if(d.skinning)if(kc&&e.useVertexTexture){if(h.boneTexture!==null){var j=v();k.uniform1i(h.boneTexture,j);S.setTexture(e.boneTexture,j)}}else h.boneGlobalMatrices!==null&&k.uniformMatrix4fv(h.boneGlobalMatrices,false,e.boneMatrices);if(f){if(c&&d.fog){i.fogColor.value=c.color;if(c instanceof THREE.Fog){i.fogNear.value=c.near;i.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)i.fogDensity.value=
  351. c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(Ha){for(var l=0,m=0,n=0,p,o,q,r,s=yb,t=s.directional.colors,u=s.directional.positions,A=s.point.colors,D=s.point.positions,E=s.point.distances,B=s.spot.colors,J=s.spot.positions,K=s.spot.distances,I=s.spot.directions,L=s.spot.angles,M=s.spot.exponents,N=s.hemi.skyColors,X=s.hemi.groundColors,$=s.hemi.positions,ga=0,T=0,ea=0,fa=0,c=p=q=q=o=0,f=b.length;c<f;c++){j=b[c];if(!j.onlyShadow&&j.visible){p=
  352. j.color;r=j.intensity;o=j.distance;if(j instanceof THREE.AmbientLight)if(S.gammaInput){l=l+p.r*p.r;m=m+p.g*p.g;n=n+p.b*p.b}else{l=l+p.r;m=m+p.g;n=n+p.b}else if(j instanceof THREE.DirectionalLight){o=ga*3;S.gammaInput?z(t,o,p,r*r):w(t,o,p,r);Ya.copy(j.matrixWorld.getPosition());Ya.subSelf(j.target.matrixWorld.getPosition());Ya.normalize();u[o]=Ya.x;u[o+1]=Ya.y;u[o+2]=Ya.z;ga=ga+1}else if(j instanceof THREE.PointLight){q=T*3;S.gammaInput?z(A,q,p,r*r):w(A,q,p,r);r=j.matrixWorld.getPosition();D[q]=r.x;
  353. D[q+1]=r.y;D[q+2]=r.z;E[T]=o;T=T+1}else if(j instanceof THREE.SpotLight){q=ea*3;S.gammaInput?z(B,q,p,r*r):w(B,q,p,r);r=j.matrixWorld.getPosition();J[q]=r.x;J[q+1]=r.y;J[q+2]=r.z;K[ea]=o;Ya.copy(r);Ya.subSelf(j.target.matrixWorld.getPosition());Ya.normalize();I[q]=Ya.x;I[q+1]=Ya.y;I[q+2]=Ya.z;L[ea]=Math.cos(j.angle);M[ea]=j.exponent;ea=ea+1}else if(j instanceof THREE.HemisphereLight){o=j.color;q=j.groundColor;p=fa*3;if(S.gammaInput){r=r*r;z(N,p,o,r);z(X,p,q,r)}else{w(N,p,o,r);w(X,p,q,r)}r=j.matrixWorld.getPosition();
  354. $[p]=r.x;$[p+1]=r.y;$[p+2]=r.z;fa=fa+1}}}c=ga*3;for(f=t.length;c<f;c++)t[c]=0;c=T*3;for(f=A.length;c<f;c++)A[c]=0;c=ea*3;for(f=B.length;c<f;c++)B[c]=0;c=fa*3;for(f=N.length;c<f;c++)N[c]=0;c=fa*3;for(f=X.length;c<f;c++)X[c]=0;s.directional.length=ga;s.point.length=T;s.spot.length=ea;s.hemi.length=fa;s.ambient[0]=l;s.ambient[1]=m;s.ambient[2]=n;Ha=false}c=yb;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;
  355. i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances;i.spotLightColor.value=c.spot.colors;i.spotLightPosition.value=c.spot.positions;i.spotLightDistance.value=c.spot.distances;i.spotLightDirection.value=c.spot.directions;i.spotLightAngle.value=c.spot.angles;i.spotLightExponent.value=c.spot.exponents;i.hemisphereLightSkyColor.value=c.hemi.skyColors;i.hemisphereLightGroundColor.value=c.hemi.groundColors;i.hemisphereLightPosition.value=
  356. c.hemi.positions}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){i.opacity.value=d.opacity;S.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color;i.map.value=d.map;i.lightMap.value=d.lightMap;i.specularMap.value=d.specularMap;if(d.bumpMap){i.bumpMap.value=d.bumpMap;i.bumpScale.value=d.bumpScale}if(d.normalMap){i.normalMap.value=d.normalMap;i.normalScale.value.copy(d.normalScale)}var Z;if(d.map)Z=d.map;
  357. else if(d.specularMap)Z=d.specularMap;else if(d.normalMap)Z=d.normalMap;else if(d.bumpMap)Z=d.bumpMap;if(Z!==void 0){c=Z.offset;Z=Z.repeat;i.offsetRepeat.value.set(c.x,c.y,Z.x,Z.y)}i.envMap.value=d.envMap;i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;i.reflectivity.value=d.reflectivity;i.refractionRatio.value=d.refractionRatio;i.combine.value=d.combine;i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof THREE.LineBasicMaterial){i.diffuse.value=
  358. d.color;i.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){i.psColor.value=d.color;i.opacity.value=d.opacity;i.size.value=d.size;i.scale.value=Q.height/2;i.map.value=d.map}else if(d instanceof THREE.MeshPhongMaterial){i.shininess.value=d.shininess;if(S.gammaInput){i.ambient.value.copyGammaToLinear(d.ambient);i.emissive.value.copyGammaToLinear(d.emissive);i.specular.value.copyGammaToLinear(d.specular)}else{i.ambient.value=d.ambient;i.emissive.value=d.emissive;i.specular.value=
  359. d.specular}d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshLambertMaterial){if(S.gammaInput){i.ambient.value.copyGammaToLinear(d.ambient);i.emissive.value.copyGammaToLinear(d.emissive)}else{i.ambient.value=d.ambient;i.emissive.value=d.emissive}d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshDepthMaterial){i.mNear.value=a.near;i.mFar.value=a.far;i.opacity.value=d.opacity}else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;
  360. if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){c=Z=0;for(f=b.length;c<f;c++){j=b[c];if(j.castShadow&&(j instanceof THREE.SpotLight||j instanceof THREE.DirectionalLight&&!j.shadowCascade)){i.shadowMap.value[Z]=j.shadowMap;i.shadowMapSize.value[Z]=j.shadowMapSize;i.shadowMatrix.value[Z]=j.shadowMatrix;i.shadowDarkness.value[Z]=j.shadowDarkness;i.shadowBias.value[Z]=j.shadowBias;Z++}}}b=d.uniformsList;i=0;for(Z=b.length;i<Z;i++)if(f=g.uniforms[b[i][1]]){c=b[i][0];l=c.type;j=c.value;if(l==="i")k.uniform1i(f,
  361. j);else if(l==="f")k.uniform1f(f,j);else if(l==="v2")k.uniform2f(f,j.x,j.y);else if(l==="v3")k.uniform3f(f,j.x,j.y,j.z);else if(l==="v4")k.uniform4f(f,j.x,j.y,j.z,j.w);else if(l==="c")k.uniform3f(f,j.r,j.g,j.b);else if(l==="iv1")k.uniform1iv(f,j);else if(l==="iv")k.uniform3iv(f,j);else if(l==="fv1")k.uniform1fv(f,j);else if(l==="fv")k.uniform3fv(f,j);else if(l==="v2v"){if(c._array===void 0)c._array=new Float32Array(2*j.length);l=0;for(m=j.length;l<m;l++){n=l*2;c._array[n]=j[l].x;c._array[n+1]=j[l].y}k.uniform2fv(f,
  362. c._array)}else if(l==="v3v"){if(c._array===void 0)c._array=new Float32Array(3*j.length);l=0;for(m=j.length;l<m;l++){n=l*3;c._array[n]=j[l].x;c._array[n+1]=j[l].y;c._array[n+2]=j[l].z}k.uniform3fv(f,c._array)}else if(l==="v4v"){if(c._array===void 0)c._array=new Float32Array(4*j.length);l=0;for(m=j.length;l<m;l++){n=l*4;c._array[n]=j[l].x;c._array[n+1]=j[l].y;c._array[n+2]=j[l].z;c._array[n+3]=j[l].w}k.uniform4fv(f,c._array)}else if(l==="m4"){if(c._array===void 0)c._array=new Float32Array(16);j.flattenToArray(c._array);
  363. k.uniformMatrix4fv(f,false,c._array)}else if(l==="m4v"){if(c._array===void 0)c._array=new Float32Array(16*j.length);l=0;for(m=j.length;l<m;l++)j[l].flattenToArrayOffset(c._array,l*16);k.uniformMatrix4fv(f,false,c._array)}else if(l==="t"){n=j;j=v();k.uniform1i(f,j);if(n)if(n.image instanceof Array&&n.image.length===6){c=n;f=j;if(c.image.length===6)if(c.needsUpdate){if(!c.image.__webglTextureCube)c.image.__webglTextureCube=k.createTexture();k.activeTexture(k.TEXTURE0+f);k.bindTexture(k.TEXTURE_CUBE_MAP,
  364. c.image.__webglTextureCube);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,c.flipY);f=c instanceof THREE.CompressedTexture;j=[];for(l=0;l<6;l++)if(S.autoScaleCubemaps&&!f){m=j;n=l;s=c.image[l];u=Uc;if(!(s.width<=u&&s.height<=u)){A=Math.max(s.width,s.height);t=Math.floor(s.width*u/A);u=Math.floor(s.height*u/A);A=document.createElement("canvas");A.width=t;A.height=u;A.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,u);s=A}m[n]=s}else j[l]=c.image[l];l=j[0];m=(l.width&l.width-1)===0&&(l.height&l.height-
  365. 1)===0;n=H(c.format);s=H(c.type);F(k.TEXTURE_CUBE_MAP,c,m);for(l=0;l<6;l++)if(f){u=j[l].mipmaps;A=0;for(D=u.length;A<D;A++){t=u[A];k.compressedTexImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,A,n,t.width,t.height,0,t.data)}}else k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,n,s,j[l]);c.generateMipmaps&&m&&k.generateMipmap(k.TEXTURE_CUBE_MAP);c.needsUpdate=false;if(c.onUpdate)c.onUpdate()}else{k.activeTexture(k.TEXTURE0+f);k.bindTexture(k.TEXTURE_CUBE_MAP,c.image.__webglTextureCube)}}else if(n instanceof
  366. THREE.WebGLRenderTargetCube){c=n;k.activeTexture(k.TEXTURE0+j);k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture)}else S.setTexture(n,j)}else if(l==="tv"){if(c._array===void 0)c._array=[];l=0;for(m=c.value.length;l<m;l++)c._array[l]=v();k.uniform1iv(f,c._array);l=0;for(m=c.value.length;l<m;l++){n=c.value[l];j=c._array[l];n&&S.setTexture(n,j)}}}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&h.cameraPosition!==null){b=a.matrixWorld.getPosition();k.uniform3f(h.cameraPosition,
  367. b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&h.viewMatrix!==null&&k.uniformMatrix4fv(h.viewMatrix,false,a._viewMatrixArray)}k.uniformMatrix4fv(h.modelViewMatrix,false,e._modelViewMatrix.elements);h.normalMatrix&&k.uniformMatrix3fv(h.normalMatrix,false,e._normalMatrix.elements);h.modelMatrix!==null&&k.uniformMatrix4fv(h.modelMatrix,false,e.matrixWorld.elements);return g}function v(){var a=ca;a>=sc&&console.warn("Trying to use "+
  368. a+" texture units while this GPU supports only "+sc);ca=ca+1;return a}function s(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function z(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function w(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function A(a,b,c){if(gb!==a){a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL);gb=a}if(a&&(rb!==b||Qb!==c)){k.polygonOffset(b,c);rb=b;
  369. Qb=c}}function J(a){for(var a=a.split("\n"),b=0,c=a.length;b<c;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function D(a,b){var c;a==="fragment"?c=k.createShader(k.FRAGMENT_SHADER):a==="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,b);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS)){console.error(k.getShaderInfoLog(c));console.error(J(b));return null}return c}function F(a,b,c){if(c){k.texParameteri(a,k.TEXTURE_WRAP_S,H(b.wrapS));k.texParameteri(a,k.TEXTURE_WRAP_T,H(b.wrapT));
  370. k.texParameteri(a,k.TEXTURE_MAG_FILTER,H(b.magFilter));k.texParameteri(a,k.TEXTURE_MIN_FILTER,H(b.minFilter))}else{k.texParameteri(a,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(a,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(a,k.TEXTURE_MAG_FILTER,E(b.magFilter));k.texParameteri(a,k.TEXTURE_MIN_FILTER,E(b.minFilter))}if(Rb&&b.type!==THREE.FloatType&&(b.anisotropy>1||b.__oldAnisotropy)){k.texParameterf(a,Rb.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,Fc));b.__oldAnisotropy=b.anisotropy}}
  371. function B(a,b){k.bindRenderbuffer(k.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height);k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,b.width,b.height);k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,a)}else k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height)}
  372. function E(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?k.NEAREST:k.LINEAR}function H(a){if(a===THREE.RepeatWrapping)return k.REPEAT;if(a===THREE.ClampToEdgeWrapping)return k.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return k.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return k.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return k.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return k.NEAREST_MIPMAP_LINEAR;if(a===
  373. THREE.LinearFilter)return k.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return k.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return k.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return k.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return k.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return k.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return k.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return k.BYTE;if(a===THREE.ShortType)return k.SHORT;if(a===
  374. THREE.UnsignedShortType)return k.UNSIGNED_SHORT;if(a===THREE.IntType)return k.INT;if(a===THREE.UnsignedIntType)return k.UNSIGNED_INT;if(a===THREE.FloatType)return k.FLOAT;if(a===THREE.AlphaFormat)return k.ALPHA;if(a===THREE.RGBFormat)return k.RGB;if(a===THREE.RGBAFormat)return k.RGBA;if(a===THREE.LuminanceFormat)return k.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return k.LUMINANCE_ALPHA;if(a===THREE.AddEquation)return k.FUNC_ADD;if(a===THREE.SubtractEquation)return k.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return k.FUNC_REVERSE_SUBTRACT;
  375. if(a===THREE.ZeroFactor)return k.ZERO;if(a===THREE.OneFactor)return k.ONE;if(a===THREE.SrcColorFactor)return k.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return k.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return k.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return k.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return k.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return k.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return k.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return k.ONE_MINUS_DST_COLOR;
  376. if(a===THREE.SrcAlphaSaturateFactor)return k.SRC_ALPHA_SATURATE;if(zb!==void 0){if(a===THREE.RGB_S3TC_DXT1_Format)return zb.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return zb.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return zb.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return zb.COMPRESSED_RGBA_S3TC_DXT5_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);var a=a||{},Q=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
  377. L=a.precision!==void 0?a.precision:"highp",K=a.alpha!==void 0?a.alpha:true,I=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:true,M=a.antialias!==void 0?a.antialias:false,T=a.stencil!==void 0?a.stencil:true,Z=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:false,ea=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),N=a.clearAlpha!==void 0?a.clearAlpha:0,fa=a.maxLights!==void 0?a.maxLights:4;this.domElement=Q;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=
  378. this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=true;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=false;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=true;this.shadowMapCascade=this.shadowMapDebug=false;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=true;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,
  379. vertices:0,faces:0,points:0}};var S=this,ra=[],wa=0,O=null,ga=null,P=-1,X=null,ia=null,$=0,ca=0,Ja=-1,ua=-1,La=-1,Wa=-1,oa=-1,Xa=-1,kb=-1,Ta=-1,gb=null,rb=null,Qb=null,fb=null,bb=0,Ma=0,za=0,xb=0,Ga=0,sb=0,hb=new THREE.Frustum,xa=new THREE.Matrix4,ib=new THREE.Matrix4,ab=new THREE.Vector4,Ya=new THREE.Vector3,Ha=true,yb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],
  380. angles:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},k,Rb,zb;try{if(!(k=Q.getContext("experimental-webgl",{alpha:K,premultipliedAlpha:I,antialias:M,stencil:T,preserveDrawingBuffer:Z})))throw"Error creating WebGL context.";}catch(Tc){console.error(Tc)}a=k.getExtension("OES_texture_float");K=k.getExtension("OES_standard_derivatives");Rb=k.getExtension("EXT_texture_filter_anisotropic")||k.getExtension("MOZ_EXT_texture_filter_anisotropic")||k.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
  381. zb=k.getExtension("WEBGL_compressed_texture_s3tc")||k.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||k.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");a||console.log("THREE.WebGLRenderer: Float textures not supported.");K||console.log("THREE.WebGLRenderer: Standard derivatives not supported.");Rb||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");zb||console.log("THREE.WebGLRenderer: S3TC compressed textures not supported.");k.clearColor(0,0,0,1);k.clearDepth(1);
  382. k.clearStencil(0);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(ea.r,ea.g,ea.b,N);this.context=k;var sc=k.getParameter(k.MAX_TEXTURE_IMAGE_UNITS),K=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS);k.getParameter(k.MAX_TEXTURE_SIZE);var Uc=k.getParameter(k.MAX_CUBE_MAP_TEXTURE_SIZE),Fc=Rb?k.getParameter(Rb.MAX_TEXTURE_MAX_ANISOTROPY_EXT):
  383. 0,jc=K>0,kc=jc&&a;zb&&k.getParameter(k.COMPRESSED_TEXTURE_FORMATS);this.getContext=function(){return k};this.supportsVertexTextures=function(){return jc};this.getMaxAnisotropy=function(){return Fc};this.setSize=function(a,b){Q.width=a;Q.height=b;this.setViewport(0,0,Q.width,Q.height)};this.setViewport=function(a,b,c,d){bb=a!==void 0?a:0;Ma=b!==void 0?b:0;za=c!==void 0?c:Q.width;xb=d!==void 0?d:Q.height;k.viewport(bb,Ma,za,xb)};this.setScissor=function(a,b,c,d){k.scissor(a,b,c,d)};this.enableScissorTest=
  384. function(a){a?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.setClearColorHex=function(a,b){ea.setHex(a);N=b;k.clearColor(ea.r,ea.g,ea.b,N)};this.setClearColor=function(a,b){ea.copy(a);N=b;k.clearColor(ea.r,ea.g,ea.b,N)};this.getClearColor=function(){return ea};this.getClearAlpha=function(){return N};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|k.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|k.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|k.STENCIL_BUFFER_BIT;k.clear(d)};this.clearTarget=function(a,
  385. b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix;delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._modelMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];
  386. k.deleteBuffer(c.__webglVertexBuffer);k.deleteBuffer(c.__webglNormalBuffer);k.deleteBuffer(c.__webglTangentBuffer);k.deleteBuffer(c.__webglColorBuffer);k.deleteBuffer(c.__webglUVBuffer);k.deleteBuffer(c.__webglUV2Buffer);k.deleteBuffer(c.__webglSkinIndicesBuffer);k.deleteBuffer(c.__webglSkinWeightsBuffer);k.deleteBuffer(c.__webglFaceBuffer);k.deleteBuffer(c.__webglLineBuffer);var d=void 0,f=void 0;if(c.numMorphTargets){d=0;for(f=c.numMorphTargets;d<f;d++)k.deleteBuffer(c.__webglMorphTargetsBuffers[d])}if(c.numMorphNormals){d=
  387. 0;for(f=c.numMorphNormals;d<f;d++)k.deleteBuffer(c.__webglMorphNormalsBuffers[d])}if(c.__webglCustomAttributesList){d=void 0;for(d in c.__webglCustomAttributesList)k.deleteBuffer(c.__webglCustomAttributesList[d].buffer)}S.info.memory.geometries--}else if(a instanceof THREE.Ribbon){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);S.info.memory.geometries--}else if(a instanceof THREE.Line){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);
  388. S.info.memory.geometries--}else if(a instanceof THREE.ParticleSystem){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);S.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;k.deleteTexture(a.__webglTexture);S.info.memory.textures--}};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){k.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){k.deleteFramebuffer(a.__webglFramebuffer[b]);
  389. k.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{k.deleteFramebuffer(a.__webglFramebuffer);k.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,f=false,a=0;for(c=ra.length;a<c;a++){d=ra[a];if(d.program===b){d.usedTimes--;d.usedTimes===0&&(f=true);break}}if(f){f=[];a=0;for(c=ra.length;a<c;a++){d=ra[a];d.program!==b&&f.push(d)}ra=f;k.deleteProgram(b);S.info.memory.programs--}}};this.updateShadowMap=function(a,b){O=null;
  390. P=X=Ta=kb=La=-1;Ha=true;ua=Ja=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=k.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=k.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=k.createBuffer();if(a.hasColors&&!a.__webglColorBuffer)a.__webglColorBuffer=k.createBuffer();if(a.hasPositions){k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,
  391. a.positionArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.position);k.vertexAttribPointer(b.attributes.position,3,k.FLOAT,false,0,0)}if(a.hasNormals){k.bindBuffer(k.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,f,e,g,h,i,j,l,n,m,p,o=a.count*3;for(p=0;p<o;p=p+9){m=a.normalArray;d=m[p];f=m[p+1];e=m[p+2];g=m[p+3];i=m[p+4];l=m[p+5];h=m[p+6];j=m[p+7];n=m[p+8];d=(d+g+h)/3;f=(f+i+j)/3;e=(e+l+n)/3;m[p]=d;m[p+1]=f;m[p+2]=e;m[p+3]=d;m[p+4]=f;m[p+5]=e;m[p+6]=d;m[p+
  392. 7]=f;m[p+8]=e}}k.bufferData(k.ARRAY_BUFFER,a.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.normal);k.vertexAttribPointer(b.attributes.normal,3,k.FLOAT,false,0,0)}if(a.hasUvs&&c.map){k.bindBuffer(k.ARRAY_BUFFER,a.__webglUvBuffer);k.bufferData(k.ARRAY_BUFFER,a.uvArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.uv);k.vertexAttribPointer(b.attributes.uv,2,k.FLOAT,false,0,0)}if(a.hasColors&&c.vertexColors!==THREE.NoColors){k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer);
  393. k.bufferData(k.ARRAY_BUFFER,a.colorArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.color);k.vertexAttribPointer(b.attributes.color,3,k.FLOAT,false,0,0)}k.drawArrays(k.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,f,e){if(d.visible!==false){c=u(a,b,c,d,e);a=c.attributes;b=false;d=f.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==X){X=d;b=true}if(e instanceof THREE.Mesh){e=f.offsets;e.length>1&&(b=true);d=0;for(c=e.length;d<c;++d){var g=e[d].index;if(b){var h=f.attributes.position,
  394. i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.position,i,k.FLOAT,false,0,g*i*4);h=f.attributes.normal;if(a.normal>=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.normal,i,k.FLOAT,false,0,g*i*4)}h=f.attributes.uv;if(a.uv>=0&&h)if(h.buffer){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.uv,i,k.FLOAT,false,0,g*i*4);k.enableVertexAttribArray(a.uv)}else k.disableVertexAttribArray(a.uv);i=f.attributes.color;if(a.color>=
  395. 0&&i){var j=i.itemSize;k.bindBuffer(k.ARRAY_BUFFER,i.buffer);k.vertexAttribPointer(a.color,j,k.FLOAT,false,0,g*j*4)}h=f.attributes.tangent;if(a.tangent>=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.tangent,i,k.FLOAT,false,0,g*i*4)}k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,f.attributes.index.buffer)}k.drawElements(k.TRIANGLES,e[d].count,k.UNSIGNED_SHORT,e[d].start*2);S.info.render.calls++;S.info.render.vertices=S.info.render.vertices+e[d].count;S.info.render.faces=S.info.render.faces+
  396. e[d].count/3}}else if(e instanceof THREE.ParticleSystem&&b){h=f.attributes.position;i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.position,i,k.FLOAT,false,0,0);i=f.attributes.color;if(a.color>=0&&i){j=i.itemSize;k.bindBuffer(k.ARRAY_BUFFER,i.buffer);k.vertexAttribPointer(a.color,j,k.FLOAT,false,0,0)}k.drawArrays(k.POINTS,0,h.numItems/3);S.info.render.calls++;S.info.render.points=S.info.render.points+h.numItems/3}}};this.renderBuffer=function(a,b,c,d,f,e){if(d.visible!==
  397. false){var g,h,c=u(a,b,c,d,e),b=c.attributes,a=false,c=f.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==X){X=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){k.bindBuffer(k.ARRAY_BUFFER,f.__webglVertexBuffer);k.vertexAttribPointer(b.position,3,k.FLOAT,false,0,0)}}else if(e.morphTargetBase){c=d.program.attributes;if(e.morphTargetBase!==-1){k.bindBuffer(k.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[e.morphTargetBase]);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}else if(c.position>=0){k.bindBuffer(k.ARRAY_BUFFER,
  398. f.__webglVertexBuffer);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}if(e.morphTargetForcedOrder.length){var i=0;h=e.morphTargetForcedOrder;for(g=e.morphTargetInfluences;i<d.numSupportedMorphTargets&&i<h.length;){k.bindBuffer(k.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[h[i]]);k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);if(d.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,f.__webglMorphNormalsBuffers[h[i]]);k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0)}e.__webglMorphTargetInfluences[i]=
  399. g[h[i]];i++}}else{h=[];g=e.morphTargetInfluences;var l,m=g.length;for(l=0;l<m;l++){i=g[l];i>0&&h.push([l,i])}if(h.length>d.numSupportedMorphTargets){h.sort(j);h.length=d.numSupportedMorphTargets}else h.length>d.numSupportedMorphNormals?h.sort(j):h.length===0&&h.push([0,0]);for(i=0;i<d.numSupportedMorphTargets;){if(h[i]){l=h[i][0];k.bindBuffer(k.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[l]);k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);if(d.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,
  400. f.__webglMorphNormalsBuffers[l]);k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0)}e.__webglMorphTargetInfluences[i]=g[l]}else{k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);d.morphNormals&&k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0);e.__webglMorphTargetInfluences[i]=0}i++}}d.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(d.program.uniforms.morphTargetInfluences,e.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){g=0;for(h=
  401. f.__webglCustomAttributesList.length;g<h;g++){c=f.__webglCustomAttributesList[g];if(b[c.buffer.belongsToAttribute]>=0){k.bindBuffer(k.ARRAY_BUFFER,c.buffer);k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,false,0,0)}}}if(b.color>=0){k.bindBuffer(k.ARRAY_BUFFER,f.__webglColorBuffer);k.vertexAttribPointer(b.color,3,k.FLOAT,false,0,0)}if(b.normal>=0){k.bindBuffer(k.ARRAY_BUFFER,f.__webglNormalBuffer);k.vertexAttribPointer(b.normal,3,k.FLOAT,false,0,0)}if(b.tangent>=0){k.bindBuffer(k.ARRAY_BUFFER,
  402. f.__webglTangentBuffer);k.vertexAttribPointer(b.tangent,4,k.FLOAT,false,0,0)}if(b.uv>=0)if(f.__webglUVBuffer){k.bindBuffer(k.ARRAY_BUFFER,f.__webglUVBuffer);k.vertexAttribPointer(b.uv,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv)}else k.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(f.__webglUV2Buffer){k.bindBuffer(k.ARRAY_BUFFER,f.__webglUV2Buffer);k.vertexAttribPointer(b.uv2,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv2)}else k.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinIndex>=
  403. 0&&b.skinWeight>=0){k.bindBuffer(k.ARRAY_BUFFER,f.__webglSkinIndicesBuffer);k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,false,0,0);k.bindBuffer(k.ARRAY_BUFFER,f.__webglSkinWeightsBuffer);k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,false,0,0)}}if(e instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==fb){k.lineWidth(d);fb=d}a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer);k.drawElements(k.LINES,f.__webglLineCount,k.UNSIGNED_SHORT,0)}else{a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,
  404. f.__webglFaceBuffer);k.drawElements(k.TRIANGLES,f.__webglFaceCount,k.UNSIGNED_SHORT,0)}S.info.render.calls++;S.info.render.vertices=S.info.render.vertices+f.__webglFaceCount;S.info.render.faces=S.info.render.faces+f.__webglFaceCount/3}else if(e instanceof THREE.Line){e=e.type===THREE.LineStrip?k.LINE_STRIP:k.LINES;d=d.linewidth;if(d!==fb){k.lineWidth(d);fb=d}k.drawArrays(e,0,f.__webglLineCount);S.info.render.calls++}else if(e instanceof THREE.ParticleSystem){k.drawArrays(k.POINTS,0,f.__webglParticleCount);
  405. S.info.render.calls++;S.info.render.points=S.info.render.points+f.__webglParticleCount}else if(e instanceof THREE.Ribbon){k.drawArrays(k.TRIANGLE_STRIP,0,f.__webglVertexCount);S.info.render.calls++}}};this.render=function(a,b,c,d){if(b instanceof THREE.Camera===false)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var f,e,g,h,j=a.__lights,p=a.fog;P=-1;Ha=true;this.autoUpdateScene&&a.updateMatrixWorld();b.parent===void 0&&b.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=
  406. new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);xa.multiply(b.projectionMatrix,b.matrixWorldInverse);hb.setFromMatrix(xa);this.autoUpdateObjects&&this.initWebGLObjects(a);l(this.renderPluginsPre,a,b);S.info.render.calls=0;S.info.render.vertices=0;S.info.render.faces=0;S.info.render.points=
  407. 0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);h=a.__webglObjects;d=0;for(f=h.length;d<f;d++){e=h[d];g=e.object;e.render=false;if(g.visible&&(!(g instanceof THREE.Mesh||g instanceof THREE.ParticleSystem)||!g.frustumCulled||hb.contains(g))){s(g,b);var o=e,q=o.object,r=o.buffer,t=void 0,t=t=void 0,t=q.material;if(t instanceof THREE.MeshFaceMaterial){t=r.materialIndex;if(t>=0){t=q.geometry.materials[t];if(t.transparent){o.transparent=
  408. t;o.opaque=null}else{o.opaque=t;o.transparent=null}}}else if(t)if(t.transparent){o.transparent=t;o.opaque=null}else{o.opaque=t;o.transparent=null}e.render=true;if(this.sortObjects===true)if(g.renderDepth!==null)e.z=g.renderDepth;else{ab.copy(g.matrixWorld.getPosition());xa.multiplyVector3(ab);e.z=ab.z}}}this.sortObjects&&h.sort(i);h=a.__webglObjectsImmediate;d=0;for(f=h.length;d<f;d++){e=h[d];g=e.object;if(g.visible){s(g,b);g=e.object.material;if(g.transparent){e.transparent=g;e.opaque=null}else{e.opaque=
  409. g;e.transparent=null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);A(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);n(a.__webglObjects,false,"",b,j,p,true,d);m(a.__webglObjectsImmediate,"",b,j,p,false,d)}else{this.setBlending(THREE.NormalBlending);n(a.__webglObjects,true,"opaque",b,j,p,false);m(a.__webglObjectsImmediate,"opaque",b,j,p,false);n(a.__webglObjects,
  410. false,"transparent",b,j,p,true);m(a.__webglObjectsImmediate,"transparent",b,j,p,true)}l(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture);k.generateMipmap(k.TEXTURE_CUBE_MAP);k.bindTexture(k.TEXTURE_CUBE_MAP,null)}else{k.bindTexture(k.TEXTURE_2D,c.__webglTexture);k.generateMipmap(k.TEXTURE_2D);k.bindTexture(k.TEXTURE_2D,null)}this.setDepthTest(true);
  411. this.setDepthWrite(true)}};this.renderImmediateObject=function(a,b,c,d,f){var e=u(a,b,c,d,f);X=-1;S.setMaterialFaces(d);f.immediateRenderCallback?f.immediateRenderCallback(e,k,hb):f.render(function(a){S.renderBufferImmediate(a,e,d)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var i=a.__objectsAdded[0],j=a,l=void 0,m=void 0,n=void 0;if(!i.__webglInit){i.__webglInit=true;
  412. i._modelViewMatrix=new THREE.Matrix4;i._normalMatrix=new THREE.Matrix3;if(i instanceof THREE.Mesh){m=i.geometry;if(m instanceof THREE.Geometry){if(m.geometryGroups===void 0){var s=m,u=void 0,v=void 0,w=void 0,z=void 0,A=void 0,D=void 0,B=void 0,E={},J=s.morphTargets.length,F=s.morphNormals.length;s.geometryGroups={};u=0;for(v=s.faces.length;u<v;u++){w=s.faces[u];z=w.materialIndex;D=z!==void 0?z:-1;E[D]===void 0&&(E[D]={hash:D,counter:0});B=E[D].hash+"_"+E[D].counter;s.geometryGroups[B]===void 0&&
  413. (s.geometryGroups[B]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:J,numMorphNormals:F});A=w instanceof THREE.Face3?3:4;if(s.geometryGroups[B].vertices+A>65535){E[D].counter=E[D].counter+1;B=E[D].hash+"_"+E[D].counter;s.geometryGroups[B]===void 0&&(s.geometryGroups[B]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:J,numMorphNormals:F})}w instanceof THREE.Face3?s.geometryGroups[B].faces3.push(u):s.geometryGroups[B].faces4.push(u);s.geometryGroups[B].vertices=s.geometryGroups[B].vertices+
  414. A}s.geometryGroupsList=[];var H=void 0;for(H in s.geometryGroups){s.geometryGroups[H].id=$++;s.geometryGroupsList.push(s.geometryGroups[H])}}for(l in m.geometryGroups){n=m.geometryGroups[l];if(!n.__webglVertexBuffer){var O=n;O.__webglVertexBuffer=k.createBuffer();O.__webglNormalBuffer=k.createBuffer();O.__webglTangentBuffer=k.createBuffer();O.__webglColorBuffer=k.createBuffer();O.__webglUVBuffer=k.createBuffer();O.__webglUV2Buffer=k.createBuffer();O.__webglSkinIndicesBuffer=k.createBuffer();O.__webglSkinWeightsBuffer=
  415. k.createBuffer();O.__webglFaceBuffer=k.createBuffer();O.__webglLineBuffer=k.createBuffer();var I=void 0,K=void 0;if(O.numMorphTargets){O.__webglMorphTargetsBuffers=[];I=0;for(K=O.numMorphTargets;I<K;I++)O.__webglMorphTargetsBuffers.push(k.createBuffer())}if(O.numMorphNormals){O.__webglMorphNormalsBuffers=[];I=0;for(K=O.numMorphNormals;I<K;I++)O.__webglMorphNormalsBuffers.push(k.createBuffer())}S.info.memory.geometries++;var P=n,L=i,M=L.geometry,N=P.faces3,Q=P.faces4,X=N.length*3+Q.length*4,ca=N.length*
  416. 1+Q.length*2,ga=N.length*3+Q.length*4,T=c(L,P),Z=f(T),ea=d(T),fa=T.vertexColors?T.vertexColors:false;P.__vertexArray=new Float32Array(X*3);if(ea)P.__normalArray=new Float32Array(X*3);if(M.hasTangents)P.__tangentArray=new Float32Array(X*4);if(fa)P.__colorArray=new Float32Array(X*3);if(Z){if(M.faceUvs.length>0||M.faceVertexUvs.length>0)P.__uvArray=new Float32Array(X*2);if(M.faceUvs.length>1||M.faceVertexUvs.length>1)P.__uv2Array=new Float32Array(X*2)}if(L.geometry.skinWeights.length&&L.geometry.skinIndices.length){P.__skinIndexArray=
  417. new Float32Array(X*4);P.__skinWeightArray=new Float32Array(X*4)}P.__faceArray=new Uint16Array(ca*3);P.__lineArray=new Uint16Array(ga*2);var ia=void 0,ra=void 0;if(P.numMorphTargets){P.__morphTargetsArrays=[];ia=0;for(ra=P.numMorphTargets;ia<ra;ia++)P.__morphTargetsArrays.push(new Float32Array(X*3))}if(P.numMorphNormals){P.__morphNormalsArrays=[];ia=0;for(ra=P.numMorphNormals;ia<ra;ia++)P.__morphNormalsArrays.push(new Float32Array(X*3))}P.__webglFaceCount=ca*3;P.__webglLineCount=ga*2;if(T.attributes){if(P.__webglCustomAttributesList===
  418. void 0)P.__webglCustomAttributesList=[];var Ja=void 0;for(Ja in T.attributes){var oa=T.attributes[Ja],ua={},xa;for(xa in oa)ua[xa]=oa[xa];if(!ua.__webglInitialized||ua.createUniqueBuffers){ua.__webglInitialized=true;var wa=1;ua.type==="v2"?wa=2:ua.type==="v3"?wa=3:ua.type==="v4"?wa=4:ua.type==="c"&&(wa=3);ua.size=wa;ua.array=new Float32Array(X*wa);ua.buffer=k.createBuffer();ua.buffer.belongsToAttribute=Ja;oa.needsUpdate=true;ua.__original=oa}P.__webglCustomAttributesList.push(ua)}}P.__inittedArrays=
  419. true;m.verticesNeedUpdate=true;m.morphTargetsNeedUpdate=true;m.elementsNeedUpdate=true;m.uvsNeedUpdate=true;m.normalsNeedUpdate=true;m.tangentsNeedUpdate=true;m.colorsNeedUpdate=true}}}else m instanceof THREE.BufferGeometry&&e(m)}else if(i instanceof THREE.Ribbon){m=i.geometry;if(!m.__webglVertexBuffer){var La=m;La.__webglVertexBuffer=k.createBuffer();La.__webglColorBuffer=k.createBuffer();S.info.memory.geometries++;var za=m,Ga=za.vertices.length;za.__vertexArray=new Float32Array(Ga*3);za.__colorArray=
  420. new Float32Array(Ga*3);za.__webglVertexCount=Ga;m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}}else if(i instanceof THREE.Line){m=i.geometry;if(!m.__webglVertexBuffer){var Ma=m;Ma.__webglVertexBuffer=k.createBuffer();Ma.__webglColorBuffer=k.createBuffer();S.info.memory.geometries++;var Ha=m,Wa=i,Xa=Ha.vertices.length;Ha.__vertexArray=new Float32Array(Xa*3);Ha.__colorArray=new Float32Array(Xa*3);Ha.__webglLineCount=Xa;b(Ha,Wa);m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}}else if(i instanceof
  421. THREE.ParticleSystem){m=i.geometry;if(!m.__webglVertexBuffer)if(m instanceof THREE.Geometry){var Ya=m;Ya.__webglVertexBuffer=k.createBuffer();Ya.__webglColorBuffer=k.createBuffer();S.info.memory.geometries++;var Ta=m,kb=i,bb=Ta.vertices.length;Ta.__vertexArray=new Float32Array(bb*3);Ta.__colorArray=new Float32Array(bb*3);Ta.__sortArray=[];Ta.__webglParticleCount=bb;b(Ta,kb);m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}else m instanceof THREE.BufferGeometry&&e(m)}}if(!i.__webglActive){if(i instanceof
  422. THREE.Mesh){m=i.geometry;if(m instanceof THREE.BufferGeometry)q(j.__webglObjects,m,i);else for(l in m.geometryGroups){n=m.geometryGroups[l];q(j.__webglObjects,n,i)}}else if(i instanceof THREE.Ribbon||i instanceof THREE.Line||i instanceof THREE.ParticleSystem){m=i.geometry;q(j.__webglObjects,m,i)}else i instanceof THREE.ImmediateRenderObject||i.immediateRenderCallback?j.__webglObjectsImmediate.push({object:i,opaque:null,transparent:null}):i instanceof THREE.Sprite?j.__webglSprites.push(i):i instanceof
  423. THREE.LensFlare&&j.__webglFlares.push(i);i.__webglActive=true}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var nb=a.__objectsRemoved[0],ab=a;nb instanceof THREE.Mesh||nb instanceof THREE.ParticleSystem||nb instanceof THREE.Ribbon||nb instanceof THREE.Line?r(ab.__webglObjects,nb):nb instanceof THREE.Sprite?t(ab.__webglSprites,nb):nb instanceof THREE.LensFlare?t(ab.__webglFlares,nb):(nb instanceof THREE.ImmediateRenderObject||nb.immediateRenderCallback)&&r(ab.__webglObjectsImmediate,
  424. nb);nb.__webglActive=false;a.__objectsRemoved.splice(0,1)}for(var hb=0,sb=a.__webglObjects.length;hb<sb;hb++){var vb=a.__webglObjects[hb].object,ha=vb.geometry,ib=void 0,gb=void 0,cb=void 0;if(vb instanceof THREE.Mesh)if(ha instanceof THREE.BufferGeometry){(ha.verticesNeedUpdate||ha.elementsNeedUpdate||ha.uvsNeedUpdate||ha.normalsNeedUpdate||ha.colorsNeedUpdate||ha.tangentsNeedUpdate)&&h(ha,k.DYNAMIC_DRAW,!ha.dynamic);ha.verticesNeedUpdate=false;ha.elementsNeedUpdate=false;ha.uvsNeedUpdate=false;
  425. ha.normalsNeedUpdate=false;ha.colorsNeedUpdate=false;ha.tangentsNeedUpdate=false}else{for(var rb=0,xb=ha.geometryGroupsList.length;rb<xb;rb++){ib=ha.geometryGroupsList[rb];cb=c(vb,ib);gb=cb.attributes&&o(cb);if(ha.verticesNeedUpdate||ha.morphTargetsNeedUpdate||ha.elementsNeedUpdate||ha.uvsNeedUpdate||ha.normalsNeedUpdate||ha.colorsNeedUpdate||ha.tangentsNeedUpdate||gb){var na=ib,yb=vb,ob=k.DYNAMIC_DRAW,zb=!ha.dynamic,fb=cb;if(na.__inittedArrays){var Rb=d(fb),Qb=fb.vertexColors?fb.vertexColors:false,
  426. jc=f(fb),Hc=Rb===THREE.SmoothShading,C=void 0,Y=void 0,Yb=void 0,R=void 0,mc=void 0,Zb=void 0,wb=void 0,Ic=void 0,Sb=void 0,nc=void 0,oc=void 0,U=void 0,V=void 0,W=void 0,ma=void 0,Ab=void 0,Bb=void 0,Cb=void 0,tc=void 0,Db=void 0,Eb=void 0,Fb=void 0,uc=void 0,Gb=void 0,Hb=void 0,Ib=void 0,vc=void 0,Jb=void 0,Kb=void 0,Lb=void 0,wc=void 0,Mb=void 0,Nb=void 0,Ob=void 0,xc=void 0,sa=void 0,kc=void 0,$b=void 0,pc=void 0,qc=void 0,Pa=void 0,sc=void 0,Na=void 0,Oa=void 0,ac=void 0,Tb=void 0,Fa=0,Ka=0,
  427. Ub=0,Vb=0,pb=0,Ua=0,va=0,$a=0,Ia=0,da=0,ja=0,y=0,ta=void 0,Qa=na.__vertexArray,yc=na.__uvArray,zc=na.__uv2Array,qb=na.__normalArray,Aa=na.__tangentArray,Ra=na.__colorArray,Ba=na.__skinIndexArray,Ca=na.__skinWeightArray,Wc=na.__morphTargetsArrays,Xc=na.__morphNormalsArrays,Yc=na.__webglCustomAttributesList,x=void 0,Pb=na.__faceArray,jb=na.__lineArray,db=yb.geometry,Fc=db.elementsNeedUpdate,cd=db.uvsNeedUpdate,Tc=db.normalsNeedUpdate,Uc=db.tangentsNeedUpdate,jd=db.colorsNeedUpdate,kd=db.morphTargetsNeedUpdate,
  428. gc=db.vertices,pa=na.faces3,qa=na.faces4,Va=db.faces,Zc=db.faceVertexUvs[0],$c=db.faceVertexUvs[1],hc=db.skinIndices,bc=db.skinWeights,cc=db.morphTargets,Jc=db.morphNormals;if(db.verticesNeedUpdate){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];U=gc[R.a];V=gc[R.b];W=gc[R.c];Qa[Ka]=U.x;Qa[Ka+1]=U.y;Qa[Ka+2]=U.z;Qa[Ka+3]=V.x;Qa[Ka+4]=V.y;Qa[Ka+5]=V.z;Qa[Ka+6]=W.x;Qa[Ka+7]=W.y;Qa[Ka+8]=W.z;Ka=Ka+9}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];U=gc[R.a];V=gc[R.b];W=gc[R.c];ma=gc[R.d];Qa[Ka]=U.x;Qa[Ka+1]=U.y;Qa[Ka+
  429. 2]=U.z;Qa[Ka+3]=V.x;Qa[Ka+4]=V.y;Qa[Ka+5]=V.z;Qa[Ka+6]=W.x;Qa[Ka+7]=W.y;Qa[Ka+8]=W.z;Qa[Ka+9]=ma.x;Qa[Ka+10]=ma.y;Qa[Ka+11]=ma.z;Ka=Ka+12}k.bindBuffer(k.ARRAY_BUFFER,na.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Qa,ob)}if(kd){Pa=0;for(sc=cc.length;Pa<sc;Pa++){C=ja=0;for(Y=pa.length;C<Y;C++){ac=pa[C];R=Va[ac];U=cc[Pa].vertices[R.a];V=cc[Pa].vertices[R.b];W=cc[Pa].vertices[R.c];Na=Wc[Pa];Na[ja]=U.x;Na[ja+1]=U.y;Na[ja+2]=U.z;Na[ja+3]=V.x;Na[ja+4]=V.y;Na[ja+5]=V.z;Na[ja+6]=W.x;Na[ja+7]=W.y;Na[ja+
  430. 8]=W.z;if(fb.morphNormals){if(Hc){Tb=Jc[Pa].vertexNormals[ac];Db=Tb.a;Eb=Tb.b;Fb=Tb.c}else Fb=Eb=Db=Jc[Pa].faceNormals[ac];Oa=Xc[Pa];Oa[ja]=Db.x;Oa[ja+1]=Db.y;Oa[ja+2]=Db.z;Oa[ja+3]=Eb.x;Oa[ja+4]=Eb.y;Oa[ja+5]=Eb.z;Oa[ja+6]=Fb.x;Oa[ja+7]=Fb.y;Oa[ja+8]=Fb.z}ja=ja+9}C=0;for(Y=qa.length;C<Y;C++){ac=qa[C];R=Va[ac];U=cc[Pa].vertices[R.a];V=cc[Pa].vertices[R.b];W=cc[Pa].vertices[R.c];ma=cc[Pa].vertices[R.d];Na=Wc[Pa];Na[ja]=U.x;Na[ja+1]=U.y;Na[ja+2]=U.z;Na[ja+3]=V.x;Na[ja+4]=V.y;Na[ja+5]=V.z;Na[ja+6]=W.x;
  431. Na[ja+7]=W.y;Na[ja+8]=W.z;Na[ja+9]=ma.x;Na[ja+10]=ma.y;Na[ja+11]=ma.z;if(fb.morphNormals){if(Hc){Tb=Jc[Pa].vertexNormals[ac];Db=Tb.a;Eb=Tb.b;Fb=Tb.c;uc=Tb.d}else uc=Fb=Eb=Db=Jc[Pa].faceNormals[ac];Oa=Xc[Pa];Oa[ja]=Db.x;Oa[ja+1]=Db.y;Oa[ja+2]=Db.z;Oa[ja+3]=Eb.x;Oa[ja+4]=Eb.y;Oa[ja+5]=Eb.z;Oa[ja+6]=Fb.x;Oa[ja+7]=Fb.y;Oa[ja+8]=Fb.z;Oa[ja+9]=uc.x;Oa[ja+10]=uc.y;Oa[ja+11]=uc.z}ja=ja+12}k.bindBuffer(k.ARRAY_BUFFER,na.__webglMorphTargetsBuffers[Pa]);k.bufferData(k.ARRAY_BUFFER,Wc[Pa],ob);if(fb.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,
  432. na.__webglMorphNormalsBuffers[Pa]);k.bufferData(k.ARRAY_BUFFER,Xc[Pa],ob)}}}if(bc.length){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];Jb=bc[R.a];Kb=bc[R.b];Lb=bc[R.c];Ca[da]=Jb.x;Ca[da+1]=Jb.y;Ca[da+2]=Jb.z;Ca[da+3]=Jb.w;Ca[da+4]=Kb.x;Ca[da+5]=Kb.y;Ca[da+6]=Kb.z;Ca[da+7]=Kb.w;Ca[da+8]=Lb.x;Ca[da+9]=Lb.y;Ca[da+10]=Lb.z;Ca[da+11]=Lb.w;Mb=hc[R.a];Nb=hc[R.b];Ob=hc[R.c];Ba[da]=Mb.x;Ba[da+1]=Mb.y;Ba[da+2]=Mb.z;Ba[da+3]=Mb.w;Ba[da+4]=Nb.x;Ba[da+5]=Nb.y;Ba[da+6]=Nb.z;Ba[da+7]=Nb.w;Ba[da+8]=Ob.x;Ba[da+9]=Ob.y;
  433. Ba[da+10]=Ob.z;Ba[da+11]=Ob.w;da=da+12}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];Jb=bc[R.a];Kb=bc[R.b];Lb=bc[R.c];wc=bc[R.d];Ca[da]=Jb.x;Ca[da+1]=Jb.y;Ca[da+2]=Jb.z;Ca[da+3]=Jb.w;Ca[da+4]=Kb.x;Ca[da+5]=Kb.y;Ca[da+6]=Kb.z;Ca[da+7]=Kb.w;Ca[da+8]=Lb.x;Ca[da+9]=Lb.y;Ca[da+10]=Lb.z;Ca[da+11]=Lb.w;Ca[da+12]=wc.x;Ca[da+13]=wc.y;Ca[da+14]=wc.z;Ca[da+15]=wc.w;Mb=hc[R.a];Nb=hc[R.b];Ob=hc[R.c];xc=hc[R.d];Ba[da]=Mb.x;Ba[da+1]=Mb.y;Ba[da+2]=Mb.z;Ba[da+3]=Mb.w;Ba[da+4]=Nb.x;Ba[da+5]=Nb.y;Ba[da+6]=Nb.z;Ba[da+7]=
  434. Nb.w;Ba[da+8]=Ob.x;Ba[da+9]=Ob.y;Ba[da+10]=Ob.z;Ba[da+11]=Ob.w;Ba[da+12]=xc.x;Ba[da+13]=xc.y;Ba[da+14]=xc.z;Ba[da+15]=xc.w;da=da+16}if(da>0){k.bindBuffer(k.ARRAY_BUFFER,na.__webglSkinIndicesBuffer);k.bufferData(k.ARRAY_BUFFER,Ba,ob);k.bindBuffer(k.ARRAY_BUFFER,na.__webglSkinWeightsBuffer);k.bufferData(k.ARRAY_BUFFER,Ca,ob)}}if(jd&&Qb){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];wb=R.vertexColors;Ic=R.color;if(wb.length===3&&Qb===THREE.VertexColors){Gb=wb[0];Hb=wb[1];Ib=wb[2]}else Ib=Hb=Gb=Ic;Ra[Ia]=
  435. Gb.r;Ra[Ia+1]=Gb.g;Ra[Ia+2]=Gb.b;Ra[Ia+3]=Hb.r;Ra[Ia+4]=Hb.g;Ra[Ia+5]=Hb.b;Ra[Ia+6]=Ib.r;Ra[Ia+7]=Ib.g;Ra[Ia+8]=Ib.b;Ia=Ia+9}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];wb=R.vertexColors;Ic=R.color;if(wb.length===4&&Qb===THREE.VertexColors){Gb=wb[0];Hb=wb[1];Ib=wb[2];vc=wb[3]}else vc=Ib=Hb=Gb=Ic;Ra[Ia]=Gb.r;Ra[Ia+1]=Gb.g;Ra[Ia+2]=Gb.b;Ra[Ia+3]=Hb.r;Ra[Ia+4]=Hb.g;Ra[Ia+5]=Hb.b;Ra[Ia+6]=Ib.r;Ra[Ia+7]=Ib.g;Ra[Ia+8]=Ib.b;Ra[Ia+9]=vc.r;Ra[Ia+10]=vc.g;Ra[Ia+11]=vc.b;Ia=Ia+12}if(Ia>0){k.bindBuffer(k.ARRAY_BUFFER,
  436. na.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Ra,ob)}}if(Uc&&db.hasTangents){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];Sb=R.vertexTangents;Ab=Sb[0];Bb=Sb[1];Cb=Sb[2];Aa[va]=Ab.x;Aa[va+1]=Ab.y;Aa[va+2]=Ab.z;Aa[va+3]=Ab.w;Aa[va+4]=Bb.x;Aa[va+5]=Bb.y;Aa[va+6]=Bb.z;Aa[va+7]=Bb.w;Aa[va+8]=Cb.x;Aa[va+9]=Cb.y;Aa[va+10]=Cb.z;Aa[va+11]=Cb.w;va=va+12}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];Sb=R.vertexTangents;Ab=Sb[0];Bb=Sb[1];Cb=Sb[2];tc=Sb[3];Aa[va]=Ab.x;Aa[va+1]=Ab.y;Aa[va+2]=Ab.z;Aa[va+3]=Ab.w;Aa[va+
  437. 4]=Bb.x;Aa[va+5]=Bb.y;Aa[va+6]=Bb.z;Aa[va+7]=Bb.w;Aa[va+8]=Cb.x;Aa[va+9]=Cb.y;Aa[va+10]=Cb.z;Aa[va+11]=Cb.w;Aa[va+12]=tc.x;Aa[va+13]=tc.y;Aa[va+14]=tc.z;Aa[va+15]=tc.w;va=va+16}k.bindBuffer(k.ARRAY_BUFFER,na.__webglTangentBuffer);k.bufferData(k.ARRAY_BUFFER,Aa,ob)}if(Tc&&Rb){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];mc=R.vertexNormals;Zb=R.normal;if(mc.length===3&&Hc)for(sa=0;sa<3;sa++){$b=mc[sa];qb[Ua]=$b.x;qb[Ua+1]=$b.y;qb[Ua+2]=$b.z;Ua=Ua+3}else for(sa=0;sa<3;sa++){qb[Ua]=Zb.x;qb[Ua+1]=Zb.y;qb[Ua+
  438. 2]=Zb.z;Ua=Ua+3}}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];mc=R.vertexNormals;Zb=R.normal;if(mc.length===4&&Hc)for(sa=0;sa<4;sa++){$b=mc[sa];qb[Ua]=$b.x;qb[Ua+1]=$b.y;qb[Ua+2]=$b.z;Ua=Ua+3}else for(sa=0;sa<4;sa++){qb[Ua]=Zb.x;qb[Ua+1]=Zb.y;qb[Ua+2]=Zb.z;Ua=Ua+3}}k.bindBuffer(k.ARRAY_BUFFER,na.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,qb,ob)}if(cd&&Zc&&jc){C=0;for(Y=pa.length;C<Y;C++){Yb=pa[C];nc=Zc[Yb];if(nc!==void 0)for(sa=0;sa<3;sa++){pc=nc[sa];yc[Ub]=pc.u;yc[Ub+1]=pc.v;Ub=Ub+2}}C=0;for(Y=
  439. qa.length;C<Y;C++){Yb=qa[C];nc=Zc[Yb];if(nc!==void 0)for(sa=0;sa<4;sa++){pc=nc[sa];yc[Ub]=pc.u;yc[Ub+1]=pc.v;Ub=Ub+2}}if(Ub>0){k.bindBuffer(k.ARRAY_BUFFER,na.__webglUVBuffer);k.bufferData(k.ARRAY_BUFFER,yc,ob)}}if(cd&&$c&&jc){C=0;for(Y=pa.length;C<Y;C++){Yb=pa[C];oc=$c[Yb];if(oc!==void 0)for(sa=0;sa<3;sa++){qc=oc[sa];zc[Vb]=qc.u;zc[Vb+1]=qc.v;Vb=Vb+2}}C=0;for(Y=qa.length;C<Y;C++){Yb=qa[C];oc=$c[Yb];if(oc!==void 0)for(sa=0;sa<4;sa++){qc=oc[sa];zc[Vb]=qc.u;zc[Vb+1]=qc.v;Vb=Vb+2}}if(Vb>0){k.bindBuffer(k.ARRAY_BUFFER,
  440. na.__webglUV2Buffer);k.bufferData(k.ARRAY_BUFFER,zc,ob)}}if(Fc){C=0;for(Y=pa.length;C<Y;C++){Pb[pb]=Fa;Pb[pb+1]=Fa+1;Pb[pb+2]=Fa+2;pb=pb+3;jb[$a]=Fa;jb[$a+1]=Fa+1;jb[$a+2]=Fa;jb[$a+3]=Fa+2;jb[$a+4]=Fa+1;jb[$a+5]=Fa+2;$a=$a+6;Fa=Fa+3}C=0;for(Y=qa.length;C<Y;C++){Pb[pb]=Fa;Pb[pb+1]=Fa+1;Pb[pb+2]=Fa+3;Pb[pb+3]=Fa+1;Pb[pb+4]=Fa+2;Pb[pb+5]=Fa+3;pb=pb+6;jb[$a]=Fa;jb[$a+1]=Fa+1;jb[$a+2]=Fa;jb[$a+3]=Fa+3;jb[$a+4]=Fa+1;jb[$a+5]=Fa+2;jb[$a+6]=Fa+2;jb[$a+7]=Fa+3;$a=$a+8;Fa=Fa+4}k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,
  441. na.__webglFaceBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Pb,ob);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,na.__webglLineBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,jb,ob)}if(Yc){sa=0;for(kc=Yc.length;sa<kc;sa++){x=Yc[sa];if(x.__original.needsUpdate){y=0;if(x.size===1)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];x.array[y]=x.value[R.a];x.array[y+1]=x.value[R.b];x.array[y+2]=x.value[R.c];y=y+3}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];x.array[y]=x.value[R.a];x.array[y+
  442. 1]=x.value[R.b];x.array[y+2]=x.value[R.c];x.array[y+3]=x.value[R.d];y=y+4}}else{if(x.boundTo==="faces"){C=0;for(Y=pa.length;C<Y;C++){ta=x.value[pa[C]];x.array[y]=ta;x.array[y+1]=ta;x.array[y+2]=ta;y=y+3}C=0;for(Y=qa.length;C<Y;C++){ta=x.value[qa[C]];x.array[y]=ta;x.array[y+1]=ta;x.array[y+2]=ta;x.array[y+3]=ta;y=y+4}}}else if(x.size===2)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];x.array[y]=U.x;x.array[y+1]=U.y;
  443. x.array[y+2]=V.x;x.array[y+3]=V.y;x.array[y+4]=W.x;x.array[y+5]=W.y;y=y+6}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];ma=x.value[R.d];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=V.x;x.array[y+3]=V.y;x.array[y+4]=W.x;x.array[y+5]=W.y;x.array[y+6]=ma.x;x.array[y+7]=ma.y;y=y+8}}else{if(x.boundTo==="faces"){C=0;for(Y=pa.length;C<Y;C++){W=V=U=ta=x.value[pa[C]];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=V.x;x.array[y+3]=V.y;x.array[y+4]=W.x;x.array[y+5]=W.y;
  444. y=y+6}C=0;for(Y=qa.length;C<Y;C++){ma=W=V=U=ta=x.value[qa[C]];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=V.x;x.array[y+3]=V.y;x.array[y+4]=W.x;x.array[y+5]=W.y;x.array[y+6]=ma.x;x.array[y+7]=ma.y;y=y+8}}}else if(x.size===3){var ba;ba=x.type==="c"?["r","g","b"]:["x","y","z"];if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];x.array[y]=U[ba[0]];x.array[y+1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+
  445. 4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+8]=W[ba[2]];y=y+9}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];ma=x.value[R.d];x.array[y]=U[ba[0]];x.array[y+1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+8]=W[ba[2]];x.array[y+9]=ma[ba[0]];x.array[y+10]=ma[ba[1]];x.array[y+11]=ma[ba[2]];y=y+12}}else if(x.boundTo===
  446. "faces"){C=0;for(Y=pa.length;C<Y;C++){W=V=U=ta=x.value[pa[C]];x.array[y]=U[ba[0]];x.array[y+1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+8]=W[ba[2]];y=y+9}C=0;for(Y=qa.length;C<Y;C++){ma=W=V=U=ta=x.value[qa[C]];x.array[y]=U[ba[0]];x.array[y+1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+
  447. 8]=W[ba[2]];x.array[y+9]=ma[ba[0]];x.array[y+10]=ma[ba[1]];x.array[y+11]=ma[ba[2]];y=y+12}}else if(x.boundTo==="faceVertices"){C=0;for(Y=pa.length;C<Y;C++){ta=x.value[pa[C]];U=ta[0];V=ta[1];W=ta[2];x.array[y]=U[ba[0]];x.array[y+1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+8]=W[ba[2]];y=y+9}C=0;for(Y=qa.length;C<Y;C++){ta=x.value[qa[C]];U=ta[0];V=ta[1];W=ta[2];ma=ta[3];x.array[y]=U[ba[0]];x.array[y+
  448. 1]=U[ba[1]];x.array[y+2]=U[ba[2]];x.array[y+3]=V[ba[0]];x.array[y+4]=V[ba[1]];x.array[y+5]=V[ba[2]];x.array[y+6]=W[ba[0]];x.array[y+7]=W[ba[1]];x.array[y+8]=W[ba[2]];x.array[y+9]=ma[ba[0]];x.array[y+10]=ma[ba[1]];x.array[y+11]=ma[ba[2]];y=y+12}}}else if(x.size===4)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(Y=pa.length;C<Y;C++){R=Va[pa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+
  449. 6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+10]=W.z;x.array[y+11]=W.w;y=y+12}C=0;for(Y=qa.length;C<Y;C++){R=Va[qa[C]];U=x.value[R.a];V=x.value[R.b];W=x.value[R.c];ma=x.value[R.d];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+10]=W.z;x.array[y+11]=W.w;x.array[y+12]=ma.x;x.array[y+13]=ma.y;x.array[y+14]=ma.z;x.array[y+15]=ma.w;y=y+16}}else if(x.boundTo===
  450. "faces"){C=0;for(Y=pa.length;C<Y;C++){W=V=U=ta=x.value[pa[C]];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+10]=W.z;x.array[y+11]=W.w;y=y+12}C=0;for(Y=qa.length;C<Y;C++){ma=W=V=U=ta=x.value[qa[C]];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+
  451. 10]=W.z;x.array[y+11]=W.w;x.array[y+12]=ma.x;x.array[y+13]=ma.y;x.array[y+14]=ma.z;x.array[y+15]=ma.w;y=y+16}}else if(x.boundTo==="faceVertices"){C=0;for(Y=pa.length;C<Y;C++){ta=x.value[pa[C]];U=ta[0];V=ta[1];W=ta[2];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+10]=W.z;x.array[y+11]=W.w;y=y+12}C=0;for(Y=qa.length;C<Y;C++){ta=x.value[qa[C]];U=ta[0];V=ta[1];W=ta[2];ma=
  452. ta[3];x.array[y]=U.x;x.array[y+1]=U.y;x.array[y+2]=U.z;x.array[y+3]=U.w;x.array[y+4]=V.x;x.array[y+5]=V.y;x.array[y+6]=V.z;x.array[y+7]=V.w;x.array[y+8]=W.x;x.array[y+9]=W.y;x.array[y+10]=W.z;x.array[y+11]=W.w;x.array[y+12]=ma.x;x.array[y+13]=ma.y;x.array[y+14]=ma.z;x.array[y+15]=ma.w;y=y+16}}k.bindBuffer(k.ARRAY_BUFFER,x.buffer);k.bufferData(k.ARRAY_BUFFER,x.array,ob)}}}if(zb){delete na.__inittedArrays;delete na.__colorArray;delete na.__normalArray;delete na.__tangentArray;delete na.__uvArray;delete na.__uv2Array;
  453. delete na.__faceArray;delete na.__vertexArray;delete na.__lineArray;delete na.__skinIndexArray;delete na.__skinWeightArray}}}}ha.verticesNeedUpdate=false;ha.morphTargetsNeedUpdate=false;ha.elementsNeedUpdate=false;ha.uvsNeedUpdate=false;ha.normalsNeedUpdate=false;ha.colorsNeedUpdate=false;ha.tangentsNeedUpdate=false;cb.attributes&&p(cb)}else if(vb instanceof THREE.Ribbon){if(ha.verticesNeedUpdate||ha.colorsNeedUpdate){var dc=ha,dd=k.DYNAMIC_DRAW,Ac=void 0,Bc=void 0,Kc=void 0,ec=void 0,Lc=void 0,ed=
  454. dc.vertices,fd=dc.colors,ld=ed.length,md=fd.length,Mc=dc.__vertexArray,Nc=dc.__colorArray,nd=dc.colorsNeedUpdate;if(dc.verticesNeedUpdate){for(Ac=0;Ac<ld;Ac++){Kc=ed[Ac];ec=Ac*3;Mc[ec]=Kc.x;Mc[ec+1]=Kc.y;Mc[ec+2]=Kc.z}k.bindBuffer(k.ARRAY_BUFFER,dc.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Mc,dd)}if(nd){for(Bc=0;Bc<md;Bc++){Lc=fd[Bc];ec=Bc*3;Nc[ec]=Lc.r;Nc[ec+1]=Lc.g;Nc[ec+2]=Lc.b}k.bindBuffer(k.ARRAY_BUFFER,dc.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Nc,dd)}}ha.verticesNeedUpdate=false;
  455. ha.colorsNeedUpdate=false}else if(vb instanceof THREE.Line){cb=c(vb,ib);gb=cb.attributes&&o(cb);if(ha.verticesNeedUpdate||ha.colorsNeedUpdate||gb){var Wb=ha,ad=k.DYNAMIC_DRAW,Cc=void 0,Dc=void 0,Oc=void 0,Da=void 0,Pc=void 0,gd=Wb.vertices,hd=Wb.colors,od=gd.length,pd=hd.length,Qc=Wb.__vertexArray,Rc=Wb.__colorArray,qd=Wb.colorsNeedUpdate,bd=Wb.__webglCustomAttributesList,Sc=void 0,id=void 0,Sa=void 0,rc=void 0,eb=void 0,ya=void 0;if(Wb.verticesNeedUpdate){for(Cc=0;Cc<od;Cc++){Oc=gd[Cc];Da=Cc*3;Qc[Da]=
  456. Oc.x;Qc[Da+1]=Oc.y;Qc[Da+2]=Oc.z}k.bindBuffer(k.ARRAY_BUFFER,Wb.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Qc,ad)}if(qd){for(Dc=0;Dc<pd;Dc++){Pc=hd[Dc];Da=Dc*3;Rc[Da]=Pc.r;Rc[Da+1]=Pc.g;Rc[Da+2]=Pc.b}k.bindBuffer(k.ARRAY_BUFFER,Wb.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Rc,ad)}if(bd){Sc=0;for(id=bd.length;Sc<id;Sc++){ya=bd[Sc];if(ya.needsUpdate&&(ya.boundTo===void 0||ya.boundTo==="vertices")){Da=0;rc=ya.value.length;if(ya.size===1)for(Sa=0;Sa<rc;Sa++)ya.array[Sa]=ya.value[Sa];else if(ya.size===
  457. 2)for(Sa=0;Sa<rc;Sa++){eb=ya.value[Sa];ya.array[Da]=eb.x;ya.array[Da+1]=eb.y;Da=Da+2}else if(ya.size===3)if(ya.type==="c")for(Sa=0;Sa<rc;Sa++){eb=ya.value[Sa];ya.array[Da]=eb.r;ya.array[Da+1]=eb.g;ya.array[Da+2]=eb.b;Da=Da+3}else for(Sa=0;Sa<rc;Sa++){eb=ya.value[Sa];ya.array[Da]=eb.x;ya.array[Da+1]=eb.y;ya.array[Da+2]=eb.z;Da=Da+3}else if(ya.size===4)for(Sa=0;Sa<rc;Sa++){eb=ya.value[Sa];ya.array[Da]=eb.x;ya.array[Da+1]=eb.y;ya.array[Da+2]=eb.z;ya.array[Da+3]=eb.w;Da=Da+4}k.bindBuffer(k.ARRAY_BUFFER,
  458. ya.buffer);k.bufferData(k.ARRAY_BUFFER,ya.array,ad)}}}}ha.verticesNeedUpdate=false;ha.colorsNeedUpdate=false;cb.attributes&&p(cb)}else if(vb instanceof THREE.ParticleSystem)if(ha instanceof THREE.BufferGeometry){(ha.verticesNeedUpdate||ha.colorsNeedUpdate)&&h(ha,k.DYNAMIC_DRAW,!ha.dynamic);ha.verticesNeedUpdate=false;ha.colorsNeedUpdate=false}else{cb=c(vb,ib);gb=cb.attributes&&o(cb);(ha.verticesNeedUpdate||ha.colorsNeedUpdate||vb.sortParticles||gb)&&g(ha,k.DYNAMIC_DRAW,vb);ha.verticesNeedUpdate=false;
  459. ha.colorsNeedUpdate=false;cb.attributes&&p(cb)}}};this.initMaterial=function(a,b,c,d){var f,e,g,h,i,j,l,m,n;a instanceof THREE.MeshDepthMaterial?n="depth":a instanceof THREE.MeshNormalMaterial?n="normal":a instanceof THREE.MeshBasicMaterial?n="basic":a instanceof THREE.MeshLambertMaterial?n="lambert":a instanceof THREE.MeshPhongMaterial?n="phong":a instanceof THREE.LineBasicMaterial?n="basic":a instanceof THREE.ParticleBasicMaterial&&(n="particle_basic");if(n){var p=THREE.ShaderLib[n];a.uniforms=
  460. THREE.UniformsUtils.clone(p.uniforms);a.vertexShader=p.vertexShader;a.fragmentShader=p.fragmentShader}var o,q,r;f=o=q=r=p=0;for(e=b.length;f<e;f++){g=b[f];if(!g.onlyShadow){g instanceof THREE.DirectionalLight&&o++;g instanceof THREE.PointLight&&q++;g instanceof THREE.SpotLight&&r++;g instanceof THREE.HemisphereLight&&p++}}if(q+r+o+p<=fa)f=o;else{f=Math.ceil(fa*o/(q+o));r=q=fa-f;p=f}e=q;g=r;h=p;p=o=0;for(r=b.length;p<r;p++){q=b[p];if(q.castShadow){q instanceof THREE.SpotLight&&o++;q instanceof THREE.DirectionalLight&&
  461. !q.shadowCascade&&o++}}m=o;if(kc&&d&&d.useVertexTexture)l=1024;else{b=k.getParameter(k.MAX_VERTEX_UNIFORM_VECTORS);b=Math.floor((b-20)/4);if(d!==void 0&&d instanceof THREE.SkinnedMesh){b=Math.min(d.bones.length,b);b<d.bones.length&&console.warn("WebGLRenderer: too many bones - "+d.bones.length+", this GPU supports just "+b+" (try OpenGL instead of ANGLE)")}l=b}var s;a:{q=a.fragmentShader;r=a.vertexShader;p=a.uniforms;b=a.attributes;o=a.defines;var c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,
  462. bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,specularMap:!!a.specularMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:l,useVertexTexture:kc&&d&&d.useVertexTexture,boneTextureWidth:d&&d.boneTextureWidth,boneTextureHeight:d&&d.boneTextureHeight,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:f,maxPointLights:e,maxSpotLights:g,maxHemiLights:h,
  463. maxShadows:m,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:a.side===THREE.DoubleSide,flipSided:a.side===THREE.BackSide},t,u,v,d=[];if(n)d.push(n);else{d.push(q);d.push(r)}for(u in o){d.push(u);d.push(o[u])}for(t in c){d.push(t);d.push(c[t])}n=d.join();t=0;for(u=ra.length;t<u;t++){d=ra[t];if(d.code===
  464. n){d.usedTimes++;s=d.program;break a}}t=[];for(v in o){u=o[v];if(u!==false){u="#define "+v+" "+u;t.push(u)}}u=t.join("\n");v=k.createProgram();t=["precision "+L+" float;",u,jc?"#define VERTEX_TEXTURES":"",S.gammaInput?"#define GAMMA_INPUT":"",S.gammaOutput?"#define GAMMA_OUTPUT":"",S.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+
  465. c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.useVertexTexture?"#define BONE_TEXTURE":"",c.boneTextureWidth?"#define N_BONE_PIXEL_X "+c.boneTextureWidth.toFixed(1):"",c.boneTextureHeight?
  466. "#define N_BONE_PIXEL_Y "+c.boneTextureHeight.toFixed(1):"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?
  467. "#define USE_SIZEATTENUATION":"","uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
  468. u=["precision "+L+" float;",c.bumpMap||c.normalMap?"#extension GL_OES_standard_derivatives : enable":"",u,"#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",S.gammaInput?"#define GAMMA_INPUT":"",S.gammaOutput?"#define GAMMA_OUTPUT":"",S.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",
  469. c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?
  470. "#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");u=D("fragment",u+q);t=D("vertex",t+r);k.attachShader(v,t);k.attachShader(v,u);k.linkProgram(v);k.getProgramParameter(v,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(v,
  471. k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");k.deleteShader(u);k.deleteShader(t);v.uniforms={};v.attributes={};var w;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","modelMatrix","cameraPosition","morphTargetInfluences"];c.useVertexTexture?t.push("boneTexture"):t.push("boneGlobalMatrices");for(w in p)t.push(w);w=t;t=0;for(u=w.length;t<u;t++){d=w[t];v.uniforms[d]=k.getUniformLocation(v,d)}t=["position","normal","uv","uv2","tangent","color","skinIndex","skinWeight"];for(w=
  472. 0;w<c.maxMorphTargets;w++)t.push("morphTarget"+w);for(w=0;w<c.maxMorphNormals;w++)t.push("morphNormal"+w);for(s in b)t.push(s);s=t;w=0;for(t=s.length;w<t;w++){u=s[w];v.attributes[u]=k.getAttribLocation(v,u)}v.id=wa++;ra.push({program:v,code:n,usedTimes:1});S.info.memory.programs=ra.length;s=v}a.program=s;s=a.program.attributes;s.position>=0&&k.enableVertexAttribArray(s.position);s.color>=0&&k.enableVertexAttribArray(s.color);s.normal>=0&&k.enableVertexAttribArray(s.normal);s.tangent>=0&&k.enableVertexAttribArray(s.tangent);
  473. if(a.skinning&&s.skinIndex>=0&&s.skinWeight>=0){k.enableVertexAttribArray(s.skinIndex);k.enableVertexAttribArray(s.skinWeight)}if(a.attributes)for(j in a.attributes)s[j]!==void 0&&s[j]>=0&&k.enableVertexAttribArray(s[j]);if(a.morphTargets){a.numSupportedMorphTargets=0;v="morphTarget";for(j=0;j<this.maxMorphTargets;j++){w=v+j;if(s[w]>=0){k.enableVertexAttribArray(s[w]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;v="morphNormal";for(j=0;j<this.maxMorphNormals;j++){w=
  474. v+j;if(s[w]>=0){k.enableVertexAttribArray(s[w]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(i in a.uniforms)a.uniformsList.push([a.uniforms[i],i])};this.setFaceCulling=function(a,b){if(a){!b||b==="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW);a==="back"?k.cullFace(k.BACK):a==="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK);k.enable(k.CULL_FACE)}else k.disable(k.CULL_FACE)};this.setMaterialFaces=function(a){var b=a.side===THREE.DoubleSide,a=a.side===THREE.BackSide;if(Ja!==b){b?k.disable(k.CULL_FACE):
  475. k.enable(k.CULL_FACE);Ja=b}if(ua!==a){a?k.frontFace(k.CW):k.frontFace(k.CCW);ua=a}};this.setDepthTest=function(a){if(kb!==a){a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST);kb=a}};this.setDepthWrite=function(a){if(Ta!==a){k.depthMask(a);Ta=a}};this.setBlending=function(a,b,c,d){if(a!==La){if(a===THREE.NoBlending)k.disable(k.BLEND);else if(a===THREE.AdditiveBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE)}else if(a===THREE.SubtractiveBlending){k.enable(k.BLEND);
  476. k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR)}else if(a===THREE.CustomBlending)k.enable(k.BLEND);else{k.enable(k.BLEND);k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD);k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}La=a}if(a===THREE.CustomBlending){if(b!==Wa){k.blendEquation(H(b));Wa=b}if(c!==oa||d!==Xa){k.blendFunc(H(c),H(d));
  477. oa=c;Xa=d}}else Xa=oa=Wa=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=k.createTexture();S.info.memory.textures++}k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,a.flipY);k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,f=H(a.format),e=H(a.type);F(k.TEXTURE_2D,a,d);if(a instanceof THREE.CompressedTexture)for(var e=
  478. a.mipmaps,g=0,h=e.length;g<h;g++){c=e[g];k.compressedTexImage2D(k.TEXTURE_2D,g,f,c.width,c.height,0,c.data)}else a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,f,c.width,c.height,0,f,e,c.data):k.texImage2D(k.TEXTURE_2D,0,f,f,e,a.image);a.generateMipmaps&&d&&k.generateMipmap(k.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;
  479. if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=k.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=H(a.format),f=H(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);F(k.TEXTURE_CUBE_MAP,a,c);for(var e=0;e<6;e++){a.__webglFramebuffer[e]=k.createFramebuffer();a.__webglRenderbuffer[e]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+
  480. e,0,d,a.width,a.height,0,d,f,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+e;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[e]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);B(a.__webglRenderbuffer[e],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=k.createFramebuffer();a.__webglRenderbuffer=k.createRenderbuffer();k.bindTexture(k.TEXTURE_2D,a.__webglTexture);F(k.TEXTURE_2D,a,c);k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,f,null);d=
  481. k.TEXTURE_2D;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,d,a.__webglTexture,0);B(a.__webglRenderbuffer,a);c&&k.generateMipmap(k.TEXTURE_2D)}b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;f=d=0}else{b=null;c=za;a=xb;d=bb;f=Ma}if(b!==ga){k.bindFramebuffer(k.FRAMEBUFFER,
  482. b);k.viewport(d,f,c,a);ga=b}Ga=c;sb=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
  483. THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.anisotropy=c.anisotropy!==void 0?c.anisotropy:1;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:
  484. THREE.RGBAFormat;this.type=c.type!==void 0?c.type:THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true};
  485. THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.anisotropy=this.anisotropy;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;a.generateMipmaps=this.generateMipmaps;return a};
  486. THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=true};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
  487. THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsLength=0;this.material=this.color=null;this.uvs=[[]];this.z=null};
  488. THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsLength=0;this.material=this.color=null;this.uvs=[[]];this.z=null};
  489. THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=this.object=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
  490. THREE.ColorUtils={adjustHSV:function(a,b,c,d){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.Math.clamp(f.h+b,0,1);f.s=THREE.Math.clamp(f.s+c,0,1);f.v=THREE.Math.clamp(f.v+d,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,f=a.b,e=Math.max(Math.max(c,d),f),g=Math.min(Math.min(c,d),f);if(g===e)g=c=0;else{var h=e-g,g=h/e,c=(c===e?(d-f)/h:d===e?2+(f-c)/h:4+(c-d)/h)/6;c<0&&(c=c+1);c>1&&(c=c-1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=e;return b}};
  491. THREE.ColorUtils.__hsv={h:0,s:0,v:0};
  492. THREE.GeometryUtils={merge:function(a,b){for(var c,d,f=a.vertices.length,e=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=e.vertices,i=a.faces,j=e.faces,l=a.faceVertexUvs[0],n=e.faceVertexUvs[0],m={},q=0;q<a.materials.length;q++)m[a.materials[q].id]=q;if(b instanceof THREE.Mesh){b.matrixAutoUpdate&&b.updateMatrix();c=b.matrix;d=new THREE.Matrix4;d.extractRotation(c,b.scale)}for(var q=0,o=h.length;q<o;q++){var p=h[q].clone();c&&c.multiplyVector3(p);g.push(p)}q=0;for(o=j.length;q<o;q++){var g=
  493. j[q],r,t,u=g.vertexNormals,v=g.vertexColors;g instanceof THREE.Face3?r=new THREE.Face3(g.a+f,g.b+f,g.c+f):g instanceof THREE.Face4&&(r=new THREE.Face4(g.a+f,g.b+f,g.c+f,g.d+f));r.normal.copy(g.normal);d&&d.multiplyVector3(r.normal);h=0;for(p=u.length;h<p;h++){t=u[h].clone();d&&d.multiplyVector3(t);r.vertexNormals.push(t)}r.color.copy(g.color);h=0;for(p=v.length;h<p;h++){t=v[h];r.vertexColors.push(t.clone())}if(g.materialIndex!==void 0){h=e.materials[g.materialIndex];p=h.id;v=m[p];if(v===void 0){v=
  494. a.materials.length;m[p]=v;a.materials.push(h)}r.materialIndex=v}r.centroid.copy(g.centroid);c&&c.multiplyVector3(r.centroid);i.push(r)}q=0;for(o=n.length;q<o;q++){c=n[q];d=[];h=0;for(p=c.length;h<p;h++)d.push(new THREE.UV(c[h].u,c[h].v));l.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,f=a.faces,e=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();a=0;for(c=d.length;a<c;a++)b.vertices.push(d[a].clone());a=0;for(c=f.length;a<c;a++)b.faces.push(f[a].clone());a=0;
  495. for(c=e.length;a<c;a++){for(var d=e[a],f=[],g=0,h=d.length;g<h;g++)f.push(new THREE.UV(d[g].u,d[g].v));b.faceVertexUvs[0].push(f)}return b},randomPointInTriangle:function(a,b,c){var d,f,e,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();f=THREE.GeometryUtils.random();if(d+f>1){d=1-d;f=1-f}e=1-d-f;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(f);g.addSelf(h);h.copy(c);h.multiplyScalar(e);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,f,e;if(a instanceof
  496. THREE.Face3){d=b.vertices[a.a];f=b.vertices[a.b];e=b.vertices[a.c];return THREE.GeometryUtils.randomPointInTriangle(d,f,e)}if(a instanceof THREE.Face4){d=b.vertices[a.a];f=b.vertices[a.b];e=b.vertices[a.c];var b=b.vertices[a.d],g;if(c)if(a._area1&&a._area2){c=a._area1;g=a._area2}else{c=THREE.GeometryUtils.triangleArea(d,f,b);g=THREE.GeometryUtils.triangleArea(f,e,b);a._area1=c;a._area2=g}else{c=THREE.GeometryUtils.triangleArea(d,f,b);g=THREE.GeometryUtils.triangleArea(f,e,b)}return THREE.GeometryUtils.random()*
  497. (c+g)<c?THREE.GeometryUtils.randomPointInTriangle(d,f,b):THREE.GeometryUtils.randomPointInTriangle(f,e,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var f=c+Math.floor((d-c)/2);return j[f]>a?b(c,f-1):j[f]<a?b(f+1,d):f}return b(0,j.length-1)}var d,f,e=a.faces,g=a.vertices,h=e.length,i=0,j=[],l,n,m,q;for(f=0;f<h;f++){d=e[f];if(d instanceof THREE.Face3){l=g[d.a];n=g[d.b];m=g[d.c];d._area=THREE.GeometryUtils.triangleArea(l,n,m)}else if(d instanceof THREE.Face4){l=
  498. g[d.a];n=g[d.b];m=g[d.c];q=g[d.d];d._area1=THREE.GeometryUtils.triangleArea(l,n,q);d._area2=THREE.GeometryUtils.triangleArea(n,m,q);d._area=d._area1+d._area2}i=i+d._area;j[f]=i}d=[];for(f=0;f<b;f++){g=THREE.GeometryUtils.random()*i;g=c(g);d[f]=THREE.GeometryUtils.randomPointInFace(e[g],a,true)}return d},triangleArea:function(a,b,c){var d,f=THREE.GeometryUtils.__v1;f.sub(a,b);d=f.length();f.sub(a,c);a=f.length();f.sub(b,c);c=f.length();b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();
  499. var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).makeTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],f=0,e=d.length;f<e;f++){if(d[f].u!==1)d[f].u=d[f].u-Math.floor(d[f].u);if(d[f].v!==1)d[f].v=d[f].v-Math.floor(d[f].v)}},triangulateQuads:function(a){var b,c,d,f,e=[],g=[],h=[];b=0;for(c=a.faceUvs.length;b<c;b++)g[b]=[];b=0;for(c=a.faceVertexUvs.length;b<
  500. c;b++)h[b]=[];b=0;for(c=a.faces.length;b<c;b++){d=a.faces[b];if(d instanceof THREE.Face4){f=d.a;var i=d.b,j=d.c,l=d.d,n=new THREE.Face3,m=new THREE.Face3;n.color.copy(d.color);m.color.copy(d.color);n.materialIndex=d.materialIndex;m.materialIndex=d.materialIndex;n.a=f;n.b=i;n.c=l;m.a=i;m.b=j;m.c=l;if(d.vertexColors.length===4){n.vertexColors[0]=d.vertexColors[0].clone();n.vertexColors[1]=d.vertexColors[1].clone();n.vertexColors[2]=d.vertexColors[3].clone();m.vertexColors[0]=d.vertexColors[1].clone();
  501. m.vertexColors[1]=d.vertexColors[2].clone();m.vertexColors[2]=d.vertexColors[3].clone()}e.push(n,m);d=0;for(f=a.faceVertexUvs.length;d<f;d++)if(a.faceVertexUvs[d].length){n=a.faceVertexUvs[d][b];i=n[1];j=n[2];l=n[3];n=[n[0].clone(),i.clone(),l.clone()];i=[i.clone(),j.clone(),l.clone()];h[d].push(n,i)}d=0;for(f=a.faceUvs.length;d<f;d++)if(a.faceUvs[d].length){i=a.faceUvs[d][b];g[d].push(i,i)}}else{e.push(d);d=0;for(f=a.faceUvs.length;d<f;d++)g[d].push(a.faceUvs[d][b]);d=0;for(f=a.faceVertexUvs.length;d<
  502. f;d++)h[d].push(a.faceVertexUvs[d][b])}}a.faces=e;a.faceUvs=g;a.faceVertexUvs=h;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=[],c=0,d=a.faces.length;c<d;c++){var f=b.length,e=a.faces[c];if(e instanceof THREE.Face4){var g=e.a,h=e.b,i=e.c,g=a.vertices[g],h=a.vertices[h],i=a.vertices[i],j=a.vertices[e.d];b.push(g.clone());b.push(h.clone());b.push(i.clone());b.push(j.clone());e.a=f;e.b=f+1;e.c=f+2;e.d=f+3}else{g=
  503. e.a;h=e.b;i=e.c;g=a.vertices[g];h=a.vertices[h];i=a.vertices[i];b.push(g.clone());b.push(h.clone());b.push(i.clone());e.a=f;e.b=f+1;e.c=f+2}}a.vertices=b;delete a.__tmpVertices},tessellate:function(a,b){var c,d,f,e,g,h,i,j,l,n,m,q,o,p,r,t,u,v,s,z=[],w=[];c=0;for(d=a.faceVertexUvs.length;c<d;c++)w[c]=[];c=0;for(d=a.faces.length;c<d;c++){f=a.faces[c];if(f instanceof THREE.Face3){e=f.a;g=f.b;h=f.c;j=a.vertices[e];l=a.vertices[g];n=a.vertices[h];q=j.distanceTo(l);o=l.distanceTo(n);m=j.distanceTo(n);if(q>
  504. b||o>b||m>b){i=a.vertices.length;v=f.clone();s=f.clone();if(q>=o&&q>=m){j=j.clone();j.lerpSelf(l,0.5);v.a=e;v.b=i;v.c=h;s.a=i;s.b=g;s.c=h;if(f.vertexNormals.length===3){e=f.vertexNormals[0].clone();e.lerpSelf(f.vertexNormals[1],0.5);v.vertexNormals[1].copy(e);s.vertexNormals[0].copy(e)}if(f.vertexColors.length===3){e=f.vertexColors[0].clone();e.lerpSelf(f.vertexColors[1],0.5);v.vertexColors[1].copy(e);s.vertexColors[0].copy(e)}f=0}else if(o>=q&&o>=m){j=l.clone();j.lerpSelf(n,0.5);v.a=e;v.b=g;v.c=
  505. i;s.a=i;s.b=h;s.c=e;if(f.vertexNormals.length===3){e=f.vertexNormals[1].clone();e.lerpSelf(f.vertexNormals[2],0.5);v.vertexNormals[2].copy(e);s.vertexNormals[0].copy(e);s.vertexNormals[1].copy(f.vertexNormals[2]);s.vertexNormals[2].copy(f.vertexNormals[0])}if(f.vertexColors.length===3){e=f.vertexColors[1].clone();e.lerpSelf(f.vertexColors[2],0.5);v.vertexColors[2].copy(e);s.vertexColors[0].copy(e);s.vertexColors[1].copy(f.vertexColors[2]);s.vertexColors[2].copy(f.vertexColors[0])}f=1}else{j=j.clone();
  506. j.lerpSelf(n,0.5);v.a=e;v.b=g;v.c=i;s.a=i;s.b=g;s.c=h;if(f.vertexNormals.length===3){e=f.vertexNormals[0].clone();e.lerpSelf(f.vertexNormals[2],0.5);v.vertexNormals[2].copy(e);s.vertexNormals[0].copy(e)}if(f.vertexColors.length===3){e=f.vertexColors[0].clone();e.lerpSelf(f.vertexColors[2],0.5);v.vertexColors[2].copy(e);s.vertexColors[0].copy(e)}f=2}z.push(v,s);a.vertices.push(j);e=0;for(g=a.faceVertexUvs.length;e<g;e++)if(a.faceVertexUvs[e].length){j=a.faceVertexUvs[e][c];s=j[0];h=j[1];v=j[2];if(f===
  507. 0){l=s.clone();l.lerpSelf(h,0.5);j=[s.clone(),l.clone(),v.clone()];h=[l.clone(),h.clone(),v.clone()]}else if(f===1){l=h.clone();l.lerpSelf(v,0.5);j=[s.clone(),h.clone(),l.clone()];h=[l.clone(),v.clone(),s.clone()]}else{l=s.clone();l.lerpSelf(v,0.5);j=[s.clone(),h.clone(),l.clone()];h=[l.clone(),h.clone(),v.clone()]}w[e].push(j,h)}}else{z.push(f);e=0;for(g=a.faceVertexUvs.length;e<g;e++)w[e].push(a.faceVertexUvs[e][c])}}else{e=f.a;g=f.b;h=f.c;i=f.d;j=a.vertices[e];l=a.vertices[g];n=a.vertices[h];m=
  508. a.vertices[i];q=j.distanceTo(l);o=l.distanceTo(n);p=n.distanceTo(m);r=j.distanceTo(m);if(q>b||o>b||p>b||r>b){t=a.vertices.length;u=a.vertices.length+1;v=f.clone();s=f.clone();if(q>=o&&q>=p&&q>=r||p>=o&&p>=q&&p>=r){q=j.clone();q.lerpSelf(l,0.5);l=n.clone();l.lerpSelf(m,0.5);v.a=e;v.b=t;v.c=u;v.d=i;s.a=t;s.b=g;s.c=h;s.d=u;if(f.vertexNormals.length===4){e=f.vertexNormals[0].clone();e.lerpSelf(f.vertexNormals[1],0.5);g=f.vertexNormals[2].clone();g.lerpSelf(f.vertexNormals[3],0.5);v.vertexNormals[1].copy(e);
  509. v.vertexNormals[2].copy(g);s.vertexNormals[0].copy(e);s.vertexNormals[3].copy(g)}if(f.vertexColors.length===4){e=f.vertexColors[0].clone();e.lerpSelf(f.vertexColors[1],0.5);g=f.vertexColors[2].clone();g.lerpSelf(f.vertexColors[3],0.5);v.vertexColors[1].copy(e);v.vertexColors[2].copy(g);s.vertexColors[0].copy(e);s.vertexColors[3].copy(g)}f=0}else{q=l.clone();q.lerpSelf(n,0.5);l=m.clone();l.lerpSelf(j,0.5);v.a=e;v.b=g;v.c=t;v.d=u;s.a=u;s.b=t;s.c=h;s.d=i;if(f.vertexNormals.length===4){e=f.vertexNormals[1].clone();
  510. e.lerpSelf(f.vertexNormals[2],0.5);g=f.vertexNormals[3].clone();g.lerpSelf(f.vertexNormals[0],0.5);v.vertexNormals[2].copy(e);v.vertexNormals[3].copy(g);s.vertexNormals[0].copy(g);s.vertexNormals[1].copy(e)}if(f.vertexColors.length===4){e=f.vertexColors[1].clone();e.lerpSelf(f.vertexColors[2],0.5);g=f.vertexColors[3].clone();g.lerpSelf(f.vertexColors[0],0.5);v.vertexColors[2].copy(e);v.vertexColors[3].copy(g);s.vertexColors[0].copy(g);s.vertexColors[1].copy(e)}f=1}z.push(v,s);a.vertices.push(q,l);
  511. e=0;for(g=a.faceVertexUvs.length;e<g;e++)if(a.faceVertexUvs[e].length){j=a.faceVertexUvs[e][c];s=j[0];h=j[1];v=j[2];j=j[3];if(f===0){l=s.clone();l.lerpSelf(h,0.5);n=v.clone();n.lerpSelf(j,0.5);s=[s.clone(),l.clone(),n.clone(),j.clone()];h=[l.clone(),h.clone(),v.clone(),n.clone()]}else{l=h.clone();l.lerpSelf(v,0.5);n=j.clone();n.lerpSelf(s,0.5);s=[s.clone(),h.clone(),l.clone(),n.clone()];h=[n.clone(),l.clone(),v.clone(),j.clone()]}w[e].push(s,h)}}else{z.push(f);e=0;for(g=a.faceVertexUvs.length;e<g;e++)w[e].push(a.faceVertexUvs[e][c])}}}a.faces=
  512. z;a.faceVertexUvs=w}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
  513. THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c,d){var f=new Image,e=new THREE.Texture(f,b),b=new THREE.ImageLoader;b.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=true;c&&c(e)});b.addEventListener("error",function(a){d&&d(a.message)});b.crossOrigin=this.crossOrigin;b.load(a,f);return e},loadCompressedTexture:function(a,b,c,d){var f=new THREE.CompressedTexture;f.mapping=b;var e=new XMLHttpRequest;e.onload=function(){var a=THREE.ImageUtils.parseDDS(e.response,
  514. true);f.format=a.format;f.mipmaps=a.mipmaps;f.image.width=a.width;f.image.height=a.height;f.generateMipmaps=false;f.needsUpdate=true;c&&c(f)};e.onerror=d;e.open("GET",a,true);e.responseType="arraybuffer";e.send(null);return f},loadTextureCube:function(a,b,c,d){var f=[];f.loadCount=0;var e=new THREE.Texture;e.image=f;if(b!==void 0)e.mapping=b;e.flipY=false;for(var b=0,g=a.length;b<g;++b){var h=new Image;f[b]=h;h.onload=function(){f.loadCount=f.loadCount+1;if(f.loadCount===6){e.needsUpdate=true;c&&
  515. c()}};h.onerror=d;h.crossOrigin=this.crossOrigin;h.src=a[b]}return e},loadCompressedTextureCube:function(a,b,c,d){var f=[];f.loadCount=0;var e=new THREE.CompressedTexture;e.image=f;if(b!==void 0)e.mapping=b;e.flipY=false;e.generateMipmaps=false;for(var b=function(a,b){return function(){var d=THREE.ImageUtils.parseDDS(a.response,true);b.format=d.format;b.mipmaps=d.mipmaps;b.width=d.width;b.height=d.height;f.loadCount=f.loadCount+1;if(f.loadCount===6){e.format=d.format;e.needsUpdate=true;c&&c()}}},
  516. g=0,h=a.length;g<h;++g){var i={};f[g]=i;var j=new XMLHttpRequest;j.onload=b(j,i);j.onerror=d;j.open("GET",a[g],true);j.responseType="arraybuffer";j.send(null)}return e},parseDDS:function(a,b){function c(a){return a.charCodeAt(0)+(a.charCodeAt(1)<<8)+(a.charCodeAt(2)<<16)+(a.charCodeAt(3)<<24)}var d={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},f=c("DXT1"),e=c("DXT3"),g=c("DXT5"),h=new Int32Array(a,0,31);if(h[0]!==542327876){console.error("ImageUtils.parseDDS(): Invalid magic number in DDS header");
  517. return d}if(!h[20]&4){console.error("ImageUtils.parseDDS(): Unsupported format, must contain a FourCC code");return d}var i=h[21];switch(i){case f:f=8;d.format=THREE.RGB_S3TC_DXT1_Format;break;case e:f=16;d.format=THREE.RGBA_S3TC_DXT3_Format;break;case g:f=16;d.format=THREE.RGBA_S3TC_DXT5_Format;break;default:console.error("ImageUtils.parseDDS(): Unsupported FourCC code: ",String.fromCharCode(i&255,i>>8&255,i>>16&255,i>>24&255));return d}d.mipmapCount=1;if(h[2]&131072&&b!==false)d.mipmapCount=Math.max(1,
  518. h[7]);d.width=h[4];d.height=h[3];h=h[1]+4;e=d.width;g=d.height;for(i=0;i<d.mipmapCount;i++){var j=Math.max(4,e)/4*Math.max(4,g)/4*f,l={data:new Uint8Array(a,h,j),width:e,height:g};d.mipmaps.push(l);h=h+j;e=Math.max(e*0.5,1);g=Math.max(g*0.5,1)}return d},getNormalMap:function(a,b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,f=a.height,e=document.createElement("canvas");e.width=d;e.height=f;var g=e.getContext("2d");g.drawImage(a,0,0);
  519. for(var h=g.getImageData(0,0,d,f).data,i=g.createImageData(d,f),j=i.data,l=0;l<d;l++)for(var n=0;n<f;n++){var m=n-1<0?0:n-1,q=n+1>f-1?f-1:n+1,o=l-1<0?0:l-1,p=l+1>d-1?d-1:l+1,r=[],t=[0,0,h[(n*d+l)*4]/255*b];r.push([-1,0,h[(n*d+o)*4]/255*b]);r.push([-1,-1,h[(m*d+o)*4]/255*b]);r.push([0,-1,h[(m*d+l)*4]/255*b]);r.push([1,-1,h[(m*d+p)*4]/255*b]);r.push([1,0,h[(n*d+p)*4]/255*b]);r.push([1,1,h[(q*d+p)*4]/255*b]);r.push([0,1,h[(q*d+l)*4]/255*b]);r.push([-1,1,h[(q*d+o)*4]/255*b]);m=[];o=r.length;for(q=0;q<
  520. o;q++){var p=r[q],u=r[(q+1)%o],p=[p[0]-t[0],p[1]-t[1],p[2]-t[2]],u=[u[0]-t[0],u[1]-t[1],u[2]-t[2]];m.push(c([p[1]*u[2]-p[2]*u[1],p[2]*u[0]-p[0]*u[2],p[0]*u[1]-p[1]*u[0]]))}r=[0,0,0];for(q=0;q<m.length;q++){r[0]=r[0]+m[q][0];r[1]=r[1]+m[q][1];r[2]=r[2]+m[q][2]}r[0]=r[0]/m.length;r[1]=r[1]/m.length;r[2]=r[2]/m.length;t=(n*d+l)*4;j[t]=(r[0]+1)/2*255|0;j[t+1]=(r[1]+1)/2*255|0;j[t+2]=r[2]*255|0;j[t+3]=255}g.putImageData(i,0,0);return e},generateDataTexture:function(a,b,c){for(var d=a*b,f=new Uint8Array(3*
  521. d),e=Math.floor(c.r*255),g=Math.floor(c.g*255),c=Math.floor(c.b*255),h=0;h<d;h++){f[h*3]=e;f[h*3+1]=g;f[h*3+2]=c}a=new THREE.DataTexture(f,a,b,THREE.RGBFormat);a.needsUpdate=true;return a}};
  522. THREE.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new THREE.Object3D,d=0,f=b.length;d<f;d++)c.add(new THREE.Mesh(a,b[d]));return c},cloneObject:function(a){var b;if(a instanceof THREE.MorphAnimMesh){b=new THREE.MorphAnimMesh(a.geometry,a.material);b.duration=a.duration;b.mirroredLoop=a.mirroredLoop;b.time=a.time;b.lastKeyframe=a.lastKeyframe;b.currentKeyframe=a.currentKeyframe;b.direction=a.direction;b.directionBackwards=a.directionBackwards}else if(a instanceof THREE.SkinnedMesh)b=
  523. new THREE.SkinnedMesh(a.geometry,a.material,a.useVertexTexture);else if(a instanceof THREE.Mesh)b=new THREE.Mesh(a.geometry,a.material);else if(a instanceof THREE.Line)b=new THREE.Line(a.geometry,a.material,a.type);else if(a instanceof THREE.Ribbon)b=new THREE.Ribbon(a.geometry,a.material);else if(a instanceof THREE.ParticleSystem){b=new THREE.ParticleSystem(a.geometry,a.material);b.sortParticles=a.sortParticles}else if(a instanceof THREE.Particle)b=new THREE.Particle(a.material);else if(a instanceof
  524. THREE.Sprite){b=new THREE.Sprite({});b.color.copy(a.color);b.map=a.map;b.blending=a.blending;b.useScreenCoordinates=a.useScreenCoordinates;b.mergeWith3D=a.mergeWith3D;b.affectedByDistance=a.affectedByDistance;b.scaleByViewport=a.scaleByViewport;b.alignment=a.alignment;b.rotation3d.copy(a.rotation3d);b.rotation=a.rotation;b.opacity=a.opacity;b.uvOffset.copy(a.uvOffset);b.uvScale.copy(a.uvScale)}else a instanceof THREE.LOD?b=new THREE.LOD:a instanceof THREE.Object3D&&(b=new THREE.Object3D);b.name=a.name;
  525. b.parent=a.parent;b.up.copy(a.up);b.position.copy(a.position);b.rotation instanceof THREE.Vector3&&b.rotation.copy(a.rotation);b.eulerOrder=a.eulerOrder;b.scale.copy(a.scale);b.dynamic=a.dynamic;b.renderDepth=a.renderDepth;b.rotationAutoUpdate=a.rotationAutoUpdate;b.matrix.copy(a.matrix);b.matrixWorld.copy(a.matrixWorld);b.matrixRotationWorld.copy(a.matrixRotationWorld);b.matrixAutoUpdate=a.matrixAutoUpdate;b.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;b.quaternion.copy(a.quaternion);b.useQuaternion=
  526. a.useQuaternion;b.boundRadius=a.boundRadius;b.boundRadiusScale=a.boundRadiusScale;b.visible=a.visible;b.castShadow=a.castShadow;b.receiveShadow=a.receiveShadow;b.frustumCulled=a.frustumCulled;for(var c=0;c<a.children.length;c++){var d=THREE.SceneUtils.cloneObject(a.children[c]);b.children[c]=d;d.parent=b}if(a instanceof THREE.LOD)for(c=0;c<a.LODs.length;c++)b.LODs[c]={visibleAtDistance:a.LODs[c].visibleAtDistance,object3D:b.children[c]};return b},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);
  527. b.remove(a);c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};
  528. THREE.WebGLRenderer&&(THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
  529. normal:{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,
  530. 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:0.98},uReflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,
  531. 1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform vec2 uNormalScale;\nuniform bool useRefract;\nuniform float uRefractionRatio;\nuniform float uReflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
  532. THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse ) {\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( tDiffuse, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n#endif\n}\nif( enableAO ) {\n#ifdef GAMMA_INPUT\nvec4 aoColor = texture2D( tAO, vUv );\naoColor.xyz *= aoColor.xyz;\ngl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n#endif\n}\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\nvec3 finalNormal = tsb * normalTex;\n#ifdef FLIP_SIDED\nfinalNormal = -finalNormal;\n#endif\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointVector = lPosition.xyz + vViewPosition.xyz;\nfloat pointDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\npointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );\npointVector = normalize( pointVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n#endif\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\nvec3 pointHalfVector = normalize( pointVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n#else\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 spotVector = lPosition.xyz + vViewPosition.xyz;\nfloat spotDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );\nspotVector = normalize( spotVector );\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );\n#endif\nspotDiffuse += spotDistance * spotLightColor[ i ] * uDiffuseColor * spotDiffuseWeight * spotEffect;\nvec3 spotHalfVector = normalize( spotVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += spotDistance * spotLightColor[ i ] * uSpecularColor * spotSpecularWeight * spotDiffuseWeight * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = normalize( lPosition.xyz + vViewPosition.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += uDiffuseColor * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, uShininess ), 0.0 );\nvec3 lVectorGround = normalize( -lPosition.xyz + vViewPosition.xyz );\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlickSky = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += uSpecularColor * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor ) + totalSpecular;\n#endif\nif ( enableReflection ) {\nvec3 vReflect;\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nvReflect = refract( cameraToVertex, normal, uRefractionRatio );\n} else {\nvReflect = reflect( cameraToVertex, normal );\n}\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );\n}",
  533. THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\nuniform bool enableDisplacement;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
  534. THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"#ifdef USE_SKINNING\nvNormal = normalMatrix * skinnedNormal.xyz;\nvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );\nvTangent = normalMatrix * skinnedTangent.xyz;\n#else\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\n#endif\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\nvec3 displacedPosition;\n#ifdef VERTEX_TEXTURES\nif ( enableDisplacement ) {\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\ndisplacedPosition = position + normalize( normal ) * df;\n} else {\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n}\n#else\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n#endif\nvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );\nvec4 mPosition = modelMatrix * vec4( displacedPosition, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\nvWorldPosition = mPosition.xyz;\nvViewPosition = -mvPosition.xyz;\n#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * mPosition;\n}\n#endif\n}"].join("\n")},
  535. cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}});
  536. THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
  537. 0,f=String(a).split(""),e=f.length,g=[],a=0;a<e;a++){var h=new THREE.Path,h=this.extractGlyphPoints(f[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,f){var e=[],g,h,i,j,l,n,m,q,o,p,r,t=b.glyphs[a]||b.glyphs["?"];if(t){if(t.o){b=t._cachedOutline||(t._cachedOutline=t.o.split(" "));j=b.length;for(a=0;a<j;){i=b[a++];switch(i){case "m":i=b[a++]*c+d;l=b[a++]*c;f.moveTo(i,l);break;case "l":i=b[a++]*c+d;l=b[a++]*c;f.lineTo(i,l);break;case "q":i=b[a++]*
  538. c+d;l=b[a++]*c;q=b[a++]*c+d;o=b[a++]*c;f.quadraticCurveTo(q,o,i,l);if(g=e[e.length-1]){n=g.x;m=g.y;g=1;for(h=this.divisions;g<=h;g++){var u=g/h;THREE.Shape.Utils.b2(u,n,q,i);THREE.Shape.Utils.b2(u,m,o,l)}}break;case "b":i=b[a++]*c+d;l=b[a++]*c;q=b[a++]*c+d;o=b[a++]*-c;p=b[a++]*c+d;r=b[a++]*-c;f.bezierCurveTo(i,l,q,o,p,r);if(g=e[e.length-1]){n=g.x;m=g.y;g=1;for(h=this.divisions;g<=h;g++){u=g/h;THREE.Shape.Utils.b3(u,n,q,p,i);THREE.Shape.Utils.b3(u,m,o,r,l)}}}}}return{offset:t.ha*c,path:f}}}};
  539. THREE.FontUtils.generateShapes=function(a,b){var b=b||{},c=b.curveSegments!==void 0?b.curveSegments:4,d=b.font!==void 0?b.font:"helvetiker",f=b.weight!==void 0?b.weight:"normal",e=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=f;THREE.FontUtils.style=e;c=THREE.FontUtils.drawText(a).paths;d=[];f=0;for(e=c.length;f<e;f++)Array.prototype.push.apply(d,c[f].toShapes());return d};
  540. (function(a){var b=function(a){for(var b=a.length,f=0,e=b-1,g=0;g<b;e=g++)f=f+(a[e].x*a[g].y-a[g].x*a[e].y);return f*0.5};a.Triangulate=function(a,d){var f=a.length;if(f<3)return null;var e=[],g=[],h=[],i,j,l;if(b(a)>0)for(j=0;j<f;j++)g[j]=j;else for(j=0;j<f;j++)g[j]=f-1-j;var n=2*f;for(j=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;f<=i&&(i=0);j=i+1;f<=j&&(j=0);l=j+1;f<=l&&(l=0);var m;a:{m=a;var q=i,o=j,p=l,r=f,t=g,u=void 0,v=void 0,s=void 0,z=void 0,w=void 0,
  541. A=void 0,J=void 0,D=void 0,F=void 0,v=m[t[q]].x,s=m[t[q]].y,z=m[t[o]].x,w=m[t[o]].y,A=m[t[p]].x,J=m[t[p]].y;if(1E-10>(z-v)*(J-s)-(w-s)*(A-v))m=false;else{for(u=0;u<r;u++)if(!(u==q||u==o||u==p)){var D=m[t[u]].x,F=m[t[u]].y,B=void 0,E=void 0,H=void 0,Q=void 0,L=void 0,K=void 0,I=void 0,M=void 0,T=void 0,Z=void 0,ea=void 0,N=void 0,B=H=L=void 0,B=A-z,E=J-w,H=v-A,Q=s-J,L=z-v,K=w-s,I=D-v,M=F-s,T=D-z,Z=F-w,ea=D-A,N=F-J,B=B*Z-E*T,L=L*M-K*I,H=H*N-Q*ea;if(B>=0&&H>=0&&L>=0){m=false;break a}}m=true}}if(m){e.push([a[g[i]],
  542. a[g[j]],a[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l<f;i++,l++)g[i]=g[l];f--;n=2*f}}return d?h:e};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){a=this.getUtoTmapping(a);return this.getPoint(a)};
  543. THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};
  544. THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=false;var b=[],c,d=this.getPoint(0),f,e=0;b.push(0);for(f=1;f<=a;f++){c=this.getPoint(f/a);e=e+c.distanceTo(d);b.push(e);d=c}return this.cacheArcLengths=b};THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=true;this.getLengths()};
  545. THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,f=c.length,e;e=b?b:a*c[f-1];for(var g=0,h=f-1,i;g<=h;){d=Math.floor(g+(h-g)/2);i=c[d]-e;if(i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}}d=h;if(c[d]==e)return d/(f-1);g=c[d];return c=(d+(e-g)/(c[d+1]-g))/(f-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
  546. THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4,a=a+1E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){a=this.getUtoTmapping(a);return this.getTangent(a)};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};
  547. THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){return this.v2.clone().subSelf(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);
  548. THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};
  549. THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};
  550. THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.SplineCurve=function(a){this.points=a==void 0?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);
  551. THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,f;f=(d.length-1)*a;a=Math.floor(f);f=f-a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);return b};
  552. THREE.EllipseCurve=function(a,b,c,d,f,e,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=f;this.aEndAngle=e;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);b=this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);b=this.aY+this.yRadius*Math.sin(b);return new THREE.Vector2(a,b)};
  553. THREE.ArcCurve=function(a,b,c,d,f,e){THREE.EllipseCurve.call(this,a,b,c,c,d,f,e)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);
  554. THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,f){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*f},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,f){var a=(c-a)*0.5,d=(d-b)*0.5,e=f*f;return(2*b-2*c+a+d)*f*e+(-3*b+3*c-2*a-d)*e+a*f+b}};
  555. THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(this.v1);return b});
  556. THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});
  557. THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});
  558. THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f,a=(d.length-1)*a;f=Math.floor(a);a=a-f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>d.length-2?d.length-1:f+1;c[3]=f>d.length-3?d.length-1:f+2;f=d[c[0]];var e=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(f.x,e.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(f.y,e.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(f.z,e.z,g.z,c.z,a);return b});
  559. THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f;f=(d.length-0)*a;a=Math.floor(f);f=f-a;a=a+(a>0?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length);c[0]=(a-1)%d.length;c[1]=a%d.length;c[2]=(a+1)%d.length;c[3]=(a+2)%d.length;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,
  560. d[c[1]].z,d[c[2]].z,d[c[3]].z,f);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};
  561. THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a<c.length;){if(c[a]>=b){b=c[a]-b;a=this.curves[a];b=1-b/a.getLength();return a.getPointAt(b)}a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
  562. THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;c<d;c++){b=b+this.curves[c].getLength();a.push(b)}return this.cacheLengths=a};
  563. THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),b,c,d,f,e,g;b=c=Number.NEGATIVE_INFINITY;f=e=Number.POSITIVE_INFINITY;var h,i,j,l,n=a[0]instanceof THREE.Vector3;l=n?new THREE.Vector3:new THREE.Vector2;i=0;for(j=a.length;i<j;i++){h=a[i];if(h.x>b)b=h.x;else if(h.x<f)f=h.x;if(h.y>c)c=h.y;else if(h.y<e)e=h.y;if(n)if(h.z>d)d=h.z;else if(h.z<g)g=h.z;l.addSelf(h)}a={minX:f,minY:e,maxX:b,maxY:c,centroid:l.divideScalar(j)};if(n){a.maxZ=d;a.minZ=g}return a};
  564. THREE.CurvePath.prototype.createPointsGeometry=function(a){a=this.getPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){a=this.getSpacedPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0;c<a.length;c++)b.vertices.push(new THREE.Vector3(a[c].x,a[c].y,a[c].z||0));return b};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
  565. THREE.CurvePath.prototype.getTransformedPoints=function(a,b){var c=this.getPoints(a),d,f;if(!b)b=this.bends;d=0;for(f=b.length;d<f;d++)c=this.getWrapPoints(c,b[d]);return c};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,b){var c=this.getSpacedPoints(a),d,f;if(!b)b=this.bends;d=0;for(f=b.length;d<f;d++)c=this.getWrapPoints(c,b[d]);return c};
  566. THREE.CurvePath.prototype.getWrapPoints=function(a,b){var c=this.getBoundingBox(),d,f,e,g,h,i;d=0;for(f=a.length;d<f;d++){e=a[d];g=e.x;h=e.y;i=g/c.maxX;i=b.getUtoTmapping(i,g);g=b.getPoint(i);h=b.getNormalVector(i).multiplyScalar(h);e.x=g.x+h.x;e.y=g.y+h.y}return a};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype);
  567. THREE.Gyroscope.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a){if(this.parent){this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix);this.matrixWorld.decompose(this.translationWorld,this.rotationWorld,this.scaleWorld);this.matrix.decompose(this.translationObject,this.rotationObject,this.scaleObject);this.matrixWorld.compose(this.translationWorld,this.rotationObject,this.scaleWorld)}else this.matrixWorld.copy(this.matrix);
  568. this.matrixWorldNeedsUpdate=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)};THREE.Gyroscope.prototype.translationWorld=new THREE.Vector3;THREE.Gyroscope.prototype.translationObject=new THREE.Vector3;THREE.Gyroscope.prototype.rotationWorld=new THREE.Quaternion;THREE.Gyroscope.prototype.rotationObject=new THREE.Quaternion;THREE.Gyroscope.prototype.scaleWorld=new THREE.Vector3;THREE.Gyroscope.prototype.scaleObject=new THREE.Vector3;
  569. THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=Object.create(THREE.CurvePath.prototype);THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"};THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
  570. THREE.Path.prototype.moveTo=function(a,b){var c=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:c})};THREE.Path.prototype.lineTo=function(a,b){var c=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args,d=new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,b));this.curves.push(d);this.actions.push({action:THREE.PathActions.LINE_TO,args:c})};
  571. THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var f=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args,e=new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(e);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:f})};
  572. THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,f,e){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(f,e));this.curves.push(h);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
  573. THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);c=new THREE.SplineCurve(c);this.curves.push(c);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};THREE.Path.prototype.arc=function(a,b,c,d,f,e){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,f,e)};
  574. THREE.Path.prototype.absarc=function(a,b,c,d,f,e){this.absellipse(a,b,c,c,d,f,e)};THREE.Path.prototype.ellipse=function(a,b,c,d,f,e,g){var h=this.actions[this.actions.length-1].args;this.absellipse(a+h[h.length-2],b+h[h.length-1],c,d,f,e,g)};THREE.Path.prototype.absellipse=function(a,b,c,d,f,e,g){var h=Array.prototype.slice.call(arguments),i=new THREE.EllipseCurve(a,b,c,d,f,e,g);this.curves.push(i);i=i.getPoint(g?1:0);h.push(i.x);h.push(i.y);this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})};
  575. THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
  576. THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(a,b)}var a=a||12,c=[],d,f,e,g,h,i,j,l,n,m,q,o,p;d=0;for(f=this.actions.length;d<f;d++){e=this.actions[d];g=e.action;e=e.args;switch(g){case THREE.PathActions.MOVE_TO:c.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];i=e[3];n=e[0];m=e[1];if(c.length>0){g=c[c.length-1];
  577. q=g.x;o=g.y}else{g=this.actions[d-1].args;q=g[g.length-2];o=g[g.length-1]}for(e=1;e<=a;e++){p=e/a;g=THREE.Shape.Utils.b2(p,q,n,h);p=THREE.Shape.Utils.b2(p,o,m,i);c.push(new THREE.Vector2(g,p))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];n=e[0];m=e[1];j=e[2];l=e[3];if(c.length>0){g=c[c.length-1];q=g.x;o=g.y}else{g=this.actions[d-1].args;q=g[g.length-2];o=g[g.length-1]}for(e=1;e<=a;e++){p=e/a;g=THREE.Shape.Utils.b3(p,q,n,j,h);p=THREE.Shape.Utils.b3(p,o,m,l,i);c.push(new THREE.Vector2(g,
  578. p))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;p=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*e[0].length;p=p.concat(e[0]);p=new THREE.SplineCurve(p);for(e=1;e<=g;e++)c.push(p.getPointAt(e/g));break;case THREE.PathActions.ARC:h=e[0];i=e[1];m=e[2];j=e[3];g=e[4];n=!!e[5];q=g-j;o=a*2;for(e=1;e<=o;e++){p=e/o;n||(p=1-p);p=j+p*q;g=h+m*Math.cos(p);p=i+m*Math.sin(p);c.push(new THREE.Vector2(g,p))}break;case THREE.PathActions.ELLIPSE:h=e[0];i=e[1];m=e[2];l=e[3];j=e[4];g=e[5];
  579. n=!!e[6];q=g-j;o=a*2;for(e=1;e<=o;e++){p=e/o;n||(p=1-p);p=j+p*q;g=h+m*Math.cos(p);p=i+l*Math.sin(p);c.push(new THREE.Vector2(g,p))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1E-10&&Math.abs(d.y-c[0].y)<1E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c};
  580. THREE.Path.prototype.toShapes=function(){var a,b,c,d,f=[],e=new THREE.Path;a=0;for(b=this.actions.length;a<b;a++){c=this.actions[a];d=c.args;c=c.action;if(c==THREE.PathActions.MOVE_TO&&e.actions.length!=0){f.push(e);e=new THREE.Path}e[c].apply(e,d)}e.actions.length!=0&&f.push(e);if(f.length==0)return[];var g;d=[];a=!THREE.Shape.Utils.isClockWise(f[0].getPoints());if(f.length==1){e=f[0];g=new THREE.Shape;g.actions=e.actions;g.curves=e.curves;d.push(g);return d}if(a){g=new THREE.Shape;a=0;for(b=f.length;a<
  581. b;a++){e=f[a];if(THREE.Shape.Utils.isClockWise(e.getPoints())){g.actions=e.actions;g.curves=e.curves;d.push(g);g=new THREE.Shape}else g.holes.push(e)}}else{a=0;for(b=f.length;a<b;a++){e=f[a];if(THREE.Shape.Utils.isClockWise(e.getPoints())){g&&d.push(g);g=new THREE.Shape;g.actions=e.actions;g.curves=e.curves}else g.holes.push(e)}d.push(g)}return d};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=Object.create(THREE.Path.prototype);
  582. THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)};THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};
  583. THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.useSpacedPoints?this.extractAllSpacedPoints(a):this.extractAllPoints(a)};THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
  584. THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),f,e,g,h,i,j,l,n,m,q,o=[];for(i=0;i<b.length;i++){j=b[i];Array.prototype.push.apply(d,j);e=Number.POSITIVE_INFINITY;for(f=0;f<j.length;f++){m=j[f];q=[];for(n=0;n<c.length;n++){l=c[n];l=m.distanceToSquared(l);q.push(l);if(l<e){e=l;g=f;h=n}}}f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;var p=[j[g],c[h],c[f]];n=THREE.FontUtils.Triangulate.area(p);var r=[j[g],j[e],c[h]];m=THREE.FontUtils.Triangulate.area(r);q=h;l=g;h=h+1;g=g+
  585. -1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;p=[j[g],c[h],c[f]];p=THREE.FontUtils.Triangulate.area(p);r=[j[g],j[e],c[h]];r=THREE.FontUtils.Triangulate.area(r);if(n+m>p+r){h=q;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1}n=c.slice(0,h);m=c.slice(h);q=j.slice(g);l=j.slice(0,g);e=[j[g],j[e],c[h]];o.push([j[g],c[h],c[f]]);o.push(e);c=n.concat(q).concat(l).concat(m)}return{shape:c,
  586. isolatedPts:o,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),e,g,h,i,j={};e=0;for(g=d.length;e<g;e++){i=d[e].x+":"+d[e].y;j[i]!==void 0&&console.log("Duplicate point",i);j[i]=e}e=0;for(g=c.length;e<g;e++){h=c[e];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}e=0;for(g=f.length;e<g;e++){h=f[e];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}return c.concat(f)},
  587. isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
  588. this.b3p3(a,f)}};
  589. THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==true){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<0)a.hierarchy[c].keys[d].time=
  590. 0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var j=a.hierarchy[c].keys[d].morphTargets[i];h[j]=-1}a.hierarchy[c].usedMorphTargets=h;for(d=0;d<a.hierarchy[c].keys.length;d++){var l=
  591. {};for(j in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===j){l[j]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(l[j]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=l}}for(d=1;d<a.hierarchy[c].keys.length;d++)if(a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time){a.hierarchy[c].keys.splice(d,1);d--}for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=d}d=parseInt(a.length*
  592. a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=true}},get:function(a){if(typeof a==="string"){if(b[a])return b[a];console.log("THREE.AnimationHandler.get: Couldn't find animation "+a);return null}},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=0;c.CATMULLROM=
  593. 1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=false;this.loop=this.isPaused=true;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.points=[];this.target=new THREE.Vector3};
  594. THREE.Animation.prototype.play=function(a,b){if(this.isPlaying===false){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,f;for(c=0;c<d;c++){f=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=true;f.matrixAutoUpdate=true;if(f.animationCache===void 0){f.animationCache={};f.animationCache.prevKey={pos:0,rot:0,scl:0};f.animationCache.nextKey={pos:0,rot:0,scl:0};f.animationCache.originalMatrix=
  595. f instanceof THREE.Bone?f.skinMatrix:f.matrix}var e=f.animationCache.prevKey;f=f.animationCache.nextKey;e.pos=this.data.hierarchy[c].keys[0];e.rot=this.data.hierarchy[c].keys[0];e.scl=this.data.hierarchy[c].keys[0];f.pos=this.getNextKeyWith("pos",c,1);f.rot=this.getNextKeyWith("rot",c,1);f.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};
  596. THREE.Animation.prototype.pause=function(){this.isPaused===true?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this)};
  597. THREE.Animation.prototype.update=function(a){if(this.isPlaying!==false){var b=["pos","rot","scl"],c,d,f,e,g,h,i,j,l;l=this.currentTime=this.currentTime+a*this.timeScale;j=this.currentTime=this.currentTime%this.data.length;parseInt(Math.min(j*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,m=this.hierarchy.length;n<m;n++){a=this.hierarchy[n];i=a.animationCache;for(var q=0;q<3;q++){c=b[q];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=l){if(j<l)if(this.loop){g=this.data.hierarchy[n].keys[0];
  598. for(h=this.getNextKeyWith(c,n,1);h.time<j;){g=h;h=this.getNextKeyWith(c,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(c,n,h.index+1)}while(h.time<j)}i.prevKey[c]=g;i.nextKey[c]=h}a.matrixAutoUpdate=true;a.matrixWorldNeedsUpdate=true;d=(j-g.time)/(h.time-g.time);f=g[c];e=h[c];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=f[0]+
  599. (e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=f;this.points[2]=e;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);c.x=f[0];c.y=f[1];c.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=
  600. this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(f,e,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=f[0]+(e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}}}}};
  601. THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,e,g,h,i,j;f=(a.length-1)*b;e=Math.floor(f);f=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>a.length-2?e:e+1;c[3]=e>a.length-3?e:e+2;e=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=f*f;g=f*c;d[0]=this.interpolate(e[0],h[0],i[0],j[0],f,c,g);d[1]=this.interpolate(e[1],h[1],i[1],j[1],f,c,g);d[2]=this.interpolate(e[2],h[2],i[2],j[2],f,c,g);return d};
  602. THREE.Animation.prototype.interpolate=function(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
  603. THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
  604. THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=
  605. false;this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}};
  606. THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,f,e;for(c=0;c<d;c++){f=this.hierarchy[c];e=this.data.hierarchy[c];f.useQuaternion=true;if(e.animationCache===void 0){e.animationCache={};e.animationCache.prevKey=null;e.animationCache.nextKey=null;e.animationCache.originalMatrix=f instanceof THREE.Bone?
  607. f.skinMatrix:f.matrix}f=this.data.hierarchy[c].keys;if(f.length){e.animationCache.prevKey=f[0];e.animationCache.nextKey=f[1];this.startTime=Math.min(f[0].time,this.startTime);this.endTime=Math.max(f[f.length-1].time,this.endTime)}}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  608. THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.data.hierarchy.length;a++){var b=this.hierarchy[a],c=this.data.hierarchy[a];if(c.animationCache!==void 0){var d=c.animationCache.originalMatrix;if(b instanceof THREE.Bone){d.copy(b.skinMatrix);b.skinMatrix=d}else{d.copy(b.matrix);b.matrix=d}delete c.animationCache}}};
  609. THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,f,e=this.data.JIT.hierarchy,g,h,i;h=this.currentTime=this.currentTime+a*this.timeScale;g=this.currentTime=this.currentTime%this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;f=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,j=this.hierarchy.length;a<j;a++){var l=this.data.hierarchy[a].keys,e=this.data.hierarchy[a].sids;d=l.length-1;f=
  610. this.hierarchy[a];if(l.length){for(l=0;l<e.length;l++){g=e[l];(h=this.getPrevKeyWith(g,a,d))&&h.apply(g)}this.data.hierarchy[a].node.updateMatrix();f.matrixWorldNeedsUpdate=true}}this.stop()}else if(!(g<this.startTime)){a=0;for(j=this.hierarchy.length;a<j;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var l=b.keys,n=b.animationCache;if(this.JITCompile&&e[a][f]!==void 0)if(d instanceof THREE.Bone){d.skinMatrix=e[a][f];d.matrixWorldNeedsUpdate=false}else{d.matrix=e[a][f];d.matrixWorldNeedsUpdate=
  611. true}else if(l.length){if(this.JITCompile&&n)d instanceof THREE.Bone?d.skinMatrix=n.originalMatrix:d.matrix=n.originalMatrix;b=n.prevKey;c=n.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=l[0];for(c=l[1];c.time<g;){b=c;c=l[b.index+1]}}else if(!i)for(var m=l.length-1;c.time<g&&c.index!==m;){b=c;c=l[b.index+1]}n.prevKey=b;n.nextKey=c}c.time>=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&e[0][f]===void 0){this.hierarchy[0].updateMatrixWorld(true);
  612. for(a=0;a<this.hierarchy.length;a++)e[a][f]=this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c%b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};
  613. THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c>=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
  614. THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new THREE.Vector3(-1,0,0));this.add(f);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,0,1);e.lookAt(new THREE.Vector3(0,1,0));this.add(e);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90,
  615. 1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,m=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,f,c);c.activeCubeFace=
  616. 2;a.render(b,e,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=m;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,f,e,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,e,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,f);this.zoom=1;this.toPerspective()};
  617. 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=true;this.inOrthographicMode=false};
  618. THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=false;this.inOrthographicMode=true};
  619. THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){if(this.inPerspectiveMode)this.toPerspective();else{this.toPerspective();this.toOrthographic()}};
  620. THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;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=false};
  621. THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};
  622. THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
  623. THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.lookVertical=true;this.autoForward=false;this.activeLook=true;this.heightSpeed=false;this.heightCoef=1;this.heightMin=0;this.heightMax=1;this.constrainVertical=false;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=
  624. this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=false;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.onMouseDown=function(a){this.domElement!==
  625. document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=true;break;case 2:this.moveBackward=true}this.mouseDragOn=true};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=false;break;case 2:this.moveBackward=false}this.mouseDragOn=false};this.onMouseMove=function(a){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-
  626. this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=true;break;case 37:case 65:this.moveLeft=true;break;case 40:case 83:this.moveBackward=true;break;case 39:case 68:this.moveRight=true;break;case 82:this.moveUp=true;break;case 70:this.moveDown=true;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
  627. false;break;case 37:case 65:this.moveLeft=false;break;case 40:case 83:this.moveBackward=false;break;case 39:case 68:this.moveRight=false;break;case 82:this.moveUp=false;break;case 70:this.moveDown=false}};this.update=function(a){var b=0;if(!this.freeze){if(this.heightSpeed){b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*b*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&
  628. this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);a=a*this.lookSpeed;this.activeLook||(a=0);this.lon=this.lon+this.mouseX*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*a;this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=
  629. this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon=this.lon+this.mouseX*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*a*b;this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,
  630. 0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),false);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),false);this.domElement.addEventListener("mouseup",
  631. c(this,this.onMouseUp),false);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),false);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),false);this.handleResize()};
  632. THREE.PathControls=function(a,b){function c(a){return(a=a*2)<1?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var f={name:c,fps:0.6,length:d,hierarchy:[]},e,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,t=0;e=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[e]={time:d,pos:g[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e<r-1;e++){t=d*h.chunks[e]/h.total;b.keys[e]={time:t,pos:g[e]}}f.hierarchy[0]=b;THREE.AnimationHandler.add(f);
  633. return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,false)}function e(a,b){var c,d,f=new THREE.Geometry;for(c=0;c<a.points.length*b;c++){d=c/(a.points.length*b);d=a.getPoint(d);f.vertices[c]=new THREE.Vector3(d.x,d.y,d.z)}return f}this.object=a;this.domElement=b!==void 0?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=true;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;
  634. this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=this.lookVertical=true;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;var g=Math.PI*2,h=Math.PI/180;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===
  635. document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.update=function(a){var b;if(this.lookHorizontal)this.lon=this.lon+this.mouseX*this.lookSpeed*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*this.lookSpeed*a;this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%g;this.phi=
  636. a>=0?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};
  637. this.onMouseMove=function(a){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),
  638. b=new THREE.MeshLambertMaterial({color:65280}),c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else{this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.target);this.animationParent.add(this.object)}if(this.createDebugPath){var a=
  639. this.debugPath,b=this.spline,g=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),q=0;q<b.points.length;q++){c=new THREE.Mesh(g,h);c.position.copy(b.points[q]);a.add(c)}}this.domElement.addEventListener("mousemove",d(this,
  640. this.onMouseMove),false)};this.handleResize()};THREE.PathControlsIdCounter=0;
  641. THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=b!==void 0?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=false;this.object.useQuaternion=true;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=
  642. new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=
  643. 1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=
  644. 0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
  645. true;break;case 2:this.object.moveBackward=true}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,g=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-g)/g;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(a.button){case 0:this.moveForward=
  646. false;break;case 2:this.moveBackward=false}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed,a=a*this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);
  647. this.object.matrixWorldNeedsUpdate=true};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
  648. -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),false);this.domElement.addEventListener("mousedown",c(this,this.mousedown),false);this.domElement.addEventListener("mouseup",
  649. c(this,this.mouseup),false);this.domElement.addEventListener("keydown",c(this,this.keydown),false);this.domElement.addEventListener("keyup",c(this,this.keyup),false);this.updateMovementVector();this.updateRotationVector()};
  650. THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=true;this.autoForward=false;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=false;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,f=new THREE.Vector3,e=new THREE.Matrix4,g=false,h=1,i=0,j=0,l=0,n=0,m=0,q=0,o=0;this.handleResize=function(){q=window.innerWidth/2;o=window.innerHeight/2};this.update=
  651. function(a){if(this.mouseLook){var b=a*this.lookSpeed;this.rotateHorizontally(b*n);this.rotateVertically(b*m)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*j);this.object.translateY(b*l);if(g)this.roll=this.roll+this.rollSpeed*a*h;if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y<this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}f.copy(this.forward);
  652. d.set(0,1,0);c.cross(d,f).normalize();d.cross(f,c).normalize();this.object.matrix.elements[0]=c.x;this.object.matrix.elements[4]=d.x;this.object.matrix.elements[8]=f.x;this.object.matrix.elements[1]=c.y;this.object.matrix.elements[5]=d.y;this.object.matrix.elements[9]=f.y;this.object.matrix.elements[2]=c.z;this.object.matrix.elements[6]=d.z;this.object.matrix.elements[10]=f.z;e.identity();e.elements[0]=Math.cos(this.roll);e.elements[4]=-Math.sin(this.roll);e.elements[1]=Math.sin(this.roll);e.elements[5]=
  653. Math.cos(this.roll);this.object.matrix.multiplySelf(e);this.object.matrixWorldNeedsUpdate=true;this.object.matrix.elements[12]=this.object.position.x;this.object.matrix.elements[13]=this.object.position.y;this.object.matrix.elements[14]=this.object.position.z};this.translateX=function(a){this.object.position.x=this.object.position.x+this.object.matrix.elements[0]*a;this.object.position.y=this.object.position.y+this.object.matrix.elements[1]*a;this.object.position.z=this.object.position.z+this.object.matrix.elements[2]*
  654. a};this.translateY=function(a){this.object.position.x=this.object.position.x+this.object.matrix.elements[4]*a;this.object.position.y=this.object.position.y+this.object.matrix.elements[5]*a;this.object.position.z=this.object.position.z+this.object.matrix.elements[6]*a};this.translateZ=function(a){this.object.position.x=this.object.position.x-this.object.matrix.elements[8]*a;this.object.position.y=this.object.position.y-this.object.matrix.elements[9]*a;this.object.position.z=this.object.position.z-
  655. this.object.matrix.elements[10]*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.elements[0],this.object.matrix.elements[1],this.object.matrix.elements[2]);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.elements[4],this.object.matrix.elements[5],this.object.matrix.elements[6]);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},
  656. false);this.domElement.addEventListener("mousemove",function(a){n=(a.clientX-q)/window.innerWidth;m=(a.clientY-o)/window.innerHeight},false);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},false);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},false);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:i=
  657. 1;break;case 37:case 65:j=-1;break;case 40:case 83:i=-1;break;case 39:case 68:j=1;break;case 81:g=true;h=1;break;case 69:g=true;h=-1;break;case 82:l=1;break;case 70:l=-1}},false);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:j=0;break;case 40:case 83:i=0;break;case 39:case 68:j=0;break;case 81:g=false;break;case 69:g=false;break;case 82:l=0;break;case 70:l=0}},false);this.handleResize()};
  658. THREE.TrackballControls=function(a,b){function c(a){if(d.enabled){a.preventDefault();a.stopPropagation();var b=0;a.wheelDelta?b=a.wheelDelta/40:a.detail&&(b=-a.detail/3);l.y=l.y+1/b*0.05}}THREE.EventTarget.call(this);var d=this;this.object=a;this.domElement=b!==void 0?b:document;this.enabled=true;this.screen={width:0,height:0,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=
  659. this.noRotate=false;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=new THREE.Vector3;var f=new THREE.Vector3,e=false,g=-1,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector2,n=new THREE.Vector2,m=new THREE.Vector2,q=new THREE.Vector2,o={type:"change"};this.handleResize=function(){this.screen.width=window.innerWidth;this.screen.height=window.innerHeight;this.screen.offsetLeft=0;this.screen.offsetTop=0;this.radius=
  660. (this.screen.width+this.screen.height)/4};this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-d.screen.offsetLeft)/d.radius*0.5,(b-d.screen.offsetTop)/d.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var c=new THREE.Vector3((a-d.screen.width*0.5-d.screen.offsetLeft)/d.radius,(d.screen.height*0.5+d.screen.offsetTop-b)/d.radius,0),e=c.length();e>1?c.normalize():c.z=Math.sqrt(1-e*e);h.copy(d.object.position).subSelf(d.target);
  661. e=d.object.up.clone().setLength(c.y);e.addSelf(d.object.up.clone().crossSelf(h).setLength(c.x));e.addSelf(h.setLength(c.z));return e};this.rotateCamera=function(){var a=Math.acos(i.dot(j)/i.length()/j.length());if(a){var b=(new THREE.Vector3).cross(i,j).normalize(),c=new THREE.Quaternion,a=a*d.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(h);c.multiplyVector3(d.object.up);c.multiplyVector3(j);if(d.staticMoving)i.copy(j);else{c.setFromAxisAngle(b,a*(d.dynamicDampingFactor-1));c.multiplyVector3(i)}}};
  662. this.zoomCamera=function(){var a=1+(n.y-l.y)*d.zoomSpeed;if(a!==1&&a>0){h.multiplyScalar(a);d.staticMoving?l.copy(n):l.y=l.y+(n.y-l.y)*this.dynamicDampingFactor}};this.panCamera=function(){var a=q.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(h.length()*d.panSpeed);var b=h.clone().crossSelf(d.object.up).setLength(a.x);b.addSelf(d.object.up.clone().setLength(a.y));d.object.position.addSelf(b);d.target.addSelf(b);d.staticMoving?m=q:m.addSelf(a.sub(q,m).multiplyScalar(d.dynamicDampingFactor))}};
  663. this.checkDistances=function(){if(!d.noZoom||!d.noPan){d.object.position.lengthSq()>d.maxDistance*d.maxDistance&&d.object.position.setLength(d.maxDistance);h.lengthSq()<d.minDistance*d.minDistance&&d.object.position.add(d.target,h.setLength(d.minDistance))}};this.update=function(){h.copy(d.object.position).subSelf(d.target);d.noRotate||d.rotateCamera();d.noZoom||d.zoomCamera();d.noPan||d.panCamera();d.object.position.add(d.target,h);d.checkDistances();d.object.lookAt(d.target);if(f.distanceToSquared(d.object.position)>
  664. 0){d.dispatchEvent(o);f.copy(d.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",function(a){if(d.enabled){if(e){i=j=d.getMouseProjectionOnBall(a.clientX,a.clientY);l=n=d.getMouseOnScreen(a.clientX,a.clientY);m=q=d.getMouseOnScreen(a.clientX,a.clientY);e=false}g!==-1&&(g===0&&!d.noRotate?j=d.getMouseProjectionOnBall(a.clientX,a.clientY):g===1&&!d.noZoom?n=d.getMouseOnScreen(a.clientX,a.clientY):g===
  665. 2&&!d.noPan&&(q=d.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(d.enabled){a.preventDefault();a.stopPropagation();if(g===-1){g=a.button;g===0&&!d.noRotate?i=j=d.getMouseProjectionOnBall(a.clientX,a.clientY):g===1&&!d.noZoom?l=n=d.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(m=q=d.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(d.enabled){a.preventDefault();a.stopPropagation();
  666. g=-1}},false);this.domElement.addEventListener("DOMMouseScroll",c,false);this.domElement.addEventListener("mousewheel",c,false);window.addEventListener("keydown",function(a){if(d.enabled&&g===-1){a.keyCode===d.keys[0]&&!d.noRotate?g=0:a.keyCode===d.keys[1]&&!d.noZoom?g=1:a.keyCode===d.keys[2]&&!d.noPan&&(g=2);g!==-1&&(e=true)}},false);window.addEventListener("keyup",function(){d.enabled&&g!==-1&&(g=-1)},false);this.handleResize()};
  667. THREE.OrbitControls=function(a,b){function c(){return 2*Math.PI/60/60*e.autoRotateSpeed}function d(a){a.preventDefault();if(u===t.ROTATE){i.set(a.clientX,a.clientY);j.sub(i,h);e.rotateLeft(2*Math.PI*j.x/g*e.userRotateSpeed);e.rotateUp(2*Math.PI*j.y/g*e.userRotateSpeed);h.copy(i)}else if(u===t.ZOOM){n.set(a.clientX,a.clientY);m.sub(n,l);m.y>0?e.zoomIn():e.zoomOut();l.copy(n)}}function f(){if(e.userRotate){document.removeEventListener("mousemove",d,false);document.removeEventListener("mouseup",f,false);
  668. u=t.NONE}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var e=this,g=1800,h=new THREE.Vector2,i=new THREE.Vector2,j=new THREE.Vector2,l=new THREE.Vector2,n=new THREE.Vector2,m=new THREE.Vector2,q=0,o=0,p=1,r=new THREE.Vector3,t={NONE:-1,ROTATE:0,ZOOM:1},u=t.NONE,v={type:"change"};this.rotateLeft=function(a){a===
  669. void 0&&(a=c());o=o-a};this.rotateRight=function(a){a===void 0&&(a=c());o=o+a};this.rotateUp=function(a){a===void 0&&(a=c());q=q-a};this.rotateDown=function(a){a===void 0&&(a=c());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,e.userZoomSpeed));p=p/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,e.userZoomSpeed));p=p*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),d=Math.atan2(b.x,b.z),e=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&
  670. this.rotateLeft(c());var d=d+o,e=e+q,e=Math.max(1E-6,Math.min(Math.PI-1E-6,e)),f=b.length();b.x=f*Math.sin(e)*Math.sin(d);b.y=f*Math.cos(e);b.z=f*Math.sin(e)*Math.cos(d);b.multiplyScalar(p);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);q=o=0;p=1;if(r.distanceTo(this.object.position)>0){this.dispatchEvent(v);r.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(e.userRotate){a.preventDefault();
  671. if(a.button===0||a.button===2){u=t.ROTATE;h.set(a.clientX,a.clientY)}else if(a.button===1){u=t.ZOOM;l.set(a.clientX,a.clientY)}document.addEventListener("mousemove",d,false);document.addEventListener("mouseup",f,false)}},false);this.domElement.addEventListener("mousewheel",function(a){e.userZoom&&(a.wheelDelta>0?e.zoomOut():e.zoomIn())},false)};
  672. THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);var a=a||50,c=c!==void 0?c:0,d=d!==void 0?d:Math.PI*2,b=b!==void 0?Math.max(3,b):8,f,e=[];f=new THREE.Vector3;var g=new THREE.UV(0.5,0.5);this.vertices.push(f);e.push(g);for(f=0;f<=b;f++){var h=new THREE.Vector3;h.x=a*Math.cos(c+f/b*d);h.y=a*Math.sin(c+f/b*d);this.vertices.push(h);e.push(new THREE.UV((h.x/a+1)/2,-(h.y/a+1)/2+1))}c=new THREE.Vector3(0,0,-1);for(f=1;f<=b;f++){this.faces.push(new THREE.Face3(f,f+1,0,[c,c,c]));this.faceVertexUvs[0].push([e[f],
  673. e[f+1],g])}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);
  674. THREE.CubeGeometry=function(a,b,c,d,f,e,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=f||1,q=h/2,r=i/2,t=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=e||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=e||1}var u=o+1,v=p+1,Z=h/o,ea=i/p,N=new THREE.Vector3;N[n]=l>0?1:-1;for(h=0;h<v;h++)for(i=0;i<u;i++){var fa=new THREE.Vector3;fa[a]=(i*Z-q)*c;fa[b]=(h*ea-r)*g;fa[n]=l;j.vertices.push(fa)}for(h=0;h<p;h++)for(i=0;i<o;i++){a=new THREE.Face4(i+
  675. u*h+t,i+u*(h+1)+t,i+1+u*(h+1)+t,i+1+u*h+t);a.normal.copy(N);a.vertexNormals.push(N.clone(),N.clone(),N.clone(),N.clone());a.materialIndex=m;j.faces.push(a);j.faceVertexUvs[0].push([new THREE.UV(i/o,1-h/p),new THREE.UV(i/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-h/p)])}}THREE.Geometry.call(this);var j=this,l=a/2,n=b/2,m=c/2,q,o,p,r,t,u;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(q=0;q<6;q++)this.materials.push(g)}q=0;r=1;o=2;t=3;p=4;u=
  676. 5}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=void 0)for(var v in h)this.sides[v]!==void 0&&(this.sides[v]=h[v]);this.sides.px&&i("z","y",-1,-1,c,b,l,q);this.sides.nx&&i("z","y",1,-1,c,b,-l,r);this.sides.py&&i("x","z",1,1,a,c,n,o);this.sides.ny&&i("x","z",1,-1,a,c,-n,t);this.sides.pz&&i("x","y",1,-1,a,b,m,p);this.sides.nz&&i("x","y",-1,-1,a,b,-m,u);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
  677. THREE.CylinderGeometry=function(a,b,c,d,f,e){THREE.Geometry.call(this);var a=a!==void 0?a:20,b=b!==void 0?b:20,c=c!==void 0?c:100,g=c/2,d=d||8,f=f||1,h,i,j=[],l=[];for(i=0;i<=f;i++){var n=[],m=[],q=i/f,o=q*(b-a)+a;for(h=0;h<=d;h++){var p=h/d,r=new THREE.Vector3;r.x=o*Math.sin(p*Math.PI*2);r.y=-q*c+g;r.z=o*Math.cos(p*Math.PI*2);this.vertices.push(r);n.push(this.vertices.length-1);m.push(new THREE.UV(p,1-q))}j.push(n);l.push(m)}c=(b-a)/c;for(h=0;h<d;h++){if(a!==0){n=this.vertices[j[0][h]].clone();m=
  678. this.vertices[j[0][h+1]].clone()}else{n=this.vertices[j[1][h]].clone();m=this.vertices[j[1][h+1]].clone()}n.setY(Math.sqrt(n.x*n.x+n.z*n.z)*c).normalize();m.setY(Math.sqrt(m.x*m.x+m.z*m.z)*c).normalize();for(i=0;i<f;i++){var q=j[i][h],o=j[i+1][h],p=j[i+1][h+1],r=j[i][h+1],t=n.clone(),u=n.clone(),v=m.clone(),s=m.clone(),z=l[i][h].clone(),w=l[i+1][h].clone(),A=l[i+1][h+1].clone(),J=l[i][h+1].clone();this.faces.push(new THREE.Face4(q,o,p,r,[t,u,v,s]));this.faceVertexUvs[0].push([z,w,A,J])}}if(!e&&a>
  679. 0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h<d;h++){q=j[0][h];o=j[0][h+1];p=this.vertices.length-1;t=new THREE.Vector3(0,1,0);u=new THREE.Vector3(0,1,0);v=new THREE.Vector3(0,1,0);z=l[0][h].clone();w=l[0][h+1].clone();A=new THREE.UV(w.u,0);this.faces.push(new THREE.Face3(q,o,p,[t,u,v]));this.faceVertexUvs[0].push([z,w,A])}}if(!e&&b>0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h<d;h++){q=j[i][h+1];o=j[i][h];p=this.vertices.length-1;t=new THREE.Vector3(0,-1,0);u=new THREE.Vector3(0,
  680. -1,0);v=new THREE.Vector3(0,-1,0);z=l[i][h+1].clone();w=l[i][h].clone();A=new THREE.UV(w.u,1);this.faces.push(new THREE.Face3(q,o,p,[t,u,v]));this.faceVertexUvs[0].push([z,w,A])}}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);
  681. THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);a=a instanceof Array?a:[a];this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
  682. THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
  683. h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);if(f===0){console.log("Either infinite or no solutions!");g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions.")}g=g/f;if(g<0){b=Math.atan2(b.y-a.y,b.x-a.x);a=Math.atan2(c.y-a.y,c.x-a.x);b>a&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function f(c,d){var e,f;for(N=c.length;--N>=0;){e=N;f=N-1;f<0&&(f=
  684. c.length-1);for(var g=0,h=m+l*2,g=0;g<h;g++){var i=T*g,j=T*(g+1),n=d+e+i,i=d+f+i,o=d+f+j,j=d+e+j,p=c,q=g,r=h,s=e,v=f,n=n+B,i=i+B,o=o+B,j=j+B;F.faces.push(new THREE.Face4(n,i,o,j,null,null,t));n=u.generateSideWallUV(F,a,p,b,n,i,o,j,q,r,s,v);F.faceVertexUvs[0].push(n)}}}function e(a,b,c){F.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c=c+B;d=d+B;e=e+B;F.faces.push(new THREE.Face3(c,d,e,null,null,r));c=f?u.generateBottomUV(F,a,b,c,d,e):u.generateTopUV(F,a,b,c,d,e);F.faceVertexUvs[0].push(c)}
  685. var h=b.amount!==void 0?b.amount:100,i=b.bevelThickness!==void 0?b.bevelThickness:6,j=b.bevelSize!==void 0?b.bevelSize:i-2,l=b.bevelSegments!==void 0?b.bevelSegments:3,n=b.bevelEnabled!==void 0?b.bevelEnabled:true,m=b.steps!==void 0?b.steps:1,q=b.extrudePath,o,p=false,r=b.material,t=b.extrudeMaterial,u=b.UVGenerator!==void 0?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,v,s,z,w;if(q){o=q.getSpacedPoints(m);p=true;n=false;v=b.frames!==void 0?b.frames:new THREE.TubeGeometry.FrenetFrames(q,m,
  686. false);s=new THREE.Vector3;z=new THREE.Vector3;w=new THREE.Vector3}if(!n)j=i=l=0;var A,J,D,F=this,B=this.vertices.length,q=a.extractPoints(),E=q.shape,q=q.holes,H=!THREE.Shape.Utils.isClockWise(E);if(H){E=E.reverse();J=0;for(D=q.length;J<D;J++){A=q[J];THREE.Shape.Utils.isClockWise(A)&&(q[J]=A.reverse())}H=false}var Q=THREE.Shape.Utils.triangulateShape(E,q),H=E;J=0;for(D=q.length;J<D;J++){A=q[J];E=E.concat(A)}var L,K,I,M,T=E.length,Z=Q.length,ea=[],N=0,fa=H.length;L=fa-1;for(K=N+1;N<fa;N++,L++,K++){L===
  687. fa&&(L=0);K===fa&&(K=0);ea[N]=d(H[N],H[L],H[K])}var S=[],ra,wa=ea.concat();J=0;for(D=q.length;J<D;J++){A=q[J];ra=[];N=0;fa=A.length;L=fa-1;for(K=N+1;N<fa;N++,L++,K++){L===fa&&(L=0);K===fa&&(K=0);ra[N]=d(A[N],A[L],A[K])}S.push(ra);wa=wa.concat(ra)}for(L=0;L<l;L++){A=L/l;I=i*(1-A);K=j*Math.sin(A*Math.PI/2);N=0;for(fa=H.length;N<fa;N++){M=c(H[N],ea[N],K);e(M.x,M.y,-I)}J=0;for(D=q.length;J<D;J++){A=q[J];ra=S[J];N=0;for(fa=A.length;N<fa;N++){M=c(A[N],ra[N],K);e(M.x,M.y,-I)}}}K=j;for(N=0;N<T;N++){M=n?c(E[N],
  688. wa[N],K):E[N];if(p){z.copy(v.normals[0]).multiplyScalar(M.x);s.copy(v.binormals[0]).multiplyScalar(M.y);w.copy(o[0]).addSelf(z).addSelf(s);e(w.x,w.y,w.z)}else e(M.x,M.y,0)}for(A=1;A<=m;A++)for(N=0;N<T;N++){M=n?c(E[N],wa[N],K):E[N];if(p){z.copy(v.normals[A]).multiplyScalar(M.x);s.copy(v.binormals[A]).multiplyScalar(M.y);w.copy(o[A]).addSelf(z).addSelf(s);e(w.x,w.y,w.z)}else e(M.x,M.y,h/m*A)}for(L=l-1;L>=0;L--){A=L/l;I=i*(1-A);K=j*Math.sin(A*Math.PI/2);N=0;for(fa=H.length;N<fa;N++){M=c(H[N],ea[N],K);
  689. e(M.x,M.y,h+I)}J=0;for(D=q.length;J<D;J++){A=q[J];ra=S[J];N=0;for(fa=A.length;N<fa;N++){M=c(A[N],ra[N],K);p?e(M.x,M.y+o[m-1].y,o[m-1].x+I):e(M.x,M.y,h+I)}}}if(n){i=T*0;for(N=0;N<Z;N++){h=Q[N];g(h[2]+i,h[1]+i,h[0]+i,true)}i=T*(m+l*2);for(N=0;N<Z;N++){h=Q[N];g(h[0]+i,h[1]+i,h[2]+i,false)}}else{for(N=0;N<Z;N++){h=Q[N];g(h[2],h[1],h[0],true)}for(N=0;N<Z;N++){h=Q[N];g(h[0]+T*m,h[1]+T*m,h[2]+T*m,false)}}h=0;f(H,h);h=h+H.length;J=0;for(D=q.length;J<D;J++){A=q[J];f(A,h);h=h+A.length}};
  690. THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d,f,e){b=a.vertices[f].x;f=a.vertices[f].y;c=a.vertices[e].x;e=a.vertices[e].y;return[new THREE.UV(a.vertices[d].x,a.vertices[d].y),new THREE.UV(b,f),new THREE.UV(c,e)]},generateBottomUV:function(a,b,c,d,f,e){return this.generateTopUV(a,b,c,d,f,e)},generateSideWallUV:function(a,b,c,d,f,e,g,h){var b=a.vertices[f].x,c=a.vertices[f].y,f=a.vertices[f].z,d=a.vertices[e].x,i=a.vertices[e].y,e=a.vertices[e].z,j=a.vertices[g].x,l=a.vertices[g].y,
  691. g=a.vertices[g].z,n=a.vertices[h].x,m=a.vertices[h].y,a=a.vertices[h].z;return Math.abs(c-i)<0.01?[new THREE.UV(b,1-f),new THREE.UV(d,1-e),new THREE.UV(j,1-g),new THREE.UV(n,1-a)]:[new THREE.UV(c,1-f),new THREE.UV(i,1-e),new THREE.UV(l,1-g),new THREE.UV(m,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;
  692. THREE.ExtrudeGeometry.__v6=new THREE.Vector2;THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);a instanceof Array===false&&(a=[a]);this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this};
  693. THREE.ShapeGeometry.prototype.addShape=function(a,b){b===void 0&&(b={});var c=b.material,d=b.UVGenerator===void 0?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,f,e,g,h=this.vertices.length;f=a.extractPoints();var i=f.shape,j=f.holes;if(!THREE.Shape.Utils.isClockWise(i)){i=i.reverse();f=0;for(e=j.length;f<e;f++){g=j[f];THREE.Shape.Utils.isClockWise(g)&&(j[f]=g.reverse())}}var l=THREE.Shape.Utils.triangulateShape(i,j);f=0;for(e=j.length;f<e;f++){g=j[f];i=i.concat(g)}j=i.length;e=l.length;for(f=
  694. 0;f<j;f++){g=i[f];this.vertices.push(new THREE.Vector3(g.x,g.y,0))}for(f=0;f<e;f++){j=l[f];i=j[2]+h;g=j[1]+h;j=j[0]+h;this.faces.push(new THREE.Face3(i,g,j,null,null,c));this.faceVertexUvs[0].push(d.generateBottomUV(this,a,b,i,g,j))}};
  695. THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);for(var b=b||12,c=c||2*Math.PI,d=[],f=(new THREE.Matrix4).makeRotationZ(c/b),e=0;e<a.length;e++){d[e]=a[e].clone();this.vertices.push(d[e])}for(var g=b+1,c=0;c<g;c++)for(e=0;e<d.length;e++){d[e]=f.multiplyVector3(d[e].clone());this.vertices.push(d[e])}for(c=0;c<b;c++){d=0;for(f=a.length;d<f-1;d++){this.faces.push(new THREE.Face4(c*f+d,(c+1)%g*f+d,(c+1)%g*f+(d+1)%f,c*f+(d+1)%f));this.faceVertexUvs[0].push([new THREE.UV(1-c/b,d/f),new THREE.UV(1-
  696. (c+1)/b,d/f),new THREE.UV(1-(c+1)/b,(d+1)/f),new THREE.UV(1-c/b,(d+1)/f)])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);
  697. THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var f=a/2,e=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,j=b/d,l=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vector3(b*i-f,-(a*j-e),0));for(a=0;a<d;a++)for(b=0;b<c;b++){f=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a);f.normal.copy(l);f.vertexNormals.push(l.clone(),l.clone(),l.clone(),l.clone());this.faces.push(f);this.faceVertexUvs[0].push([new THREE.UV(b/c,1-a/d),new THREE.UV(b/c,1-(a+1)/d),new THREE.UV((b+
  698. 1)/c,1-(a+1)/d),new THREE.UV((b+1)/c,1-a/d)])}this.computeCentroids()};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);
  699. THREE.SphereGeometry=function(a,b,c,d,f,e,g){THREE.Geometry.call(this);var a=a||50,d=d!==void 0?d:0,f=f!==void 0?f:Math.PI*2,e=e!==void 0?e:0,g=g!==void 0?g:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,i,j=[],l=[];for(i=0;i<=c;i++){var n=[],m=[];for(h=0;h<=b;h++){var q=h/b,o=i/c,p=new THREE.Vector3;p.x=-a*Math.cos(d+q*f)*Math.sin(e+o*g);p.y=a*Math.cos(e+o*g);p.z=a*Math.sin(d+q*f)*Math.sin(e+o*g);this.vertices.push(p);n.push(this.vertices.length-1);m.push(new THREE.UV(q,
  700. 1-o))}j.push(n);l.push(m)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=j[i][h+1],f=j[i][h],e=j[i+1][h],g=j[i+1][h+1],n=this.vertices[d].clone().normalize(),m=this.vertices[f].clone().normalize(),q=this.vertices[e].clone().normalize(),o=this.vertices[g].clone().normalize(),p=l[i][h+1].clone(),r=l[i][h].clone(),t=l[i+1][h].clone(),u=l[i+1][h+1].clone();if(Math.abs(this.vertices[d].y)==a){this.faces.push(new THREE.Face3(d,e,g,[n,q,o]));this.faceVertexUvs[0].push([p,t,u])}else if(Math.abs(this.vertices[e].y)==
  701. a){this.faces.push(new THREE.Face3(d,f,e,[n,m,q]));this.faceVertexUvs[0].push([p,r,t])}else{this.faces.push(new THREE.Face4(d,f,e,g,[n,m,q,o]));this.faceVertexUvs[0].push([p,r,t,u])}}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype);
  702. THREE.TextGeometry=function(a,b){var c=THREE.FontUtils.generateShapes(a,b);b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=false;THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype);
  703. THREE.TorusGeometry=function(a,b,c,d,f){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=f||Math.PI*2;f=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var e=d/this.segmentsT*this.arc,g=c/this.segmentsR*Math.PI*2;f.x=this.radius*Math.cos(e);f.y=this.radius*Math.sin(e);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(e);h.y=(this.radius+this.tube*Math.cos(g))*Math.sin(e);h.z=
  704. this.tube*Math.sin(g);this.vertices.push(h);a.push(new THREE.UV(d/this.segmentsT,c/this.segmentsR));b.push(h.clone().subSelf(f).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var f=(this.segmentsT+1)*c+d-1,e=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(f,e,g,h,[b[f],b[e],b[g],b[h]]);i.normal.addSelf(b[f]);i.normal.addSelf(b[e]);i.normal.addSelf(b[g]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);this.faceVertexUvs[0].push([a[f].clone(),
  705. a[e].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);
  706. THREE.TorusKnotGeometry=function(a,b,c,d,f,e,g){function h(a,b,c,d,e,f){var g=Math.cos(a);Math.cos(b);b=Math.sin(a);a=c/d*a;c=Math.cos(a);g=e*(2+c)*0.5*g;b=e*(2+c)*b*0.5;e=f*e*Math.sin(a)*0.5;return new THREE.Vector3(g,b,e)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=f||2;this.q=e||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=
  707. Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var i=a/this.segmentsR*2*this.p*Math.PI,g=b/this.segmentsT*2*Math.PI,e=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.sub(i,e);d.add(i,e);f.cross(c,d);d.cross(f,c);f.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);e.x=e.x+(i*d.x+g*f.x);e.y=e.y+(i*d.y+g*f.y);e.z=e.z+(i*d.z+g*f.z);this.grid[a][b]=this.vertices.push(new THREE.Vector3(e.x,e.y,e.z))-1}}for(a=0;a<
  708. this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var f=(a+1)%this.segmentsR,e=(b+1)%this.segmentsT,c=this.grid[a][b],d=this.grid[f][b],f=this.grid[f][e],e=this.grid[a][e],g=new THREE.UV(a/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(c,d,f,e));this.faceVertexUvs[0].push([g,i,j,l])}this.computeCentroids();this.computeFaceNormals();
  709. this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);
  710. THREE.TubeGeometry=function(a,b,c,d,f,e){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.segmentsRadius=d||8;this.closed=f||false;if(e)this.debug=new THREE.Object3D;this.grid=[];var g,h,e=this.segments+1,i,j,l,n=new THREE.Vector3,m,q,o,b=new THREE.TubeGeometry.FrenetFrames(a,b,f);m=b.tangents;q=b.normals;o=b.binormals;this.tangents=m;this.normals=q;this.binormals=o;for(b=0;b<e;b++){this.grid[b]=[];d=b/(e-1);l=a.getPointAt(d);d=m[b];g=q[b];h=o[b];if(this.debug){this.debug.add(new THREE.ArrowHelper(d,
  711. l,c,255));this.debug.add(new THREE.ArrowHelper(g,l,c,16711680));this.debug.add(new THREE.ArrowHelper(h,l,c,65280))}for(d=0;d<this.segmentsRadius;d++){i=d/this.segmentsRadius*2*Math.PI;j=-this.radius*Math.cos(i);i=this.radius*Math.sin(i);n.copy(l);n.x=n.x+(j*g.x+i*h.x);n.y=n.y+(j*g.y+i*h.y);n.z=n.z+(j*g.z+i*h.z);this.grid[b][d]=this.vertices.push(new THREE.Vector3(n.x,n.y,n.z))-1}}for(b=0;b<this.segments;b++)for(d=0;d<this.segmentsRadius;d++){e=f?(b+1)%this.segments:b+1;n=(d+1)%this.segmentsRadius;
  712. a=this.grid[b][d];c=this.grid[e][d];e=this.grid[e][n];n=this.grid[b][n];m=new THREE.UV(b/this.segments,d/this.segmentsRadius);q=new THREE.UV((b+1)/this.segments,d/this.segmentsRadius);o=new THREE.UV((b+1)/this.segments,(d+1)/this.segmentsRadius);g=new THREE.UV(b/this.segments,(d+1)/this.segmentsRadius);this.faces.push(new THREE.Face4(a,c,e,n));this.faceVertexUvs[0].push([m,q,o,g])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
  713. THREE.TubeGeometry.FrenetFrames=function(a,b,c){new THREE.Vector3;var d=new THREE.Vector3;new THREE.Vector3;var f=[],e=[],g=[],h=new THREE.Vector3,i=new THREE.Matrix4,b=b+1,j,l,n;this.tangents=f;this.normals=e;this.binormals=g;for(j=0;j<b;j++){l=j/(b-1);f[j]=a.getTangentAt(l);f[j].normalize()}e[0]=new THREE.Vector3;g[0]=new THREE.Vector3;a=Number.MAX_VALUE;j=Math.abs(f[0].x);l=Math.abs(f[0].y);n=Math.abs(f[0].z);if(j<=a){a=j;d.set(1,0,0)}if(l<=a){a=l;d.set(0,1,0)}n<=a&&d.set(0,0,1);h.cross(f[0],d).normalize();
  714. e[0].cross(f[0],h);g[0].cross(f[0],e[0]);for(j=1;j<b;j++){e[j]=e[j-1].clone();g[j]=g[j-1].clone();h.cross(f[j-1],f[j]);if(h.length()>1E-4){h.normalize();d=Math.acos(f[j-1].dot(f[j]));i.makeRotationAxis(h,d).multiplyVector3(e[j])}g[j].cross(f[j],e[j])}if(c){d=Math.acos(e[0].dot(e[b-1]));d=d/(b-1);f[0].dot(h.cross(e[0],e[b-1]))>0&&(d=-d);for(j=1;j<b;j++){i.makeRotationAxis(f[j],d*j).multiplyVector3(e[j]);g[j].cross(f[j],e[j])}}};
  715. THREE.PolyhedronGeometry=function(a,b,c,d){function f(a){var b=a.normalize().clone();b.index=i.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+0.5,a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+0.5;b.uv=new THREE.UV(c,1-a);return b}function e(a,b,c,d){if(d<1){d=new THREE.Face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()]);d.centroid.addSelf(a).addSelf(b).addSelf(c).divideScalar(3);d.normal=d.centroid.clone().normalize();i.faces.push(d);d=Math.atan2(d.centroid.z,-d.centroid.x);
  716. i.faceVertexUvs[0].push([h(a.uv,a,d),h(b.uv,b,d),h(c.uv,c,d)])}else{d=d-1;e(a,g(a,b),g(a,c),d);e(g(a,b),b,g(b,c),d);e(g(a,c),g(b,c),c,d);e(g(a,b),g(b,c),g(a,c),d)}}function g(a,b){n[a.index]||(n[a.index]=[]);n[b.index]||(n[b.index]=[]);var c=n[a.index][b.index];c===void 0&&(n[a.index][b.index]=n[b.index][a.index]=c=f((new THREE.Vector3).add(a,b).divideScalar(2)));return c}function h(a,b,c){c<0&&a.u===1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);
  717. for(var c=c||1,d=d||0,i=this,j=0,l=a.length;j<l;j++)f(new THREE.Vector3(a[j][0],a[j][1],a[j][2]));for(var n=[],a=this.vertices,j=0,l=b.length;j<l;j++)e(a[b[j][0]],a[b[j][1]],a[b[j][2]],d);this.mergeVertices();j=0;for(l=this.vertices.length;j<l;j++)this.vertices[j].multiplyScalar(c);this.computeCentroids();this.boundingSphere={radius:c}};THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
  718. THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[[-1,c,0],[1,c,0],[-1,-c,0],[1,-c,0],[0,-1,c],[0,1,c],[0,-1,-c],[0,1,-c],[c,0,-1],[c,0,1],[-c,0,-1],[-c,0,1]],[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]],a,b)};THREE.IcosahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
  719. THREE.OctahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],[[0,2,4],[0,4,3],[0,3,5],[0,5,2],[1,2,5],[1,5,3],[1,3,4],[1,4,2]],a,b)};THREE.OctahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],[[2,1,0],[0,3,2],[1,3,0],[2,3,1]],a,b)};THREE.TetrahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
  720. THREE.ParametricGeometry=function(a,b,c,d){THREE.Geometry.call(this);var f=this.vertices,e=this.faces,g=this.faceVertexUvs[0],d=d===void 0?false:d,h,i,j,l,n=b+1;for(h=0;h<=c;h++){l=h/c;for(i=0;i<=b;i++){j=i/b;j=a(j,l);f.push(j)}}var m,q,o,p;for(h=0;h<c;h++)for(i=0;i<b;i++){a=h*n+i;f=h*n+i+1;l=(h+1)*n+i;j=(h+1)*n+i+1;m=new THREE.UV(i/b,h/c);q=new THREE.UV((i+1)/b,h/c);o=new THREE.UV(i/b,(h+1)/c);p=new THREE.UV((i+1)/b,(h+1)/c);if(d){e.push(new THREE.Face3(a,f,l));e.push(new THREE.Face3(f,j,l));g.push([m,
  721. q,o]);g.push([q,p,o])}else{e.push(new THREE.Face4(a,f,j,l));g.push([m,q,p,o])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype);
  722. THREE.ConvexGeometry=function(a){function b(a){var b=a.length();return new THREE.UV(a.x/b,a.y/b)}THREE.Geometry.call(this);for(var c=[[0,1,2],[0,2,1]],d=3;d<a.length;d++){var f=d,e=a[f].clone(),g=e.length();e.x=e.x+g*(Math.random()-0.5)*2E-6;e.y=e.y+g*(Math.random()-0.5)*2E-6;e.z=e.z+g*(Math.random()-0.5)*2E-6;for(var g=[],h=0;h<c.length;){var i=c[h],j=e,l=a[i[0]],n;n=l;var m=a[i[1]],q=a[i[2]],o=new THREE.Vector3,p=new THREE.Vector3;o.sub(q,m);p.sub(n,m);o.crossSelf(p);o.isZero()||o.normalize();n=
  723. o;l=n.dot(l);if(n.dot(j)>=l){for(j=0;j<3;j++){l=[i[j],i[(j+1)%3]];n=true;for(m=0;m<g.length;m++)if(g[m][0]===l[1]&&g[m][1]===l[0]){g[m]=g[g.length-1];g.pop();n=false;break}n&&g.push(l)}c[h]=c[c.length-1];c.pop()}else h++}for(m=0;m<g.length;m++)c.push([g[m][0],g[m][1],f])}f=0;e=Array(a.length);for(d=0;d<c.length;d++){g=c[d];for(h=0;h<3;h++){if(e[g[h]]===void 0){e[g[h]]=f++;this.vertices.push(a[g[h]])}g[h]=e[g[h]]}}for(d=0;d<c.length;d++)this.faces.push(new THREE.Face3(c[d][0],c[d][1],c[d][2]));for(d=
  724. 0;d<this.faces.length;d++){g=this.faces[d];this.faceVertexUvs[0].push([b(this.vertices[g.a]),b(this.vertices[g.b]),b(this.vertices[g.c])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ConvexGeometry.prototype=Object.create(THREE.Geometry.prototype);
  725. THREE.AxisHelper=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3);a.vertices.push(new THREE.Vector3(0,100,0));var b=new THREE.CylinderGeometry(0,5,25,5,1),c;c=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(c);
  726. c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.AxisHelper.prototype=Object.create(THREE.Object3D.prototype);
  727. THREE.ArrowHelper=function(a,b,c,d){THREE.Object3D.call(this);d===void 0&&(d=16776960);c===void 0&&(c=20);var f=new THREE.Geometry;f.vertices.push(new THREE.Vector3(0,0,0));f.vertices.push(new THREE.Vector3(0,1,0));this.line=new THREE.Line(f,new THREE.LineBasicMaterial({color:d}));this.add(this.line);f=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(f,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);if(b instanceof THREE.Vector3)this.position=
  728. b;this.setDirection(a);this.setLength(c)};THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.setDirection=function(a){var b=(new THREE.Vector3(0,1,0)).crossSelf(a),a=Math.acos((new THREE.Vector3(0,1,0)).dot(a.clone().normalize()));this.matrix=(new THREE.Matrix4).makeRotationAxis(b.normalize(),a);this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};THREE.ArrowHelper.prototype.setLength=function(a){this.scale.set(a,a,a)};
  729. THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};
  730. THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.geometry.vertices.push(new THREE.Vector3);d.geometry.colors.push(new THREE.Color(b));d.pointMap[a]===void 0&&(d.pointMap[a]=[]);d.pointMap[a].push(d.geometry.vertices.length-1)}THREE.Line.call(this);var d=this;this.geometry=new THREE.Geometry;this.material=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors});this.type=THREE.LinePieces;this.matrixWorld=a.matrixWorld;this.matrixAutoUpdate=false;this.pointMap=
  731. {};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1",
  732. "cf2",3355443);b("cf3","cf4",3355443);this.camera=a;this.update(a)};THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype);
  733. THREE.CameraHelper.prototype.update=function(){function a(a,d,f,e){THREE.CameraHelper.__v.set(d,f,e);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=b.pointMap[a];if(a!==void 0){d=0;for(f=a.length;d<f;d++)b.geometry.vertices[a[d]].copy(THREE.CameraHelper.__v)}}var b=this;THREE.CameraHelper.__c.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);
  734. a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",0.7,1.1,-1);a("u2",-0.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);this.geometry.verticesNeedUpdate=true};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
  735. THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=false;this.supportUVs=true;this.debug=false};THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};function orderedKey(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}
  736. var G={computeEdgeFaces:function(a){function b(a,b){g[a]===void 0&&(g[a]=[]);g[a].push(b)}var c,d,f,e,g={};c=0;for(d=a.faces.length;c<d;c++){f=a.faces[c];if(f instanceof THREE.Face3){e=orderedKey(f.a,f.b);b(e,c);e=orderedKey(f.b,f.c);b(e,c);e=orderedKey(f.c,f.a);b(e,c)}else if(f instanceof THREE.Face4){e=orderedKey(f.a,f.b);b(e,c);e=orderedKey(f.b,f.c);b(e,c);e=orderedKey(f.c,f.d);b(e,c);e=orderedKey(f.d,f.a);b(e,c)}}return g}};
  737. THREE.SubdivisionModifier.prototype.smooth=function(a){function b(){l.debug&&(console&&console.assert)&&console.assert.apply(console,arguments)}function c(){l.debug&&console.log.apply(console,arguments)}function d(){console&&console.log.apply(console,arguments)}function f(a,b,d,f,g,h,m){var n=new THREE.Face4(a,b,d,f,null,g.color,g.materialIndex);if(l.useOldVertexColors){n.vertexColors=[];for(var o,p,q,r=0;r<4;r++){q=h[r];o=new THREE.Color;o.setRGB(0,0,0);for(var s=0;s<q.length;s++){p=g.vertexColors[q[s]-
  738. 1];o.r=o.r+p.r;o.g=o.g+p.g;o.b=o.b+p.b}o.r=o.r/q.length;o.g=o.g/q.length;o.b=o.b/q.length;n.vertexColors[r]=o}}i.push(n);if(l.supportUVs){g=[e(a,""),e(b,m),e(d,m),e(f,m)];g[0]?g[1]?g[2]?g[3]?j.push(g):c("d :( ",f+":"+m):c("c :( ",d+":"+m):c("b :( ",b+":"+m):c("a :( ",a+":"+m)}}function e(a,b){var e=a+":"+b,f=t[e];if(!f){a>=q&&a<q+m.length?c("face pt"):c("edge pt");d("warning, UV not found for",e);return null}return f}function g(a,b,c){var e=a+":"+b;e in t?d("dup vertexNo",a,"oldFaceNo",b,"value",
  739. c,"key",e,t[e]):t[e]=c}var h=[],i=[],j=[],l=this,n=a.vertices,m=a.faces,q=n.length,h=n.concat(),o=[],p={},r={},t={},u,v,s,z,w,A=a.faceVertexUvs[0],J;c("originalFaces, uvs, originalVerticesLength",m.length,A.length,q);if(l.supportUVs){u=0;for(v=A.length;u<v;u++){s=0;for(z=A[u].length;s<z;s++){J=m[u]["abcd".charAt(s)];g(J,u,A[u][s])}}}if(A.length==0)l.supportUVs=false;u=0;for(var D in t)u++;if(!u){l.supportUVs=false;c("no uvs")}u=0;for(v=m.length;u<v;u++){w=m[u];o.push(w.centroid);h.push(w.centroid);
  740. if(l.supportUVs){z=new THREE.UV;if(w instanceof THREE.Face3){z.u=e(w.a,u).u+e(w.b,u).u+e(w.c,u).u;z.v=e(w.a,u).v+e(w.b,u).v+e(w.c,u).v;z.u=z.u/3;z.v=z.v/3}else if(w instanceof THREE.Face4){z.u=e(w.a,u).u+e(w.b,u).u+e(w.c,u).u+e(w.d,u).u;z.v=e(w.a,u).v+e(w.b,u).v+e(w.c,u).v+e(w.d,u).v;z.u=z.u/4;z.v=z.v/4}g(q+u,"",z)}}D=G.computeEdgeFaces(a);var F,B;v=0;var E,H,A={};J={};for(u in D){F=D[u];E=u.split("_");H=E[0];E=E[1];s=H;w=[H,E];A[s]===void 0&&(A[s]=[]);A[s].push(w);s=E;w=[H,E];A[s]===void 0&&(A[s]=
  741. []);A[s].push(w);s=0;for(z=F.length;s<z;s++){w=F[s];B=H;var Q=w,L=u;J[B]===void 0&&(J[B]={});J[B][Q]=L;B=E;Q=u;J[B]===void 0&&(J[B]={});J[B][w]=Q}F.length<2&&(r[u]=true)}for(u in D){F=D[u];w=F[0];B=F[1];E=u.split("_");H=E[0];E=E[1];z=new THREE.Vector3;b(F.length>0,"an edge without faces?!");if(F.length==1){z.addSelf(n[H]);z.addSelf(n[E]);z.multiplyScalar(0.5)}else{z.addSelf(o[w]);z.addSelf(o[B]);z.addSelf(n[H]);z.addSelf(n[E]);z.multiplyScalar(0.25)}p[u]=q+m.length+v;h.push(z);v++;if(l.supportUVs){z=
  742. new THREE.UV;z.u=e(H,w).u+e(E,w).u;z.v=e(H,w).v+e(E,w).v;z.u=z.u/2;z.v=z.v/2;g(p[u],w,z);if(F.length>=2){b(F.length==2,"did we plan for more than 2 edges?");z=new THREE.UV;z.u=e(H,B).u+e(E,B).u;z.v=e(H,B).v+e(E,B).v;z.u=z.u/2;z.v=z.v/2;g(p[u],B,z)}}}c("-- Step 2 done");console.log("facePoints",o,"edgePoints",p);console.log("edgeFaceMap",D,"vertexEdgeMap",A);var K,I;z=["123","12","2","23"];B=["123","23","3","31"];var Q=["123","31","1","12"],L=["1234","12","2","23"],M=["1234","23","3","34"],T=["1234",
  743. "34","4","41"],Z=["1234","41","1","12"];u=0;for(v=o.length;u<v;u++){w=m[u];F=q+u;if(w instanceof THREE.Face3){H=orderedKey(w.a,w.b);E=orderedKey(w.b,w.c);K=orderedKey(w.c,w.a);f(F,p[H],w.b,p[E],w,z,u);f(F,p[E],w.c,p[K],w,B,u);f(F,p[K],w.a,p[H],w,Q,u)}else if(w instanceof THREE.Face4){H=orderedKey(w.a,w.b);E=orderedKey(w.b,w.c);K=orderedKey(w.c,w.d);I=orderedKey(w.d,w.a);f(F,p[H],w.b,p[E],w,L,u);f(F,p[E],w.c,p[K],w,M,u);f(F,p[K],w.d,p[I],w,T,u);f(F,p[I],w.a,p[H],w,Z,u)}else c("face should be a face!",
  744. w)}p=new THREE.Vector3;w=new THREE.Vector3;u=0;for(v=n.length;u<v;u++)if(A[u]!==void 0){p.set(0,0,0);w.set(0,0,0);E=new THREE.Vector3(0,0,0);F=0;for(s in J[u]){p.addSelf(o[s]);F++}B=0;H=A[u].length;z=F!=H;for(s=0;s<H;s++)r[orderedKey(A[u][s][0],A[u][s][1])]&&B++;p.divideScalar(F);B=0;if(z){for(s=0;s<H;s++){F=A[u][s];if(Q=D[orderedKey(F[0],F[1])].length==1){F=n[F[0]].clone().addSelf(n[F[1]]).divideScalar(2);w.addSelf(F);B++}}w.divideScalar(4);b(B==2,"should have only 2 boundary edges")}else{for(s=
  745. 0;s<H;s++){F=A[u][s];F=n[F[0]].clone().addSelf(n[F[1]]).divideScalar(2);w.addSelf(F)}w.divideScalar(H)}E.addSelf(n[u]);if(z){E.divideScalar(2);E.addSelf(w)}else{E.multiplyScalar(H-3);E.addSelf(p);E.addSelf(w.multiplyScalar(2));E.divideScalar(H)}h[u]=E}a.vertices=h;a.faces=i;a.faceVertexUvs[0]=j;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};
  746. THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare=function(a,b,c,d,f){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;a!==void 0&&this.add(a,b,c,d,f)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype);
  747. THREE.LensFlare.prototype.add=function(a,b,c,d,f,e){b===void 0&&(b=-1);c===void 0&&(c=0);e===void 0&&(e=1);f===void 0&&(f=new THREE.Color(16777215));if(d===void 0)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:e,color:f,blending:d})};
  748. THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=-this.positionScreen.x*2,f=-this.positionScreen.y*2;for(a=0;a<b;a++){c=this.lensFlares[a];c.x=this.positionScreen.x+d*c.distance;c.y=this.positionScreen.y+f*c.distance;c.wantedRotation=c.x*Math.PI*0.25;c.rotation=c.rotation+(c.wantedRotation-c.rotation)*0.25}};
  749. THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)};THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype);
  750. THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={startFrame:b,endFrame:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:false,time:0,direction:1,weight:1,directionBackwards:false,mirroredLoop:false};this.animationsMap[a]=b;this.animationsList.push(b)};
  751. THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)(\d+)/,c,d={},f=this.geometry,e=0,g=f.morphTargets.length;e<g;e++){var h=f.morphTargets[e].name.match(b);if(h&&h.length>1){var i=h[1];d[i]||(d[i]={start:Infinity,end:-Infinity});h=d[i];if(e<h.start)h.start=e;if(e>h.end)h.end=e;c||(c=i)}}for(i in d){h=d[i];this.createAnimation(i,h.start,h.end,a)}this.firstAnimation=c};
  752. THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a]){a.direction=1;a.directionBackwards=false}};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a]){a.direction=-1;a.directionBackwards=true}};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];if(c){c.fps=b;c.duration=(c.end-c.start)/c.fps}};
  753. THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];if(c){c.duration=b;c.fps=(c.end-c.start)/c.duration}};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];if(c)c.weight=b};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];if(c)c.time=b};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
  754. THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];if(b){b.time=0;b.active=true}else console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=false};
  755. THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var f=d.duration/d.length;d.time=d.time+d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<0)d.time=d.time+d.duration}var e=d.startFrame+THREE.Math.clamp(Math.floor(d.time/
  756. f),0,d.length-1),g=d.weight;if(e!==d.currentFrame){this.morphTargetInfluences[d.lastFrame]=0;this.morphTargetInfluences[d.currentFrame]=1*g;this.morphTargetInfluences[e]=0;d.lastFrame=d.currentFrame;d.currentFrame=e}f=d.time%f/f;d.directionBackwards&&(f=1-f);this.morphTargetInfluences[d.currentFrame]=f*g;this.morphTargetInfluences[d.lastFrame]=(1-f)*g}}};
  757. THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,f,e,g,h,i,j,l,n,m,q;this.init=function(o){b=o.context;c=o;d=new Float32Array(16);f=new Uint16Array(6);o=0;d[o++]=-1;d[o++]=-1;d[o++]=0;d[o++]=0;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=
  758. 0;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=0;d[o++]=1;o=0;f[o++]=0;f[o++]=1;f[o++]=2;f[o++]=0;f[o++]=2;f[o++]=3;e=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
  759. b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
  760. b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){j=false;l=a(THREE.ShaderFlares.lensFlare)}else{j=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}n={};m={};n.vertex=b.getAttribLocation(l,"position");n.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l,
  761. "color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");q=false};this.render=function(a,d,f,t){var a=a.__webglFlares,u=a.length;if(u){var v=new THREE.Vector3,s=t/f,z=f*0.5,w=t*0.5,A=16/t,J=new THREE.Vector2(A*s,A),D=new THREE.Vector3(1,1,0),F=new THREE.Vector2(1,1),B=m,A=n;b.useProgram(l);if(!q){b.enableVertexAttribArray(n.vertex);b.enableVertexAttribArray(n.uv);q=true}b.uniform1i(B.occlusionMap,0);b.uniform1i(B.map,
  762. 1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(A.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(A.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var E,H,Q,L,K;for(E=0;E<u;E++){A=16/t;J.set(A*s,A);L=a[E];v.set(L.matrixWorld.elements[12],L.matrixWorld.elements[13],L.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(v);d.projectionMatrix.multiplyVector3(v);D.copy(v);F.x=D.x*z+z;F.y=D.y*w+w;if(j||F.x>0&&F.x<f&&F.y>0&&
  763. F.y<t){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,F.x-8,F.y-8,16,16,0);b.uniform1i(B.renderType,0);b.uniform2f(B.scale,J.x,J.y);b.uniform3f(B.screenPosition,D.x,D.y,D.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,F.x-8,F.y-8,16,16,0);b.uniform1i(B.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
  764. b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);L.positionScreen.copy(D);L.customUpdateCallback?L.customUpdateCallback(L):L.updateLensFlares();b.uniform1i(B.renderType,2);b.enable(b.BLEND);H=0;for(Q=L.lensFlares.length;H<Q;H++){K=L.lensFlares[H];if(K.opacity>0.001&&K.scale>0.001){D.x=K.x;D.y=K.y;D.z=K.z;A=K.size*K.scale/t;J.x=A*s;J.y=A;b.uniform3f(B.screenPosition,D.x,D.y,D.z);b.uniform2f(B.scale,J.x,J.y);b.uniform1f(B.rotation,K.rotation);b.uniform1f(B.opacity,K.opacity);
  765. b.uniform3f(B.color,K.color.r,K.color.g,K.color.b);c.setBlending(K.blending,K.blendEquation,K.blendSrc,K.blendDst);c.setTexture(K.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
  766. THREE.ShadowMapPlugin=function(){var a,b,c,d,f,e,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,
  767. vertexShader:g.vertexShader,uniforms:h,skinning:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;f._shadowPass=true;e._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(l,n){var m,q,o,p,r,t,u,v,s,z=[];p=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces?
  768. a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);m=0;for(q=l.__lights.length;m<q;m++){o=l.__lights[m];if(o.castShadow)if(o instanceof THREE.DirectionalLight&&o.shadowCascade)for(r=0;r<o.shadowCascadeCount;r++){var w;if(o.shadowCascadeArray[r])w=o.shadowCascadeArray[r];else{s=o;u=r;w=new THREE.DirectionalLight;w.isVirtual=true;w.onlyShadow=true;w.castShadow=true;w.shadowCameraNear=s.shadowCameraNear;w.shadowCameraFar=s.shadowCameraFar;w.shadowCameraLeft=s.shadowCameraLeft;w.shadowCameraRight=
  769. s.shadowCameraRight;w.shadowCameraBottom=s.shadowCameraBottom;w.shadowCameraTop=s.shadowCameraTop;w.shadowCameraVisible=s.shadowCameraVisible;w.shadowDarkness=s.shadowDarkness;w.shadowBias=s.shadowCascadeBias[u];w.shadowMapWidth=s.shadowCascadeWidth[u];w.shadowMapHeight=s.shadowCascadeHeight[u];w.pointsWorld=[];w.pointsFrustum=[];v=w.pointsWorld;t=w.pointsFrustum;for(var A=0;A<8;A++){v[A]=new THREE.Vector3;t[A]=new THREE.Vector3}v=s.shadowCascadeNearZ[u];s=s.shadowCascadeFarZ[u];t[0].set(-1,-1,v);
  770. t[1].set(1,-1,v);t[2].set(-1,1,v);t[3].set(1,1,v);t[4].set(-1,-1,s);t[5].set(1,-1,s);t[6].set(-1,1,s);t[7].set(1,1,s);w.originalCamera=n;t=new THREE.Gyroscope;t.position=o.shadowCascadeOffset;t.add(w);t.add(w.target);n.add(t);o.shadowCascadeArray[r]=w;console.log("Created virtualLight",w)}u=o;v=r;s=u.shadowCascadeArray[v];s.position.copy(u.position);s.target.position.copy(u.target.position);s.lookAt(s.target);s.shadowCameraVisible=u.shadowCameraVisible;s.shadowDarkness=u.shadowDarkness;s.shadowBias=
  771. u.shadowCascadeBias[v];t=u.shadowCascadeNearZ[v];u=u.shadowCascadeFarZ[v];s=s.pointsFrustum;s[0].z=t;s[1].z=t;s[2].z=t;s[3].z=t;s[4].z=u;s[5].z=u;s[6].z=u;s[7].z=u;z[p]=w;p++}else{z[p]=o;p++}}m=0;for(q=z.length;m<q;m++){o=z[m];if(!o.shadowMap){o.shadowMap=new THREE.WebGLRenderTarget(o.shadowMapWidth,o.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat});o.shadowMapSize=new THREE.Vector2(o.shadowMapWidth,o.shadowMapHeight);o.shadowMatrix=new THREE.Matrix4}if(!o.shadowCamera){if(o instanceof
  772. THREE.SpotLight)o.shadowCamera=new THREE.PerspectiveCamera(o.shadowCameraFov,o.shadowMapWidth/o.shadowMapHeight,o.shadowCameraNear,o.shadowCameraFar);else if(o instanceof THREE.DirectionalLight)o.shadowCamera=new THREE.OrthographicCamera(o.shadowCameraLeft,o.shadowCameraRight,o.shadowCameraTop,o.shadowCameraBottom,o.shadowCameraNear,o.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}l.add(o.shadowCamera);b.autoUpdateScene&&l.updateMatrixWorld()}if(o.shadowCameraVisible&&
  773. !o.cameraHelper){o.cameraHelper=new THREE.CameraHelper(o.shadowCamera);o.shadowCamera.add(o.cameraHelper)}if(o.isVirtual&&w.originalCamera==n){r=n;p=o.shadowCamera;t=o.pointsFrustum;s=o.pointsWorld;i.set(Infinity,Infinity,Infinity);j.set(-Infinity,-Infinity,-Infinity);for(u=0;u<8;u++){v=s[u];v.copy(t[u]);THREE.ShadowMapPlugin.__projector.unprojectVector(v,r);p.matrixWorldInverse.multiplyVector3(v);if(v.x<i.x)i.x=v.x;if(v.x>j.x)j.x=v.x;if(v.y<i.y)i.y=v.y;if(v.y>j.y)j.y=v.y;if(v.z<i.z)i.z=v.z;if(v.z>
  774. j.z)j.z=v.z}p.left=i.x;p.right=j.x;p.top=j.y;p.bottom=i.y;p.updateProjectionMatrix()}p=o.shadowMap;t=o.shadowMatrix;r=o.shadowCamera;r.position.copy(o.matrixWorld.getPosition());r.lookAt(o.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(o.cameraHelper)o.cameraHelper.visible=o.shadowCameraVisible;o.shadowCameraVisible&&o.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiplySelf(r.projectionMatrix);t.multiplySelf(r.matrixWorldInverse);
  775. if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);h.multiply(r.projectionMatrix,r.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(p);b.clear();s=l.__webglObjects;o=0;for(p=s.length;o<p;o++){u=s[o];t=u.object;u.render=false;if(t.visible&&t.castShadow&&(!(t instanceof THREE.Mesh)||!t.frustumCulled||
  776. g.contains(t))){t._modelViewMatrix.multiply(r.matrixWorldInverse,t.matrixWorld);u.render=true}}o=0;for(p=s.length;o<p;o++){u=s[o];if(u.render){t=u.object;u=u.buffer;v=t.customDepthMaterial?t.customDepthMaterial:t instanceof THREE.SkinnedMesh?t.geometry.morphTargets.length?e:f:t.geometry.morphTargets.length?d:c;u instanceof THREE.BufferGeometry?b.renderBufferDirect(r,l.__lights,null,v,u,t):b.renderBuffer(r,l.__lights,null,v,u,t)}}s=l.__webglObjectsImmediate;o=0;for(p=s.length;o<p;o++){u=s[o];t=u.object;
  777. if(t.visible&&t.castShadow){t._modelViewMatrix.multiply(r.matrixWorldInverse,t.matrixWorld);b.renderImmediateObject(r,l.__lights,null,c,t)}}}m=b.getClearColor();q=b.getClearAlpha();a.clearColor(m.r,m.g,m.b,q);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
  778. THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,f,e,g,h,i,j,l;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);f=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=0;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=0;d[a++]=1;a=0;f[a++]=0;f[a++]=1;f[a++]=2;f[a++]=0;f[a++]=2;f[a++]=3;e=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
  779. g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,m=b.createProgram(),q=b.createShader(b.FRAGMENT_SHADER),o=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,a.fragmentShader);b.shaderSource(o,a.vertexShader);b.compileShader(q);b.compileShader(o);b.attachShader(m,q);b.attachShader(m,o);b.linkProgram(m);h=m;i={};j={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");j.uvOffset=b.getUniformLocation(h,"uvOffset");j.uvScale=b.getUniformLocation(h,
  780. "uvScale");j.rotation=b.getUniformLocation(h,"rotation");j.scale=b.getUniformLocation(h,"scale");j.alignment=b.getUniformLocation(h,"alignment");j.color=b.getUniformLocation(h,"color");j.map=b.getUniformLocation(h,"map");j.opacity=b.getUniformLocation(h,"opacity");j.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");j.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");j.screenPosition=b.getUniformLocation(h,"screenPosition");j.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
  781. j.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");l=false};this.render=function(d,f,q,o){var d=d.__webglSprites,p=d.length;if(p){var r=i,t=j,u=o/q,q=q*0.5,v=o*0.5,s=true;b.useProgram(h);if(!l){b.enableVertexAttribArray(r.position);b.enableVertexAttribArray(r.uv);l=true}b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(true);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(r.position,2,b.FLOAT,false,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
  782. g);b.uniformMatrix4fv(t.projectionMatrix,false,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(t.map,0);for(var z,w=[],r=0;r<p;r++){z=d[r];if(z.visible&&z.opacity!==0)if(z.useScreenCoordinates)z.z=-z.position.z;else{z._modelViewMatrix.multiply(f.matrixWorldInverse,z.matrixWorld);z.z=-z._modelViewMatrix.elements[14]}}d.sort(a);for(r=0;r<p;r++){z=d[r];if(z.visible&&z.opacity!==0&&z.map&&z.map.image&&z.map.image.width){if(z.useScreenCoordinates){b.uniform1i(t.useScreenCoordinates,1);
  783. b.uniform3f(t.screenPosition,(z.position.x-q)/q,(v-z.position.y)/v,Math.max(0,Math.min(1,z.position.z)))}else{b.uniform1i(t.useScreenCoordinates,0);b.uniform1i(t.affectedByDistance,z.affectedByDistance?1:0);b.uniformMatrix4fv(t.modelViewMatrix,false,z._modelViewMatrix.elements)}f=z.map.image.width/(z.scaleByViewport?o:1);w[0]=f*u*z.scale.x;w[1]=f*z.scale.y;b.uniform2f(t.uvScale,z.uvScale.x,z.uvScale.y);b.uniform2f(t.uvOffset,z.uvOffset.x,z.uvOffset.y);b.uniform2f(t.alignment,z.alignment.x,z.alignment.y);
  784. b.uniform1f(t.opacity,z.opacity);b.uniform3f(t.color,z.color.r,z.color.g,z.color.b);b.uniform1f(t.rotation,z.rotation);b.uniform2fv(t.scale,w);if(z.mergeWith3D&&!s){b.enable(b.DEPTH_TEST);s=true}else if(!z.mergeWith3D&&s){b.disable(b.DEPTH_TEST);s=false}c.setBlending(z.blending,z.blendEquation,z.blendSrc,z.blendDst);c.setTexture(z.map,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
  785. THREE.DepthPassPlugin=function(){this.enabled=false;this.renderTarget=null;var a,b,c,d,f=new THREE.Frustum,e=new THREE.Matrix4;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render=
  786. function(a,b){this.enabled&&this.update(a,b)};this.update=function(g,h){var i,j,l,n,m,q;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.setDepthTest(true);b.autoUpdateScene&&g.updateMatrixWorld();if(!h._viewMatrixArray)h._viewMatrixArray=new Float32Array(16);if(!h._projectionMatrixArray)h._projectionMatrixArray=new Float32Array(16);h.matrixWorldInverse.getInverse(h.matrixWorld);h.matrixWorldInverse.flattenToArray(h._viewMatrixArray);h.projectionMatrix.flattenToArray(h._projectionMatrixArray);e.multiply(h.projectionMatrix,
  787. h.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(this.renderTarget);b.clear();q=g.__webglObjects;i=0;for(j=q.length;i<j;i++){l=q[i];m=l.object;l.render=false;if(m.visible&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||f.contains(m))){m._modelViewMatrix.multiply(h.matrixWorldInverse,m.matrixWorld);l.render=true}}i=0;for(j=q.length;i<j;i++){l=q[i];if(l.render){m=l.object;l=l.buffer;m.material&&b.setMaterialFaces(m.material);n=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?
  788. d:c;l instanceof THREE.BufferGeometry?b.renderBufferDirect(h,g.__lights,null,n,l,m):b.renderBuffer(h,g.__lights,null,n,l,m)}}q=g.__webglObjectsImmediate;i=0;for(j=q.length;i<j;i++){l=q[i];m=l.object;if(m.visible&&m.castShadow){m._modelViewMatrix.multiply(h.matrixWorldInverse,m.matrixWorld);b.renderImmediateObject(h,g.__lights,null,c,m)}}i=b.getClearColor();j=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,j);a.enable(a.BLEND)}};
  789. THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = ( visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n( visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
  790. lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}};
  791. THREE.ShaderSprite={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
  792. fragmentShader:"precision mediump float;\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\n}"}};