ThreeWebGL.js 235 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. // ThreeWebGL.js - http://github.com/mrdoob/three.js
  2. 'use strict';var THREE=THREE||{REVISION:"50dev"};self.console||(self.console={info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}});self.Int32Array||(self.Int32Array=Array,self.Float32Array=Array);
  3. (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)window.requestAnimationFrame=function(b){var c=Date.now(),e=Math.max(0,16-(c-a)),h=window.setTimeout(function(){b(c+e)},e);a=c+e;return h};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
  4. function(a){clearTimeout(a)}})();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;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;
  5. 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(){};THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;
  6. 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;THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;
  7. THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
  8. 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);
  9. 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=
  10. 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 Math.floor(this.r*255)<<16^Math.floor(this.g*255)<<8^Math.floor(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
  11. THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
  12. 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=
  13. 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)},
  14. 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(){return this.lengthSq()<1.0E-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};
  15. 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+
  16. 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=
  17. 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())},
  18. 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,
  19. 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],h=d[8],j=d[1],l=d[5],k=d[9],i=d[2],m=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-k,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(j,l);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(k));if(Math.abs(k)<
  20. 0.99999){this.y=Math.atan2(h,d);this.z=Math.atan2(j,l)}else{this.y=Math.atan2(-i,f);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(m));if(Math.abs(m)<0.99999){this.y=Math.atan2(-i,d);this.z=Math.atan2(-e,l)}else{this.y=0;this.z=Math.atan2(h,f)}}else if(b==="ZYX"){this.y=Math.asin(-c(i));if(Math.abs(i)<0.99999){this.x=Math.atan2(m,d);this.z=Math.atan2(j,f)}else{this.x=0;this.z=Math.atan2(-e,l)}}else if(b==="YZX"){this.z=Math.asin(c(j));if(Math.abs(j)<0.99999){this.x=Math.atan2(-k,l);this.y=Math.atan2(-i,
  21. f)}else{this.x=0;this.y=Math.atan2(i,d)}}else if(b==="XZY"){this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(m,l);this.y=Math.atan2(h,f)}else{this.x=Math.atan2(-h,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,h=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-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),h+d-f-e)}else if(b===
  22. "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),h-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-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),h-d-f+e);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-d+f-e)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-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),h+d-f-e)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z*
  23. a.y),h-d+f-e);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+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),h-d+f-e);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+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=
  24. 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(){return this.lengthSq()<1.0E-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};
  25. 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=
  26. 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())},
  27. 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*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1.0E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y=
  28. 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],h=a[1],j=a[5],l=a[9];c=a[2];b=a[6];var k=a[10];if(Math.abs(d-h)<0.01&&Math.abs(e-c)<0.01&&Math.abs(l-b)<0.01){if(Math.abs(d+h)<0.1&&Math.abs(e+c)<0.1&&Math.abs(l+b)<0.1&&Math.abs(f+j+k-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;j=(j+1)/2;k=(k+1)/2;d=(d+h)/4;e=(e+c)/4;l=(l+b)/4;if(f>j&&f>k)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(j>
  29. k)if(j<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(j);b=d/c;d=l/c}else if(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);b=e/d;c=l/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-l)*(b-l)+(e-c)*(e-c)+(h-d)*(h-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-l)/a;this.y=(e-c)/a;this.z=(h-d)/a;this.w=Math.acos((f+j+k-1)/2);return this}};
  30. 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]};
  31. 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],h=c[4],j=c[5],l=c[6],k=c[7],i=c[8],m=c[9],n=c[10],q=c[11],u=c[12],o=c[13],r=c[14],c=c[15];b[0].set(e-a,k-h,q-i,c-u);b[1].set(e+a,k+h,q+i,c+u);b[2].set(e+d,k+j,q+m,c+o);b[3].set(e-d,k-j,q-m,c-o);b[4].set(e-f,k-l,q-n,c-r);b[5].set(e+f,k+l,q+n,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))}};
  32. 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;
  33. THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3,n=new THREE.Vector3,q=function(a,b){return a.distance-b.distance},u=new THREE.Vector3,o=new THREE.Vector3,r=new THREE.Vector3,p,v,x,F=function(a,b,c){u.sub(c,a);p=u.dot(b);v=o.add(a,r.copy(b).multiplyScalar(p));
  34. return x=c.distanceTo(v)},s,I,A,N,D,H,G,R,U=function(a,b,c,d){u.sub(d,b);o.sub(c,b);r.sub(a,b);s=u.dot(u);I=u.dot(o);A=u.dot(r);N=o.dot(o);D=o.dot(r);H=1/(s*N-I*I);G=(N*A-I*D)*H;R=(s*D-I*A)*H;return G>=0&&R>=0&&G+R<1},T=1.0E-4;this.setPrecision=function(a){T=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var o=0,u=a.children.length;o<u;o++)Array.prototype.push.apply(d,this.intersectObject(a.children[o],b));if(a instanceof THREE.Particle){x=F(this.origin,this.direction,a.matrixWorld.getPosition());
  35. if(x>a.scale.x)return[];c={distance:x,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){o=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());o=a.geometry.boundingSphere.radius*Math.max(o.x,Math.max(o.y,o.z));x=F(this.origin,this.direction,a.matrixWorld.getPosition());if(x>o)return d;var r,p,s=a.geometry,v=s.vertices,A;a.matrixRotationWorld.extractRotation(a.matrixWorld);o=0;for(u=s.faces.length;o<
  36. u;o++){c=s.faces[o];l.copy(this.origin);k.copy(this.direction);A=a.matrixWorld;i=A.multiplyVector3(i.copy(c.centroid)).subSelf(l);m=a.matrixRotationWorld.multiplyVector3(m.copy(c.normal));r=k.dot(m);if(!(Math.abs(r)<T)){p=m.dot(i)/r;if(!(p<0)&&(a.doubleSided||(a.flipSided?r>0:r<0))){n.add(l,k.multiplyScalar(p));x=l.distanceTo(n);if(!(x<this.near)&&!(x>this.far))if(c instanceof THREE.Face3){f=A.multiplyVector3(f.copy(v[c.a]));e=A.multiplyVector3(e.copy(v[c.b]));h=A.multiplyVector3(h.copy(v[c.c]));
  37. if(U(n,f,e,h)){c={distance:x,point:n.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=A.multiplyVector3(f.copy(v[c.a]));e=A.multiplyVector3(e.copy(v[c.b]));h=A.multiplyVector3(h.copy(v[c.c]));j=A.multiplyVector3(j.copy(v[c.d]));if(U(n,f,e,j)||U(n,e,h,j)){c={distance:x,point:n.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(q);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],b));c.sort(q);
  38. return c}};
  39. THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b=0,c=0,d=0,f=0,e=0,h=0,j=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,h,i,m){j=false;b=e;c=h;d=i;f=m;a()};this.addPoint=function(e,h){if(j===true){j=false;b=e;c=h;d=e;f=h}else{b=b<e?b:e;c=c<h?c:
  40. h;d=d>e?d:e;f=f>h?f:h}a()};this.add3Points=function(e,h,i,m,n,q){if(j===true){j=false;b=e<i?e<n?e:n:i<n?i:n;c=h<m?h<q?h:q:m<q?m:q;d=e>i?e>n?e:n:i>n?i:n;f=h>m?h>q?h:q:m>q?m:q}else{b=e<i?e<n?e<b?e:b:n<b?n:b:i<n?i<b?i:b:n<b?n:b;c=h<m?h<q?h<c?h:c:q<c?q:c:m<q?m<c?m:c:q<c?q:c;d=e>i?e>n?e>d?e:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d;f=h>m?h>q?h>f?h:f:q>f?q:f:m>q?m>f?m:f:q>f?q:f}a()};this.addRectangle=function(e){if(j===true){j=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();
  41. 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(){j=true;f=d=c=b=0;a()};this.isEmpty=function(){return j}};
  42. 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}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
  43. 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],h=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],k=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*j;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*f;i[4]=b*e;i[5]=b*h;i[6]=b*j;i[7]=b*l;i[8]=b*k;return this},
  44. 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,h,j,l,k,i,m,n,q,u,o){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,h||0,j||0,l||0,k||0,i!==void 0?i:1,m||0,n||0,q||0,u||0,o!==void 0?o:1)};
  45. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,h,j,l,k,i,m,n,q,u,o){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=h;r[13]=j;r[2]=l;r[6]=k;r[10]=i;r[14]=m;r[3]=n;r[7]=q;r[11]=u;r[15]=o;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,
  46. f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],j=c[8],l=c[12],k=c[1],i=c[5],m=c[9],n=c[13],q=c[2],u=c[6],o=c[10],r=c[14],p=c[3],v=c[7],x=c[11],c=c[15],F=d[0],s=d[4],
  47. I=d[8],A=d[12],N=d[1],D=d[5],H=d[9],G=d[13],R=d[2],U=d[6],T=d[10],z=d[14],K=d[3],V=d[7],E=d[11],d=d[15];f[0]=e*F+h*N+j*R+l*K;f[4]=e*s+h*D+j*U+l*V;f[8]=e*I+h*H+j*T+l*E;f[12]=e*A+h*G+j*z+l*d;f[1]=k*F+i*N+m*R+n*K;f[5]=k*s+i*D+m*U+n*V;f[9]=k*I+i*H+m*T+n*E;f[13]=k*A+i*G+m*z+n*d;f[2]=q*F+u*N+o*R+r*K;f[6]=q*s+u*D+o*U+r*V;f[10]=q*I+u*H+o*T+r*E;f[14]=q*A+u*G+o*z+r*d;f[3]=p*F+v*N+x*R+c*K;f[7]=p*s+v*D+x*U+c*V;f[11]=p*I+v*H+x*T+c*E;f[15]=p*A+v*G+x*z+c*d;return this},multiplySelf:function(a){return this.multiply(this,
  48. 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]=
  49. 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,
  50. 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]*
  51. 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],h=a[5],j=a[9],l=a[13],k=a[2],i=a[6],m=a[10],n=a[14],q=a[3],u=a[7],o=a[11],a=a[15];return f*j*i*q-d*l*i*q-f*h*m*q+c*l*m*q+d*h*n*q-c*j*n*q-f*j*k*u+d*l*k*u+f*e*m*u-b*l*m*u-d*e*n*u+b*j*n*u+f*h*k*o-c*l*k*o-f*e*i*o+b*l*i*o+c*e*n*o-b*h*n*o-d*h*k*a+c*j*k*a+d*e*i*a-b*j*i*a-c*e*m*a+b*h*m*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;
  52. 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]=
  53. 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],
  54. a[9],a[10])},getInverse:function(a){var b=this.elements,c=a.elements,d=c[0],f=c[4],e=c[8],h=c[12],j=c[1],l=c[5],k=c[9],i=c[13],m=c[2],n=c[6],q=c[10],u=c[14],o=c[3],r=c[7],p=c[11],c=c[15];b[0]=k*u*r-i*q*r+i*n*p-l*u*p-k*n*c+l*q*c;b[4]=h*q*r-e*u*r-h*n*p+f*u*p+e*n*c-f*q*c;b[8]=e*i*r-h*k*r+h*l*p-f*i*p-e*l*c+f*k*c;b[12]=h*k*n-e*i*n-h*l*q+f*i*q+e*l*u-f*k*u;b[1]=i*q*o-k*u*o-i*m*p+j*u*p+k*m*c-j*q*c;b[5]=e*u*o-h*q*o+h*m*p-d*u*p-e*m*c+d*q*c;b[9]=h*k*o-e*i*o-h*j*p+d*i*p+e*j*c-d*k*c;b[13]=e*i*m-h*k*m+h*j*q-d*
  55. i*q-e*j*u+d*k*u;b[2]=l*u*o-i*n*o+i*m*r-j*u*r-l*m*c+j*n*c;b[6]=h*n*o-f*u*o-h*m*r+d*u*r+f*m*c-d*n*c;b[10]=f*i*o-h*l*o+h*j*r-d*i*r-f*j*c+d*l*c;b[14]=h*l*m-f*i*m-h*j*n+d*i*n+f*j*u-d*l*u;b[3]=k*n*o-l*q*o-k*m*r+j*q*r+l*m*p-j*n*p;b[7]=f*q*o-e*n*o+e*m*r-d*q*r-f*m*p+d*n*p;b[11]=e*l*o-f*k*o-e*j*r+d*k*r+f*j*p-d*l*p;b[15]=f*k*m-e*l*m+e*j*n-d*k*n-f*j*q+d*l*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,h=Math.cos(d),d=Math.sin(d),
  56. j=Math.cos(f),f=Math.sin(f),l=Math.cos(e),e=Math.sin(e);if(b===void 0||b==="XYZ"){var k=h*l,i=h*e,m=d*l,n=d*e;c[0]=j*l;c[4]=-j*e;c[8]=f;c[1]=i+m*f;c[5]=k-n*f;c[9]=-d*j;c[2]=n-k*f;c[6]=m+i*f;c[10]=h*j}else if(b==="YXZ"){k=j*l;i=j*e;m=f*l;n=f*e;c[0]=k+n*d;c[4]=m*d-i;c[8]=h*f;c[1]=h*e;c[5]=h*l;c[9]=-d;c[2]=i*d-m;c[6]=n+k*d;c[10]=h*j}else if(b==="ZXY"){k=j*l;i=j*e;m=f*l;n=f*e;c[0]=k-n*d;c[4]=-h*e;c[8]=m+i*d;c[1]=i+m*d;c[5]=h*l;c[9]=n-k*d;c[2]=-h*f;c[6]=d;c[10]=h*j}else if(b==="ZYX"){k=h*l;i=h*e;m=d*l;
  57. n=d*e;c[0]=j*l;c[4]=m*f-i;c[8]=k*f+n;c[1]=j*e;c[5]=n*f+k;c[9]=i*f-m;c[2]=-f;c[6]=d*j;c[10]=h*j}else if(b==="YZX"){k=h*j;i=h*f;m=d*j;n=d*f;c[0]=j*l;c[4]=n-k*e;c[8]=m*e+i;c[1]=e;c[5]=h*l;c[9]=-d*l;c[2]=-f*l;c[6]=i*e+m;c[10]=k-n*e}else if(b==="XZY"){k=h*j;i=h*f;m=d*j;n=d*f;c[0]=j*l;c[4]=-e;c[8]=f*l;c[1]=k*e+n;c[5]=h*l;c[9]=i*e-m;c[2]=m*e-i;c[6]=d*l;c[10]=n*e+k}return this},setRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w,h=c+c,j=d+d,l=f+f,a=c*h,k=c*j,c=c*l,i=d*j,d=d*
  58. l,f=f*l,h=e*h,j=e*j,e=e*l;b[0]=1-(i+f);b[4]=k-e;b[8]=c+j;b[1]=k+e;b[5]=1-(a+f);b[9]=d-h;b[2]=c-j;b[6]=d+h;b[10]=1-(a+i);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,h=THREE.Matrix4.__v3;f.set(d[0],d[1],d[2]);e.set(d[4],d[5],d[6]);
  59. h.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=h.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]/
  60. 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]*
  61. 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],h=b[8],j=b[9],l=b[10],k=b[11],i=Math.cos(a),a=Math.sin(a);b[4]=i*c+a*h;b[5]=i*d+a*j;b[6]=i*f+a*l;b[7]=i*e+a*k;b[8]=i*h-a*c;b[9]=i*j-a*d;b[10]=i*l-a*f;b[11]=i*k-a*e;return this},rotateY:function(a){var b=
  62. this.elements,c=b[0],d=b[1],f=b[2],e=b[3],h=b[8],j=b[9],l=b[10],k=b[11],i=Math.cos(a),a=Math.sin(a);b[0]=i*c-a*h;b[1]=i*d-a*j;b[2]=i*f-a*l;b[3]=i*e-a*k;b[8]=i*h+a*c;b[9]=i*j+a*d;b[10]=i*l+a*f;b[11]=i*k+a*e;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],h=b[4],j=b[5],l=b[6],k=b[7],i=Math.cos(a),a=Math.sin(a);b[0]=i*c+a*h;b[1]=i*d+a*j;b[2]=i*f+a*l;b[3]=i*e+a*k;b[4]=i*h-a*c;b[5]=i*j-a*d;b[6]=i*l-a*f;b[7]=i*k-a*e;return this},rotateByAxis:function(a,b){var c=this.elements;
  63. 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,h=Math.sqrt(d*d+f*f+e*e),d=d/h,f=f/h,e=e/h,h=d*d,j=f*f,l=e*e,k=Math.cos(b),i=Math.sin(b),m=1-k,n=d*f*m,q=d*e*m,m=f*e*m,d=d*i,u=f*i,i=e*i,e=h+(1-h)*k,h=n+i,f=q-u,n=n-i,j=j+(1-j)*k,i=m+d,q=q+u,m=m-d,l=l+(1-l)*k,k=c[0],d=c[1],u=c[2],o=c[3],r=c[4],p=c[5],v=c[6],x=c[7],F=c[8],s=c[9],I=c[10],A=c[11];c[0]=e*k+h*r+f*F;c[1]=e*d+h*
  64. p+f*s;c[2]=e*u+h*v+f*I;c[3]=e*o+h*x+f*A;c[4]=n*k+j*r+i*F;c[5]=n*d+j*p+i*s;c[6]=n*u+j*v+i*I;c[7]=n*o+j*x+i*A;c[8]=q*k+m*r+l*F;c[9]=q*d+m*p+l*s;c[10]=q*u+m*v+l*I;c[11]=q*o+m*x+l*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]+
  65. 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);
  66. return this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,h=a.y,j=a.z,l=f*e,k=f*h;this.set(l*e+c,l*h-d*j,l*j+d*h,0,l*h+d*j,k*h+c,k*j-d*e,0,l*j-d*h,k*j+d*e,f*j*j+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 h=this.elements;h[0]=2*f/(b-a);h[4]=0;h[8]=(b+a)/(b-a);h[12]=0;h[1]=0;h[5]=2*f/(d-c);h[9]=(d+c)/(d-c);h[13]=0;h[2]=0;h[6]=0;h[10]=-(e+f)/(e-f);h[14]=-2*e*f/(e-f);h[3]=
  67. 0;h[7]=0;h[11]=-1;h[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 h=this.elements,j=b-a,l=c-d,k=e-f;h[0]=2/j;h[4]=0;h[8]=0;h[12]=-((b+a)/j);h[1]=0;h[5]=2/l;h[9]=0;h[13]=-((c+d)/l);h[2]=0;h[6]=0;h[10]=-2/k;h[14]=-((e+f)/k);h[3]=0;h[7]=0;h[11]=0;h[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],
  68. 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;
  69. THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";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="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=false;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=
  70. 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};
  71. THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiply(a,this.matrix);this.scale.getScaleFromMatrix(this.matrix);this.rotation.setEulerFromRotationMatrix((new THREE.Matrix4).extractRotation(this.matrix),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,
  72. this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},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.");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=
  73. 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)}},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c<d;c++){f=this.children[c];if(f.name===a)return f;if(b){f=f.getChildByName(a,b);if(f!==void 0)return f}}},updateMatrix:function(){this.matrix.setPosition(this.position);
  74. this.useQuaternion===true?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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.multiply(this.parent.matrixWorld,
  75. this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},worldToLocal:function(a){return THREE.Object3D.__m1.getInverse(this.matrixWorld).multiplyVector3(a)},localToWorld:function(a){return this.matrixWorld.multiplyVector3(a)}};THREE.Object3D.__m1=new THREE.Matrix4;THREE.Object3DCount=0;
  76. THREE.Projector=function(){function a(){var a;if(e===h.length){a=new THREE.RenderableObject;h.push(a)}else a=h[e];e++;return a}function b(){var a;if(l===k.length){a=new THREE.RenderableVertex;k.push(a)}else a=k[l];l++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,h=b.z+b.w,f=-a.z+a.w,j=-b.z+b.w;if(e>=0&&h>=0&&f>=0&&j>=0)return true;if(e<0&&h<0||f<0&&j<0)return false;e<0?c=Math.max(c,e/(e-h)):h<0&&(d=Math.min(d,e/(e-h)));f<0?c=Math.max(c,f/(f-j)):j<0&&(d=Math.min(d,
  77. f/(f-j)));if(d<c)return false;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return true}var f,e,h=[],j,l,k=[],i,m,n=[],q,u=[],o,r,p=[],v,x,F=[],s={objects:[],sprites:[],lights:[],elements:[]},I=new THREE.Vector3,A=new THREE.Vector4,N=new THREE.Matrix4,D=new THREE.Matrix4,H=new THREE.Frustum,G=new THREE.Vector4,R=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);N.multiply(b.projectionMatrix,b.matrixWorldInverse);N.multiplyVector3(a);return a};this.unprojectVector=
  78. function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);N.multiply(b.matrixWorld,b.projectionMatrixInverse);N.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.projectGraph=function(b,d){e=0;s.objects.length=0;s.sprites.length=0;s.lights.length=0;var h=function(b){if(b.visible!==false){if((b instanceof THREE.Mesh||b instanceof
  79. THREE.Line)&&(b.frustumCulled===false||H.contains(b)===true)){I.copy(b.matrixWorld.getPosition());N.multiplyVector3(I);f=a();f.object=b;f.z=I.z;s.objects.push(f)}else if(b instanceof THREE.Sprite||b instanceof THREE.Particle){I.copy(b.matrixWorld.getPosition());N.multiplyVector3(I);f=a();f.object=b;f.z=I.z;s.sprites.push(f)}else b instanceof THREE.Light&&s.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)h(b.children[c])}};h(b);d===true&&s.objects.sort(c);return s};this.projectScene=function(a,
  80. e,h){var f=e.near,I=e.far,E=false,$,fa,J,ra,S,ba,aa,va,L,qa,xa,Aa,Pa,ja,Ba;x=r=q=m=0;s.elements.length=0;if(e.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(e)}a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);N.multiply(e.projectionMatrix,e.matrixWorldInverse);H.setFromMatrix(N);s=this.projectGraph(a,false);a=0;for($=s.objects.length;a<$;a++){L=s.objects[a].object;qa=L.matrixWorld;l=0;if(L instanceof THREE.Mesh){xa=L.geometry;
  81. Aa=L.geometry.materials;ra=xa.vertices;Pa=xa.faces;ja=xa.faceVertexUvs;xa=L.matrixRotationWorld.extractRotation(qa);fa=0;for(J=ra.length;fa<J;fa++){j=b();j.positionWorld.copy(ra[fa]);qa.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);N.multiplyVector4(j.positionScreen);j.positionScreen.x=j.positionScreen.x/j.positionScreen.w;j.positionScreen.y=j.positionScreen.y/j.positionScreen.w;j.visible=j.positionScreen.z>f&&j.positionScreen.z<I}ra=0;for(fa=Pa.length;ra<fa;ra++){J=Pa[ra];
  82. if(J instanceof THREE.Face3){S=k[J.a];ba=k[J.b];aa=k[J.c];if(S.visible===true&&ba.visible===true&&aa.visible===true){E=(aa.positionScreen.x-S.positionScreen.x)*(ba.positionScreen.y-S.positionScreen.y)-(aa.positionScreen.y-S.positionScreen.y)*(ba.positionScreen.x-S.positionScreen.x)<0;if(L.doubleSided===true||E!==L.flipSided){va=void 0;if(m===n.length){va=new THREE.RenderableFace3;n.push(va)}else va=n[m];m++;i=va;i.v1.copy(S);i.v2.copy(ba);i.v3.copy(aa)}else continue}else continue}else if(J instanceof
  83. THREE.Face4){S=k[J.a];ba=k[J.b];aa=k[J.c];va=k[J.d];if(S.visible===true&&ba.visible===true&&aa.visible===true&&va.visible===true){E=(va.positionScreen.x-S.positionScreen.x)*(ba.positionScreen.y-S.positionScreen.y)-(va.positionScreen.y-S.positionScreen.y)*(ba.positionScreen.x-S.positionScreen.x)<0||(ba.positionScreen.x-aa.positionScreen.x)*(va.positionScreen.y-aa.positionScreen.y)-(ba.positionScreen.y-aa.positionScreen.y)*(va.positionScreen.x-aa.positionScreen.x)<0;if(L.doubleSided===true||E!==L.flipSided){Ba=
  84. void 0;if(q===u.length){Ba=new THREE.RenderableFace4;u.push(Ba)}else Ba=u[q];q++;i=Ba;i.v1.copy(S);i.v2.copy(ba);i.v3.copy(aa);i.v4.copy(va)}else continue}else continue}i.normalWorld.copy(J.normal);E===false&&(L.flipSided===true||L.doubleSided===true)&&i.normalWorld.negate();xa.multiplyVector3(i.normalWorld);i.centroidWorld.copy(J.centroid);qa.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);N.multiplyVector3(i.centroidScreen);aa=J.vertexNormals;S=0;for(ba=aa.length;S<ba;S++){va=
  85. i.vertexNormalsWorld[S];va.copy(aa[S]);E===false&&(L.flipSided===true||L.doubleSided===true)&&va.negate();xa.multiplyVector3(va)}S=0;for(ba=ja.length;S<ba;S++){Ba=ja[S][ra];if(Ba!==void 0){aa=0;for(va=Ba.length;aa<va;aa++)i.uvs[S][aa]=Ba[aa]}}i.material=L.material;i.faceMaterial=J.materialIndex!==null?Aa[J.materialIndex]:null;i.z=i.centroidScreen.z;s.elements.push(i)}}else if(L instanceof THREE.Line){D.multiply(N,qa);ra=L.geometry.vertices;S=b();S.positionScreen.copy(ra[0]);D.multiplyVector4(S.positionScreen);
  86. qa=L.type===THREE.LinePieces?2:1;fa=1;for(J=ra.length;fa<J;fa++){S=b();S.positionScreen.copy(ra[fa]);D.multiplyVector4(S.positionScreen);if(!((fa+1)%qa>0)){ba=k[l-2];G.copy(S.positionScreen);R.copy(ba.positionScreen);if(d(G,R)===true){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Aa=void 0;if(r===p.length){Aa=new THREE.RenderableLine;p.push(Aa)}else Aa=p[r];r++;o=Aa;o.v1.positionScreen.copy(G);o.v2.positionScreen.copy(R);o.z=Math.max(G.z,R.z);o.material=L.material;s.elements.push(o)}}}}}a=0;for($=
  87. s.sprites.length;a<$;a++){L=s.sprites[a].object;qa=L.matrixWorld;if(L instanceof THREE.Particle){A.set(qa.elements[12],qa.elements[13],qa.elements[14],1);N.multiplyVector4(A);A.z=A.z/A.w;if(A.z>0&&A.z<1){f=void 0;if(x===F.length){f=new THREE.RenderableParticle;F.push(f)}else f=F[x];x++;v=f;v.x=A.x/A.w;v.y=A.y/A.w;v.z=A.z;v.rotation=L.rotation.z;v.scale.x=L.scale.x*Math.abs(v.x-(A.x+e.projectionMatrix.elements[0])/(A.w+e.projectionMatrix.elements[12]));v.scale.y=L.scale.y*Math.abs(v.y-(A.y+e.projectionMatrix.elements[5])/
  88. (A.w+e.projectionMatrix.elements[13]));v.material=L.material;s.elements.push(v)}}}h&&s.elements.sort(c);return s}};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};
  89. 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),h=Math.sin(a.y/2),j=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=e*d*f+c*h*j;this.y=c*h*f-e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f-e*h*j}else if(b==="YXZ"){this.x=e*d*f+c*h*j;this.y=c*h*f-e*d*j;this.z=
  90. c*d*j-e*h*f;this.w=c*d*f+e*h*j}else if(b==="ZXY"){this.x=e*d*f-c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f-e*h*j}else if(b==="ZYX"){this.x=e*d*f-c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j-e*h*f;this.w=c*d*f+e*h*j}else if(b==="YZX"){this.x=e*d*f+c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j-e*h*f;this.w=c*d*f-e*h*j}else if(b==="XZY"){this.x=e*d*f-c*h*j;this.y=c*h*f-e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f+e*h*j}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*
  91. 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],h=b[9],j=b[2],l=b[6],b=b[10],k=c+e+b;if(k>0){c=0.5/Math.sqrt(k+1);this.w=0.25/c;this.x=(l-h)*c;this.y=(d-j)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(l-h)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+j)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-j)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(h+l)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
  92. (d+j)/c;this.y=(h+l)/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=
  93. this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,h=a.y,j=a.z,a=a.w;this.x=b*a+f*e+c*j-d*h;this.y=c*a+f*h+d*e-b*j;this.z=d*a+f*j+b*h-c*e;this.w=f*a-b*e-c*h-d*j;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,
  94. e=this.x,h=this.y,j=this.z,l=this.w,k=l*c+h*f-j*d,i=l*d+j*c-e*f,m=l*f+e*d-h*c,c=-e*c-h*d-j*f;b.x=k*l+c*-e+i*-j-m*-h;b.y=i*l+c*-h+m*-e-k*-j;b.z=m*l+c*-j+k*-h-i*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,h=e*a.w+c*a.x+d*a.y+f*a.z;if(h<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;h=-h}else this.copy(a);if(h>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var j=Math.acos(h),l=Math.sqrt(1-h*h);if(Math.abs(l)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);
  95. this.y=0.5*(d+this.y);this.z=0.5*(f+this.z);return this}h=Math.sin((1-b)*j)/l;j=Math.sin(b*j)/l;this.w=e*h+this.w*j;this.x=c*h+this.x*j;this.y=d*h+this.y*j;this.z=f*h+this.z*j;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
  96. 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.0010){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};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
  97. 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};
  98. 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();
  99. return a}};THREE.Face4=function(a,b,c,d,f,e,h){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=h;this.centroid=new THREE.Vector3};
  100. 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();
  101. 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)}};
  102. 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.dynamic=this.hasTangents=false};
  103. 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,h=f.vertexNormals.length;e<h;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,
  104. 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,h=new THREE.Vector3,j=new THREE.Vector3;a=0;for(b=this.faces.length;a<
  105. b;a++){c=this.faces[a];d=this.vertices[c.a];f=this.vertices[c.b];e=this.vertices[c.c];h.sub(e,f);j.sub(d,f);h.crossSelf(j);h.isZero()||h.normalize();c.normal.copy(h)}},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];
  106. 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;
  107. 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?
  108. 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=
  109. [];var h=this.morphNormals[a].faceNormals,j=this.morphNormals[a].vertexNormals,l,k;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];l=new THREE.Vector3;k=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};h.push(l);j.push(k)}}h=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];
  110. l=h.faceNormals[c];k=h.vertexNormals[c];l.copy(f.normal);if(f instanceof THREE.Face3){k.a.copy(f.vertexNormals[0]);k.b.copy(f.vertexNormals[1]);k.c.copy(f.vertexNormals[2])}else{k.a.copy(f.vertexNormals[0]);k.b.copy(f.vertexNormals[1]);k.c.copy(f.vertexNormals[2]);k.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,e,f,S){j=a.vertices[b];l=a.vertices[c];
  111. k=a.vertices[d];i=h[e];m=h[f];n=h[S];q=l.x-j.x;u=k.x-j.x;o=l.y-j.y;r=k.y-j.y;p=l.z-j.z;v=k.z-j.z;x=m.u-i.u;F=n.u-i.u;s=m.v-i.v;I=n.v-i.v;A=1/(x*I-F*s);G.set((I*q-s*u)*A,(I*o-s*r)*A,(I*p-s*v)*A);R.set((x*u-F*q)*A,(x*r-F*o)*A,(x*v-F*p)*A);D[b].addSelf(G);D[c].addSelf(G);D[d].addSelf(G);H[b].addSelf(R);H[c].addSelf(R);H[d].addSelf(R)}var b,c,d,f,e,h,j,l,k,i,m,n,q,u,o,r,p,v,x,F,s,I,A,N,D=[],H=[],G=new THREE.Vector3,R=new THREE.Vector3,U=new THREE.Vector3,T=new THREE.Vector3,z=new THREE.Vector3;b=0;for(c=
  112. this.vertices.length;b<c;b++){D[b]=new THREE.Vector3;H[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];h=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++){z.copy(e.vertexNormals[d]);f=e[K[d]];N=D[f];U.copy(N);U.subSelf(z.multiplyScalar(z.dot(N))).normalize();
  113. T.cross(e.vertexNormals[d],N);f=T.dot(H[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(U.x,U.y,U.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=
  114. 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(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,h,j,l;e=0;for(h=this.vertices.length;e<h;e++){d=this.vertices[e];d=
  115. [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(h=this.faces.length;e<h;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,a.materialIndex);
  116. d=0;for(j=this.faceVertexUvs.length;d<j;d++)(l=this.faceVertexUvs[d][e])&&l.splice(f,1);this.faces[e].vertexColors=a.vertexColors;break}}}c=this.vertices.length-b.length;this.vertices=b;return c}};THREE.GeometryCount=0;
  117. THREE.Spline=function(a){function b(a,b,c,d,e,f,h){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},f,e,h,j,l,k,i,m,n;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);h=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:
  118. e+2;k=this.points[c[0]];i=this.points[c[1]];m=this.points[c[2]];n=this.points[c[3]];j=h*h;l=h*j;d.x=b(k.x,i.x,m.x,n.x,h,j,l);d.y=b(k.y,i.y,m.y,n.y,h,j,l);d.z=b(k.z,i.z,m.z,n.z,h,j,l);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,e=b=b=0,f=new THREE.Vector3,h=new THREE.Vector3,j=[],i=0;j[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++){b=
  119. a/c;d=this.getPoint(b);h.copy(d);i=i+h.distanceTo(f);f.copy(d);b=(this.points.length-1)*b;b=Math.floor(b);if(b!=e){j[b]=i;e=b}}j[j.length]=i;return{chunks:j,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,h,j=[],i=new THREE.Vector3,k=this.getLength();j.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=k.chunks[b]-k.chunks[b-1];h=Math.ceil(a*c/k.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<h-1;c++){d=e+c*(1/h)*(f-e);d=this.getPoint(d);
  120. j.push(i.copy(d).clone())}j.push(i.copy(this.points[b]).clone())}this.points=j}};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)};
  121. 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)};
  122. 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){this.fov=2*Math.atan((b!==void 0?b:24)/(a*2))*(180/Math.PI);this.updateProjectionMatrix()};
  123. 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()};
  124. 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)};
  125. 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);
  126. 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;
  127. 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);
  128. 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);
  129. 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=
  130. 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(){}};
  131. 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/
  132. 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=
  133. 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,b){var e=new Image;e.onload=function(){if(!c(this.width)||!c(this.height)){var b=d(this.width),e=d(this.height);a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,b,e)}else a.image=this;a.needsUpdate=true};e.crossOrigin=j.crossOrigin;e.src=b}function e(a,c,d,e,h,j){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=
  134. d;if(e){a[c].repeat.set(e[0],e[1]);if(e[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(e[1]!=1)a[c].wrapT=THREE.RepeatWrapping}h&&a[c].offset.set(h[0],h[1]);if(j){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[c].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[c].wrapT=e[j[1]]}f(a[c],b+"/"+d)}function h(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var j=this,l="MeshLambertMaterial",k={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};
  135. if(a.shading){var i=a.shading.toLowerCase();i==="phong"?l="MeshPhongMaterial":i==="basic"&&(l="MeshBasicMaterial")}if(a.blending!==void 0&&THREE[a.blending]!==void 0)k.blending=THREE[a.blending];if(a.transparent!==void 0||a.opacity<1)k.transparent=a.transparent;if(a.depthTest!==void 0)k.depthTest=a.depthTest;if(a.depthWrite!==void 0)k.depthWrite=a.depthWrite;if(a.vertexColors!==void 0)if(a.vertexColors=="face")k.vertexColors=THREE.FaceColors;else if(a.vertexColors)k.vertexColors=THREE.VertexColors;
  136. if(a.colorDiffuse)k.color=h(a.colorDiffuse);else if(a.DbgColor)k.color=a.DbgColor;if(a.colorSpecular)k.specular=h(a.colorSpecular);if(a.colorAmbient)k.ambient=h(a.colorAmbient);if(a.transparency)k.opacity=a.transparency;if(a.specularCoef)k.shininess=a.specularCoef;a.mapDiffuse&&b&&e(k,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(k,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(k,"normalMap",a.mapNormal,a.mapNormalRepeat,
  137. a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(k,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){l=THREE.ShaderUtils.lib.normal;i=THREE.UniformsUtils.clone(l.uniforms);i.tNormal.texture=k.normalMap;if(a.mapNormalFactor)i.uNormalScale.value=a.mapNormalFactor;if(k.map){i.tDiffuse.texture=k.map;i.enableDiffuse.value=true}if(k.specularMap){i.tSpecular.texture=k.specularMap;i.enableSpecular.value=true}if(k.lightMap){i.tAO.texture=k.lightMap;
  138. i.enableAO.value=true}i.uDiffuseColor.value.setHex(k.color);i.uSpecularColor.value.setHex(k.specular);i.uAmbientColor.value.setHex(k.ambient);i.uShininess.value=k.shininess;if(k.opacity!==void 0)i.uOpacity.value=k.opacity;k=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:i,lights:true,fog:true})}else k=new THREE[l](k);if(a.DbgName!==void 0)k.name=a.DbgName;return k}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
  139. 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)};
  140. THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,e){var h=new XMLHttpRequest;h.onreadystatechange=function(){if(h.readyState==4)if(h.status==200||h.status==0){var j=JSON.parse(h.responseText);a.loadAjaxBuffers(j,c,f,d,e)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+h.status+"]")};h.open("GET",b,true);h.overrideMimeType&&h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)};
  141. THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var e=new XMLHttpRequest,h=c+"/"+a.buffers,j=0;e.onreadystatechange=function(){if(e.readyState==4)e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.response,b,d,a.materials):console.error("THREE.BinaryLoader: Couldn't load ["+h+"] ["+e.status+"]");else if(e.readyState==3){if(f){j==0&&(j=e.getResponseHeader("Content-Length"));f({total:j,loaded:e.responseText.length})}}else e.readyState==2&&(j=e.getResponseHeader("Content-Length"))};
  142. e.open("GET",h,true);e.responseType="arraybuffer";e.send(null)};
  143. THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,l,k,i,m,n,q,u,o,r,p,v,x,F;function s(a){return a%4?4-a%4:0}function I(a,b){return(new Uint8Array(a,b,1))[0]}function A(a,b){return(new Uint32Array(a,b,1))[0]}function N(b,c){var d,e,f,h,j,i,k,l,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[d*3];f=m[d*3+1];h=m[d*3+2];j=V[e*2];e=V[e*2+1];i=V[f*2];k=V[f*2+1];f=V[h*2];l=V[h*2+1];h=T.faceVertexUvs[0];var n=[];n.push(new THREE.UV(j,e));n.push(new THREE.UV(i,k));n.push(new THREE.UV(f,
  144. l));h.push(n)}}function D(b,c){var d,e,f,h,j,i,k,l,m,n,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[d*4];f=o[d*4+1];h=o[d*4+2];j=o[d*4+3];i=V[e*2];e=V[e*2+1];k=V[f*2];m=V[f*2+1];l=V[h*2];n=V[h*2+1];h=V[j*2];f=V[j*2+1];j=T.faceVertexUvs[0];var q=[];q.push(new THREE.UV(i,e));q.push(new THREE.UV(k,m));q.push(new THREE.UV(l,n));q.push(new THREE.UV(h,f));j.push(q)}}function H(b,c,d){for(var e,f,h,j,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*3];f=c[d*3+1];h=c[d*3+2];j=i[d];
  145. T.faces.push(new THREE.Face3(e,f,h,null,null,j))}}function G(b,c,d){for(var e,f,h,j,i,c=new Uint32Array(a,c,4*b),k=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*4];f=c[d*4+1];h=c[d*4+2];j=c[d*4+3];i=k[d];T.faces.push(new THREE.Face4(e,f,h,j,null,null,i))}}function R(b,c,d,e){for(var f,h,j,i,k,l,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),n=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*3];h=c[e*3+1];j=c[e*3+2];k=d[e*3];l=d[e*3+1];m=d[e*3+2];i=n[e];var o=K[l*3],q=K[l*3+1];l=K[l*3+2];var r=K[m*3],
  146. p=K[m*3+1];m=K[m*3+2];T.faces.push(new THREE.Face3(f,h,j,[new THREE.Vector3(K[k*3],K[k*3+1],K[k*3+2]),new THREE.Vector3(o,q,l),new THREE.Vector3(r,p,m)],null,i))}}function U(b,c,d,e){for(var f,h,j,i,k,l,m,n,o,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),q=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*4];h=c[e*4+1];j=c[e*4+2];i=c[e*4+3];l=d[e*4];m=d[e*4+1];n=d[e*4+2];o=d[e*4+3];k=q[e];var r=K[m*3],p=K[m*3+1];m=K[m*3+2];var u=K[n*3],s=K[n*3+1];n=K[n*3+2];var v=K[o*3],x=K[o*3+1];o=K[o*3+2];T.faces.push(new THREE.Face4(f,
  147. h,j,i,[new THREE.Vector3(K[l*3],K[l*3+1],K[l*3+2]),new THREE.Vector3(r,p,m),new THREE.Vector3(u,s,n),new THREE.Vector3(v,x,o)],null,k))}}var T=this,z=0,K=[],V=[],E,$,fa;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(T,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d=d+String.fromCharCode(a[b+e]);return d})(a,z,12);c=I(a,z+12);I(a,z+13);I(a,z+14);I(a,z+15);f=I(a,z+16);l=I(a,z+17);k=I(a,z+18);i=I(a,z+19);m=A(a,z+20);n=A(a,z+20+4);q=A(a,z+20+8);b=A(a,z+20+12);
  148. u=A(a,z+20+16);o=A(a,z+20+20);r=A(a,z+20+24);p=A(a,z+20+28);v=A(a,z+20+32);x=A(a,z+20+36);F=A(a,z+20+40);z=z+c;c=f*3+i;fa=f*4+i;E=b*c;$=u*(c+l*3);f=o*(c+k*3);i=r*(c+l*3+k*3);c=p*fa;l=v*(fa+l*4);k=x*(fa+k*4);z=z+function(b){var b=new Float32Array(a,b,m*3),c,d,e,f;for(c=0;c<m;c++){d=b[c*3];e=b[c*3+1];f=b[c*3+2];T.vertices.push(new THREE.Vector3(d,e,f))}return m*3*Float32Array.BYTES_PER_ELEMENT}(z);z=z+function(b){if(n){var b=new Int8Array(a,b,n*3),c,d,e,f;for(c=0;c<n;c++){d=b[c*3];e=b[c*3+1];f=b[c*
  149. 3+2];K.push(d/127,e/127,f/127)}}return n*3*Int8Array.BYTES_PER_ELEMENT}(z);z=z+s(n*3);z=z+function(b){if(q){var b=new Float32Array(a,b,q*2),c,d,e;for(c=0;c<q;c++){d=b[c*2];e=b[c*2+1];V.push(d,e)}}return q*2*Float32Array.BYTES_PER_ELEMENT}(z);E=z+E+s(b*2);$=E+$+s(u*2);f=$+f+s(o*2);i=f+i+s(r*2);c=i+c+s(p*2);l=c+l+s(v*2);k=l+k+s(x*2);(function(a){if(o){var b=a+o*Uint32Array.BYTES_PER_ELEMENT*3;H(o,a,b+o*Uint32Array.BYTES_PER_ELEMENT*3);N(o,b)}})($);(function(a){if(r){var b=a+r*Uint32Array.BYTES_PER_ELEMENT*
  150. 3,c=b+r*Uint32Array.BYTES_PER_ELEMENT*3;R(r,a,b,c+r*Uint32Array.BYTES_PER_ELEMENT*3);N(r,c)}})(f);(function(a){if(x){var b=a+x*Uint32Array.BYTES_PER_ELEMENT*4;G(x,a,b+x*Uint32Array.BYTES_PER_ELEMENT*4);D(x,b)}})(l);(function(a){if(F){var b=a+F*Uint32Array.BYTES_PER_ELEMENT*4,c=b+F*Uint32Array.BYTES_PER_ELEMENT*4;U(F,a,b,c+F*Uint32Array.BYTES_PER_ELEMENT*4);D(F,c)}})(k);b&&H(b,z,z+b*Uint32Array.BYTES_PER_ELEMENT*3);(function(a){if(u){var b=a+u*Uint32Array.BYTES_PER_ELEMENT*3;R(u,a,b,b+u*Uint32Array.BYTES_PER_ELEMENT*
  151. 3)}})(E);p&&G(p,i,i+p*Uint32Array.BYTES_PER_ELEMENT*4);(function(a){if(v){var b=a+v*Uint32Array.BYTES_PER_ELEMENT*4;U(v,a,b,b+v*Uint32Array.BYTES_PER_ELEMENT*4)}})(c);this.computeCentroids();this.computeFaceNormals();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};
  152. THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})},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}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);
  153. THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
  154. THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,f){var e=new XMLHttpRequest,h=0;e.onreadystatechange=function(){if(e.readyState===e.DONE)if(e.status===200||e.status===0){if(e.responseText){var j=JSON.parse(e.responseText);a.createModel(j,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){h===0&&(h=e.getResponseHeader("Content-Length"));
  155. f({total:h,loaded:e.responseText.length})}}else e.readyState===e.HEADERS_RECEIVED&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",b,true);e.overrideMimeType&&e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
  156. 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);(function(b){var c,f,l,k,i,m,n,q,u,o,r,p,v,x,F=a.faces;m=a.vertices;var s=a.normals,I=a.colors,A=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&A++;for(c=0;c<A;c++){d.faceUvs[c]=[];d.faceVertexUvs[c]=[]}k=0;for(i=m.length;k<i;){n=new THREE.Vector3;n.x=m[k++]*b;n.y=m[k++]*b;n.z=m[k++]*b;d.vertices.push(n)}k=0;for(i=F.length;k<i;){b=F[k++];m=b&1;l=b&2;c=b&
  157. 4;f=b&8;q=b&16;n=b&32;o=b&64;b=b&128;if(m){r=new THREE.Face4;r.a=F[k++];r.b=F[k++];r.c=F[k++];r.d=F[k++];m=4}else{r=new THREE.Face3;r.a=F[k++];r.b=F[k++];r.c=F[k++];m=3}if(l){l=F[k++];r.materialIndex=l}l=d.faces.length;if(c)for(c=0;c<A;c++){p=a.uvs[c];u=F[k++];x=p[u*2];u=p[u*2+1];d.faceUvs[c][l]=new THREE.UV(x,u)}if(f)for(c=0;c<A;c++){p=a.uvs[c];v=[];for(f=0;f<m;f++){u=F[k++];x=p[u*2];u=p[u*2+1];v[f]=new THREE.UV(x,u)}d.faceVertexUvs[c][l]=v}if(q){q=F[k++]*3;f=new THREE.Vector3;f.x=s[q++];f.y=s[q++];
  158. f.z=s[q];r.normal=f}if(n)for(c=0;c<m;c++){q=F[k++]*3;f=new THREE.Vector3;f.x=s[q++];f.y=s[q++];f.z=s[q];r.vertexNormals.push(f)}if(o){n=F[k++];n=new THREE.Color(I[n]);r.color=n}if(b)for(c=0;c<m;c++){n=F[k++];n=new THREE.Color(I[n]);r.vertexColors.push(n)}d.faces.push(r)}})(f);(function(){var b,c,f,l;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b=b+2){f=a.skinWeights[b];l=a.skinWeights[b+1];d.skinWeights.push(new THREE.Vector4(f,l,0,0))}}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b=
  159. b+2){f=a.skinIndices[b];l=a.skinIndices[b+1];d.skinIndices.push(new THREE.Vector4(f,l,0,0))}}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,l,k,i,m;c=0;for(f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];i=d.morphTargets[c].vertices;m=a.morphTargets[c].vertices;l=0;for(k=m.length;l<k;l=l+3){var n=new THREE.Vector3;n.x=m[l]*b;n.y=m[l+1]*b;n.z=m[l+2]*b;i.push(n)}}}if(a.morphColors!==
  160. void 0){c=0;for(f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];k=d.morphColors[c].colors;i=a.morphColors[c].colors;b=0;for(l=i.length;b<l;b=b+3){m=new THREE.Color(16755200);m.setRGB(i[b],i[b+1],i[b+2]);k.push(m)}}}})(f);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
  161. 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",
  162. 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 h=a.materials[e],j=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},l=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},k=function(a,d,e,f,h,i){a[d]=new THREE.Texture;a[d].sourceFile=
  163. e;if(f){a[d].repeat.set(f[0],f[1]);if(f[0]!=1)a[d].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[d].wrapT=THREE.RepeatWrapping}h&&a[d].offset.set(h[0],h[1]);if(i){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[i[0]]!==void 0)a[d].wrapS=f[i[0]];if(f[i[1]]!==void 0)a[d].wrapT=f[i[1]]}var k=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!j(a.width)||!j(a.height)){var b=l(a.width),c=l(a.height);k.image=document.createElement("canvas");k.image.width=
  164. b;k.image.height=c;k.image.getContext("2d").drawImage(a,0,0,b,c)}else k.image=a;k.needsUpdate=true});a.crossOrigin=c.crossOrigin;a.load(c.path+"/"+e);b&&b.add(a)},i=function(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255},m="MeshLambertMaterial",n={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:h.wireframe};if(h.shading){var q=h.shading.toLowerCase();q==="phong"?m="MeshPhongMaterial":q==="basic"&&(m="MeshBasicMaterial")}if(h.blending!==void 0&&THREE[h.blending]!==void 0)n.blending=
  165. THREE[h.blending];if(h.transparent!==void 0||h.opacity<1)n.transparent=h.transparent;if(h.depthTest!==void 0)n.depthTest=h.depthTest;if(h.depthWrite!==void 0)n.depthWrite=h.depthWrite;if(h.vertexColors!==void 0)if(h.vertexColors=="face")n.vertexColors=THREE.FaceColors;else if(h.vertexColors)n.vertexColors=THREE.VertexColors;if(h.colorDiffuse)n.color=i(h.colorDiffuse);else if(h.DbgColor)n.color=h.DbgColor;if(h.colorSpecular)n.specular=i(h.colorSpecular);if(h.colorAmbient)n.ambient=i(h.colorAmbient);
  166. if(h.transparency)n.opacity=h.transparency;if(h.specularCoef)n.shininess=h.specularCoef;h.mapDiffuse&&k(n,"map",h.mapDiffuse,h.mapDiffuseRepeat,h.mapDiffuseOffset,h.mapDiffuseWrap);h.mapLight&&k(n,"lightMap",h.mapLight,h.mapLightRepeat,h.mapLightOffset,h.mapLightWrap);h.mapNormal&&k(n,"normalMap",h.mapNormal,h.mapNormalRepeat,h.mapNormalOffset,h.mapNormalWrap);h.mapSpecular&&k(n,"specularMap",h.mapSpecular,h.mapSpecularRepeat,h.mapSpecularOffset,h.mapSpecularWrap);if(h.mapNormal){k=THREE.ShaderUtils.lib.normal;
  167. i=THREE.UniformsUtils.clone(k.uniforms);i.tNormal.texture=n.normalMap;if(h.mapNormalFactor)i.uNormalScale.value=h.mapNormalFactor;if(n.map){i.tDiffuse.texture=n.map;i.enableDiffuse.value=true}if(n.specularMap){i.tSpecular.texture=n.specularMap;i.enableSpecular.value=true}if(n.lightMap){i.tAO.texture=n.lightMap;i.enableAO.value=true}i.uDiffuseColor.value.setHex(n.color);i.uSpecularColor.value.setHex(n.specular);i.uAmbientColor.value.setHex(n.ambient);i.uShininess.value=n.shininess;if(n.opacity!==void 0)i.uOpacity.value=
  168. n.opacity;n=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:i,lights:true,fog:true})}else n=new THREE[m](n);if(h.DbgName!==void 0)n.name=h.DbgName;d.materials[e]=n}}var h=a.faces,u=a.vertices,n=a.normals,k=a.colors,i=0;if(a.uvs)for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&i++;for(e=0;e<i;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}m=0;for(q=u.length;m<q;){var o=new THREE.Vector3;o.x=u[m++]*f;o.y=u[m++]*f;o.z=u[m++]*f;d.vertices.push(o)}m=0;for(q=h.length;m<
  169. q;){var r=h[m++],p=r&2,e=r&4,v=r&8,x=r&16,u=r&32,F=r&64,o=r&128;if(r&1){r=new THREE.Face4;r.a=h[m++];r.b=h[m++];r.c=h[m++];r.d=h[m++];var s=4}else{r=new THREE.Face3;r.a=h[m++];r.b=h[m++];r.c=h[m++];s=3}if(p){p=h[m++];r.materialIndex=p}var I=d.faces.length;if(e)for(e=0;e<i;e++){var A=a.uvs[e],p=h[m++],N=A[p*2],p=A[p*2+1];d.faceUvs[e][I]=new THREE.UV(N,p)}if(v)for(e=0;e<i;e++){for(var A=a.uvs[e],v=[],D=0;D<s;D++){p=h[m++];N=A[p*2];p=A[p*2+1];v[D]=new THREE.UV(N,p)}d.faceVertexUvs[e][I]=v}if(x){x=h[m++]*
  170. 3;p=new THREE.Vector3;p.x=n[x++];p.y=n[x++];p.z=n[x];r.normal=p}if(u)for(e=0;e<s;e++){x=h[m++]*3;p=new THREE.Vector3;p.x=n[x++];p.y=n[x++];p.z=n[x];r.vertexNormals.push(p)}if(F){u=h[m++];r.color=new THREE.Color(k[u])}if(o)for(e=0;e<s;e++){u=h[m++];r.vertexColors.push(new THREE.Color(k[u]))}d.faces.push(r)}if(a.skinWeights){e=0;for(h=a.skinWeights.length;e<h;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(h=a.skinIndices.length;e<h;e=e+
  171. 2){n=0;d.skinIndices.push(new THREE.Vector4(a.skinIndices[e],a.skinIndices[e+1],n,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){e=0;for(h=a.morphTargets.length;e<h;e++){d.morphTargets[e]={};d.morphTargets[e].name=a.morphTargets[e].name;d.morphTargets[e].vertices=[];n=d.morphTargets[e].vertices;k=a.morphTargets[e].vertices;p=0;for(i=k.length;p<i;p=p+3){o=new THREE.Vector3;o.x=k[p]*f;o.y=k[p+1]*f;o.z=k[p+2]*f;n.push(o)}}}if(a.morphColors){e=0;for(h=a.morphColors.length;e<h;e++){d.morphColors[e]=
  172. {};d.morphColors[e].name=a.morphColors[e].name;d.morphColors[e].colors=[];f=d.morphColors[e].colors;k=a.morphColors[e].colors;n=0;for(i=k.length;n<i;n=n+3){m=new THREE.Color(16755200);m.setRGB(k[n],k[n+1],k[n+2]);f.push(m)}}}d.computeCentroids();d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
  173. THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
  174. 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.createScene(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,true);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
  175. THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function f(){var a;for(n in z.objects)if(!J.objects[n]){p=z.objects[n];if(p.geometry!==void 0){if(G=J.geometries[p.geometry]){a=false;R=J.materials[p.materials[0]];(a=R instanceof THREE.ShaderMaterial)&&G.computeTangents();s=p.position;I=p.rotation;A=p.quaternion;N=p.scale;v=p.matrix;A=0;p.materials.length==0&&(R=new THREE.MeshFaceMaterial);p.materials.length>1&&(R=new THREE.MeshFaceMaterial);
  176. a=new THREE.Mesh(G,R);a.name=n;if(v){a.matrixAutoUpdate=false;a.matrix.set(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15])}else{a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(I[0],I[1],I[2]);a.scale.set(N[0],N[1],N[2])}a.visible=p.visible;a.doubleSided=p.doubleSided;a.castShadow=p.castShadow;a.receiveShadow=p.receiveShadow;J.scene.add(a);J.objects[n]=a}}else{s=p.position;I=p.rotation;A=p.quaternion;
  177. N=p.scale;A=0;a=new THREE.Object3D;a.name=n;a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[3]);a.useQuaternion=true}else a.rotation.set(I[0],I[1],I[2]);a.scale.set(N[0],N[1],N[2]);a.visible=p.visible!==void 0?p.visible:false;J.scene.add(a);J.objects[n]=a;J.empties[n]=a}}}function e(a){return function(b){J.geometries[a]=b;f();V=V-1;l.onLoadComplete();j()}}function h(a){return function(b){J.geometries[a]=b}}function j(){l.callbackProgress({totalModels:$,totalTextures:fa,loadedModels:$-
  178. V,loadedTextures:fa-E},J);l.onLoadProgress();V===0&&E===0&&b(J)}var l=this,k=THREE.Loader.prototype.extractUrlBase(c),i,m,n,q,u,o,r,p,v,x,F,s,I,A,N,D,H,G,R,U,T,z,K,V,E,$,fa,J;z=a;c=new THREE.BinaryLoader;K=new THREE.JSONLoader;E=V=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(z.transform){a=z.transform.position;x=z.transform.rotation;D=z.transform.scale;a&&J.scene.position.set(a[0],a[1],a[2]);x&&J.scene.rotation.set(x[0],x[1],
  179. x[2]);D&&J.scene.scale.set(D[0],D[1],D[2]);if(a||x||D){J.scene.updateMatrix();J.scene.updateMatrixWorld()}}a=function(a){return function(){E=E-a;j();l.onLoadComplete()}};for(u in z.cameras){D=z.cameras[u];D.type==="perspective"?U=new THREE.PerspectiveCamera(D.fov,D.aspect,D.near,D.far):D.type==="ortho"&&(U=new THREE.OrthographicCamera(D.left,D.right,D.top,D.bottom,D.near,D.far));s=D.position;x=D.target;D=D.up;U.position.set(s[0],s[1],s[2]);U.target=new THREE.Vector3(x[0],x[1],x[2]);D&&U.up.set(D[0],
  180. D[1],D[2]);J.cameras[u]=U}for(q in z.lights){x=z.lights[q];u=x.color!==void 0?x.color:16777215;U=x.intensity!==void 0?x.intensity:1;if(x.type==="directional"){s=x.direction;F=new THREE.DirectionalLight(u,U);F.position.set(s[0],s[1],s[2]);F.position.normalize()}else if(x.type==="point"){s=x.position;F=x.distance;F=new THREE.PointLight(u,U,F);F.position.set(s[0],s[1],s[2])}else x.type==="ambient"&&(F=new THREE.AmbientLight(u));J.scene.add(F);J.lights[q]=F}for(o in z.fogs){q=z.fogs[o];q.type==="linear"?
  181. T=new THREE.Fog(0,q.near,q.far):q.type==="exp2"&&(T=new THREE.FogExp2(0,q.density));D=q.color;T.color.setRGB(D[0],D[1],D[2]);J.fogs[o]=T}if(J.cameras&&z.defaults.camera)J.currentCamera=J.cameras[z.defaults.camera];if(J.fogs&&z.defaults.fog)J.scene.fog=J.fogs[z.defaults.fog];D=z.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(D[0],D[1],D[2]);J.bgColorAlpha=z.defaults.bgalpha;for(i in z.geometries){o=z.geometries[i];if(o.type=="bin_mesh"||o.type=="ascii_mesh"){V=V+1;l.onLoadStart()}}$=V;
  182. for(i in z.geometries){o=z.geometries[i];if(o.type==="cube"){G=new THREE.CubeGeometry(o.width,o.height,o.depth,o.segmentsWidth,o.segmentsHeight,o.segmentsDepth,null,o.flipped,o.sides);J.geometries[i]=G}else if(o.type==="plane"){G=new THREE.PlaneGeometry(o.width,o.height,o.segmentsWidth,o.segmentsHeight);J.geometries[i]=G}else if(o.type==="sphere"){G=new THREE.SphereGeometry(o.radius,o.segmentsWidth,o.segmentsHeight);J.geometries[i]=G}else if(o.type==="cylinder"){G=new THREE.CylinderGeometry(o.topRad,
  183. o.botRad,o.height,o.radSegs,o.heightSegs);J.geometries[i]=G}else if(o.type==="torus"){G=new THREE.TorusGeometry(o.radius,o.tube,o.segmentsR,o.segmentsT);J.geometries[i]=G}else if(o.type==="icosahedron"){G=new THREE.IcosahedronGeometry(o.radius,o.subdivisions);J.geometries[i]=G}else if(o.type==="bin_mesh")c.load(d(o.url,z.urlBaseType),e(i));else if(o.type==="ascii_mesh")K.load(d(o.url,z.urlBaseType),e(i));else if(o.type==="embedded_mesh"){o=z.embeds[o.id];o.metadata=z.metadata;o&&K.createModel(o,h(i),
  184. "")}}for(r in z.textures){i=z.textures[r];if(i.url instanceof Array){E=E+i.url.length;for(o=0;o<i.url.length;o++)l.onLoadStart()}else{E=E+1;l.onLoadStart()}}fa=E;for(r in z.textures){i=z.textures[r];if(i.mapping!==void 0&&THREE[i.mapping]!==void 0)i.mapping=new THREE[i.mapping];if(i.url instanceof Array){o=i.url.length;T=[];for(c=0;c<o;c++)T[c]=d(i.url[c],z.urlBaseType);o=THREE.ImageUtils.loadTextureCube(T,i.mapping,a(o))}else{o=THREE.ImageUtils.loadTexture(d(i.url,z.urlBaseType),i.mapping,a(1));
  185. if(THREE[i.minFilter]!==void 0)o.minFilter=THREE[i.minFilter];if(THREE[i.magFilter]!==void 0)o.magFilter=THREE[i.magFilter];if(i.repeat){o.repeat.set(i.repeat[0],i.repeat[1]);if(i.repeat[0]!==1)o.wrapS=THREE.RepeatWrapping;if(i.repeat[1]!==1)o.wrapT=THREE.RepeatWrapping}i.offset&&o.offset.set(i.offset[0],i.offset[1]);if(i.wrap){T={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(T[i.wrap[0]]!==void 0)o.wrapS=T[i.wrap[0]];if(T[i.wrap[1]]!==void 0)o.wrapT=T[i.wrap[1]]}}J.textures[r]=
  186. o}for(m in z.materials){v=z.materials[m];for(H in v.parameters)if(H==="envMap"||H==="map"||H==="lightMap")v.parameters[H]=J.textures[v.parameters[H]];else if(H==="shading")v.parameters[H]=v.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H==="blending")v.parameters[H]=v.parameters[H]in THREE?THREE[v.parameters[H]]:THREE.NormalBlending;else if(H==="combine")v.parameters[H]=v.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(H==="vertexColors")if(v.parameters[H]==
  187. "face")v.parameters[H]=THREE.FaceColors;else if(v.parameters[H])v.parameters[H]=THREE.VertexColors;if(v.parameters.opacity!==void 0&&v.parameters.opacity<1)v.parameters.transparent=true;if(v.parameters.normalMap){r=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(r.uniforms);i=v.parameters.color;o=v.parameters.specular;T=v.parameters.ambient;c=v.parameters.shininess;a.tNormal.texture=J.textures[v.parameters.normalMap];if(v.parameters.normalMapFactor)a.uNormalScale.value=v.parameters.normalMapFactor;
  188. if(v.parameters.map){a.tDiffuse.texture=v.parameters.map;a.enableDiffuse.value=true}if(v.parameters.lightMap){a.tAO.texture=v.parameters.lightMap;a.enableAO.value=true}if(v.parameters.specularMap){a.tSpecular.texture=J.textures[v.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(o);a.uAmbientColor.value.setHex(T);a.uShininess.value=c;if(v.parameters.opacity)a.uOpacity.value=v.parameters.opacity;R=new THREE.ShaderMaterial({fragmentShader:r.fragmentShader,
  189. vertexShader:r.vertexShader,uniforms:a,lights:true,fog:true})}else R=new THREE[v.type](v.parameters);J.materials[m]=R}f();l.callbackSync(J);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
  190. 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}};
  191. THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;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.depthTest=a.depthTest!==void 0?
  192. a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.needsUpdate=this.visible=true};THREE.MaterialCount=0;
  193. THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  194. THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
  195. true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==
  196. void 0?a.morphTargets:false};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  197. THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=
  198. a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?
  199. a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
  200. THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:false;this.perPixel=
  201. a.perPixel!==void 0?a.perPixel:false;this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=
  202. a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?
  203. a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);
  204. THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshFaceMaterial=function(){};
  205. THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:true;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
  206. THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=
  207. a.fog!==void 0?a.fog:false;this.lights=a.lights!==void 0?a.lights:false;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);
  208. THREE.Texture=function(a,b,c,d,f,e,h,j,l){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=l!==void 0?l:1;this.format=h!==void 0?h:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
  209. new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;
  210. THREE.DataTexture=function(a,b,c,d,f,e,h,j,l,k){THREE.Texture.call(this,null,e,h,j,l,k,d,f);this.image={data:a,width:b,height:c}};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};
  211. THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=Object.create(THREE.Object3D.prototype);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};
  212. THREE.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);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);
  213. 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);
  214. 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);
  215. 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)};
  216. 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=
  217. 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=
  218. 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};
  219. 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)}for(var b=this.bones.length,c=this.bones,d=this.boneMatrices,a=0;a<b;a++)c[a].skinMatrix.flattenToArrayOffset(d,
  220. a*16);if(this.useVertexTexture)this.boneTexture.needsUpdate=true};
  221. THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(true);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);b.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a],f=this.geometry.skinIndices[a].x,e=this.geometry.skinIndices[a].y,
  222. d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[f].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[e].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x=this.geometry.skinWeights[a].x+c;this.geometry.skinWeights[a].y=this.geometry.skinWeights[a].y+c}}}};
  223. THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};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)};
  224. 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=
  225. false}};
  226. 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?
  227. 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=
  228. 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);
  229. 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);
  230. 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);
  231. THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)this.__lights.indexOf(a)===-1&&this.__lights.push(a);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])};
  232. 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])};
  233. 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};
  234. 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",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#endif",
  235. envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.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, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\n}\n#endif",
  236. envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\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",
  237. map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",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:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\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",
  238. lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",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",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_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",
  239. 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\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
  240. 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\nvarying vec3 vWorldPosition;\n#endif",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\nvWorldPosition = mPosition.xyz;\n#endif",
  241. 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_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\nvarying vec3 vWorldPosition;\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  242. 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#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 = 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 = 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 = 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\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_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",
  243. 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",
  244. skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix( skinIndex.x );\nmat4 boneMatY = getBoneMatrix( skinIndex.y );\n#endif",skinning_vertex:"#ifdef USE_SKINNING\nvec4 skinned = boneMatX * skinVertexA * skinWeight.x;\nskinned \t += boneMatY * skinVertexB * skinWeight.y;\ngl_Position = projectionMatrix * modelViewMatrix * skinned;\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",
  245. 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;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
  246. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",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;\nvec3 transformedNormal = normalMatrix * morphedNormal;\n#else\nvec3 transformedNormal = normalMatrix * normal;\n#endif",
  247. skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = skinWeight.x * boneMatX;\nskinMatrix \t+= skinWeight.y * boneMatY;\nvec4 skinnedNormal = skinMatrix * vec4( transformedNormal, 0.0 );\ntransformedNormal = skinnedNormal.xyz;\n#endif",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",
  248. 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",
  249. 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 ++ ) {\n#ifdef USE_MORPHTARGETS\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );\n#else\n#ifdef USE_SKINNING\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * skinned;\n#else\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n#endif\n#endif\n}\n#endif",
  250. 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"};
  251. 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}};
  252. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture: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}},fog:{fogDensity:{type:"f",
  253. 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:[]},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",
  254. 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",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture: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:6,texture:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",
  255. value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}};
  256. 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",
  257. 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,
  258. THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinning_vertex,
  259. THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_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,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,
  260. THREE.ShaderChunk.alphatest_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,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)},
  261. wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying 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,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
  262. THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif",THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),
  263. 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,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif",
  264. 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")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,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)},
  265. shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",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.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
  266. THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,
  267. 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;",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,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",
  268. THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_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;",
  269. THREE.ShaderChunk.color_pars_vertex,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.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
  270. 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.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
  271. THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_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}"}};
  272. 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 e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=true;var h=1;f.type==="v2"?h=2:f.type==="v3"?h=3:f.type==="v4"?h=4:f.type==="c"&&(h=3);f.size=h;f.array=new Float32Array(c*h);f.buffer=g.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=true}a.__webglCustomAttributesList.push(f)}}}
  273. 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 instanceof THREE.ShaderMaterial?true:false}function e(a,b,c){var d,e,f,h,i=a.vertices;h=i.length;
  274. var j=a.colors,k=j.length,m=a.__vertexArray,l=a.__colorArray,n=a.__sortArray,o=a.verticesNeedUpdate,q=a.colorsNeedUpdate,r=a.__webglCustomAttributesList;if(c.sortParticles){Vb.copy(Wb);Vb.multiplySelf(c.matrixWorld);for(d=0;d<h;d++){e=i[d];pb.copy(e);Vb.multiplyVector3(pb);n[d]=[pb.z,d]}n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++){e=i[n[d][1]];f=d*3;m[f]=e.x;m[f+1]=e.y;m[f+2]=e.z}for(d=0;d<k;d++){f=d*3;e=j[n[d][1]];l[f]=e.r;l[f+1]=e.g;l[f+2]=e.b}if(r){j=0;for(k=r.length;j<k;j++){i=r[j];
  275. if(i.boundTo===void 0||i.boundTo==="vertices"){f=0;e=i.value.length;if(i.size===1)for(d=0;d<e;d++){h=n[d][1];i.array[d]=i.value[h]}else if(i.size===2)for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[f]=h.x;i.array[f+1]=h.y;f=f+2}else if(i.size===3)if(i.type==="c")for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[f]=h.r;i.array[f+1]=h.g;i.array[f+2]=h.b;f=f+3}else for(d=0;d<e;d++){h=n[d][1];h=i.value[h];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;f=f+3}else if(i.size===4)for(d=0;d<e;d++){h=n[d][1];
  276. h=i.value[h];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;i.array[f+3]=h.w;f=f+4}}}}}else{if(o)for(d=0;d<h;d++){e=i[d];f=d*3;m[f]=e.x;m[f+1]=e.y;m[f+2]=e.z}if(q)for(d=0;d<k;d++){e=j[d];f=d*3;l[f]=e.r;l[f+1]=e.g;l[f+2]=e.b}if(r){j=0;for(k=r.length;j<k;j++){i=r[j];if(i.needsUpdate&&(i.boundTo===void 0||i.boundTo==="vertices")){e=i.value.length;f=0;if(i.size===1)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(i.size===2)for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;f=f+2}else if(i.size===
  277. 3)if(i.type==="c")for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.r;i.array[f+1]=h.g;i.array[f+2]=h.b;f=f+3}else for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;f=f+3}else if(i.size===4)for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;i.array[f+3]=h.w;f=f+4}}}}}if(o||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,a.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,m,b)}if(q||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,a.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,
  278. l,b)}if(r){j=0;for(k=r.length;j<k;j++){i=r[j];if(i.needsUpdate||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.bufferData(g.ARRAY_BUFFER,i.array,b)}}}}function h(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,f=a.length;d<f;d++){aa=J=null;S=ba=qa=L=Qa=Ba=xa=-1;Wa=true;a[d].render(b,c,gc,xc);aa=J=null;S=ba=qa=L=Qa=Ba=xa=-1;Wa=true}}function k(a,b,c,d,f,g,e,h){var i,j,k,m;if(b){j=a.length-1;m=b=-1}else{j=0;b=a.length;m=1}for(var l=j;l!==b;l=
  279. l+m){i=a[l];if(i.render){j=i.object;k=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;e&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);v(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);k instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,g,i,k,j):E.renderBuffer(d,f,g,i,k,j)}}}function i(a,b,c,d,f,g,e){for(var h,i,j=0,k=a.length;j<k;j++){h=a[j];i=h.object;if(i.visible){if(e)h=e;else{h=h[b];
  280. if(!h)continue;g&&E.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);v(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}E.renderImmediateObject(c,d,f,h,i)}}}function m(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function q(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function u(a,b){for(var c=
  281. a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function o(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,f){if(d.needsUpdate){d.program&&E.deallocateMaterial(d);E.initMaterial(d,b,c,f);d.needsUpdate=false}if(d.morphTargets&&!f.__webglMorphTargetInfluences)f.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);var e=false,h=d.program,i=h.uniforms,j=d.uniforms;if(h!==J){g.useProgram(h);J=h;e=true}if(d.id!==S){S=d.id;e=true}if(e||a!==aa){g.uniformMatrix4fv(i.projectionMatrix,
  282. false,a._projectionMatrixArray);a!==aa&&(aa=a)}if(e){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(Wa){for(var k,l=0,m=0,n=0,o,q,r,p=yc,u=p.directional.colors,s=p.directional.positions,v=p.point.colors,x=p.point.positions,z=p.point.distances,D=p.spot.colors,I=p.spot.positions,K=p.spot.distances,
  283. H=p.spot.directions,G=p.spot.angles,R=p.spot.exponents,T=0,V=0,U=0,L=r=0,c=L=0,e=b.length;c<e;c++){k=b[c];if(!k.onlyShadow&&k.visible){o=k.color;q=k.intensity;r=k.distance;if(k instanceof THREE.AmbientLight)if(E.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(k instanceof THREE.DirectionalLight){r=T*3;if(E.gammaInput){u[r]=o.r*o.r*q*q;u[r+1]=o.g*o.g*q*q;u[r+2]=o.b*o.b*q*q}else{u[r]=o.r*q;u[r+1]=o.g*q;u[r+2]=o.b*q}Ha.copy(k.matrixWorld.getPosition());Ha.subSelf(k.target.matrixWorld.getPosition());
  284. Ha.normalize();s[r]=Ha.x;s[r+1]=Ha.y;s[r+2]=Ha.z;T=T+1}else if(k instanceof THREE.PointLight){L=V*3;if(E.gammaInput){v[L]=o.r*o.r*q*q;v[L+1]=o.g*o.g*q*q;v[L+2]=o.b*o.b*q*q}else{v[L]=o.r*q;v[L+1]=o.g*q;v[L+2]=o.b*q}o=k.matrixWorld.getPosition();x[L]=o.x;x[L+1]=o.y;x[L+2]=o.z;z[V]=r;V=V+1}else if(k instanceof THREE.SpotLight){L=U*3;if(E.gammaInput){D[L]=o.r*o.r*q*q;D[L+1]=o.g*o.g*q*q;D[L+2]=o.b*o.b*q*q}else{D[L]=o.r*q;D[L+1]=o.g*q;D[L+2]=o.b*q}o=k.matrixWorld.getPosition();I[L]=o.x;I[L+1]=o.y;I[L+2]=
  285. o.z;K[U]=r;Ha.copy(o);Ha.subSelf(k.target.matrixWorld.getPosition());Ha.normalize();H[L]=Ha.x;H[L+1]=Ha.y;H[L+2]=Ha.z;G[U]=Math.cos(k.angle);R[U]=k.exponent;U=U+1}}}c=T*3;for(e=u.length;c<e;c++)u[c]=0;c=V*3;for(e=v.length;c<e;c++)v[c]=0;c=U*3;for(e=D.length;c<e;c++)D[c]=0;p.directional.length=T;p.point.length=V;p.spot.length=U;p.ambient[0]=l;p.ambient[1]=m;p.ambient[2]=n;Wa=false}c=yc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=
  286. c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances;j.spotLightColor.value=c.spot.colors;j.spotLightPosition.value=c.spot.positions;j.spotLightDistance.value=c.spot.distances;j.spotLightDirection.value=c.spot.directions;j.spotLightAngle.value=c.spot.angles;j.spotLightExponent.value=c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){j.opacity.value=
  287. d.opacity;E.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color;(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y);j.lightMap.texture=d.lightMap;j.envMap.texture=d.envMap;j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;j.reflectivity.value=d.reflectivity;j.refractionRatio.value=d.refractionRatio;j.combine.value=d.combine;j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof
  288. THREE.LineBasicMaterial){j.diffuse.value=d.color;j.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){j.psColor.value=d.color;j.opacity.value=d.opacity;j.size.value=d.size;j.scale.value=N.height/2;j.map.texture=d.map}else if(d instanceof THREE.MeshPhongMaterial){j.shininess.value=d.shininess;if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive);j.specular.value.copyGammaToLinear(d.specular)}else{j.ambient.value=d.ambient;
  289. j.emissive.value=d.emissive;j.specular.value=d.specular}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshLambertMaterial){if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive)}else{j.ambient.value=d.ambient;j.emissive.value=d.emissive}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshDepthMaterial){j.mNear.value=a.near;j.mFar.value=a.far;j.opacity.value=d.opacity}else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=
  290. d.opacity;if(f.receiveShadow&&!d._shadowPass&&j.shadowMatrix){e=c=0;for(k=b.length;e<k;e++){l=b[e];if(l.castShadow&&(l instanceof THREE.SpotLight||l instanceof THREE.DirectionalLight&&!l.shadowCascade)){j.shadowMap.texture[c]=l.shadowMap;j.shadowMapSize.value[c]=l.shadowMapSize;j.shadowMatrix.value[c]=l.shadowMatrix;j.shadowDarkness.value[c]=l.shadowDarkness;j.shadowBias.value[c]=l.shadowBias;c++}}}b=d.uniformsList;j=0;for(c=b.length;j<c;j++)if(l=h.uniforms[b[j][1]]){e=b[j][0];m=e.type;k=e.value;
  291. if(m==="i")g.uniform1i(l,k);else if(m==="f")g.uniform1f(l,k);else if(m==="v2")g.uniform2f(l,k.x,k.y);else if(m==="v3")g.uniform3f(l,k.x,k.y,k.z);else if(m==="v4")g.uniform4f(l,k.x,k.y,k.z,k.w);else if(m==="c")g.uniform3f(l,k.r,k.g,k.b);else if(m==="iv1")g.uniform1iv(l,k);else if(m==="iv")g.uniform3iv(l,k);else if(m==="fv1")g.uniform1fv(l,k);else if(m==="fv")g.uniform3fv(l,k);else if(m==="v2v"){if(e._array===void 0)e._array=new Float32Array(2*k.length);m=0;for(n=k.length;m<n;m++){p=m*2;e._array[p]=
  292. k[m].x;e._array[p+1]=k[m].y}g.uniform2fv(l,e._array)}else if(m==="v3v"){if(e._array===void 0)e._array=new Float32Array(3*k.length);m=0;for(n=k.length;m<n;m++){p=m*3;e._array[p]=k[m].x;e._array[p+1]=k[m].y;e._array[p+2]=k[m].z}g.uniform3fv(l,e._array)}else if(m==="v4v"){if(e._array===void 0)e._array=new Float32Array(4*k.length);m=0;for(n=k.length;m<n;m++){p=m*4;e._array[p]=k[m].x;e._array[p+1]=k[m].y;e._array[p+2]=k[m].z;e._array[p+3]=k[m].w}g.uniform4fv(l,e._array)}else if(m==="m4"){if(e._array===
  293. void 0)e._array=new Float32Array(16);k.flattenToArray(e._array);g.uniformMatrix4fv(l,false,e._array)}else if(m==="m4v"){if(e._array===void 0)e._array=new Float32Array(16*k.length);m=0;for(n=k.length;m<n;m++)k[m].flattenToArrayOffset(e._array,m*16);g.uniformMatrix4fv(l,false,e._array)}else if(m==="t"){g.uniform1i(l,k);if(l=e.texture)if(l.image instanceof Array&&l.image.length===6){e=l;if(e.image.length===6)if(e.needsUpdate){if(!e.image.__webglTextureCube)e.image.__webglTextureCube=g.createTexture();
  294. g.activeTexture(g.TEXTURE0+k);g.bindTexture(g.TEXTURE_CUBE_MAP,e.image.__webglTextureCube);g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,e.flipY);k=[];for(l=0;l<6;l++){m=k;n=l;if(E.autoScaleCubemaps){p=e.image[l];s=Oc;if(!(p.width<=s&&p.height<=s)){v=Math.max(p.width,p.height);u=Math.floor(p.width*s/v);s=Math.floor(p.height*s/v);v=document.createElement("canvas");v.width=u;v.height=s;v.getContext("2d").drawImage(p,0,0,p.width,p.height,0,0,u,s);p=v}}else p=e.image[l];m[n]=p}l=k[0];m=(l.width&l.width-1)===0&&
  295. (l.height&l.height-1)===0;n=A(e.format);p=A(e.type);F(g.TEXTURE_CUBE_MAP,e,m);for(l=0;l<6;l++)g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,n,p,k[l]);e.generateMipmaps&&m&&g.generateMipmap(g.TEXTURE_CUBE_MAP);e.needsUpdate=false;if(e.onUpdate)e.onUpdate()}else{g.activeTexture(g.TEXTURE0+k);g.bindTexture(g.TEXTURE_CUBE_MAP,e.image.__webglTextureCube)}}else if(l instanceof THREE.WebGLRenderTargetCube){e=l;g.activeTexture(g.TEXTURE0+k);g.bindTexture(g.TEXTURE_CUBE_MAP,e.__webglTexture)}else E.setTexture(l,
  296. k)}else if(m==="tv"){if(e._array===void 0){e._array=[];m=0;for(n=e.texture.length;m<n;m++)e._array[m]=k+m}g.uniform1iv(l,e._array);m=0;for(n=e.texture.length;m<n;m++)(l=e.texture[m])&&E.setTexture(l,e._array[m])}}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&i.cameraPosition!==null){b=a.matrixWorld.getPosition();g.uniform3f(i.cameraPosition,b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||
  297. d.skinning)&&i.viewMatrix!==null&&g.uniformMatrix4fv(i.viewMatrix,false,a._viewMatrixArray)}if(d.skinning)if(hc&&f.useVertexTexture){if(i.boneTexture!==null){g.uniform1i(i.boneTexture,12);E.setTexture(f.boneTexture,12)}}else i.boneGlobalMatrices!==null&&g.uniformMatrix4fv(i.boneGlobalMatrices,false,f.boneMatrices);g.uniformMatrix4fv(i.modelViewMatrix,false,f._modelViewMatrix.elements);i.normalMatrix&&g.uniformMatrix3fv(i.normalMatrix,false,f._normalMatrix.elements);i.objectMatrix!==null&&g.uniformMatrix4fv(i.objectMatrix,
  298. false,f.matrixWorld.elements);return h}function p(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function v(a,b,c){if(Va!==a){a?g.enable(g.POLYGON_OFFSET_FILL):g.disable(g.POLYGON_OFFSET_FILL);Va=a}if(a&&(ob!==b||Lb!==c)){g.polygonOffset(b,c);ob=b;Lb=c}}function x(a,b){var c;a==="fragment"?c=g.createShader(g.FRAGMENT_SHADER):a==="vertex"&&(c=g.createShader(g.VERTEX_SHADER));g.shaderSource(c,b);g.compileShader(c);
  299. if(!g.getShaderParameter(c,g.COMPILE_STATUS)){console.error(g.getShaderInfoLog(c));console.error(b);return null}return c}function F(a,b,c){if(c){g.texParameteri(a,g.TEXTURE_WRAP_S,A(b.wrapS));g.texParameteri(a,g.TEXTURE_WRAP_T,A(b.wrapT));g.texParameteri(a,g.TEXTURE_MAG_FILTER,A(b.magFilter));g.texParameteri(a,g.TEXTURE_MIN_FILTER,A(b.minFilter))}else{g.texParameteri(a,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_MAG_FILTER,I(b.magFilter));
  300. g.texParameteri(a,g.TEXTURE_MIN_FILTER,I(b.minFilter))}xb&&g.texParameterf(a,xb.TEXTURE_MAX_ANISOTROPY_EXT,b.anisotropy)}function s(a,b){g.bindRenderbuffer(g.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,b.width,b.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_STENCIL,b.width,b.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,
  301. g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,a)}else g.renderbufferStorage(g.RENDERBUFFER,g.RGBA4,b.width,b.height)}function I(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?g.NEAREST:g.LINEAR}function A(a){return a===THREE.RepeatWrapping?g.REPEAT:a===THREE.ClampToEdgeWrapping?g.CLAMP_TO_EDGE:a===THREE.MirroredRepeatWrapping?g.MIRRORED_REPEAT:a===THREE.NearestFilter?g.NEAREST:a===THREE.NearestMipMapNearestFilter?g.NEAREST_MIPMAP_NEAREST:a===
  302. THREE.NearestMipMapLinearFilter?g.NEAREST_MIPMAP_LINEAR:a===THREE.LinearFilter?g.LINEAR:a===THREE.LinearMipMapNearestFilter?g.LINEAR_MIPMAP_NEAREST:a===THREE.LinearMipMapLinearFilter?g.LINEAR_MIPMAP_LINEAR:a===THREE.UnsignedByteType?g.UNSIGNED_BYTE:a===THREE.UnsignedShort4444Type?g.UNSIGNED_SHORT_4_4_4_4:a===THREE.UnsignedShort5551Type?g.UNSIGNED_SHORT_5_5_5_1:a===THREE.UnsignedShort565Type?g.UNSIGNED_SHORT_5_6_5:a===THREE.ByteType?g.BYTE:a===THREE.ShortType?g.SHORT:a===THREE.UnsignedShortType?g.UNSIGNED_SHORT:
  303. a===THREE.IntType?g.INT:a===THREE.UnsignedIntType?g.UNSIGNED_INT:a===THREE.FloatType?g.FLOAT:a===THREE.AlphaFormat?g.ALPHA:a===THREE.RGBFormat?g.RGB:a===THREE.RGBAFormat?g.RGBA:a===THREE.LuminanceFormat?g.LUMINANCE:a===THREE.LuminanceAlphaFormat?g.LUMINANCE_ALPHA:a===THREE.AddEquation?g.FUNC_ADD:a===THREE.SubtractEquation?g.FUNC_SUBTRACT:a===THREE.ReverseSubtractEquation?g.FUNC_REVERSE_SUBTRACT:a===THREE.ZeroFactor?g.ZERO:a===THREE.OneFactor?g.ONE:a===THREE.SrcColorFactor?g.SRC_COLOR:a===THREE.OneMinusSrcColorFactor?
  304. g.ONE_MINUS_SRC_COLOR:a===THREE.SrcAlphaFactor?g.SRC_ALPHA:a===THREE.OneMinusSrcAlphaFactor?g.ONE_MINUS_SRC_ALPHA:a===THREE.DstAlphaFactor?g.DST_ALPHA:a===THREE.OneMinusDstAlphaFactor?g.ONE_MINUS_DST_ALPHA:a===THREE.DstColorFactor?g.DST_COLOR:a===THREE.OneMinusDstColorFactor?g.ONE_MINUS_DST_COLOR:a===THREE.SrcAlphaSaturateFactor?g.SRC_ALPHA_SATURATE:0}console.log("THREE.WebGLRenderer",THREE.REVISION);var a=a||{},N=a.canvas!==void 0?a.canvas:document.createElement("canvas"),D=a.precision!==void 0?
  305. a.precision:"highp",H=a.alpha!==void 0?a.alpha:true,G=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:true,R=a.antialias!==void 0?a.antialias:false,U=a.stencil!==void 0?a.stencil:true,T=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:false,z=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),K=a.clearAlpha!==void 0?a.clearAlpha:0,V=a.maxLights!==void 0?a.maxLights:4;this.domElement=N;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=
  306. 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,vertices:0,faces:0,points:0}};
  307. var E=this,$=[],fa=0,J=null,ra=null,S=-1,ba=null,aa=null,va=0,L=-1,qa=-1,xa=-1,Aa=-1,Pa=-1,ja=-1,Ba=-1,Qa=-1,Va=null,ob=null,Lb=null,wb=null,Ub=0,Mb=0,Nb=0,Ob=0,gc=0,xc=0,ic=new THREE.Frustum,Wb=new THREE.Matrix4,Vb=new THREE.Matrix4,pb=new THREE.Vector4,Ha=new THREE.Vector3,Wa=true,yc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],angles:[],exponents:[]}},g,xb;try{if(!(g=
  308. N.getContext("experimental-webgl",{alpha:H,premultipliedAlpha:G,antialias:R,stencil:U,preserveDrawingBuffer:T})))throw"Error creating WebGL context.";}catch(Pc){console.error(Pc)}(a=g.getExtension("OES_texture_float"))||console.log("THREE.WebGLRenderer: Float textures not supported.");(xb=g.getExtension("EXT_texture_filter_anisotropic")||g.getExtension("MOZ_EXT_texture_filter_anisotropic")||g.getExtension("WEBKIT_EXT_texture_filter_anisotropic"))||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");
  309. g.clearColor(0,0,0,1);g.clearDepth(1);g.clearStencil(0);g.enable(g.DEPTH_TEST);g.depthFunc(g.LEQUAL);g.frontFace(g.CCW);g.cullFace(g.BACK);g.enable(g.CULL_FACE);g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA);g.clearColor(z.r,z.g,z.b,K);this.context=g;H=g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS);g.getParameter(g.MAX_TEXTURE_SIZE);var Oc=g.getParameter(g.MAX_CUBE_MAP_TEXTURE_SIZE),Qc=xb?g.getParameter(xb.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,jc=H>0,hc=
  310. jc&&a;this.getContext=function(){return g};this.supportsVertexTextures=function(){return jc};this.getMaxAnisotropy=function(){return Qc};this.setSize=function(a,b){N.width=a;N.height=b;this.setViewport(0,0,N.width,N.height)};this.setViewport=function(a,b,c,d){Ub=a;Mb=b;Nb=c;Ob=d;g.viewport(Ub,Mb,Nb,Ob)};this.setScissor=function(a,b,c,d){g.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?g.enable(g.SCISSOR_TEST):g.disable(g.SCISSOR_TEST)};this.setClearColorHex=function(a,b){z.setHex(a);K=b;g.clearColor(z.r,
  311. z.g,z.b,K)};this.setClearColor=function(a,b){z.copy(a);K=b;g.clearColor(z.r,z.g,z.b,K)};this.getClearColor=function(){return z};this.getClearAlpha=function(){return K};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|g.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|g.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|g.STENCIL_BUFFER_BIT;g.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=
  312. 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._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];g.deleteBuffer(c.__webglVertexBuffer);g.deleteBuffer(c.__webglNormalBuffer);g.deleteBuffer(c.__webglTangentBuffer);g.deleteBuffer(c.__webglColorBuffer);
  313. g.deleteBuffer(c.__webglUVBuffer);g.deleteBuffer(c.__webglUV2Buffer);g.deleteBuffer(c.__webglSkinVertexABuffer);g.deleteBuffer(c.__webglSkinVertexBBuffer);g.deleteBuffer(c.__webglSkinIndicesBuffer);g.deleteBuffer(c.__webglSkinWeightsBuffer);g.deleteBuffer(c.__webglFaceBuffer);g.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d<e;d++)g.deleteBuffer(c.__webglMorphTargetsBuffers[d])}if(c.numMorphNormals){d=0;for(e=c.numMorphNormals;d<e;d++)g.deleteBuffer(c.__webglMorphNormalsBuffers[d])}if(c.__webglCustomAttributesList){d=
  314. void 0;for(d in c.__webglCustomAttributesList)g.deleteBuffer(c.__webglCustomAttributesList[d].buffer)}E.info.memory.geometries--}else if(a instanceof THREE.Ribbon){a=a.geometry;g.deleteBuffer(a.__webglVertexBuffer);g.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}else if(a instanceof THREE.Line){a=a.geometry;g.deleteBuffer(a.__webglVertexBuffer);g.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}else if(a instanceof THREE.ParticleSystem){a=a.geometry;g.deleteBuffer(a.__webglVertexBuffer);
  315. g.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;g.deleteTexture(a.__webglTexture);E.info.memory.textures--}};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){g.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){g.deleteFramebuffer(a.__webglFramebuffer[b]);g.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{g.deleteFramebuffer(a.__webglFramebuffer);
  316. g.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=false,a=0;for(c=$.length;a<c;a++){d=$[a];if(d.program===b){d.usedTimes--;d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=$.length;a<c;a++){d=$[a];d.program!==b&&e.push(d)}$=e;g.deleteProgram(b);E.info.memory.programs--}}};this.updateShadowMap=function(a,b){J=null;S=ba=Qa=Ba=xa=-1;Wa=true;qa=L=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,
  317. b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=g.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=g.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=g.createBuffer();if(a.hasColors&&!a.__webglColorBuffer)a.__webglColorBuffer=g.createBuffer();if(a.hasPositions){g.bindBuffer(g.ARRAY_BUFFER,a.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,a.positionArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.position);g.vertexAttribPointer(b.attributes.position,
  318. 3,g.FLOAT,false,0,0)}if(a.hasNormals){g.bindBuffer(g.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,e,f,h,i,j,k,m,l,n,o,q=a.count*3;for(o=0;o<q;o=o+9){n=a.normalArray;d=n[o];e=n[o+1];f=n[o+2];h=n[o+3];j=n[o+4];m=n[o+5];i=n[o+6];k=n[o+7];l=n[o+8];d=(d+h+i)/3;e=(e+j+k)/3;f=(f+m+l)/3;n[o]=d;n[o+1]=e;n[o+2]=f;n[o+3]=d;n[o+4]=e;n[o+5]=f;n[o+6]=d;n[o+7]=e;n[o+8]=f}}g.bufferData(g.ARRAY_BUFFER,a.normalArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.normal);g.vertexAttribPointer(b.attributes.normal,
  319. 3,g.FLOAT,false,0,0)}if(a.hasUvs&&c.map){g.bindBuffer(g.ARRAY_BUFFER,a.__webglUvBuffer);g.bufferData(g.ARRAY_BUFFER,a.uvArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.uv);g.vertexAttribPointer(b.attributes.uv,2,g.FLOAT,false,0,0)}if(a.hasColors&&c.vertexColors!==THREE.NoColors){g.bindBuffer(g.ARRAY_BUFFER,a.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,a.colorArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.color);g.vertexAttribPointer(b.attributes.color,3,g.FLOAT,false,
  320. 0,0)}g.drawArrays(g.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(d.visible!==false){c=r(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ba){ba=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;f.length>1&&(b=true);d=0;for(c=f.length;d<c;++d){var h=f[d].index;if(b){var i=e.attributes.position,j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.position,j,g.FLOAT,false,0,h*j*4);i=e.attributes.normal;if(a.normal>=
  321. 0&&i){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.normal,j,g.FLOAT,false,0,h*j*4)}i=e.attributes.uv;if(a.uv>=0&&i)if(i.buffer){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.uv,j,g.FLOAT,false,0,h*j*4);g.enableVertexAttribArray(a.uv)}else g.disableVertexAttribArray(a.uv);i=e.attributes.color;if(a.color>=0&&i){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.color,j,g.FLOAT,false,0,h*j*4)}i=e.attributes.tangent;if(a.tangent>=
  322. 0&&i){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.tangent,j,g.FLOAT,false,0,h*j*4)}g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.attributes.index.buffer)}g.drawElements(g.TRIANGLES,f[d].count,g.UNSIGNED_SHORT,f[d].start*2);E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+f[d].count;E.info.render.faces=E.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var h,i,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+
  323. c.id*2+(d.wireframe?1:0);if(c!==ba){ba=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(b.position,3,g.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}else if(c.position>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(c.position,
  324. 3,g.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var k=0;i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;k<d.numSupportedMorphTargets&&k<i.length;){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[k]]);g.vertexAttribPointer(c["morphTarget"+k],3,g.FLOAT,false,0,0);if(d.morphNormals){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[k]]);g.vertexAttribPointer(c["morphNormal"+k],3,g.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[k]=h[i[k]];k++}}else{i=[];h=f.morphTargetInfluences;
  325. var m,l=h.length;for(m=0;m<l;m++){k=h[m];k>0&&i.push([m,k])}if(i.length>d.numSupportedMorphTargets){i.sort(j);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals?i.sort(j):i.length===0&&i.push([0,0]);for(k=0;k<d.numSupportedMorphTargets;){if(i[k]){m=i[k][0];g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);g.vertexAttribPointer(c["morphTarget"+k],3,g.FLOAT,false,0,0);if(d.morphNormals){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]);g.vertexAttribPointer(c["morphNormal"+
  326. k],3,g.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[k]=h[m]}else{g.vertexAttribPointer(c["morphTarget"+k],3,g.FLOAT,false,0,0);d.morphNormals&&g.vertexAttribPointer(c["morphNormal"+k],3,g.FLOAT,false,0,0);f.__webglMorphTargetInfluences[k]=0}k++}}d.program.uniforms.morphTargetInfluences!==null&&g.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){h=0;for(i=e.__webglCustomAttributesList.length;h<i;h++){c=e.__webglCustomAttributesList[h];
  327. if(b[c.buffer.belongsToAttribute]>=0){g.bindBuffer(g.ARRAY_BUFFER,c.buffer);g.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,g.FLOAT,false,0,0)}}}if(b.color>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglColorBuffer);g.vertexAttribPointer(b.color,3,g.FLOAT,false,0,0)}if(b.normal>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglNormalBuffer);g.vertexAttribPointer(b.normal,3,g.FLOAT,false,0,0)}if(b.tangent>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglTangentBuffer);g.vertexAttribPointer(b.tangent,4,g.FLOAT,
  328. false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUVBuffer);g.vertexAttribPointer(b.uv,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv)}else g.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUV2Buffer);g.vertexAttribPointer(b.uv2,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv2)}else g.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){g.bindBuffer(g.ARRAY_BUFFER,
  329. e.__webglSkinVertexABuffer);g.vertexAttribPointer(b.skinVertexA,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);g.vertexAttribPointer(b.skinIndex,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==wb){g.lineWidth(d);
  330. wb=d}a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);g.drawElements(g.LINES,e.__webglLineCount,g.UNSIGNED_SHORT,0)}else{a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);g.drawElements(g.TRIANGLES,e.__webglFaceCount,g.UNSIGNED_SHORT,0)}E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+e.__webglFaceCount;E.info.render.faces=E.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?g.LINE_STRIP:g.LINES;d=d.linewidth;
  331. if(d!==wb){g.lineWidth(d);wb=d}g.drawArrays(f,0,e.__webglLineCount);E.info.render.calls++}else if(f instanceof THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);E.info.render.calls++;E.info.render.points=E.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);E.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,m,n=a.__lights,o=a.fog;S=-1;Wa=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");
  332. a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=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);Wb.multiply(b.projectionMatrix,b.matrixWorldInverse);ic.setFromMatrix(Wb);this.autoUpdateObjects&&this.initWebGLObjects(a);l(this.renderPluginsPre,
  333. a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;E.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d<e;d++){f=m[d];j=f.object;f.render=false;if(j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||ic.contains(j))){p(j,b);var q=f,r=q.object,u=q.buffer,s=void 0,s=s=void 0,s=r.material;if(s instanceof THREE.MeshFaceMaterial){s=
  334. u.materialIndex;if(s>=0){s=r.geometry.materials[s];if(s.transparent){q.transparent=s;q.opaque=null}else{q.opaque=s;q.transparent=null}}}else if(s)if(s.transparent){q.transparent=s;q.opaque=null}else{q.opaque=s;q.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{pb.copy(j.matrixWorld.getPosition());Wb.multiplyVector3(pb);f.z=pb.z}}}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d<e;d++){f=m[d];j=f.object;if(j.visible){p(j,b);j=f.object.material;
  335. if(j.transparent){f.transparent=j;f.opaque=null}else{f.opaque=j;f.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);v(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);k(a.__webglObjects,false,"",b,n,o,true,d);i(a.__webglObjectsImmediate,"",b,n,o,false,d)}else{this.setBlending(THREE.NormalBlending);k(a.__webglObjects,true,"opaque",b,n,o,false);i(a.__webglObjectsImmediate,
  336. "opaque",b,n,o,false);k(a.__webglObjects,false,"transparent",b,n,o,true);i(a.__webglObjectsImmediate,"transparent",b,n,o,true)}l(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){g.bindTexture(g.TEXTURE_CUBE_MAP,c.__webglTexture);g.generateMipmap(g.TEXTURE_CUBE_MAP);g.bindTexture(g.TEXTURE_CUBE_MAP,null)}else{g.bindTexture(g.TEXTURE_2D,c.__webglTexture);g.generateMipmap(g.TEXTURE_2D);
  337. g.bindTexture(g.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};this.renderImmediateObject=function(a,b,c,d,e){var f=r(a,b,c,d,e);ba=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,g,ic):e.render(function(a){E.renderBufferImmediate(a,f,d)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=a,j=void 0,
  338. k=void 0,l=void 0;if(!h.__webglInit){h.__webglInit=true;h._modelViewMatrix=new THREE.Matrix4;h._normalMatrix=new THREE.Matrix3;if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.Geometry){if(k.geometryGroups===void 0){var p=k,r=void 0,s=void 0,v=void 0,x=void 0,A=void 0,z=void 0,D=void 0,F={},I=p.morphTargets.length,J=p.morphNormals.length;p.geometryGroups={};r=0;for(s=p.faces.length;r<s;r++){v=p.faces[r];x=v.materialIndex;z=x!==void 0?x:-1;F[z]===void 0&&(F[z]={hash:z,counter:0});D=F[z].hash+
  339. "_"+F[z].counter;p.geometryGroups[D]===void 0&&(p.geometryGroups[D]={faces3:[],faces4:[],materialIndex:x,vertices:0,numMorphTargets:I,numMorphNormals:J});A=v instanceof THREE.Face3?3:4;if(p.geometryGroups[D].vertices+A>65535){F[z].counter=F[z].counter+1;D=F[z].hash+"_"+F[z].counter;p.geometryGroups[D]===void 0&&(p.geometryGroups[D]={faces3:[],faces4:[],materialIndex:x,vertices:0,numMorphTargets:I,numMorphNormals:J})}v instanceof THREE.Face3?p.geometryGroups[D].faces3.push(r):p.geometryGroups[D].faces4.push(r);
  340. p.geometryGroups[D].vertices=p.geometryGroups[D].vertices+A}p.geometryGroupsList=[];var K=void 0;for(K in p.geometryGroups){p.geometryGroups[K].id=va++;p.geometryGroupsList.push(p.geometryGroups[K])}}for(j in k.geometryGroups){l=k.geometryGroups[j];if(!l.__webglVertexBuffer){var H=l;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();
  341. H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer=g.createBuffer();H.__webglFaceBuffer=g.createBuffer();H.__webglLineBuffer=g.createBuffer();var L=void 0,N=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];L=0;for(N=H.numMorphTargets;L<N;L++)H.__webglMorphTargetsBuffers.push(g.createBuffer())}if(H.numMorphNormals){H.__webglMorphNormalsBuffers=[];L=0;for(N=H.numMorphNormals;L<N;L++)H.__webglMorphNormalsBuffers.push(g.createBuffer())}E.info.memory.geometries++;
  342. var G=l,S=h,T=S.geometry,U=G.faces3,V=G.faces4,R=U.length*3+V.length*4,aa=U.length*1+V.length*2,ba=U.length*3+V.length*4,$=c(S,G),fa=f($),qa=d($),xa=$.vertexColors?$.vertexColors:false;G.__vertexArray=new Float32Array(R*3);if(qa)G.__normalArray=new Float32Array(R*3);if(T.hasTangents)G.__tangentArray=new Float32Array(R*4);if(xa)G.__colorArray=new Float32Array(R*3);if(fa){if(T.faceUvs.length>0||T.faceVertexUvs.length>0)G.__uvArray=new Float32Array(R*2);if(T.faceUvs.length>1||T.faceVertexUvs.length>
  343. 1)G.__uv2Array=new Float32Array(R*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(R*4);G.__skinVertexBArray=new Float32Array(R*4);G.__skinIndexArray=new Float32Array(R*4);G.__skinWeightArray=new Float32Array(R*4)}G.__faceArray=new Uint16Array(aa*3);G.__lineArray=new Uint16Array(ba*2);var ra=void 0,Lb=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];ra=0;for(Lb=G.numMorphTargets;ra<Lb;ra++)G.__morphTargetsArrays.push(new Float32Array(R*
  344. 3))}if(G.numMorphNormals){G.__morphNormalsArrays=[];ra=0;for(Lb=G.numMorphNormals;ra<Lb;ra++)G.__morphNormalsArrays.push(new Float32Array(R*3))}G.__webglFaceCount=aa*3;G.__webglLineCount=ba*2;if($.attributes){if(G.__webglCustomAttributesList===void 0)G.__webglCustomAttributesList=[];var Ba=void 0;for(Ba in $.attributes){var Aa=$.attributes[Ba],ja={},wb;for(wb in Aa)ja[wb]=Aa[wb];if(!ja.__webglInitialized||ja.createUniqueBuffers){ja.__webglInitialized=true;var Ha=1;ja.type==="v2"?Ha=2:ja.type==="v3"?
  345. Ha=3:ja.type==="v4"?Ha=4:ja.type==="c"&&(Ha=3);ja.size=Ha;ja.array=new Float32Array(R*Ha);ja.buffer=g.createBuffer();ja.buffer.belongsToAttribute=Ba;Aa.needsUpdate=true;ja.__original=Aa}G.__webglCustomAttributesList.push(ja)}}G.__inittedArrays=true;k.verticesNeedUpdate=true;k.morphTargetsNeedUpdate=true;k.elementsNeedUpdate=true;k.uvsNeedUpdate=true;k.normalsNeedUpdate=true;k.tangentsNeedUpdate=true;k.colorsNeedUpdate=true}}}else if(k instanceof THREE.BufferGeometry){var Ub=k,Pa=void 0,Qa=void 0,
  346. Va=void 0;for(Pa in Ub.attributes){Va=Pa==="index"?g.ELEMENT_ARRAY_BUFFER:g.ARRAY_BUFFER;Qa=Ub.attributes[Pa];Qa.buffer=g.createBuffer();g.bindBuffer(Va,Qa.buffer);g.bufferData(Va,Qa.array,g.STATIC_DRAW)}}}else if(h instanceof THREE.Ribbon){k=h.geometry;if(!k.__webglVertexBuffer){var pb=k;pb.__webglVertexBuffer=g.createBuffer();pb.__webglColorBuffer=g.createBuffer();E.info.memory.geometries++;var Wa=k,ob=Wa.vertices.length;Wa.__vertexArray=new Float32Array(ob*3);Wa.__colorArray=new Float32Array(ob*
  347. 3);Wa.__webglVertexCount=ob;k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.Line){k=h.geometry;if(!k.__webglVertexBuffer){var xb=k;xb.__webglVertexBuffer=g.createBuffer();xb.__webglColorBuffer=g.createBuffer();E.info.memory.geometries++;var kc=k,Wb=h,Mb=kc.vertices.length;kc.__vertexArray=new Float32Array(Mb*3);kc.__colorArray=new Float32Array(Mb*3);kc.__webglLineCount=Mb;b(kc,Wb);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}else if(h instanceof THREE.ParticleSystem){k=
  348. h.geometry;if(!k.__webglVertexBuffer){var Vb=k;Vb.__webglVertexBuffer=g.createBuffer();Vb.__webglColorBuffer=g.createBuffer();E.info.geometries++;var Xb=k,hc=h,Nb=Xb.vertices.length;Xb.__vertexArray=new Float32Array(Nb*3);Xb.__colorArray=new Float32Array(Nb*3);Xb.__sortArray=[];Xb.__webglParticleCount=Nb;b(Xb,hc);k.verticesNeedUpdate=true;k.colorsNeedUpdate=true}}}if(!h.__webglActive){if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.BufferGeometry)m(i.__webglObjects,k,h);else for(j in k.geometryGroups){l=
  349. k.geometryGroups[j];m(i.__webglObjects,l,h)}}else if(h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem){k=h.geometry;m(i.__webglObjects,k,h)}else h instanceof THREE.ImmediateRenderObject||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=true}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Ra=
  350. a.__objectsRemoved[0],zc=a;Ra instanceof THREE.Mesh||Ra instanceof THREE.ParticleSystem||Ra instanceof THREE.Ribbon||Ra instanceof THREE.Line?u(zc.__webglObjects,Ra):Ra instanceof THREE.Sprite?o(zc.__webglSprites,Ra):Ra instanceof THREE.LensFlare?o(zc.__webglFlares,Ra):(Ra instanceof THREE.ImmediateRenderObject||Ra.immediateRenderCallback)&&u(zc.__webglObjectsImmediate,Ra);Ra.__webglActive=false;a.__objectsRemoved.splice(0,1)}for(var Ob=0,ic=a.__webglObjects.length;Ob<ic;Ob++){var Xa=a.__webglObjects[Ob].object,
  351. W=Xa.geometry,lc=void 0,Yb=void 0,Ka=void 0;if(Xa instanceof THREE.Mesh)if(W instanceof THREE.BufferGeometry){if(W.verticesNeedUpdate||W.elementsNeedUpdate||W.uvsNeedUpdate||W.normalsNeedUpdate||W.colorsNeedUpdate||W.tangentsNeedUpdate){var qb=W,Zb=g.DYNAMIC_DRAW,jc=!W.dynamic,$b=qb.attributes,Rc=$b.index,Sc=$b.position,Tc=$b.normal,Uc=$b.uv,Vc=$b.color,Wc=$b.tangent;if(qb.elementsNeedUpdate&&Rc!==void 0){g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,Rc.buffer);g.bufferData(g.ELEMENT_ARRAY_BUFFER,Rc.array,
  352. Zb)}if(qb.verticesNeedUpdate&&Sc!==void 0){g.bindBuffer(g.ARRAY_BUFFER,Sc.buffer);g.bufferData(g.ARRAY_BUFFER,Sc.array,Zb)}if(qb.normalsNeedUpdate&&Tc!==void 0){g.bindBuffer(g.ARRAY_BUFFER,Tc.buffer);g.bufferData(g.ARRAY_BUFFER,Tc.array,Zb)}if(qb.uvsNeedUpdate&&Uc!==void 0){g.bindBuffer(g.ARRAY_BUFFER,Uc.buffer);g.bufferData(g.ARRAY_BUFFER,Uc.array,Zb)}if(qb.colorsNeedUpdate&&Vc!==void 0){g.bindBuffer(g.ARRAY_BUFFER,Vc.buffer);g.bufferData(g.ARRAY_BUFFER,Vc.array,Zb)}if(qb.tangentsNeedUpdate&&Wc!==
  353. void 0){g.bindBuffer(g.ARRAY_BUFFER,Wc.buffer);g.bufferData(g.ARRAY_BUFFER,Wc.array,Zb)}if(jc){var gc=void 0;for(gc in qb.attributes)delete qb.attributes[gc].array}}W.verticesNeedUpdate=false;W.elementsNeedUpdate=false;W.uvsNeedUpdate=false;W.normalsNeedUpdate=false;W.colorsNeedUpdate=false;W.tangentsNeedUpdate=false}else{for(var Xc=0,xc=W.geometryGroupsList.length;Xc<xc;Xc++){lc=W.geometryGroupsList[Xc];Ka=c(Xa,lc);Yb=Ka.attributes&&n(Ka);if(W.verticesNeedUpdate||W.morphTargetsNeedUpdate||W.elementsNeedUpdate||
  354. W.uvsNeedUpdate||W.normalsNeedUpdate||W.colorsNeedUpdate||W.tangentsNeedUpdate||Yb){var Y=lc,yc=Xa,Ma=g.DYNAMIC_DRAW,Oc=!W.dynamic,Pb=Ka;if(Y.__inittedArrays){var fd=d(Pb),Yc=Pb.vertexColors?Pb.vertexColors:false,gd=f(Pb),Ac=fd===THREE.SmoothShading,y=void 0,M=void 0,Ua=void 0,C=void 0,ac=void 0,yb=void 0,Ya=void 0,Bc=void 0,rb=void 0,bc=void 0,cc=void 0,O=void 0,P=void 0,Q=void 0,ga=void 0,Za=void 0,$a=void 0,ab=void 0,mc=void 0,bb=void 0,cb=void 0,db=void 0,nc=void 0,eb=void 0,fb=void 0,gb=void 0,
  355. oc=void 0,hb=void 0,ib=void 0,jb=void 0,pc=void 0,kb=void 0,lb=void 0,mb=void 0,qc=void 0,zb=void 0,Ab=void 0,Bb=void 0,Cc=void 0,Cb=void 0,Db=void 0,Eb=void 0,Dc=void 0,ca=void 0,hd=void 0,Fb=void 0,dc=void 0,ec=void 0,Ca=void 0,id=void 0,ya=void 0,za=void 0,Gb=void 0,sb=void 0,sa=0,wa=0,tb=0,ub=0,Sa=0,Ga=0,ha=0,Ia=0,ta=0,B=0,X=0,w=0,Na=void 0,Da=Y.__vertexArray,rc=Y.__uvArray,sc=Y.__uv2Array,Ta=Y.__normalArray,ka=Y.__tangentArray,Ea=Y.__colorArray,la=Y.__skinVertexAArray,ma=Y.__skinVertexBArray,
  356. na=Y.__skinIndexArray,oa=Y.__skinWeightArray,Zc=Y.__morphTargetsArrays,$c=Y.__morphNormalsArrays,ad=Y.__webglCustomAttributesList,t=void 0,nb=Y.__faceArray,Oa=Y.__lineArray,Ja=yc.geometry,Pc=Ja.elementsNeedUpdate,jd=Ja.uvsNeedUpdate,Qc=Ja.normalsNeedUpdate,qd=Ja.tangentsNeedUpdate,rd=Ja.colorsNeedUpdate,sd=Ja.morphTargetsNeedUpdate,Qb=Ja.vertices,da=Y.faces3,ea=Y.faces4,ua=Ja.faces,bd=Ja.faceVertexUvs[0],cd=Ja.faceVertexUvs[1],Rb=Ja.skinVerticesA,Sb=Ja.skinVerticesB,Tb=Ja.skinIndices,Hb=Ja.skinWeights,
  357. Ib=Ja.morphTargets,Ec=Ja.morphNormals;if(Ja.verticesNeedUpdate){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];O=Qb[C.a];P=Qb[C.b];Q=Qb[C.c];Da[wa]=O.x;Da[wa+1]=O.y;Da[wa+2]=O.z;Da[wa+3]=P.x;Da[wa+4]=P.y;Da[wa+5]=P.z;Da[wa+6]=Q.x;Da[wa+7]=Q.y;Da[wa+8]=Q.z;wa=wa+9}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];O=Qb[C.a];P=Qb[C.b];Q=Qb[C.c];ga=Qb[C.d];Da[wa]=O.x;Da[wa+1]=O.y;Da[wa+2]=O.z;Da[wa+3]=P.x;Da[wa+4]=P.y;Da[wa+5]=P.z;Da[wa+6]=Q.x;Da[wa+7]=Q.y;Da[wa+8]=Q.z;Da[wa+9]=ga.x;Da[wa+10]=ga.y;Da[wa+11]=ga.z;wa=
  358. wa+12}g.bindBuffer(g.ARRAY_BUFFER,Y.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,Da,Ma)}if(sd){Ca=0;for(id=Ib.length;Ca<id;Ca++){y=X=0;for(M=da.length;y<M;y++){Gb=da[y];C=ua[Gb];O=Ib[Ca].vertices[C.a];P=Ib[Ca].vertices[C.b];Q=Ib[Ca].vertices[C.c];ya=Zc[Ca];ya[X]=O.x;ya[X+1]=O.y;ya[X+2]=O.z;ya[X+3]=P.x;ya[X+4]=P.y;ya[X+5]=P.z;ya[X+6]=Q.x;ya[X+7]=Q.y;ya[X+8]=Q.z;if(Pb.morphNormals){if(Ac){sb=Ec[Ca].vertexNormals[Gb];bb=sb.a;cb=sb.b;db=sb.c}else db=cb=bb=Ec[Ca].faceNormals[Gb];za=$c[Ca];za[X]=bb.x;
  359. za[X+1]=bb.y;za[X+2]=bb.z;za[X+3]=cb.x;za[X+4]=cb.y;za[X+5]=cb.z;za[X+6]=db.x;za[X+7]=db.y;za[X+8]=db.z}X=X+9}y=0;for(M=ea.length;y<M;y++){Gb=ea[y];C=ua[Gb];O=Ib[Ca].vertices[C.a];P=Ib[Ca].vertices[C.b];Q=Ib[Ca].vertices[C.c];ga=Ib[Ca].vertices[C.d];ya=Zc[Ca];ya[X]=O.x;ya[X+1]=O.y;ya[X+2]=O.z;ya[X+3]=P.x;ya[X+4]=P.y;ya[X+5]=P.z;ya[X+6]=Q.x;ya[X+7]=Q.y;ya[X+8]=Q.z;ya[X+9]=ga.x;ya[X+10]=ga.y;ya[X+11]=ga.z;if(Pb.morphNormals){if(Ac){sb=Ec[Ca].vertexNormals[Gb];bb=sb.a;cb=sb.b;db=sb.c;nc=sb.d}else nc=
  360. db=cb=bb=Ec[Ca].faceNormals[Gb];za=$c[Ca];za[X]=bb.x;za[X+1]=bb.y;za[X+2]=bb.z;za[X+3]=cb.x;za[X+4]=cb.y;za[X+5]=cb.z;za[X+6]=db.x;za[X+7]=db.y;za[X+8]=db.z;za[X+9]=nc.x;za[X+10]=nc.y;za[X+11]=nc.z}X=X+12}g.bindBuffer(g.ARRAY_BUFFER,Y.__webglMorphTargetsBuffers[Ca]);g.bufferData(g.ARRAY_BUFFER,Zc[Ca],Ma);if(Pb.morphNormals){g.bindBuffer(g.ARRAY_BUFFER,Y.__webglMorphNormalsBuffers[Ca]);g.bufferData(g.ARRAY_BUFFER,$c[Ca],Ma)}}}if(Hb.length){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];hb=Hb[C.a];ib=Hb[C.b];
  361. jb=Hb[C.c];oa[B]=hb.x;oa[B+1]=hb.y;oa[B+2]=hb.z;oa[B+3]=hb.w;oa[B+4]=ib.x;oa[B+5]=ib.y;oa[B+6]=ib.z;oa[B+7]=ib.w;oa[B+8]=jb.x;oa[B+9]=jb.y;oa[B+10]=jb.z;oa[B+11]=jb.w;kb=Tb[C.a];lb=Tb[C.b];mb=Tb[C.c];na[B]=kb.x;na[B+1]=kb.y;na[B+2]=kb.z;na[B+3]=kb.w;na[B+4]=lb.x;na[B+5]=lb.y;na[B+6]=lb.z;na[B+7]=lb.w;na[B+8]=mb.x;na[B+9]=mb.y;na[B+10]=mb.z;na[B+11]=mb.w;zb=Rb[C.a];Ab=Rb[C.b];Bb=Rb[C.c];la[B]=zb.x;la[B+1]=zb.y;la[B+2]=zb.z;la[B+3]=1;la[B+4]=Ab.x;la[B+5]=Ab.y;la[B+6]=Ab.z;la[B+7]=1;la[B+8]=Bb.x;la[B+
  362. 9]=Bb.y;la[B+10]=Bb.z;la[B+11]=1;Cb=Sb[C.a];Db=Sb[C.b];Eb=Sb[C.c];ma[B]=Cb.x;ma[B+1]=Cb.y;ma[B+2]=Cb.z;ma[B+3]=1;ma[B+4]=Db.x;ma[B+5]=Db.y;ma[B+6]=Db.z;ma[B+7]=1;ma[B+8]=Eb.x;ma[B+9]=Eb.y;ma[B+10]=Eb.z;ma[B+11]=1;B=B+12}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];hb=Hb[C.a];ib=Hb[C.b];jb=Hb[C.c];pc=Hb[C.d];oa[B]=hb.x;oa[B+1]=hb.y;oa[B+2]=hb.z;oa[B+3]=hb.w;oa[B+4]=ib.x;oa[B+5]=ib.y;oa[B+6]=ib.z;oa[B+7]=ib.w;oa[B+8]=jb.x;oa[B+9]=jb.y;oa[B+10]=jb.z;oa[B+11]=jb.w;oa[B+12]=pc.x;oa[B+13]=pc.y;oa[B+14]=pc.z;
  363. oa[B+15]=pc.w;kb=Tb[C.a];lb=Tb[C.b];mb=Tb[C.c];qc=Tb[C.d];na[B]=kb.x;na[B+1]=kb.y;na[B+2]=kb.z;na[B+3]=kb.w;na[B+4]=lb.x;na[B+5]=lb.y;na[B+6]=lb.z;na[B+7]=lb.w;na[B+8]=mb.x;na[B+9]=mb.y;na[B+10]=mb.z;na[B+11]=mb.w;na[B+12]=qc.x;na[B+13]=qc.y;na[B+14]=qc.z;na[B+15]=qc.w;zb=Rb[C.a];Ab=Rb[C.b];Bb=Rb[C.c];Cc=Rb[C.d];la[B]=zb.x;la[B+1]=zb.y;la[B+2]=zb.z;la[B+3]=1;la[B+4]=Ab.x;la[B+5]=Ab.y;la[B+6]=Ab.z;la[B+7]=1;la[B+8]=Bb.x;la[B+9]=Bb.y;la[B+10]=Bb.z;la[B+11]=1;la[B+12]=Cc.x;la[B+13]=Cc.y;la[B+14]=Cc.z;
  364. la[B+15]=1;Cb=Sb[C.a];Db=Sb[C.b];Eb=Sb[C.c];Dc=Sb[C.d];ma[B]=Cb.x;ma[B+1]=Cb.y;ma[B+2]=Cb.z;ma[B+3]=1;ma[B+4]=Db.x;ma[B+5]=Db.y;ma[B+6]=Db.z;ma[B+7]=1;ma[B+8]=Eb.x;ma[B+9]=Eb.y;ma[B+10]=Eb.z;ma[B+11]=1;ma[B+12]=Dc.x;ma[B+13]=Dc.y;ma[B+14]=Dc.z;ma[B+15]=1;B=B+16}if(B>0){g.bindBuffer(g.ARRAY_BUFFER,Y.__webglSkinVertexABuffer);g.bufferData(g.ARRAY_BUFFER,la,Ma);g.bindBuffer(g.ARRAY_BUFFER,Y.__webglSkinVertexBBuffer);g.bufferData(g.ARRAY_BUFFER,ma,Ma);g.bindBuffer(g.ARRAY_BUFFER,Y.__webglSkinIndicesBuffer);
  365. g.bufferData(g.ARRAY_BUFFER,na,Ma);g.bindBuffer(g.ARRAY_BUFFER,Y.__webglSkinWeightsBuffer);g.bufferData(g.ARRAY_BUFFER,oa,Ma)}}if(rd&&Yc){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];Ya=C.vertexColors;Bc=C.color;if(Ya.length===3&&Yc===THREE.VertexColors){eb=Ya[0];fb=Ya[1];gb=Ya[2]}else gb=fb=eb=Bc;Ea[ta]=eb.r;Ea[ta+1]=eb.g;Ea[ta+2]=eb.b;Ea[ta+3]=fb.r;Ea[ta+4]=fb.g;Ea[ta+5]=fb.b;Ea[ta+6]=gb.r;Ea[ta+7]=gb.g;Ea[ta+8]=gb.b;ta=ta+9}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];Ya=C.vertexColors;Bc=C.color;if(Ya.length===
  366. 4&&Yc===THREE.VertexColors){eb=Ya[0];fb=Ya[1];gb=Ya[2];oc=Ya[3]}else oc=gb=fb=eb=Bc;Ea[ta]=eb.r;Ea[ta+1]=eb.g;Ea[ta+2]=eb.b;Ea[ta+3]=fb.r;Ea[ta+4]=fb.g;Ea[ta+5]=fb.b;Ea[ta+6]=gb.r;Ea[ta+7]=gb.g;Ea[ta+8]=gb.b;Ea[ta+9]=oc.r;Ea[ta+10]=oc.g;Ea[ta+11]=oc.b;ta=ta+12}if(ta>0){g.bindBuffer(g.ARRAY_BUFFER,Y.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ea,Ma)}}if(qd&&Ja.hasTangents){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];rb=C.vertexTangents;Za=rb[0];$a=rb[1];ab=rb[2];ka[ha]=Za.x;ka[ha+1]=Za.y;ka[ha+2]=
  367. Za.z;ka[ha+3]=Za.w;ka[ha+4]=$a.x;ka[ha+5]=$a.y;ka[ha+6]=$a.z;ka[ha+7]=$a.w;ka[ha+8]=ab.x;ka[ha+9]=ab.y;ka[ha+10]=ab.z;ka[ha+11]=ab.w;ha=ha+12}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];rb=C.vertexTangents;Za=rb[0];$a=rb[1];ab=rb[2];mc=rb[3];ka[ha]=Za.x;ka[ha+1]=Za.y;ka[ha+2]=Za.z;ka[ha+3]=Za.w;ka[ha+4]=$a.x;ka[ha+5]=$a.y;ka[ha+6]=$a.z;ka[ha+7]=$a.w;ka[ha+8]=ab.x;ka[ha+9]=ab.y;ka[ha+10]=ab.z;ka[ha+11]=ab.w;ka[ha+12]=mc.x;ka[ha+13]=mc.y;ka[ha+14]=mc.z;ka[ha+15]=mc.w;ha=ha+16}g.bindBuffer(g.ARRAY_BUFFER,
  368. Y.__webglTangentBuffer);g.bufferData(g.ARRAY_BUFFER,ka,Ma)}if(Qc&&fd){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];ac=C.vertexNormals;yb=C.normal;if(ac.length===3&&Ac)for(ca=0;ca<3;ca++){Fb=ac[ca];Ta[Ga]=Fb.x;Ta[Ga+1]=Fb.y;Ta[Ga+2]=Fb.z;Ga=Ga+3}else for(ca=0;ca<3;ca++){Ta[Ga]=yb.x;Ta[Ga+1]=yb.y;Ta[Ga+2]=yb.z;Ga=Ga+3}}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];ac=C.vertexNormals;yb=C.normal;if(ac.length===4&&Ac)for(ca=0;ca<4;ca++){Fb=ac[ca];Ta[Ga]=Fb.x;Ta[Ga+1]=Fb.y;Ta[Ga+2]=Fb.z;Ga=Ga+3}else for(ca=0;ca<
  369. 4;ca++){Ta[Ga]=yb.x;Ta[Ga+1]=yb.y;Ta[Ga+2]=yb.z;Ga=Ga+3}}g.bindBuffer(g.ARRAY_BUFFER,Y.__webglNormalBuffer);g.bufferData(g.ARRAY_BUFFER,Ta,Ma)}if(jd&&bd&&gd){y=0;for(M=da.length;y<M;y++){Ua=da[y];C=ua[Ua];bc=bd[Ua];if(bc!==void 0)for(ca=0;ca<3;ca++){dc=bc[ca];rc[tb]=dc.u;rc[tb+1]=dc.v;tb=tb+2}}y=0;for(M=ea.length;y<M;y++){Ua=ea[y];C=ua[Ua];bc=bd[Ua];if(bc!==void 0)for(ca=0;ca<4;ca++){dc=bc[ca];rc[tb]=dc.u;rc[tb+1]=dc.v;tb=tb+2}}if(tb>0){g.bindBuffer(g.ARRAY_BUFFER,Y.__webglUVBuffer);g.bufferData(g.ARRAY_BUFFER,
  370. rc,Ma)}}if(jd&&cd&&gd){y=0;for(M=da.length;y<M;y++){Ua=da[y];C=ua[Ua];cc=cd[Ua];if(cc!==void 0)for(ca=0;ca<3;ca++){ec=cc[ca];sc[ub]=ec.u;sc[ub+1]=ec.v;ub=ub+2}}y=0;for(M=ea.length;y<M;y++){Ua=ea[y];C=ua[Ua];cc=cd[Ua];if(cc!==void 0)for(ca=0;ca<4;ca++){ec=cc[ca];sc[ub]=ec.u;sc[ub+1]=ec.v;ub=ub+2}}if(ub>0){g.bindBuffer(g.ARRAY_BUFFER,Y.__webglUV2Buffer);g.bufferData(g.ARRAY_BUFFER,sc,Ma)}}if(Pc){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];nb[Sa]=sa;nb[Sa+1]=sa+1;nb[Sa+2]=sa+2;Sa=Sa+3;Oa[Ia]=sa;Oa[Ia+1]=
  371. sa+1;Oa[Ia+2]=sa;Oa[Ia+3]=sa+2;Oa[Ia+4]=sa+1;Oa[Ia+5]=sa+2;Ia=Ia+6;sa=sa+3}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];nb[Sa]=sa;nb[Sa+1]=sa+1;nb[Sa+2]=sa+3;nb[Sa+3]=sa+1;nb[Sa+4]=sa+2;nb[Sa+5]=sa+3;Sa=Sa+6;Oa[Ia]=sa;Oa[Ia+1]=sa+1;Oa[Ia+2]=sa;Oa[Ia+3]=sa+3;Oa[Ia+4]=sa+1;Oa[Ia+5]=sa+2;Oa[Ia+6]=sa+2;Oa[Ia+7]=sa+3;Ia=Ia+8;sa=sa+4}g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,Y.__webglFaceBuffer);g.bufferData(g.ELEMENT_ARRAY_BUFFER,nb,Ma);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,Y.__webglLineBuffer);g.bufferData(g.ELEMENT_ARRAY_BUFFER,
  372. Oa,Ma)}if(ad){ca=0;for(hd=ad.length;ca<hd;ca++){t=ad[ca];if(t.__original.needsUpdate){w=0;if(t.size===1)if(t.boundTo===void 0||t.boundTo==="vertices"){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];t.array[w]=t.value[C.a];t.array[w+1]=t.value[C.b];t.array[w+2]=t.value[C.c];w=w+3}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];t.array[w]=t.value[C.a];t.array[w+1]=t.value[C.b];t.array[w+2]=t.value[C.c];t.array[w+3]=t.value[C.d];w=w+4}}else{if(t.boundTo==="faces"){y=0;for(M=da.length;y<M;y++){Na=t.value[da[y]];t.array[w]=
  373. Na;t.array[w+1]=Na;t.array[w+2]=Na;w=w+3}y=0;for(M=ea.length;y<M;y++){Na=t.value[ea[y]];t.array[w]=Na;t.array[w+1]=Na;t.array[w+2]=Na;t.array[w+3]=Na;w=w+4}}}else if(t.size===2)if(t.boundTo===void 0||t.boundTo==="vertices"){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];O=t.value[C.a];P=t.value[C.b];Q=t.value[C.c];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=P.x;t.array[w+3]=P.y;t.array[w+4]=Q.x;t.array[w+5]=Q.y;w=w+6}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];O=t.value[C.a];P=t.value[C.b];Q=t.value[C.c];
  374. ga=t.value[C.d];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=P.x;t.array[w+3]=P.y;t.array[w+4]=Q.x;t.array[w+5]=Q.y;t.array[w+6]=ga.x;t.array[w+7]=ga.y;w=w+8}}else{if(t.boundTo==="faces"){y=0;for(M=da.length;y<M;y++){Q=P=O=Na=t.value[da[y]];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=P.x;t.array[w+3]=P.y;t.array[w+4]=Q.x;t.array[w+5]=Q.y;w=w+6}y=0;for(M=ea.length;y<M;y++){ga=Q=P=O=Na=t.value[ea[y]];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=P.x;t.array[w+3]=P.y;t.array[w+4]=Q.x;t.array[w+5]=Q.y;
  375. t.array[w+6]=ga.x;t.array[w+7]=ga.y;w=w+8}}}else if(t.size===3){var Z;Z=t.type==="c"?["r","g","b"]:["x","y","z"];if(t.boundTo===void 0||t.boundTo==="vertices"){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];O=t.value[C.a];P=t.value[C.b];Q=t.value[C.c];t.array[w]=O[Z[0]];t.array[w+1]=O[Z[1]];t.array[w+2]=O[Z[2]];t.array[w+3]=P[Z[0]];t.array[w+4]=P[Z[1]];t.array[w+5]=P[Z[2]];t.array[w+6]=Q[Z[0]];t.array[w+7]=Q[Z[1]];t.array[w+8]=Q[Z[2]];w=w+9}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];O=t.value[C.a];P=t.value[C.b];
  376. Q=t.value[C.c];ga=t.value[C.d];t.array[w]=O[Z[0]];t.array[w+1]=O[Z[1]];t.array[w+2]=O[Z[2]];t.array[w+3]=P[Z[0]];t.array[w+4]=P[Z[1]];t.array[w+5]=P[Z[2]];t.array[w+6]=Q[Z[0]];t.array[w+7]=Q[Z[1]];t.array[w+8]=Q[Z[2]];t.array[w+9]=ga[Z[0]];t.array[w+10]=ga[Z[1]];t.array[w+11]=ga[Z[2]];w=w+12}}else if(t.boundTo==="faces"){y=0;for(M=da.length;y<M;y++){Q=P=O=Na=t.value[da[y]];t.array[w]=O[Z[0]];t.array[w+1]=O[Z[1]];t.array[w+2]=O[Z[2]];t.array[w+3]=P[Z[0]];t.array[w+4]=P[Z[1]];t.array[w+5]=P[Z[2]];t.array[w+
  377. 6]=Q[Z[0]];t.array[w+7]=Q[Z[1]];t.array[w+8]=Q[Z[2]];w=w+9}y=0;for(M=ea.length;y<M;y++){ga=Q=P=O=Na=t.value[ea[y]];t.array[w]=O[Z[0]];t.array[w+1]=O[Z[1]];t.array[w+2]=O[Z[2]];t.array[w+3]=P[Z[0]];t.array[w+4]=P[Z[1]];t.array[w+5]=P[Z[2]];t.array[w+6]=Q[Z[0]];t.array[w+7]=Q[Z[1]];t.array[w+8]=Q[Z[2]];t.array[w+9]=ga[Z[0]];t.array[w+10]=ga[Z[1]];t.array[w+11]=ga[Z[2]];w=w+12}}}else if(t.size===4)if(t.boundTo===void 0||t.boundTo==="vertices"){y=0;for(M=da.length;y<M;y++){C=ua[da[y]];O=t.value[C.a];
  378. P=t.value[C.b];Q=t.value[C.c];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=O.z;t.array[w+3]=O.w;t.array[w+4]=P.x;t.array[w+5]=P.y;t.array[w+6]=P.z;t.array[w+7]=P.w;t.array[w+8]=Q.x;t.array[w+9]=Q.y;t.array[w+10]=Q.z;t.array[w+11]=Q.w;w=w+12}y=0;for(M=ea.length;y<M;y++){C=ua[ea[y]];O=t.value[C.a];P=t.value[C.b];Q=t.value[C.c];ga=t.value[C.d];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=O.z;t.array[w+3]=O.w;t.array[w+4]=P.x;t.array[w+5]=P.y;t.array[w+6]=P.z;t.array[w+7]=P.w;t.array[w+8]=Q.x;t.array[w+
  379. 9]=Q.y;t.array[w+10]=Q.z;t.array[w+11]=Q.w;t.array[w+12]=ga.x;t.array[w+13]=ga.y;t.array[w+14]=ga.z;t.array[w+15]=ga.w;w=w+16}}else if(t.boundTo==="faces"){y=0;for(M=da.length;y<M;y++){Q=P=O=Na=t.value[da[y]];t.array[w]=O.x;t.array[w+1]=O.y;t.array[w+2]=O.z;t.array[w+3]=O.w;t.array[w+4]=P.x;t.array[w+5]=P.y;t.array[w+6]=P.z;t.array[w+7]=P.w;t.array[w+8]=Q.x;t.array[w+9]=Q.y;t.array[w+10]=Q.z;t.array[w+11]=Q.w;w=w+12}y=0;for(M=ea.length;y<M;y++){ga=Q=P=O=Na=t.value[ea[y]];t.array[w]=O.x;t.array[w+
  380. 1]=O.y;t.array[w+2]=O.z;t.array[w+3]=O.w;t.array[w+4]=P.x;t.array[w+5]=P.y;t.array[w+6]=P.z;t.array[w+7]=P.w;t.array[w+8]=Q.x;t.array[w+9]=Q.y;t.array[w+10]=Q.z;t.array[w+11]=Q.w;t.array[w+12]=ga.x;t.array[w+13]=ga.y;t.array[w+14]=ga.z;t.array[w+15]=ga.w;w=w+16}}g.bindBuffer(g.ARRAY_BUFFER,t.buffer);g.bufferData(g.ARRAY_BUFFER,t.array,Ma)}}}if(Oc){delete Y.__inittedArrays;delete Y.__colorArray;delete Y.__normalArray;delete Y.__tangentArray;delete Y.__uvArray;delete Y.__uv2Array;delete Y.__faceArray;
  381. delete Y.__vertexArray;delete Y.__lineArray;delete Y.__skinVertexAArray;delete Y.__skinVertexBArray;delete Y.__skinIndexArray;delete Y.__skinWeightArray}}}}W.verticesNeedUpdate=false;W.morphTargetsNeedUpdate=false;W.elementsNeedUpdate=false;W.uvsNeedUpdate=false;W.normalsNeedUpdate=false;W.colorsNeedUpdate=false;W.tangentsNeedUpdate=false;Ka.attributes&&q(Ka)}else if(Xa instanceof THREE.Ribbon){if(W.verticesNeedUpdate||W.colorsNeedUpdate){var Jb=W,kd=g.DYNAMIC_DRAW,tc=void 0,uc=void 0,Fc=void 0,Kb=
  382. void 0,Gc=void 0,ld=Jb.vertices,md=Jb.colors,td=ld.length,ud=md.length,Hc=Jb.__vertexArray,Ic=Jb.__colorArray,vd=Jb.colorsNeedUpdate;if(Jb.verticesNeedUpdate){for(tc=0;tc<td;tc++){Fc=ld[tc];Kb=tc*3;Hc[Kb]=Fc.x;Hc[Kb+1]=Fc.y;Hc[Kb+2]=Fc.z}g.bindBuffer(g.ARRAY_BUFFER,Jb.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,Hc,kd)}if(vd){for(uc=0;uc<ud;uc++){Gc=md[uc];Kb=uc*3;Ic[Kb]=Gc.r;Ic[Kb+1]=Gc.g;Ic[Kb+2]=Gc.b}g.bindBuffer(g.ARRAY_BUFFER,Jb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ic,kd)}}W.verticesNeedUpdate=
  383. false;W.colorsNeedUpdate=false}else if(Xa instanceof THREE.Line){Ka=c(Xa,lc);Yb=Ka.attributes&&n(Ka);if(W.verticesNeedUpdate||W.colorsNeedUpdate||Yb){var vb=W,dd=g.DYNAMIC_DRAW,vc=void 0,wc=void 0,Jc=void 0,pa=void 0,Kc=void 0,nd=vb.vertices,od=vb.colors,wd=nd.length,xd=od.length,Lc=vb.__vertexArray,Mc=vb.__colorArray,yd=vb.colorsNeedUpdate,ed=vb.__webglCustomAttributesList,Nc=void 0,pd=void 0,Fa=void 0,fc=void 0,La=void 0,ia=void 0;if(vb.verticesNeedUpdate){for(vc=0;vc<wd;vc++){Jc=nd[vc];pa=vc*3;
  384. Lc[pa]=Jc.x;Lc[pa+1]=Jc.y;Lc[pa+2]=Jc.z}g.bindBuffer(g.ARRAY_BUFFER,vb.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,Lc,dd)}if(yd){for(wc=0;wc<xd;wc++){Kc=od[wc];pa=wc*3;Mc[pa]=Kc.r;Mc[pa+1]=Kc.g;Mc[pa+2]=Kc.b}g.bindBuffer(g.ARRAY_BUFFER,vb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Mc,dd)}if(ed){Nc=0;for(pd=ed.length;Nc<pd;Nc++){ia=ed[Nc];if(ia.needsUpdate&&(ia.boundTo===void 0||ia.boundTo==="vertices")){pa=0;fc=ia.value.length;if(ia.size===1)for(Fa=0;Fa<fc;Fa++)ia.array[Fa]=ia.value[Fa];
  385. else if(ia.size===2)for(Fa=0;Fa<fc;Fa++){La=ia.value[Fa];ia.array[pa]=La.x;ia.array[pa+1]=La.y;pa=pa+2}else if(ia.size===3)if(ia.type==="c")for(Fa=0;Fa<fc;Fa++){La=ia.value[Fa];ia.array[pa]=La.r;ia.array[pa+1]=La.g;ia.array[pa+2]=La.b;pa=pa+3}else for(Fa=0;Fa<fc;Fa++){La=ia.value[Fa];ia.array[pa]=La.x;ia.array[pa+1]=La.y;ia.array[pa+2]=La.z;pa=pa+3}else if(ia.size===4)for(Fa=0;Fa<fc;Fa++){La=ia.value[Fa];ia.array[pa]=La.x;ia.array[pa+1]=La.y;ia.array[pa+2]=La.z;ia.array[pa+3]=La.w;pa=pa+4}g.bindBuffer(g.ARRAY_BUFFER,
  386. ia.buffer);g.bufferData(g.ARRAY_BUFFER,ia.array,dd)}}}}W.verticesNeedUpdate=false;W.colorsNeedUpdate=false;Ka.attributes&&q(Ka)}else if(Xa instanceof THREE.ParticleSystem){Ka=c(Xa,lc);Yb=Ka.attributes&&n(Ka);(W.verticesNeedUpdate||W.colorsNeedUpdate||Xa.sortParticles||Yb)&&e(W,g.DYNAMIC_DRAW,Xa);W.verticesNeedUpdate=false;W.colorsNeedUpdate=false;Ka.attributes&&q(Ka)}}};this.initMaterial=function(a,b,c,d){var e,f,h,i,j,k,m,l;a instanceof THREE.MeshDepthMaterial?l="depth":a instanceof THREE.MeshNormalMaterial?
  387. l="normal":a instanceof THREE.MeshBasicMaterial?l="basic":a instanceof THREE.MeshLambertMaterial?l="lambert":a instanceof THREE.MeshPhongMaterial?l="phong":a instanceof THREE.LineBasicMaterial?l="basic":a instanceof THREE.ParticleBasicMaterial&&(l="particle_basic");if(l){var n=THREE.ShaderLib[l];a.uniforms=THREE.UniformsUtils.clone(n.uniforms);a.vertexShader=n.vertexShader;a.fragmentShader=n.fragmentShader}var o,q;o=h=e=n=0;for(f=b.length;o<f;o++){q=b[o];if(!q.onlyShadow){q instanceof THREE.DirectionalLight&&
  388. h++;q instanceof THREE.PointLight&&e++;q instanceof THREE.SpotLight&&n++}}if(e+n+h<=V){o=h;f=e}else{o=Math.ceil(V*h/(e+h));n=f=V-o}e=o;h=n;n=m=0;for(o=b.length;n<o;n++){q=b[n];if(q.castShadow){q instanceof THREE.SpotLight&&m++;q instanceof THREE.DirectionalLight&&!q.shadowCascade&&m++}}if(hc&&d.useVertexTexture)k=1024;else{b=g.getParameter(g.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 - "+
  389. d.bones.length+", this GPU supports just "+b+" (try OpenGL instead of ANGLE)")}k=b}var p;a:{q=a.fragmentShader;o=a.vertexShader;var n=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:k,useVertexTexture:hc&&d.useVertexTexture,boneTextureWidth:d.boneTextureWidth,boneTextureHeight:d.boneTextureHeight,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,
  390. maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxSpotLights:h,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:d&&d.doubleSided},r,d=[];if(l)d.push(l);else{d.push(q);d.push(o)}for(r in c){d.push(r);d.push(c[r])}l=d.join();r=0;for(d=$.length;r<d;r++){e=$[r];if(e.code===
  391. l){e.usedTimes++;p=e.program;break a}}r=g.createProgram();d=["precision "+D+" float;",jc?"#define VERTEX_TEXTURES":"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.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_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":
  392. "",c.lightMap?"#define USE_LIGHTMAP":"",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?"#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":
  393. "",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\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 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
  394. e=["precision "+D+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
  395. "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",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.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");
  396. e=x("fragment",e+q);d=x("vertex",d+o);g.attachShader(r,d);g.attachShader(r,e);g.linkProgram(r);g.getProgramParameter(r,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(r,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(e);g.deleteShader(d);r.uniforms={};r.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","morphTargetInfluences"];c.useVertexTexture?d.push("boneTexture"):
  397. d.push("boneGlobalMatrices");for(s in n)d.push(s);s=d;d=0;for(n=s.length;d<n;d++){e=s[d];r.uniforms[e]=g.getUniformLocation(r,e)}d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(s=0;s<c.maxMorphNormals;s++)d.push("morphNormal"+s);for(p in b)d.push(p);p=d;s=0;for(c=p.length;s<c;s++){d=p[s];r.attributes[d]=g.getAttribLocation(r,d)}r.id=fa++;$.push({program:r,code:l,usedTimes:1});E.info.memory.programs=
  398. $.length;p=r}a.program=p;p=a.program.attributes;p.position>=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){g.enableVertexAttribArray(p.skinVertexA);g.enableVertexAttribArray(p.skinVertexB);g.enableVertexAttribArray(p.skinIndex);g.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(j in a.attributes)p[j]!==
  399. void 0&&p[j]>=0&&g.enableVertexAttribArray(p[j]);if(a.morphTargets){a.numSupportedMorphTargets=0;r="morphTarget";for(j=0;j<this.maxMorphTargets;j++){s=r+j;if(p[s]>=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;r="morphNormal";for(j=0;j<this.maxMorphNormals;j++){s=r+j;if(p[s]>=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(i in a.uniforms)a.uniformsList.push([a.uniforms[i],i])};this.setFaceCulling=
  400. function(a,b){if(a){!b||b==="ccw"?g.frontFace(g.CCW):g.frontFace(g.CW);a==="back"?g.cullFace(g.BACK):a==="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK);g.enable(g.CULL_FACE)}else g.disable(g.CULL_FACE)};this.setObjectFaces=function(a){if(L!==a.doubleSided){a.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE);L=a.doubleSided}if(qa!==a.flipSided){a.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW);qa=a.flipSided}};this.setDepthTest=function(a){if(Ba!==a){a?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST);
  401. Ba=a}};this.setDepthWrite=function(a){if(Qa!==a){g.depthMask(a);Qa=a}};this.setBlending=function(a,b,c,d){if(a!==xa){if(a===THREE.NoBlending)g.disable(g.BLEND);else if(a===THREE.AdditiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE)}else if(a===THREE.SubtractiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,g.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,
  402. g.SRC_COLOR)}else if(a===THREE.CustomBlending)g.enable(g.BLEND);else{g.enable(g.BLEND);g.blendEquationSeparate(g.FUNC_ADD,g.FUNC_ADD);g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA)}xa=a}if(a===THREE.CustomBlending){if(b!==Aa){g.blendEquation(A(b));Aa=b}if(c!==Pa||d!==ja){g.blendFunc(A(c),A(d));Pa=c;ja=d}}else ja=Pa=Aa=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=g.createTexture();E.info.memory.textures++}g.activeTexture(g.TEXTURE0+
  403. b);g.bindTexture(g.TEXTURE_2D,a.__webglTexture);g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,a.flipY);g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=A(a.format),f=A(a.type);F(g.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?g.texImage2D(g.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):g.texImage2D(g.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&g.generateMipmap(g.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{g.activeTexture(g.TEXTURE0+
  404. b);g.bindTexture(g.TEXTURE_2D,a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=g.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=A(a.format),e=A(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];g.bindTexture(g.TEXTURE_CUBE_MAP,a.__webglTexture);F(g.TEXTURE_CUBE_MAP,a,c);
  405. for(var f=0;f<6;f++){a.__webglFramebuffer[f]=g.createFramebuffer();a.__webglRenderbuffer[f]=g.createRenderbuffer();g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,i=g.TEXTURE_CUBE_MAP_POSITIVE_X+f;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer[f]);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,i,h.__webglTexture,0);s(a.__webglRenderbuffer[f],a)}c&&g.generateMipmap(g.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=g.createFramebuffer();a.__webglRenderbuffer=
  406. g.createRenderbuffer();g.bindTexture(g.TEXTURE_2D,a.__webglTexture);F(g.TEXTURE_2D,a,c);g.texImage2D(g.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=g.TEXTURE_2D;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,d,a.__webglTexture,0);s(a.__webglRenderbuffer,a);c&&g.generateMipmap(g.TEXTURE_2D)}b?g.bindTexture(g.TEXTURE_CUBE_MAP,null):g.bindTexture(g.TEXTURE_2D,null);g.bindRenderbuffer(g.RENDERBUFFER,null);g.bindFramebuffer(g.FRAMEBUFFER,
  407. null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=Nb;a=Ob;d=Ub;e=Mb}if(b!==ra){g.bindFramebuffer(g.FRAMEBUFFER,b);g.viewport(d,e,c,a);ra=b}gc=c;xc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
  408. 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.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type:
  409. THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true};
  410. 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.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;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};
  411. 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)};
  412. 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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
  413. 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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
  414. THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=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};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]};
  415. 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,
  416. 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,h=a.length;e<h;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=
  417. {radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,f,e=0,h=a.length;e<h;e=e+3){b=a[e];d=a[e+1];f=a[e+2];b=Math.sqrt(b*b+d*d+f*f);b>c&&(c=b)}this.boundingSphere.radius=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]=
  418. 0}var f=this.offsets,e=this.attributes.index.array,h=this.attributes.position.array,j=this.attributes.normal.array,l,k,i,m,n,q,u=new THREE.Vector3,o=new THREE.Vector3,r=new THREE.Vector3,p=new THREE.Vector3,v=new THREE.Vector3;c=0;for(d=f.length;c<d;++c){b=f[c].start;l=f[c].count;var x=f[c].index;a=b;for(b=b+l;a<b;a=a+3){l=x+e[a];k=x+e[a+1];i=x+e[a+2];m=h[l*3];n=h[l*3+1];q=h[l*3+2];u.set(m,n,q);m=h[k*3];n=h[k*3+1];q=h[k*3+2];o.set(m,n,q);m=h[i*3];n=h[i*3+1];q=h[i*3+2];r.set(m,n,q);p.sub(r,o);v.sub(u,
  419. o);p.crossSelf(v);j[l*3]=j[l*3]+p.x;j[l*3+1]=j[l*3+1]+p.y;j[l*3+2]=j[l*3+2]+p.z;j[k*3]=j[k*3]+p.x;j[k*3+1]=j[k*3+1]+p.y;j[k*3+2]=j[k*3+2]+p.z;j[i*3]=j[i*3]+p.x;j[i*3+1]=j[i*3+1]+p.y;j[i*3+2]=j[i*3+2]+p.z}}a=0;for(b=j.length;a<b;a=a+3){m=j[a];n=j[a+1];q=j[a+2];c=1/Math.sqrt(m*m+n*n+q*q);j[a]=j[a]*c;j[a+1]=j[a+1]*c;j[a+2]=j[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a,b,c){m=d[a*3];n=d[a*3+1];q=d[a*3+2];u=d[b*3];o=d[b*3+1];r=d[b*3+2];p=d[c*3];v=d[c*3+1];x=d[c*3+2];F=
  420. e[a*2];s=e[a*2+1];I=e[b*2];A=e[b*2+1];N=e[c*2];D=e[c*2+1];H=u-m;G=p-m;R=o-n;U=v-n;T=r-q;z=x-q;K=I-F;V=N-F;E=A-s;$=D-s;fa=1/(K*$-V*E);J.set(($*H-E*G)*fa,($*R-E*U)*fa,($*T-E*z)*fa);ra.set((K*G-V*H)*fa,(K*U-V*R)*fa,(K*z-V*T)*fa);k[a].addSelf(J);k[b].addSelf(J);k[c].addSelf(J);i[a].addSelf(ra);i[b].addSelf(ra);i[c].addSelf(ra)}function b(a){ja.x=f[a*3];ja.y=f[a*3+1];ja.z=f[a*3+2];Ba.copy(ja);Va=k[a];Aa.copy(Va);Aa.subSelf(ja.multiplyScalar(ja.dot(Va))).normalize();Pa.cross(Ba,Va);ob=Pa.dot(i[a]);Qa=ob<
  421. 0?-1:1;l[a*4]=Aa.x;l[a*4+1]=Aa.y;l[a*4+2]=Aa.z;l[a*4+3]=Qa}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 c=this.attributes.index.array,d=this.attributes.position.array,f=this.attributes.normal.array,e=this.attributes.uv.array,h=d.length/3;if(this.attributes.tangent===void 0){var j=4*h;this.attributes.tangent=
  422. {itemSize:4,array:new Float32Array(j),numItems:j}}for(var l=this.attributes.tangent.array,k=[],i=[],j=0;j<h;j++){k[j]=new THREE.Vector3;i[j]=new THREE.Vector3}var m,n,q,u,o,r,p,v,x,F,s,I,A,N,D,H,G,R,U,T,z,K,V,E,$,fa,J=new THREE.Vector3,ra=new THREE.Vector3,S,ba,aa,va,L,qa=this.offsets,j=0;for(ba=qa.length;j<ba;++j){S=qa[j].start;aa=qa[j].count;var xa=qa[j].index,h=S;for(S=S+aa;h<S;h=h+3){aa=xa+c[h];va=xa+c[h+1];L=xa+c[h+2];a(aa,va,L)}}var Aa=new THREE.Vector3,Pa=new THREE.Vector3,ja=new THREE.Vector3,
  423. Ba=new THREE.Vector3,Qa,Va,ob,j=0;for(ba=qa.length;j<ba;++j){S=qa[j].start;aa=qa[j].count;xa=qa[j].index;h=S;for(S=S+aa;h<S;h=h+3){aa=xa+c[h];va=xa+c[h+1];L=xa+c[h+2];b(aa);b(va);b(L)}}this.tangentsNeedUpdate=this.hasTangents=true}}};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype);
  424. 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);
  425. 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;
  426. THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.lineGeometry.vertices.push(new THREE.Vector3);d.lineGeometry.colors.push(new THREE.Color(b));d.pointMap[a]===void 0&&(d.pointMap[a]=[]);d.pointMap[a].push(d.lineGeometry.vertices.length-1)}THREE.Object3D.call(this);var d=this;this.lineGeometry=new THREE.Geometry;this.lineMaterial=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors});this.pointMap={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4",
  427. "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","cf2",3355443);b("cf3","cf4",3355443);this.camera=a;this.update(a);
  428. this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THREE.LinePieces);this.add(this.lines)};THREE.CameraHelper.prototype=Object.create(THREE.Object3D.prototype);
  429. 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.lineGeometry.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,
  430. 1);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.lineGeometry.verticesNeedUpdate=true};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
  431. 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);
  432. 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})};
  433. 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}};THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);
  434. 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,h,j,l,k,i,m,n,q;this.init=function(u){b=u.context;c=u;d=new Float32Array(16);f=new Uint16Array(6);u=0;d[u++]=-1;d[u++]=-1;d[u++]=0;d[u++]=0;d[u++]=1;d[u++]=-1;d[u++]=1;d[u++]=
  435. 0;d[u++]=1;d[u++]=1;d[u++]=1;d[u++]=1;d[u++]=-1;d[u++]=1;d[u++]=0;d[u++]=1;u=0;f[u++]=0;f[u++]=1;f[u++]=2;f[u++]=0;f[u++]=2;f[u++]=3;e=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);j=b.createTexture();l=b.createTexture();b.bindTexture(b.TEXTURE_2D,j);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
  436. 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,l);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);
  437. b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){k=false;i=a(THREE.ShaderFlares.lensFlare)}else{k=true;i=a(THREE.ShaderFlares.lensFlareVertexTexture)}m={};n={};m.vertex=b.getAttribLocation(i,"position");m.uv=b.getAttribLocation(i,"uv");n.renderType=b.getUniformLocation(i,"renderType");n.map=b.getUniformLocation(i,"map");n.occlusionMap=b.getUniformLocation(i,"occlusionMap");n.opacity=b.getUniformLocation(i,"opacity");n.color=b.getUniformLocation(i,
  438. "color");n.scale=b.getUniformLocation(i,"scale");n.rotation=b.getUniformLocation(i,"rotation");n.screenPosition=b.getUniformLocation(i,"screenPosition");q=false};this.render=function(a,d,f,p){var a=a.__webglFlares,v=a.length;if(v){var x=new THREE.Vector3,F=p/f,s=f*0.5,I=p*0.5,A=16/p,N=new THREE.Vector2(A*F,A),D=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),G=n,A=m;b.useProgram(i);if(!q){b.enableVertexAttribArray(m.vertex);b.enableVertexAttribArray(m.uv);q=true}b.uniform1i(G.occlusionMap,0);b.uniform1i(G.map,
  439. 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,h);b.disable(b.CULL_FACE);b.depthMask(false);var R,U,T,z,K;for(R=0;R<v;R++){A=16/p;N.set(A*F,A);z=a[R];x.set(z.matrixWorld.elements[12],z.matrixWorld.elements[13],z.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(x);d.projectionMatrix.multiplyVector3(x);D.copy(x);H.x=D.x*s+s;H.y=D.y*I+I;if(k||H.x>0&&H.x<f&&H.y>0&&
  440. H.y<p){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,j);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,H.x-8,H.y-8,16,16,0);b.uniform1i(G.renderType,0);b.uniform2f(G.scale,N.x,N.y);b.uniform3f(G.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,l);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,H.x-8,H.y-8,16,16,0);b.uniform1i(G.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
  441. b.bindTexture(b.TEXTURE_2D,j);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);z.positionScreen.copy(D);z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();b.uniform1i(G.renderType,2);b.enable(b.BLEND);U=0;for(T=z.lensFlares.length;U<T;U++){K=z.lensFlares[U];if(K.opacity>0.0010&&K.scale>0.0010){D.x=K.x;D.y=K.y;D.z=K.z;A=K.size*K.scale/p;N.x=A*F;N.y=A;b.uniform3f(G.screenPosition,D.x,D.y,D.z);b.uniform2f(G.scale,N.x,N.y);b.uniform1f(G.rotation,K.rotation);b.uniform1f(G.opacity,K.opacity);
  442. b.uniform3f(G.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)}}};
  443. THREE.ShadowMapPlugin=function(){var a,b,c,d,f,e=new THREE.Frustum,h=new THREE.Matrix4,j=new THREE.Vector3,l=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:h,morphTargets:true});f=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,
  444. vertexShader:e.vertexShader,uniforms:h,skinning:true});c._shadowPass=true;d._shadowPass=true;f._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,i){var m,n,q,u,o,r,p,v,x,F=[];u=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);m=0;for(n=k.__lights.length;m<n;m++){q=k.__lights[m];if(q.castShadow)if(q instanceof THREE.DirectionalLight&&
  445. q.shadowCascade)for(o=0;o<q.shadowCascadeCount;o++){var s;if(q.shadowCascadeArray[o])s=q.shadowCascadeArray[o];else{x=q;p=o;s=new THREE.DirectionalLight;s.isVirtual=true;s.onlyShadow=true;s.castShadow=true;s.shadowCameraNear=x.shadowCameraNear;s.shadowCameraFar=x.shadowCameraFar;s.shadowCameraLeft=x.shadowCameraLeft;s.shadowCameraRight=x.shadowCameraRight;s.shadowCameraBottom=x.shadowCameraBottom;s.shadowCameraTop=x.shadowCameraTop;s.shadowCameraVisible=x.shadowCameraVisible;s.shadowDarkness=x.shadowDarkness;
  446. s.shadowBias=x.shadowCascadeBias[p];s.shadowMapWidth=x.shadowCascadeWidth[p];s.shadowMapHeight=x.shadowCascadeHeight[p];s.pointsWorld=[];s.pointsFrustum=[];v=s.pointsWorld;r=s.pointsFrustum;for(var I=0;I<8;I++){v[I]=new THREE.Vector3;r[I]=new THREE.Vector3}v=x.shadowCascadeNearZ[p];x=x.shadowCascadeFarZ[p];r[0].set(-1,-1,v);r[1].set(1,-1,v);r[2].set(-1,1,v);r[3].set(1,1,v);r[4].set(-1,-1,x);r[5].set(1,-1,x);r[6].set(-1,1,x);r[7].set(1,1,x);s.originalCamera=i;r=new THREE.Gyroscope;r.position=q.shadowCascadeOffset;
  447. r.add(s);r.add(s.target);i.add(r);q.shadowCascadeArray[o]=s;console.log("Created virtualLight",s)}p=q;v=o;x=p.shadowCascadeArray[v];x.position.copy(p.position);x.target.position.copy(p.target.position);x.lookAt(x.target);x.shadowCameraVisible=p.shadowCameraVisible;x.shadowDarkness=p.shadowDarkness;x.shadowBias=p.shadowCascadeBias[v];r=p.shadowCascadeNearZ[v];p=p.shadowCascadeFarZ[v];x=x.pointsFrustum;x[0].z=r;x[1].z=r;x[2].z=r;x[3].z=r;x[4].z=p;x[5].z=p;x[6].z=p;x[7].z=p;F[u]=s;u++}else{F[u]=q;u++}}m=
  448. 0;for(n=F.length;m<n;m++){q=F[m];if(!q.shadowMap){q.shadowMap=new THREE.WebGLRenderTarget(q.shadowMapWidth,q.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat});q.shadowMapSize=new THREE.Vector2(q.shadowMapWidth,q.shadowMapHeight);q.shadowMatrix=new THREE.Matrix4}if(!q.shadowCamera){if(q instanceof THREE.SpotLight)q.shadowCamera=new THREE.PerspectiveCamera(q.shadowCameraFov,q.shadowMapWidth/q.shadowMapHeight,q.shadowCameraNear,q.shadowCameraFar);else if(q instanceof
  449. THREE.DirectionalLight)q.shadowCamera=new THREE.OrthographicCamera(q.shadowCameraLeft,q.shadowCameraRight,q.shadowCameraTop,q.shadowCameraBottom,q.shadowCameraNear,q.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}k.add(q.shadowCamera);b.autoUpdateScene&&k.updateMatrixWorld()}if(q.shadowCameraVisible&&!q.cameraHelper){q.cameraHelper=new THREE.CameraHelper(q.shadowCamera);q.shadowCamera.add(q.cameraHelper)}if(q.isVirtual&&s.originalCamera==i){o=i;u=q.shadowCamera;
  450. r=q.pointsFrustum;x=q.pointsWorld;j.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(p=0;p<8;p++){v=x[p];v.copy(r[p]);THREE.ShadowMapPlugin.__projector.unprojectVector(v,o);u.matrixWorldInverse.multiplyVector3(v);if(v.x<j.x)j.x=v.x;if(v.x>l.x)l.x=v.x;if(v.y<j.y)j.y=v.y;if(v.y>l.y)l.y=v.y;if(v.z<j.z)j.z=v.z;if(v.z>l.z)l.z=v.z}u.left=j.x;u.right=l.x;u.top=l.y;u.bottom=j.y;u.updateProjectionMatrix()}u=q.shadowMap;r=q.shadowMatrix;o=q.shadowCamera;o.position.copy(q.matrixWorld.getPosition());
  451. o.lookAt(q.target.matrixWorld.getPosition());o.updateMatrixWorld();o.matrixWorldInverse.getInverse(o.matrixWorld);if(q.cameraHelper)q.cameraHelper.lines.visible=q.shadowCameraVisible;q.shadowCameraVisible&&q.cameraHelper.update();r.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);r.multiplySelf(o.projectionMatrix);r.multiplySelf(o.matrixWorldInverse);if(!o._viewMatrixArray)o._viewMatrixArray=new Float32Array(16);if(!o._projectionMatrixArray)o._projectionMatrixArray=new Float32Array(16);o.matrixWorldInverse.flattenToArray(o._viewMatrixArray);
  452. o.projectionMatrix.flattenToArray(o._projectionMatrixArray);h.multiply(o.projectionMatrix,o.matrixWorldInverse);e.setFromMatrix(h);b.setRenderTarget(u);b.clear();x=k.__webglObjects;q=0;for(u=x.length;q<u;q++){p=x[q];r=p.object;p.render=false;if(r.visible&&r.castShadow&&(!(r instanceof THREE.Mesh)||!r.frustumCulled||e.contains(r))){r._modelViewMatrix.multiply(o.matrixWorldInverse,r.matrixWorld);p.render=true}}q=0;for(u=x.length;q<u;q++){p=x[q];if(p.render){r=p.object;p=p.buffer;v=r.customDepthMaterial?
  453. r.customDepthMaterial:r.geometry.morphTargets.length?d:r instanceof THREE.SkinnedMesh?f:c;p instanceof THREE.BufferGeometry?b.renderBufferDirect(o,k.__lights,null,v,p,r):b.renderBuffer(o,k.__lights,null,v,p,r)}}x=k.__webglObjectsImmediate;q=0;for(u=x.length;q<u;q++){p=x[q];r=p.object;if(r.visible&&r.castShadow){r._modelViewMatrix.multiply(o.matrixWorldInverse,r.matrixWorld);b.renderImmediateObject(o,k.__lights,null,c,r)}}}m=b.getClearColor();n=b.getClearAlpha();a.clearColor(m.r,m.g,m.b,n);a.enable(a.BLEND);
  454. b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
  455. THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,f,e,h,j,l,k,i;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();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
  456. h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,n=b.createProgram(),q=b.createShader(b.FRAGMENT_SHADER),u=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,a.fragmentShader);b.shaderSource(u,a.vertexShader);b.compileShader(q);b.compileShader(u);b.attachShader(n,q);b.attachShader(n,u);b.linkProgram(n);j=n;l={};k={};l.position=b.getAttribLocation(j,"position");l.uv=b.getAttribLocation(j,"uv");k.uvOffset=b.getUniformLocation(j,"uvOffset");k.uvScale=b.getUniformLocation(j,
  457. "uvScale");k.rotation=b.getUniformLocation(j,"rotation");k.scale=b.getUniformLocation(j,"scale");k.alignment=b.getUniformLocation(j,"alignment");k.color=b.getUniformLocation(j,"color");k.map=b.getUniformLocation(j,"map");k.opacity=b.getUniformLocation(j,"opacity");k.useScreenCoordinates=b.getUniformLocation(j,"useScreenCoordinates");k.affectedByDistance=b.getUniformLocation(j,"affectedByDistance");k.screenPosition=b.getUniformLocation(j,"screenPosition");k.modelViewMatrix=b.getUniformLocation(j,"modelViewMatrix");
  458. k.projectionMatrix=b.getUniformLocation(j,"projectionMatrix");i=false};this.render=function(d,f,q,u){var d=d.__webglSprites,o=d.length;if(o){var r=l,p=k,v=u/q,q=q*0.5,x=u*0.5,F=true;b.useProgram(j);if(!i){b.enableVertexAttribArray(r.position);b.enableVertexAttribArray(r.uv);i=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,
  459. h);b.uniformMatrix4fv(p.projectionMatrix,false,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(p.map,0);for(var s,I=[],r=0;r<o;r++){s=d[r];if(s.visible&&s.opacity!==0)if(s.useScreenCoordinates)s.z=-s.position.z;else{s._modelViewMatrix.multiply(f.matrixWorldInverse,s.matrixWorld);s.z=-s._modelViewMatrix.elements[14]}}d.sort(a);for(r=0;r<o;r++){s=d[r];if(s.visible&&s.opacity!==0&&s.map&&s.map.image&&s.map.image.width){if(s.useScreenCoordinates){b.uniform1i(p.useScreenCoordinates,1);
  460. b.uniform3f(p.screenPosition,(s.position.x-q)/q,(x-s.position.y)/x,Math.max(0,Math.min(1,s.position.z)))}else{b.uniform1i(p.useScreenCoordinates,0);b.uniform1i(p.affectedByDistance,s.affectedByDistance?1:0);b.uniformMatrix4fv(p.modelViewMatrix,false,s._modelViewMatrix.elements)}f=s.map.image.width/(s.scaleByViewport?u:1);I[0]=f*v*s.scale.x;I[1]=f*s.scale.y;b.uniform2f(p.uvScale,s.uvScale.x,s.uvScale.y);b.uniform2f(p.uvOffset,s.uvOffset.x,s.uvOffset.y);b.uniform2f(p.alignment,s.alignment.x,s.alignment.y);
  461. b.uniform1f(p.opacity,s.opacity);b.uniform3f(p.color,s.color.r,s.color.g,s.color.b);b.uniform1f(p.rotation,s.rotation);b.uniform2fv(p.scale,I);if(s.mergeWith3D&&!F){b.enable(b.DEPTH_TEST);F=true}else if(!s.mergeWith3D&&F){b.disable(b.DEPTH_TEST);F=false}c.setBlending(s.blending,s.blendEquation,s.blendSrc,s.blendDst);c.setTexture(s.map,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
  462. 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}"},
  463. 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}"}};
  464. 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}",
  465. 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}"}};