ThreeWebGL.js 186 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. // ThreeWebGL.js - http://github.com/mrdoob/three.js
  2. 'use strict';var THREE=THREE||{REVISION:"49dev"};if(!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=(new Date).getTime(),g=Math.max(0,16-(c-a)),i=window.setTimeout(function(){b(c+g)},g);a=c+g;return i};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
  4. function(a){clearTimeout(a)}})();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
  5. 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);
  6. 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,g;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),f=6*a-d,a=c*(1-b),g=c*(1-b*f),b=c*(1-b*(1-f)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
  7. 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+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
  8. THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
  9. 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+=a.x;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-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,
  10. 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)},lerpSelf:function(a,
  11. b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},isZero:function(){return 1.0E-4>this.lengthSq()},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};
  12. 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+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},
  13. 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-=a.x;this.y-=a.y;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*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):
  14. 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())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=
  15. (a.x-this.x)*b;this.y+=(a.y-this.y)*b;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,a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.n14;this.y=
  16. a.n24;this.z=a.n34;return this},getRotationFromMatrix:function(a,b){var c=b?b.x:1,d=b?b.y:1,f=b?b.z:1,g=a.n11/c,i=a.n12/d,c=a.n21/c,d=a.n22/d,h=a.n23/f,k=a.n33/f;this.y=Math.asin(a.n13/f);f=Math.cos(this.y);1.0E-5<Math.abs(f)?(this.x=Math.atan2(-h/f,k/f),this.z=Math.atan2(-i/f,g/f)):(this.x=0,this.z=Math.atan2(c,d));return this},getScaleFromMatrix:function(a){var b=this.set(a.n11,a.n21,a.n31).length(),c=this.set(a.n12,a.n22,a.n32).length(),a=this.set(a.n13,a.n23,a.n33).length();this.x=b;this.y=c;
  17. this.z=a},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},isZero:function(){return 1.0E-4>this.lengthSq()},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=void 0!==d?d:1};
  18. 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=void 0!==a.w?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+=a.x;this.y+=a.y;this.z+=a.z;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-=
  19. a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(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())},normalize:function(){return this.divideScalar(this.length())},
  20. setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
  21. THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
  22. THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),f=0;6>f;f++)if(a=b[f].x*c.n14+b[f].y*c.n24+b[f].z*c.n34+b[f].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
  23. THREE.Ray=function(a,b){function c(a,b,c){r.sub(c,a);z=r.dot(b);w=o.add(a,t.copy(b).multiplyScalar(z));return P=c.distanceTo(w)}function d(a,b,c,d){r.sub(d,b);o.sub(c,b);t.sub(a,b);A=r.dot(r);q=r.dot(o);G=r.dot(t);H=o.dot(o);M=o.dot(t);I=1/(A*H-q*q);K=(H*G-q*M)*I;N=(A*M-q*G)*I;return 0<=K&&0<=N&&1>K+N}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;var f=1.0E-4;this.setPrecision=function(a){f=a};var g=new THREE.Vector3,i=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,
  24. j=new THREE.Vector3,m=new THREE.Vector3,n=new THREE.Vector3,l=new THREE.Vector3,u=new THREE.Vector3;this.intersectObject=function(a){var b,r=[];if(a instanceof THREE.Particle){var o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};r.push(b)}else if(a instanceof THREE.Mesh){var o=c(this.origin,this.direction,a.matrixWorld.getPosition()),t=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),
  25. a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(t.x,Math.max(t.y,t.z)))return r;var q,e,w=a.geometry,z=w.vertices,A;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,t=w.faces.length;o<t;o++)if(b=w.faces[o],j.copy(this.origin),m.copy(this.direction),A=a.matrixWorld,n=A.multiplyVector3(n.copy(b.centroid)).subSelf(j),l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),q=m.dot(l),!(Math.abs(q)<f)&&(e=l.dot(n)/q,!(0>e)&&(a.doubleSided||(a.flipSided?
  26. 0<q:0>q))))if(u.add(j,m.multiplyScalar(e)),b instanceof THREE.Face3)g=A.multiplyVector3(g.copy(z[b.a].position)),i=A.multiplyVector3(i.copy(z[b.b].position)),h=A.multiplyVector3(h.copy(z[b.c].position)),d(u,g,i,h)&&(b={distance:j.distanceTo(u),point:u.clone(),face:b,object:a},r.push(b));else if(b instanceof THREE.Face4&&(g=A.multiplyVector3(g.copy(z[b.a].position)),i=A.multiplyVector3(i.copy(z[b.b].position)),h=A.multiplyVector3(h.copy(z[b.c].position)),k=A.multiplyVector3(k.copy(z[b.d].position)),
  27. d(u,g,i,k)||d(u,i,h,k)))b={distance:j.distanceTo(u),point:u.clone(),face:b,object:a},r.push(b)}return r};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(function(a,b){return a.distance-b.distance});return b};var r=new THREE.Vector3,o=new THREE.Vector3,t=new THREE.Vector3,z,w,P,A,q,G,H,M,I,K,N};
  28. THREE.Rectangle=function(){function a(){g=d-b;i=f-c}var b,c,d,f,g,i,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(g,i,m,n){h=!1;b=g;c=i;d=m;f=n;a()};this.addPoint=function(g,i){h?(h=!1,b=g,c=i,d=g,f=i):(b=b<g?b:g,c=c<i?c:i,d=d>g?d:g,f=f>i?f:i);a()};this.add3Points=
  29. function(g,i,m,n,l,u){h?(h=!1,b=g<m?g<l?g:l:m<l?m:l,c=i<n?i<u?i:u:n<u?n:u,d=g>m?g>l?g:l:m>l?m:l,f=i>n?i>u?i:u:n>u?n:u):(b=g<m?g<l?g<b?g:b:l<b?l:b:m<l?m<b?m:b:l<b?l:b,c=i<n?i<u?i<c?i:c:u<c?u:c:n<u?n<c?n:c:u<c?u:c,d=g>m?g>l?g>d?g:d:l>d?l:d:m>l?m>d?m:d:l>d?l:d,f=i>n?i>u?i>f?i:f:u>f?u:f:n>u?n>f?n:f:u>f?u:f);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),f=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),f=f>
  30. g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||f<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};
  31. 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 0>a?-1:0<a?1:0}};THREE.Matrix3=function(){this.m=[]};
  32. THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,g,i,h,k,j,m,n,l,u,r,o){this.set(void 0!==a?a:1,b||0,c||0,d||0,f||0,void 0!==g?g:1,i||0,h||0,k||0,j||0,void 0!==m?m:1,n||0,l||0,u||0,r||0,void 0!==o?o:1);this.m33=new THREE.Matrix3};
  33. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,g,i,h,k,j,m,n,l,u,r,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=i;this.n24=h;this.n31=k;this.n32=j;this.n33=m;this.n34=n;this.n41=l;this.n42=u;this.n43=r;this.n44=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){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
  34. b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(0===g.length())g.z=1;d.cross(c,g).normalize();0===d.length()&&(g.x+=1.0E-4,d.cross(c,g).normalize());f.cross(g,d);this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,n=a.n32,l=a.n33,u=a.n34,r=a.n41,o=a.n42,t=a.n43,z=a.n44,w=b.n11,
  35. P=b.n12,A=b.n13,q=b.n14,G=b.n21,H=b.n22,M=b.n23,I=b.n24,K=b.n31,N=b.n32,ja=b.n33,oa=b.n34,ka=b.n41,Y=b.n42,S=b.n43,C=b.n44;this.n11=c*w+d*G+f*K+g*ka;this.n12=c*P+d*H+f*N+g*Y;this.n13=c*A+d*M+f*ja+g*S;this.n14=c*q+d*I+f*oa+g*C;this.n21=i*w+h*G+k*K+j*ka;this.n22=i*P+h*H+k*N+j*Y;this.n23=i*A+h*M+k*ja+j*S;this.n24=i*q+h*I+k*oa+j*C;this.n31=m*w+n*G+l*K+u*ka;this.n32=m*P+n*H+l*N+u*Y;this.n33=m*A+n*M+l*ja+u*S;this.n34=m*q+n*I+l*oa+u*C;this.n41=r*w+o*G+t*K+z*ka;this.n42=r*P+o*H+t*N+z*Y;this.n43=r*A+o*M+t*
  36. ja+z*S;this.n44=r*q+o*I+t*oa+z*C;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
  37. a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*
  38. c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
  39. a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,k=this.n31,j=this.n32,m=this.n33,n=this.n34,l=this.n41,u=this.n42,r=this.n43,o=this.n44;return d*i*j*l-c*h*j*l-d*g*m*l+b*h*m*l+c*g*n*l-b*i*n*l-d*i*k*u+c*h*k*u+d*f*m*u-a*h*m*u-c*f*n*u+a*i*n*u+d*g*k*r-b*h*k*r-d*f*j*r+a*h*j*r+b*f*n*r-a*g*n*r-c*g*k*o+b*i*k*o+c*f*j*o-a*i*j*o-b*f*m*o+a*g*m*o},transpose:function(){var a;
  40. a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n34=a;return this},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=
  41. this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=
  42. 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},setRotationY: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},setRotationZ: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);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,i=a.y,h=a.z,k=f*g,j=f*i;this.set(k*g+c,k*i-d*h,k*h+d*i,0,k*i+d*h,j*i+c,j*h-d*g,0,k*h-d*i,j*h+d*g,f*h*h+c,0,0,0,0,1);return this},
  43. setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,k=a.n24,j=a.n31,m=
  44. a.n32,n=a.n33,l=a.n34,u=a.n41,r=a.n42,o=a.n43,t=a.n44;this.n11=h*l*r-k*n*r+k*m*o-i*l*o-h*m*t+i*n*t;this.n12=f*n*r-d*l*r-f*m*o+c*l*o+d*m*t-c*n*t;this.n13=d*k*r-f*h*r+f*i*o-c*k*o-d*i*t+c*h*t;this.n14=f*h*m-d*k*m-f*i*n+c*k*n+d*i*l-c*h*l;this.n21=k*n*u-h*l*u-k*j*o+g*l*o+h*j*t-g*n*t;this.n22=d*l*u-f*n*u+f*j*o-b*l*o-d*j*t+b*n*t;this.n23=f*h*u-d*k*u-f*g*o+b*k*o+d*g*t-b*h*t;this.n24=d*k*j-f*h*j+f*g*n-b*k*n-d*g*l+b*h*l;this.n31=i*l*u-k*m*u+k*j*r-g*l*r-i*j*t+g*m*t;this.n32=f*m*u-c*l*u-f*j*r+b*l*r+c*j*t-b*m*
  45. t;this.n33=c*k*u-f*i*u+f*g*r-b*k*r-c*g*t+b*i*t;this.n34=f*i*j-c*k*j-f*g*m+b*k*m+c*g*l-b*i*l;this.n41=h*m*u-i*n*u-h*j*r+g*n*r+i*j*o-g*m*o;this.n42=c*n*u-d*m*u+d*j*r-b*n*r-c*j*o+b*m*o;this.n43=d*i*u-c*h*u-d*g*r+b*h*r+c*g*o-b*i*o;this.n44=c*h*j-d*i*j+d*g*m-b*h*m-c*g*n+b*i*n;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,g=Math.cos(c),c=Math.sin(c),i=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var k=i*h,j=i*f,
  46. m=d*h,n=d*f;this.n11=k+n*c;this.n12=m*c-j;this.n13=g*d;this.n21=g*f;this.n22=g*h;this.n23=-c;this.n31=j*c-m;this.n32=n+k*c;this.n33=g*i;break;case "ZXY":k=i*h;j=i*f;m=d*h;n=d*f;this.n11=k-n*c;this.n12=-g*f;this.n13=m+j*c;this.n21=j+m*c;this.n22=g*h;this.n23=n-k*c;this.n31=-g*d;this.n32=c;this.n33=g*i;break;case "ZYX":k=g*h;j=g*f;m=c*h;n=c*f;this.n11=i*h;this.n12=m*d-j;this.n13=k*d+n;this.n21=i*f;this.n22=n*d+k;this.n23=j*d-m;this.n31=-d;this.n32=c*i;this.n33=g*i;break;case "YZX":k=g*i;j=g*d;m=c*i;
  47. n=c*d;this.n11=i*h;this.n12=n-k*f;this.n13=m*f+j;this.n21=f;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=j*f+m;this.n33=k-n*f;break;case "XZY":k=g*i;j=g*d;m=c*i;n=c*d;this.n11=i*h;this.n12=-f;this.n13=d*h;this.n21=k*f+n;this.n22=g*h;this.n23=j*f-m;this.n31=m*f-j;this.n32=c*h;this.n33=n*f+k;break;default:k=g*h,j=g*f,m=c*h,n=c*f,this.n11=i*h,this.n12=-i*f,this.n13=d,this.n21=j+m*d,this.n22=k-n*d,this.n23=-c*i,this.n31=n-k*d,this.n32=m+j*d,this.n33=g*i}return this},setRotationFromQuaternion:function(a){var b=
  48. a.x,c=a.y,d=a.z,f=a.w,g=b+b,i=c+c,h=d+d,a=b*g,k=b*i,b=b*h,j=c*i,c=c*h,d=d*h,g=f*g,i=f*i,f=f*h;this.n11=1-(j+d);this.n12=k-f;this.n13=b+i;this.n21=k+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-i;this.n32=c+g;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;
  49. d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);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=d.length();
  50. c.y=f.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=
  51. a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===a.z)return this.rotateZ(b);var c=a.x,d=a.y,f=a.z,g=Math.sqrt(c*c+d*d+f*f),c=c/g,d=d/g,f=f/g,g=c*c,i=d*d,h=f*f,k=Math.cos(b),j=Math.sin(b),m=1-k,n=c*d*m,l=c*f*m,m=d*f*m,c=c*j,u=d*j,j=f*j,f=
  52. g+(1-g)*k,g=n+j,d=l-u,n=n-j,i=i+(1-i)*k,j=m+c,l=l+u,m=m-c,h=h+(1-h)*k,k=this.n11,c=this.n21,u=this.n31,r=this.n41,o=this.n12,t=this.n22,z=this.n32,w=this.n42,P=this.n13,A=this.n23,q=this.n33,G=this.n43;this.n11=f*k+g*o+d*P;this.n21=f*c+g*t+d*A;this.n31=f*u+g*z+d*q;this.n41=f*r+g*w+d*G;this.n12=n*k+i*o+j*P;this.n22=n*c+i*t+j*A;this.n32=n*u+i*z+j*q;this.n42=n*r+i*w+j*G;this.n13=l*k+m*o+h*P;this.n23=l*c+m*t+h*A;this.n33=l*u+m*z+h*q;this.n43=l*r+m*w+h*G;return this},rotateX:function(a){var b=this.n12,
  53. c=this.n22,d=this.n32,f=this.n42,g=this.n13,i=this.n23,h=this.n33,k=this.n43,j=Math.cos(a),a=Math.sin(a);this.n12=j*b+a*g;this.n22=j*c+a*i;this.n32=j*d+a*h;this.n42=j*f+a*k;this.n13=j*g-a*b;this.n23=j*i-a*c;this.n33=j*h-a*d;this.n43=j*k-a*f;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,f=this.n41,g=this.n13,i=this.n23,h=this.n33,k=this.n43,j=Math.cos(a),a=Math.sin(a);this.n11=j*b-a*g;this.n21=j*c-a*i;this.n31=j*d-a*h;this.n41=j*f-a*k;this.n13=j*g+a*b;this.n23=j*i+a*c;this.n33=
  54. j*h+a*d;this.n43=j*k+a*f;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,f=this.n41,g=this.n12,i=this.n22,h=this.n32,k=this.n42,j=Math.cos(a),a=Math.sin(a);this.n11=j*b+a*g;this.n21=j*c+a*i;this.n31=j*d+a*h;this.n41=j*f+a*k;this.n12=j*g-a*b;this.n22=j*i-a*c;this.n32=j*h-a*d;this.n42=j*k-a*f;return this},translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*
  55. c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this},clone:function(){return new THREE.Matrix4(this.n11,this.n12,this.n13,this.n14,this.n21,this.n22,this.n23,this.n24,this.n31,this.n32,this.n33,this.n34,this.n41,this.n42,this.n43,this.n44)}};
  56. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*i+a.n31*j;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*i;c[4]=a*h;c[5]=a*k;c[6]=a*j;c[7]=a*m;c[8]=a*n;return b};
  57. THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var i;i=new THREE.Matrix4;i.n11=2*f/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*f/(d-c);i.n23=(d+c)/(d-c);i.n24=0;i.n31=0;i.n32=0;i.n33=-(g+f)/(g-f);i.n34=-2*g*f/(g-f);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
  58. THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var i,h,k,j;i=new THREE.Matrix4;h=b-a;k=c-d;j=g-f;i.n11=2/h;i.n12=0;i.n13=0;i.n14=-((b+a)/h);i.n21=0;i.n22=2/k;i.n23=0;i.n24=-((c+d)/k);i.n31=0;i.n32=0;i.n33=-2/j;i.n34=-((g+f)/j);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
  59. THREE.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=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
  60. !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
  61. THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiply(a,this.matrix);this.scale.getScaleFromMatrix(this.matrix);this.rotation.getRotationFromMatrix(this.matrix,this.scale);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,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,
  62. this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)},add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(-1===this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=
  63. this.children.indexOf(a);if(-1!==b){a.parent=void 0;this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__removeObject(a)}},getChildByName:function(a,b){var c,d,f;for(c=0,d=this.children.length;c<d;c++){f=this.children[c];if(f.name===a||b&&(f=f.getChildByName(a,b),void 0!==f))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,
  64. this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},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=!1,a=!0;for(var b=0,c=this.children.length;b<
  65. c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
  66. THREE.Projector=function(){function a(){var a=i[g]=i[g]||new THREE.RenderableObject;g++;return a}function b(){var a=j[k]=j[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,i=-b.z+b.w;if(0<=f&&0<=e&&0<=g&&0<=i)return!0;if(0>f&&0>e||0>g&&0>i)return!1;0>f?c=Math.max(c,f/(f-e)):0>e&&(d=Math.min(d,f/(f-e)));0>g?c=Math.max(c,g/(g-i)):0>i&&(d=Math.min(d,g/(g-i)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
  67. var f,g,i=[],h,k,j=[],m,n,l=[],u,r=[],o,t,z=[],w,P,A=[],q={objects:[],sprites:[],lights:[],elements:[]},G=new THREE.Vector3,H=new THREE.Vector4,M=new THREE.Matrix4,I=new THREE.Matrix4,K=new THREE.Frustum,N=new THREE.Vector4,ja=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);M.multiply(b.projectionMatrix,b.matrixWorldInverse);M.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);M.multiply(b.matrixWorld,
  68. b.projectionMatrixInverse);M.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){g=0;q.objects.length=0;q.sprites.length=0;q.lights.length=0;var i=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||K.contains(b))?(G.copy(b.matrixWorld.getPosition()),M.multiplyVector3(G),
  69. f=a(),f.object=b,f.z=G.z,q.objects.push(f)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(G.copy(b.matrixWorld.getPosition()),M.multiplyVector3(G),f=a(),f.object=b,f.z=G.z,q.sprites.push(f)):b instanceof THREE.Light&&q.lights.push(b);for(var c=0,e=b.children.length;c<e;c++)i(b.children[c])}};i(b);d&&q.objects.sort(c);return q};this.projectScene=function(a,f,g){var i=f.near,C=f.far,e=!1,G,Ba,T,sa,J,aa,ta,xa,X,Aa,Ma,Wa,Ta,Ka,Ca;P=t=u=n=0;q.elements.length=0;void 0===f.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
  70. a.add(f));a.updateMatrixWorld();f.matrixWorldInverse.getInverse(f.matrixWorld);M.multiply(f.projectionMatrix,f.matrixWorldInverse);K.setFromMatrix(M);q=this.projectGraph(a,!1);for(a=0,G=q.objects.length;a<G;a++)if(X=q.objects[a].object,Aa=X.matrixWorld,k=0,X instanceof THREE.Mesh){Ma=X.geometry;Wa=X.geometry.materials;sa=Ma.vertices;Ta=Ma.faces;Ka=Ma.faceVertexUvs;Ma=X.matrixRotationWorld.extractRotation(Aa);for(Ba=0,T=sa.length;Ba<T;Ba++)h=b(),h.positionWorld.copy(sa[Ba].position),Aa.multiplyVector3(h.positionWorld),
  71. h.positionScreen.copy(h.positionWorld),M.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>i&&h.positionScreen.z<C;for(sa=0,Ba=Ta.length;sa<Ba;sa++){T=Ta[sa];if(T instanceof THREE.Face3)if(J=j[T.a],aa=j[T.b],ta=j[T.c],J.visible&&aa.visible&&ta.visible)if(e=0>(ta.positionScreen.x-J.positionScreen.x)*(aa.positionScreen.y-J.positionScreen.y)-(ta.positionScreen.y-J.positionScreen.y)*(aa.positionScreen.x-J.positionScreen.x),
  72. X.doubleSided||e!=X.flipSided)xa=l[n]=l[n]||new THREE.RenderableFace3,n++,m=xa,m.v1.copy(J),m.v2.copy(aa),m.v3.copy(ta);else continue;else continue;else if(T instanceof THREE.Face4)if(J=j[T.a],aa=j[T.b],ta=j[T.c],xa=j[T.d],J.visible&&aa.visible&&ta.visible&&xa.visible)if(e=0>(xa.positionScreen.x-J.positionScreen.x)*(aa.positionScreen.y-J.positionScreen.y)-(xa.positionScreen.y-J.positionScreen.y)*(aa.positionScreen.x-J.positionScreen.x)||0>(aa.positionScreen.x-ta.positionScreen.x)*(xa.positionScreen.y-
  73. ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),X.doubleSided||e!=X.flipSided)Ca=r[u]=r[u]||new THREE.RenderableFace4,u++,m=Ca,m.v1.copy(J),m.v2.copy(aa),m.v3.copy(ta),m.v4.copy(xa);else continue;else continue;m.normalWorld.copy(T.normal);!e&&(X.flipSided||X.doubleSided)&&m.normalWorld.negate();Ma.multiplyVector3(m.normalWorld);m.centroidWorld.copy(T.centroid);Aa.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);M.multiplyVector3(m.centroidScreen);
  74. ta=T.vertexNormals;for(J=0,aa=ta.length;J<aa;J++)xa=m.vertexNormalsWorld[J],xa.copy(ta[J]),!e&&(X.flipSided||X.doubleSided)&&xa.negate(),Ma.multiplyVector3(xa);for(J=0,aa=Ka.length;J<aa;J++)if(Ca=Ka[J][sa])for(ta=0,xa=Ca.length;ta<xa;ta++)m.uvs[J][ta]=Ca[ta];m.material=X.material;m.faceMaterial=null!==T.materialIndex?Wa[T.materialIndex]:null;m.z=m.centroidScreen.z;q.elements.push(m)}}else if(X instanceof THREE.Line){I.multiply(M,Aa);sa=X.geometry.vertices;J=b();J.positionScreen.copy(sa[0].position);
  75. I.multiplyVector4(J.positionScreen);for(Ba=1,T=sa.length;Ba<T;Ba++)if(J=b(),J.positionScreen.copy(sa[Ba].position),I.multiplyVector4(J.positionScreen),aa=j[k-2],N.copy(J.positionScreen),ja.copy(aa.positionScreen),d(N,ja))N.multiplyScalar(1/N.w),ja.multiplyScalar(1/ja.w),Aa=z[t]=z[t]||new THREE.RenderableLine,t++,o=Aa,o.v1.positionScreen.copy(N),o.v2.positionScreen.copy(ja),o.z=Math.max(N.z,ja.z),o.material=X.material,q.elements.push(o)}for(a=0,G=q.sprites.length;a<G;a++)if(X=q.sprites[a].object,Aa=
  76. X.matrixWorld,X instanceof THREE.Particle&&(H.set(Aa.n14,Aa.n24,Aa.n34,1),M.multiplyVector4(H),H.z/=H.w,0<H.z&&1>H.z))i=A[P]=A[P]||new THREE.RenderableParticle,P++,w=i,w.x=H.x/H.w,w.y=H.y/H.w,w.z=H.z,w.rotation=X.rotation.z,w.scale.x=X.scale.x*Math.abs(w.x-(H.x+f.projectionMatrix.n11)/(H.w+f.projectionMatrix.n14)),w.scale.y=X.scale.y*Math.abs(w.y-(H.y+f.projectionMatrix.n22)/(H.w+f.projectionMatrix.n24)),w.material=X.material,q.elements.push(w);g&&q.elements.sort(c);return q}};
  77. THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
  78. 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){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),i=a*b,h=d*f;this.w=i*g-h*c;this.x=i*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
  79. this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
  80. this.normalize();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*=-1;this.y*=-1;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);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,
  81. 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,g=a.x,i=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*i;this.y=c*a+f*i+d*g-b*h;this.z=d*a+f*h+b*i-c*g;this.w=f*a-b*g-c*i-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,i=this.y,h=this.z,k=this.w,j=k*c+i*f-h*d,m=k*d+h*c-g*f,n=k*f+g*
  82. d-i*c,c=-g*c-i*d-h*f;b.x=j*k+c*-g+m*-h-n*-i;b.y=m*k+c*-i+n*-g-j*-h;b.z=n*k+c*-h+j*-i-m*-g;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
  83. 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;0>f?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(1<=Math.abs(f))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(0.0010>Math.abs(f))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
  84. THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,f,g){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=g;this.centroid=new THREE.Vector3};
  85. 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;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
  86. return a}};THREE.Face4=function(a,b,c,d,f,g,i){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=i;this.centroid=new THREE.Vector3};
  87. 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;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
  88. 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+=(a.u-this.u)*b;this.v+=(a.v-this.v)*b;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
  89. THREE.Geometry=function(){this.id=THREE.GeometryCount++;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=!1};
  90. 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].position);c=0;for(d=this.faces.length;c<d;c++){var f=this.faces[c];b.multiplyVector3(f.normal);for(var g=0,i=f.vertexNormals.length;g<i;g++)b.multiplyVector3(f.vertexNormals[g]);a.multiplyVector3(f.centroid)}},computeCentroids:function(){var a,b,c;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,
  91. 0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(){var a,b,c,d,f,g,i=new THREE.Vector3,
  92. h=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],f=this.vertices[c.b],g=this.vertices[c.c],i.sub(g.position,f.position),h.sub(d.position,f.position),i.crossSelf(h),i.isZero()||i.normalize(),c.normal.copy(i)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof
  93. THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;for(a=0,b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),
  94. d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],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])):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;for(c=0,d=this.faces.length;c<
  95. d;c++){f=this.faces[c];f.__originalFaceNormal?f.__originalFaceNormal.copy(f.normal):f.__originalFaceNormal=f.normal.clone();if(!f.__originalVertexNormals)f.__originalVertexNormals=[];for(a=0,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 g=new THREE.Geometry;g.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};
  96. this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var i=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,k,j;for(c=0,d=this.faces.length;c<d;c++)f=this.faces[c],k=new THREE.Vector3,j=f instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},i.push(k),h.push(j)}i=this.morphNormals[a];g.vertices=this.morphTargets[a].vertices;g.computeFaceNormals();
  97. g.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)f=this.faces[c],k=i.faceNormals[c],j=i.vertexNormals[c],k.copy(f.normal),f instanceof THREE.Face3?(j.a.copy(f.vertexNormals[0]),j.b.copy(f.vertexNormals[1]),j.c.copy(f.vertexNormals[2])):(j.a.copy(f.vertexNormals[0]),j.b.copy(f.vertexNormals[1]),j.c.copy(f.vertexNormals[2]),j.d.copy(f.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)f=this.faces[c],f.normal=f.__originalFaceNormal,f.vertexNormals=f.__originalVertexNormals},computeTangents:function(){function a(a,
  98. b,c,d,f,g,J){h=a.vertices[b].position;k=a.vertices[c].position;j=a.vertices[d].position;m=i[f];n=i[g];l=i[J];u=k.x-h.x;r=j.x-h.x;o=k.y-h.y;t=j.y-h.y;z=k.z-h.z;w=j.z-h.z;P=n.u-m.u;A=l.u-m.u;q=n.v-m.v;G=l.v-m.v;H=1/(P*G-A*q);N.set((G*u-q*r)*H,(G*o-q*t)*H,(G*z-q*w)*H);ja.set((P*r-A*u)*H,(P*t-A*o)*H,(P*w-A*z)*H);I[b].addSelf(N);I[c].addSelf(N);I[d].addSelf(N);K[b].addSelf(ja);K[c].addSelf(ja);K[d].addSelf(ja)}var b,c,d,f,g,i,h,k,j,m,n,l,u,r,o,t,z,w,P,A,q,G,H,M,I=[],K=[],N=new THREE.Vector3,ja=new THREE.Vector3,
  99. oa=new THREE.Vector3,ka=new THREE.Vector3,Y=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)I[b]=new THREE.Vector3,K[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],i=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var S=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)Y.copy(g.vertexNormals[d]),f=g[S[d]],
  100. M=I[f],oa.copy(M),oa.subSelf(Y.multiplyScalar(Y.dot(M))).normalize(),ka.cross(g.vertexNormals[d],M),f=ka.dot(K[f]),f=0>f?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.z,f)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;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<
  101. f;d++){a=this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=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].position.length(),a>b&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,
  102. 4),g,i;for(g=0,i=this.vertices.length;g<i;g++)d=this.vertices[g].position,d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_"),void 0===a[d]?(a[d]=g,b.push(this.vertices[g]),c[g]=b.length-1):c[g]=c[a[d]];for(g=0,i=this.faces.length;g<i;g++)if(a=this.faces[g],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];this.vertices=b}};THREE.GeometryCount=0;
  103. THREE.Spline=function(a){function b(a,b,c,d,f,g,i){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*i+(-3*(b-c)-2*a-d)*g+a*f+b}this.points=a;var c=[],d={x:0,y:0,z:0},f,g,i,h,k,j,m,n,l;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;g=Math.floor(f);i=f-g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>this.points.length-2?this.points.length-1:g+1;c[3]=g>this.points.length-3?this.points.length-1:
  104. g+2;j=this.points[c[0]];m=this.points[c[1]];n=this.points[c[2]];l=this.points[c[3]];h=i*i;k=i*h;d.x=b(j.x,m.x,n.x,l.x,i,h,k);d.y=b(j.y,m.y,n.y,l.y,i,h,k);d.z=b(j.z,m.z,n.z,l.z,i,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,f=b=b=0,g=new THREE.Vector3,i=new THREE.Vector3,h=[],j=0;h[0]=0;a||(a=100);c=this.points.length*a;g.copy(this.points[0]);for(a=1;a<c;a++)b=
  105. a/c,d=this.getPoint(b),i.copy(d),j+=i.distanceTo(g),g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=f&&(h[b]=j,f=b);h[h.length]=j;return{chunks:h,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,f,g,i,h=[],j=new THREE.Vector3,l=this.getLength();h.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];i=Math.ceil(a*c/l.total);f=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<i-1;c++)d=f+c*(1/i)*(g-f),d=this.getPoint(d),
  106. h.push(j.copy(d).clone());h.push(j.copy(this.points[b]).clone())}this.points=h}};THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)};
  107. THREE.OrthographicCamera=function(a,b,c,d,f,g){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==f?f:0.1;this.far=void 0!==g?g:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};
  108. THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:0.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};
  109. THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=g;this.updateProjectionMatrix()};
  110. 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=THREE.Matrix4.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=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
  111. this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
  112. 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=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
  113. !1;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=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
  114. THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
  115. THREE.SpotLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};
  116. THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
  117. THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=void 0!==a.opacity?a.opacity:1;this.transparent=void 0!==a.transparent?a.transparent:!1;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.blendSrc=void 0!==a.blendSrc?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=void 0!==a.blendDst?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=void 0!==a.blendEquation?a.blendEquation:THREE.AddEquation;this.depthTest=void 0!==a.depthTest?a.depthTest:
  118. !0;this.depthWrite=void 0!==a.depthWrite?a.depthWrite:!0;this.polygonOffset=void 0!==a.polygonOffset?a.polygonOffset:!1;this.polygonOffsetFactor=void 0!==a.polygonOffsetFactor?a.polygonOffsetFactor:0;this.polygonOffsetUnits=void 0!==a.polygonOffsetUnits?a.polygonOffsetUnits:0;this.alphaTest=void 0!==a.alphaTest?a.alphaTest:0;this.overdraw=void 0!==a.overdraw?a.overdraw:!1;this.needsUpdate=!0};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;
  119. THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;THREE.AdditiveAlphaBlending=5;THREE.CustomBlending=6;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;
  120. THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;
  121. THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=void 0!==a.linewidth?a.linewidth:1;this.linecap=void 0!==a.linecap?a.linecap:"round";this.linejoin=void 0!==a.linejoin?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1;this.fog=void 0!==a.fog?a.fog:!0};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  122. THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:
  123. !0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?
  124. a.morphTargets:!1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  125. THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=void 0!==a.emissive?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=void 0!==a.wrapAround?a.wrapAround:!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=
  126. void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:!0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?
  127. a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  128. THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=void 0!==a.emissive?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=void 0!==a.specular?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=void 0!==a.shininess?a.shininess:30;this.metal=void 0!==a.metal?a.metal:!1;this.perPixel=
  129. void 0!==a.perPixel?a.perPixel:!1;this.wrapAround=void 0!==a.wrapAround?a.wrapAround:!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:!0;this.shading=void 0!==
  130. a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:
  131. !1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;
  132. THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;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:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
  133. THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:null;this.size=void 0!==a.size?a.size:1;this.sizeAttenuation=void 0!==a.sizeAttenuation?a.sizeAttenuation:!0;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.fog=void 0!==a.fog?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
  134. THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=void 0!==a.fragmentShader?a.fragmentShader:"void main() {}";this.vertexShader=void 0!==a.vertexShader?a.vertexShader:"void main() {}";this.uniforms=void 0!==a.uniforms?a.uniforms:{};this.attributes=a.attributes;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.fog=void 0!==
  135. a.fog?a.fog:!1;this.lights=void 0!==a.lights?a.lights:!1;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
  136. THREE.Texture=function(a,b,c,d,f,g,i,h){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==f?f:THREE.LinearFilter;this.minFilter=void 0!==g?g:THREE.LinearMipMapLinearFilter;this.format=void 0!==i?i:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
  137. !0;this.needsUpdate=this.premultiplyAlpha=!1;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;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
  138. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;
  139. THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,f,g,i,h,k,j){THREE.Texture.call(this,null,g,i,h,k,j,d,f);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
  140. THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
  141. THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.ParticleBasicMaterial({color:16777215*Math.random()});this.sortParticles=!1;if(this.geometry)this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius;this.frustumCulled=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
  142. THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()});this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  143. THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random(),wireframe:!0});if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,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),
  144. this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
  145. THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  146. THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
  147. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,f,g,i,h;if(void 0!==this.geometry.bones){for(c=0;c<this.geometry.bones.length;c++)f=this.geometry.bones[c],g=f.pos,i=f.rotq,h=f.scl,d=this.addBone(),d.name=f.name,d.position.set(g[0],g[1],g[2]),d.quaternion.set(i[0],i[1],i[2],i[3]),d.useQuaternion=!0,void 0!==h?d.scale.set(h[0],h[1],h[2]):d.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)f=this.geometry.bones[c],
  148. d=this.bones[c],-1===f.parent?this.add(d):this.bones[f.parent].add(d);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){void 0===a&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  149. 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=!1;for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,!1):c.updateMatrixWorld(!0)}for(var b=this.bones.length,c=this.bones,d=this.boneMatrices,a=0;a<b;a++)c[a].skinMatrix.flattenToArrayOffset(d,
  150. 16*a)};
  151. THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);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,16*c)}if(void 0===this.geometry.skinVerticesA){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,f=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y,d=
  152. 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[g].multiplyVector3(d));1!==this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y&&(c=0.5*(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y)),this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
  153. THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length&&!(b<this.LODs[c].visibleAtDistance);c++);this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
  154. THREE.LOD.prototype.update=function(a){if(1<this.LODs.length){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.matrixWorld.n14+a.n32*this.matrixWorld.n24+a.n33*this.matrixWorld.n34+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=!1}};
  155. THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:new THREE.Texture;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.blendSrc=void 0!==a.blendSrc?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=void 0!==a.blendDst?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=void 0!==a.blendEquation?a.blendEquation:THREE.AddEquation;this.useScreenCoordinates=void 0!==a.useScreenCoordinates?
  156. a.useScreenCoordinates:!0;this.mergeWith3D=void 0!==a.mergeWith3D?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=void 0!==a.affectedByDistance?a.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=void 0!==a.scaleByViewport?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=
  157. new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(1!==this.scale.x||1!==this.scale.y)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};
  158. THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);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);
  159. THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.__objects=[];this.__lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
  160. THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.__objects.indexOf(a)){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.__addObject(a.children[b])};
  161. THREE.Scene.prototype.__removeObject=function(a){if(a instanceof THREE.Light){var b=this.__lights.indexOf(a);-1!==b&&this.__lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.__objects.indexOf(a),-1!==b&&(this.__objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.__removeObject(a.children[b])};
  162. THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};
  163. 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",
  164. 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",
  165. 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",
  166. map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\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",
  167. 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#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
  168. 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\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
  169. lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\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#endif",
  170. 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#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  171. 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_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#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",
  172. 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\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * modelViewMatrix * gl_Position;\n#endif",
  173. morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",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",
  174. 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",
  175. shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
  176. 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\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n#endif\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",
  177. linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
  178. THREE.UniformsUtils={merge:function(a){var b,c,d,f={};for(b=0;b<a.length;b++)for(c in d=this.clone(a[b]),d)f[c]=d[c];return f},clone:function(a){var b,c,d,f={};for(b in a)for(c in f[b]={},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}};
  179. 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",
  180. 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:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",
  181. 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",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}};
  182. 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",
  183. 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,
  184. 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.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
  185. 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,THREE.ShaderChunk.alphatest_fragment,
  186. 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)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,
  187. 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 );",THREE.ShaderChunk.map_vertex,
  188. THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
  189. 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",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  190. 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)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",
  191. 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 );",THREE.ShaderChunk.map_vertex,
  192. 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,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;",
  193. 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 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  194. THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,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;",
  195. THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,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,
  196. "}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",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}"}};
  197. THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var f in d.attributes){var g=d.attributes[f];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var i=1;"v2"===g.type?i=2:"v3"===g.type?i=3:"v4"===g.type?i=4:"c"===g.type&&(i=3);g.size=i;g.array=new Float32Array(c*i);g.buffer=e.createBuffer();g.buffer.belongsToAttribute=f;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}}
  198. function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c){var d,f,g,i,h=a.vertices;i=h.length;
  199. var j=a.colors,l=j.length,m=a.__vertexArray,n=a.__colorArray,k=a.__sortArray,r=a.__dirtyVertices,o=a.__dirtyColors,u=a.__webglCustomAttributesList;if(c.sortParticles){Ob.copy(mb);Ob.multiplySelf(c.matrixWorld);for(d=0;d<i;d++)f=h[d].position,Na.copy(f),Ob.multiplyVector3(Na),k[d]=[Na.z,d];k.sort(function(a,b){return b[0]-a[0]});for(d=0;d<i;d++)f=h[k[d][1]].position,g=3*d,m[g]=f.x,m[g+1]=f.y,m[g+2]=f.z;for(d=0;d<l;d++)g=3*d,f=j[k[d][1]],n[g]=f.r,n[g+1]=f.g,n[g+2]=f.b;if(u)for(j=0,l=u.length;j<l;j++)if(h=
  200. u[j],void 0===h.boundTo||"vertices"===h.boundTo)if(g=0,f=h.value.length,1===h.size)for(d=0;d<f;d++)i=k[d][1],h.array[d]=h.value[i];else if(2===h.size)for(d=0;d<f;d++)i=k[d][1],i=h.value[i],h.array[g]=i.x,h.array[g+1]=i.y,g+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<f;d++)i=k[d][1],i=h.value[i],h.array[g]=i.r,h.array[g+1]=i.g,h.array[g+2]=i.b,g+=3;else for(d=0;d<f;d++)i=k[d][1],i=h.value[i],h.array[g]=i.x,h.array[g+1]=i.y,h.array[g+2]=i.z,g+=3;else if(4===h.size)for(d=0;d<f;d++)i=k[d][1],i=h.value[i],
  201. h.array[g]=i.x,h.array[g+1]=i.y,h.array[g+2]=i.z,h.array[g+3]=i.w,g+=4}else{if(r)for(d=0;d<i;d++)f=h[d].position,g=3*d,m[g]=f.x,m[g+1]=f.y,m[g+2]=f.z;if(o)for(d=0;d<l;d++)f=j[d],g=3*d,n[g]=f.r,n[g+1]=f.g,n[g+2]=f.b;if(u)for(j=0,l=u.length;j<l;j++)if(h=u[j],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(f=h.value.length,g=0,1===h.size)for(d=0;d<f;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<f;d++)i=h.value[d],h.array[g]=i.x,h.array[g+1]=i.y,g+=2;else if(3===h.size)if("c"===
  202. h.type)for(d=0;d<f;d++)i=h.value[d],h.array[g]=i.r,h.array[g+1]=i.g,h.array[g+2]=i.b,g+=3;else for(d=0;d<f;d++)i=h.value[d],h.array[g]=i.x,h.array[g+1]=i.y,h.array[g+2]=i.z,g+=3;else if(4===h.size)for(d=0;d<f;d++)i=h.value[d],h.array[g]=i.x,h.array[g+1]=i.y,h.array[g+2]=i.z,h.array[g+3]=i.w,g+=4}if(r||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,m,b);if(o||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,
  203. n,b);if(u)for(j=0,l=u.length;j<l;j++)if(h=u[j],h.needsUpdate||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,h.buffer),e.bufferData(e.ARRAY_BUFFER,h.array,b)}function i(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var e=0,d=a.length;e<d;e++)aa=Ba=null,sa=J=Ca=Ka=Aa=-1,a[e].render(b,c,pc,qc),aa=Ba=null,sa=J=Ca=Ka=Aa=-1}function k(a,b,c,e,d,f,g,i){var h,j,l,m;b?(j=a.length-1,m=b=-1):(j=0,b=a.length,m=1);for(var k=j;k!==b;k+=m)if(h=a[k],h.render){j=h.object;l=h.buffer;if(i)h=i;else{h=h[c];if(!h)continue;
  204. g&&C.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);C.setDepthTest(h.depthTest);C.setDepthWrite(h.depthWrite);z(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}C.setObjectFaces(j);l instanceof THREE.BufferGeometry?C.renderBufferDirect(e,d,f,h,l,j):C.renderBuffer(e,d,f,h,l,j)}}function j(a,b,c,e,d,f,g){for(var i,h,j=0,l=a.length;j<l;j++)if(i=a[j],h=i.object,h.visible){if(g)i=g;else{i=i[b];if(!i)continue;f&&C.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);C.setDepthTest(i.depthTest);
  205. C.setDepthWrite(i.depthWrite);z(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}C.renderImmediateObject(c,e,d,i,h)}}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!0;return!1}function l(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function u(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function r(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,
  206. 1)}function o(a,b,c,d,f){if(!d.program||d.needsUpdate)C.initMaterial(d,b,c,f),d.needsUpdate=!1;if(d.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(C.maxMorphTargets);for(var g=0,i=C.maxMorphTargets;g<i;g++)f.__webglMorphTargetInfluences[g]=0}var h=!1,g=d.program,i=g.uniforms,j=d.uniforms;g!==Ba&&(e.useProgram(g),Ba=g,h=!0);if(d.id!==sa)sa=d.id,h=!0;if(h||a!==aa)e.uniformMatrix4fv(i.projectionMatrix,!1,a._projectionMatrixArray),a!==aa&&(aa=a);if(h){if(c&&
  207. d.fog)if(j.fogColor.value=c.color,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){var l,m=0,k=0,n=0,r,o,u,t=rc,q=t.directional.colors,z=t.directional.positions,w=t.point.colors,A=t.point.positions,J=t.point.distances,M=0,N=0,I=u=0;for(c=0,h=b.length;c<h;c++)if(l=b[c],!l.onlyShadow)if(r=l.color,o=l.intensity,u=l.distance,l instanceof
  208. THREE.AmbientLight)C.gammaInput?(m+=r.r*r.r,k+=r.g*r.g,n+=r.b*r.b):(m+=r.r,k+=r.g,n+=r.b);else if(l instanceof THREE.DirectionalLight)u=3*M,C.gammaInput?(q[u]=r.r*r.r*o*o,q[u+1]=r.g*r.g*o*o,q[u+2]=r.b*r.b*o*o):(q[u]=r.r*o,q[u+1]=r.g*o,q[u+2]=r.b*o),nb.copy(l.matrixWorld.getPosition()),nb.subSelf(l.target.matrixWorld.getPosition()),nb.normalize(),z[u]=nb.x,z[u+1]=nb.y,z[u+2]=nb.z,M+=1;else if(l instanceof THREE.PointLight||l instanceof THREE.SpotLight)I=3*N,C.gammaInput?(w[I]=r.r*r.r*o*o,w[I+1]=r.g*
  209. r.g*o*o,w[I+2]=r.b*r.b*o*o):(w[I]=r.r*o,w[I+1]=r.g*o,w[I+2]=r.b*o),l=l.matrixWorld.getPosition(),A[I]=l.x,A[I+1]=l.y,A[I+2]=l.z,J[N]=u,N+=1;for(c=3*M,h=q.length;c<h;c++)q[c]=0;for(c=3*N,h=w.length;c<h;c++)w[c]=0;t.point.length=N;t.directional.length=M;t.ambient[0]=m;t.ambient[1]=k;t.ambient[2]=n;c=rc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=
  210. c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,C.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?
  211. 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 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=H.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=
  212. d.shininess,C.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.emissive.value.copyGammaToLinear(d.emissive),j.specular.value.copyGammaToLinear(d.specular)):(j.ambient.value=d.ambient,j.emissive.value=d.emissive,j.specular.value=d.specular),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)C.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.emissive.value.copyGammaToLinear(d.emissive)):(j.ambient.value=d.ambient,j.emissive.value=d.emissive),
  213. 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=d.opacity;if(f.receiveShadow&&!d._shadowPass&&j.shadowMatrix){h=c=0;for(m=b.length;h<m;h++)if(k=b[h],k.castShadow&&(k instanceof THREE.SpotLight||k instanceof THREE.DirectionalLight&&!k.shadowCascade))j.shadowMap.texture[c]=k.shadowMap,j.shadowMapSize.value[c]=k.shadowMapSize,j.shadowMatrix.value[c]=
  214. k.shadowMatrix,j.shadowDarkness.value[c]=k.shadowDarkness,j.shadowBias.value[c]=k.shadowBias,c++}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(k=g.uniforms[b[j][1]])if(h=b[j][0],n=h.type,m=h.value,"i"===n)e.uniform1i(k,m);else if("f"===n)e.uniform1f(k,m);else if("v2"===n)e.uniform2f(k,m.x,m.y);else if("v3"===n)e.uniform3f(k,m.x,m.y,m.z);else if("v4"===n)e.uniform4f(k,m.x,m.y,m.z,m.w);else if("c"===n)e.uniform3f(k,m.r,m.g,m.b);else if("fv1"===n)e.uniform1fv(k,m);else if("fv"===n)e.uniform3fv(k,m);
  215. else if("v2v"===n){if(!h._array)h._array=new Float32Array(2*m.length);for(n=0,t=m.length;n<t;n++)q=2*n,h._array[q]=m[n].x,h._array[q+1]=m[n].y;e.uniform2fv(k,h._array)}else if("v3v"===n){if(!h._array)h._array=new Float32Array(3*m.length);for(n=0,t=m.length;n<t;n++)q=3*n,h._array[q]=m[n].x,h._array[q+1]=m[n].y,h._array[q+2]=m[n].z;e.uniform3fv(k,h._array)}else if("v4v"==n){if(!h._array)h._array=new Float32Array(4*m.length);for(n=0,t=m.length;n<t;n++)q=4*n,h._array[q]=m[n].x,h._array[q+1]=m[n].y,h._array[q+
  216. 2]=m[n].z,h._array[q+3]=m[n].w;e.uniform4fv(k,h._array)}else if("m4"===n){if(!h._array)h._array=new Float32Array(16);m.flattenToArray(h._array);e.uniformMatrix4fv(k,!1,h._array)}else if("m4v"===n){if(!h._array)h._array=new Float32Array(16*m.length);for(n=0,t=m.length;n<t;n++)m[n].flattenToArrayOffset(h._array,16*n);e.uniformMatrix4fv(k,!1,h._array)}else if("t"===n){if(e.uniform1i(k,m),k=h.texture)if(k.image instanceof Array&&6===k.image.length){if(h=k,6===h.image.length)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=
  217. e.createTexture();e.activeTexture(e.TEXTURE0+m);e.bindTexture(e.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);m=[];for(k=0;6>k;k++){n=m;t=k;if(C.autoScaleCubemaps){if(q=h.image[k],w=Ic,!(q.width<=w&&q.height<=w))A=Math.max(q.width,q.height),z=Math.floor(q.width*w/A),w=Math.floor(q.height*w/A),A=document.createElement("canvas"),A.width=z,A.height=w,A.getContext("2d").drawImage(q,0,0,q.width,q.height,0,0,z,w),q=A}else q=h.image[k];n[t]=q}k=m[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);t=
  218. G(h.format);q=G(h.type);P(e.TEXTURE_CUBE_MAP,h,n);for(k=0;6>k;k++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,t,t,q,m[k]);h.generateMipmaps&&n&&e.generateMipmap(e.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdate)h.onUpdate()}else e.activeTexture(e.TEXTURE0+m),e.bindTexture(e.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(h=k,e.activeTexture(e.TEXTURE0+m),e.bindTexture(e.TEXTURE_CUBE_MAP,h.__webglTexture)):C.setTexture(k,m)}else if("tv"===n){if(!h._array){h._array=
  219. [];for(n=0,t=h.texture.length;n<t;n++)h._array[n]=m+n}e.uniform1iv(k,h._array);for(n=0,t=h.texture.length;n<t;n++)(k=h.texture[n])&&C.setTexture(k,h._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==i.cameraPosition)b=a.matrixWorld.getPosition(),e.uniform3f(i.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==i.viewMatrix&&e.uniformMatrix4fv(i.viewMatrix,
  220. !1,a._viewMatrixArray);d.skinning&&e.uniformMatrix4fv(i.boneGlobalMatrices,!1,f.boneMatrices)}e.uniformMatrix4fv(i.modelViewMatrix,!1,f._modelViewMatrixArray);i.normalMatrix&&e.uniformMatrix3fv(i.normalMatrix,!1,f._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||f.receiveShadow)&&null!==i.objectMatrix&&e.uniformMatrix4fv(i.objectMatrix,!1,f._objectMatrixArray);return g}function t(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);
  221. var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function z(a,b,c){sc!==a&&(a?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),sc=a);if(a&&(Yb!==b||Zb!==c))e.polygonOffset(b,c),Yb=b,Zb=c}function w(a,b){var c;"fragment"===a?c=e.createShader(e.FRAGMENT_SHADER):"vertex"===a&&(c=e.createShader(e.VERTEX_SHADER));e.shaderSource(c,b);e.compileShader(c);return!e.getShaderParameter(c,e.COMPILE_STATUS)?(console.error(e.getShaderInfoLog(c)),
  222. console.error(b),null):c}function P(a,b,c){c?(e.texParameteri(a,e.TEXTURE_WRAP_S,G(b.wrapS)),e.texParameteri(a,e.TEXTURE_WRAP_T,G(b.wrapT)),e.texParameteri(a,e.TEXTURE_MAG_FILTER,G(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,G(b.minFilter))):(e.texParameteri(a,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_MAG_FILTER,q(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,q(b.minFilter)))}function A(a,b){e.bindRenderbuffer(e.RENDERBUFFER,
  223. a);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,a)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height)}function q(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;
  224. default:return e.LINEAR}}function G(a){switch(a){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
  225. case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedIntType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA;
  226. case THREE.AddEquation:return e.FUNC_ADD;case THREE.SubtractEquation:return e.FUNC_SUBTRACT;case THREE.ReverseSubtractEquation:return e.FUNC_REVERSE_SUBTRACT;case THREE.ZeroFactor:return e.ZERO;case THREE.OneFactor:return e.ONE;case THREE.SrcColorFactor:return e.SRC_COLOR;case THREE.OneMinusSrcColorFactor:return e.ONE_MINUS_SRC_COLOR;case THREE.SrcAlphaFactor:return e.SRC_ALPHA;case THREE.OneMinusSrcAlphaFactor:return e.ONE_MINUS_SRC_ALPHA;case THREE.DstAlphaFactor:return e.DST_ALPHA;case THREE.OneMinusDstAlphaFactor:return e.ONE_MINUS_DST_ALPHA;
  227. case THREE.DstColorFactor:return e.DST_COLOR;case THREE.OneMinusDstColorFactor:return e.ONE_MINUS_DST_COLOR;case THREE.SrcAlphaSaturateFactor:return e.SRC_ALPHA_SATURATE}return 0}var a=a||{},H=void 0!==a.canvas?a.canvas:document.createElement("canvas"),M=void 0!==a.precision?a.precision:"highp",I=void 0!==a.alpha?a.alpha:!0,K=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,N=void 0!==a.antialias?a.antialias:!1,ja=void 0!==a.stencil?a.stencil:!0,oa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:
  228. !1,ka=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),Y=void 0!==a.clearAlpha?a.clearAlpha:0,S=void 0!==a.maxLights?a.maxLights:4;this.domElement=H;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=
  229. this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var C=this,e,Sa=[],Ba=null,T=null,sa=-1,J=null,aa=null,ta=0,xa=null,X=null,Aa=null,Ma=null,Wa=null,Ta=null,Ka=null,Ca=null,sc=null,Yb=null,Zb=null,tb=null,$b=0,Hb=0,Pb=0,ac=0,pc=0,qc=0,Ib=new THREE.Frustum,mb=new THREE.Matrix4,Ob=new THREE.Matrix4,Na=new THREE.Vector4,
  230. nb=new THREE.Vector3,rc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};e=function(){var a;try{if(!(a=H.getContext("experimental-webgl",{alpha:I,premultipliedAlpha:K,antialias:N,stencil:ja,preserveDrawingBuffer:oa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();
  231. e.clearColor(0,0,0,1);e.clearDepth(1);e.clearStencil(0);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(ka.r,ka.g,ka.b,Y);this.context=e;var bc=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);e.getParameter(e.MAX_TEXTURE_SIZE);var Ic=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return e};this.supportsVertexTextures=
  232. function(){return 0<bc};this.setSize=function(a,b){H.width=a;H.height=b;this.setViewport(0,0,H.width,H.height)};this.setViewport=function(a,b,c,d){$b=a;Hb=b;Pb=c;ac=d;e.viewport($b,Hb,Pb,ac)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){ka.setHex(a);Y=b;e.clearColor(ka.r,ka.g,ka.b,Y)};this.setClearColor=function(a,b){ka.copy(a);Y=b;e.clearColor(ka.r,ka.g,ka.b,Y)};this.getClearColor=
  233. function(){return ka};this.getClearAlpha=function(){return Y};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=e.COLOR_BUFFER_BIT;if(void 0===b||b)d|=e.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=e.STENCIL_BUFFER_BIT;e.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=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=
  234. !1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);
  235. e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);var d=void 0,f=void 0;if(c.numMorphTargets)for(d=0,f=c.numMorphTargets;d<f;d++)e.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.numMorphNormals)for(d=0,f=c.numMorphNormals;d<f;d++)e.deleteBuffer(c.__webglMorphNormalsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)e.deleteBuffer(c.__webglCustomAttributesList[d].buffer);
  236. C.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),C.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),C.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),C.info.memory.geometries--};this.deallocateTexture=
  237. function(a){if(a.__webglInit)a.__webglInit=!1,e.deleteTexture(a.__webglTexture),C.info.memory.textures--};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture)if(e.deleteTexture(a.__webglTexture),a instanceof THREE.WebGLRenderTargetCube)for(var b=0;6>b;b++)e.deleteFramebuffer(a.__webglFramebuffer[b]),e.deleteRenderbuffer(a.__webglRenderbuffer[b]);else e.deleteFramebuffer(a.__webglFramebuffer),e.deleteRenderbuffer(a.__webglRenderbuffer)};this.updateShadowMap=function(a,b){Ba=null;sa=J=Ca=
  238. Ka=Aa=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=e.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=e.createBuffer();a.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,a.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(b.attributes.position),e.vertexAttribPointer(b.attributes.position,3,e.FLOAT,!1,0,0));if(a.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,a.__webglNormalBuffer);
  239. if(c===THREE.FlatShading){var d,f,g,h,i,j,m,n,k,l,r=3*a.count;for(l=0;l<r;l+=9)c=a.normalArray,d=c[l],f=c[l+1],g=c[l+2],h=c[l+3],j=c[l+4],n=c[l+5],i=c[l+6],m=c[l+7],k=c[l+8],d=(d+h+i)/3,f=(f+j+m)/3,g=(g+n+k)/3,c[l]=d,c[l+1]=f,c[l+2]=g,c[l+3]=d,c[l+4]=f,c[l+5]=g,c[l+6]=d,c[l+7]=f,c[l+8]=g}e.bufferData(e.ARRAY_BUFFER,a.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(b.attributes.normal);e.vertexAttribPointer(b.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,a.count);a.count=0};
  240. this.renderBufferDirect=function(a,b,c,d,f,g){if(0!==d.opacity&&(c=o(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*f.id+2*c.id+(d.wireframe?1:0),d!==J&&(J=d,b=!0),g instanceof THREE.Mesh)){g=f.offsets;d=0;for(c=g.length;d<c;++d)b&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexPositionBuffer),e.vertexAttribPointer(a.position,f.vertexPositionBuffer.itemSize,e.FLOAT,!1,0,12*g[d].index),0<=a.normal&&f.vertexNormalBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexNormalBuffer),e.vertexAttribPointer(a.normal,f.vertexNormalBuffer.itemSize,
  241. e.FLOAT,!1,0,12*g[d].index)),0<=a.uv&&f.vertexUvBuffer&&(f.vertexUvBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.vertexUvBuffer),e.vertexAttribPointer(a.uv,f.vertexUvBuffer.itemSize,e.FLOAT,!1,0,8*g[d].index),e.enableVertexAttribArray(a.uv)):e.disableVertexAttribArray(a.uv)),0<=a.color&&f.vertexColorBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexColorBuffer),e.vertexAttribPointer(a.color,f.vertexColorBuffer.itemSize,e.FLOAT,!1,0,16*g[d].index)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.vertexIndexBuffer)),e.drawElements(e.TRIANGLES,
  242. g[d].count,e.UNSIGNED_SHORT,2*g[d].start),C.info.render.calls++,C.info.render.vertices+=g[d].count,C.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,f,g){if(0!==d.opacity){var h,i,c=o(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*f.id+2*c.id+(d.wireframe?1:0);c!==J&&(J=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?
  243. (e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):0<=c.position&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j[h]]),e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,
  244. !1,0,0),d.morphNormals&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphNormalsBuffers[j[h]]),e.vertexAttribPointer(c["morphNormal"+h],3,e.FLOAT,!1,0,0)),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],l=-1,m=0;i=g.morphTargetInfluences;var n,k=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(n=0;n<k;n++)!j[n]&&i[n]>l&&(m=n,l=i[m]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[m]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,
  245. !1,0,0);d.morphNormals&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphNormalsBuffers[m]),e.vertexAttribPointer(c["morphNormal"+h],3,e.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[h]=l;j[m]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList)for(h=0,i=f.__webglCustomAttributesList.length;h<i;h++)c=f.__webglCustomAttributesList[h],0<=b[c.buffer.belongsToAttribute]&&(e.bindBuffer(e.ARRAY_BUFFER,
  246. c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0));0<=b.color&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));0<=b.normal&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));0<=b.tangent&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));0<=b.uv&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),
  247. e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));0<=b.uv2&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&0<=b.skinIndex&&0<=b.skinWeight&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,
  248. f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==tb&&(e.lineWidth(d),tb=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,
  249. 0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),C.info.render.calls++,C.info.render.vertices+=f.__webglFaceCount,C.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==tb&&(e.lineWidth(d),tb=d),e.drawArrays(g,0,f.__webglLineCount),C.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),C.info.render.calls++,
  250. C.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),C.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,l,n,m=a.__lights,r=a.fog;sa=-1;void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);
  251. b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);mb.multiply(b.projectionMatrix,b.matrixWorldInverse);Ib.setFromMatrix(mb);this.autoUpdateObjects&&this.initWebGLObjects(a);h(this.renderPluginsPre,a,b);C.info.render.calls=0;C.info.render.vertices=0;C.info.render.faces=0;C.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,
  252. this.autoClearStencil);n=a.__webglObjects;for(d=0,f=n.length;d<f;d++)if(g=n[d],l=g.object,g.render=!1,l.visible&&(!(l instanceof THREE.Mesh||l instanceof THREE.ParticleSystem)||!l.frustumCulled||Ib.contains(l))){l.matrixWorld.flattenToArray(l._objectMatrixArray);t(l,b);var o=g,u=o.object,q=o.buffer,w=void 0,w=w=void 0,w=u.material;if(w instanceof THREE.MeshFaceMaterial){if(w=q.materialIndex,0<=w)w=u.geometry.materials[w],w.transparent?(o.transparent=w,o.opaque=null):(o.opaque=w,o.transparent=null)}else if(w)w.transparent?
  253. (o.transparent=w,o.opaque=null):(o.opaque=w,o.transparent=null);g.render=!0;if(this.sortObjects)l.renderDepth?g.z=l.renderDepth:(Na.copy(l.matrixWorld.getPosition()),mb.multiplyVector3(Na),g.z=Na.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;for(d=0,f=n.length;d<f;d++)if(g=n[d],l=g.object,l.visible)l.matrixAutoUpdate&&l.matrixWorld.flattenToArray(l._objectMatrixArray),t(l,b),l=g.object.material,l.transparent?(g.transparent=l,g.opaque=null):(g.opaque=l,g.transparent=null);a.overrideMaterial?
  254. (d=a.overrideMaterial,this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst),this.setDepthTest(d.depthTest),this.setDepthWrite(d.depthWrite),z(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,m,r,!0,d),j(a.__webglObjectsImmediate,"",b,m,r,!1,d)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,m,r,!1),j(a.__webglObjectsImmediate,"opaque",b,m,r,!1),k(a.__webglObjects,!1,"transparent",b,m,r,!0),j(a.__webglObjectsImmediate,"transparent",
  255. b,m,r,!0));h(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,c.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,
  256. c,d,f){var g=o(a,b,c,d,f);J=-1;C.setObjectFaces(f);f.immediateRenderCallback?f.immediateRenderCallback(g,e,Ib):f.render(function(a){C.renderBufferImmediate(a,g,d.shading)})};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,k=void 0,o=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=
  257. new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var q=k,t=void 0,w=void 0,z=void 0,A=void 0,H=void 0,G=void 0,I=void 0,J={},M=q.morphTargets.length,N=q.morphNormals.length;q.geometryGroups={};for(t=0,w=q.faces.length;t<w;t++)z=q.faces[t],A=z.materialIndex,G=void 0!==A?A:-1,void 0===J[G]&&(J[G]=
  258. {hash:G,counter:0}),I=J[G].hash+"_"+J[G].counter,void 0===q.geometryGroups[I]&&(q.geometryGroups[I]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:M,numMorphNormals:N}),H=z instanceof THREE.Face3?3:4,65535<q.geometryGroups[I].vertices+H&&(J[G].counter+=1,I=J[G].hash+"_"+J[G].counter,void 0===q.geometryGroups[I]&&(q.geometryGroups[I]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:M,numMorphNormals:N})),z instanceof THREE.Face3?q.geometryGroups[I].faces3.push(t):q.geometryGroups[I].faces4.push(t),
  259. q.geometryGroups[I].vertices+=H;q.geometryGroupsList=[];var P=void 0;for(P in q.geometryGroups)q.geometryGroups[P].id=ta++,q.geometryGroupsList.push(q.geometryGroups[P])}for(j in k.geometryGroups)if(o=k.geometryGroups[j],!o.__webglVertexBuffer){var K=o;K.__webglVertexBuffer=e.createBuffer();K.__webglNormalBuffer=e.createBuffer();K.__webglTangentBuffer=e.createBuffer();K.__webglColorBuffer=e.createBuffer();K.__webglUVBuffer=e.createBuffer();K.__webglUV2Buffer=e.createBuffer();K.__webglSkinVertexABuffer=
  260. e.createBuffer();K.__webglSkinVertexBBuffer=e.createBuffer();K.__webglSkinIndicesBuffer=e.createBuffer();K.__webglSkinWeightsBuffer=e.createBuffer();K.__webglFaceBuffer=e.createBuffer();K.__webglLineBuffer=e.createBuffer();var S=void 0,X=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];for(S=0,X=K.numMorphTargets;S<X;S++)K.__webglMorphTargetsBuffers.push(e.createBuffer())}if(K.numMorphNormals){K.__webglMorphNormalsBuffers=[];for(S=0,X=K.numMorphNormals;S<X;S++)K.__webglMorphNormalsBuffers.push(e.createBuffer())}C.info.memory.geometries++;
  261. var ca=o,Y=h,aa=Y.geometry,ja=ca.faces3,ka=ca.faces4,T=3*ja.length+4*ka.length,sa=1*ja.length+2*ka.length,xa=3*ja.length+4*ka.length,oa=c(Y,ca),Aa=f(oa),Ba=d(oa),Ma=oa.vertexColors?oa.vertexColors:!1;ca.__vertexArray=new Float32Array(3*T);if(Ba)ca.__normalArray=new Float32Array(3*T);if(aa.hasTangents)ca.__tangentArray=new Float32Array(4*T);if(Ma)ca.__colorArray=new Float32Array(3*T);if(Aa){if(0<aa.faceUvs.length||0<aa.faceVertexUvs.length)ca.__uvArray=new Float32Array(2*T);if(1<aa.faceUvs.length||
  262. 1<aa.faceVertexUvs.length)ca.__uv2Array=new Float32Array(2*T)}if(Y.geometry.skinWeights.length&&Y.geometry.skinIndices.length)ca.__skinVertexAArray=new Float32Array(4*T),ca.__skinVertexBArray=new Float32Array(4*T),ca.__skinIndexArray=new Float32Array(4*T),ca.__skinWeightArray=new Float32Array(4*T);ca.__faceArray=new Uint16Array(3*sa);ca.__lineArray=new Uint16Array(2*xa);var Ca=void 0,Ka=void 0;if(ca.numMorphTargets){ca.__morphTargetsArrays=[];for(Ca=0,Ka=ca.numMorphTargets;Ca<Ka;Ca++)ca.__morphTargetsArrays.push(new Float32Array(3*
  263. T))}if(ca.numMorphNormals){ca.__morphNormalsArrays=[];for(Ca=0,Ka=ca.numMorphNormals;Ca<Ka;Ca++)ca.__morphNormalsArrays.push(new Float32Array(3*T))}ca.__webglFaceCount=3*sa;ca.__webglLineCount=2*xa;if(oa.attributes){if(void 0===ca.__webglCustomAttributesList)ca.__webglCustomAttributesList=[];var Ta=void 0;for(Ta in oa.attributes){var Sa=oa.attributes[Ta],La={},Wa;for(Wa in Sa)La[Wa]=Sa[Wa];if(!La.__webglInitialized||La.createUniqueBuffers){La.__webglInitialized=!0;var Na=1;"v2"===La.type?Na=2:"v3"===
  264. La.type?Na=3:"v4"===La.type?Na=4:"c"===La.type&&(Na=3);La.size=Na;La.array=new Float32Array(T*Na);La.buffer=e.createBuffer();La.buffer.belongsToAttribute=Ta;Sa.needsUpdate=!0;La.__original=Sa}ca.__webglCustomAttributesList.push(La)}}ca.__inittedArrays=!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}}else if(h instanceof THREE.Ribbon){if(k=h.geometry,!k.__webglVertexBuffer){var nb=k;nb.__webglVertexBuffer=
  265. e.createBuffer();nb.__webglColorBuffer=e.createBuffer();C.info.memory.geometries++;var mb=k,tb=mb.vertices.length;mb.__vertexArray=new Float32Array(3*tb);mb.__colorArray=new Float32Array(3*tb);mb.__webglVertexCount=tb;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Ob=k;Ob.__webglVertexBuffer=e.createBuffer();Ob.__webglColorBuffer=e.createBuffer();C.info.memory.geometries++;var cc=k,$b=h,Hb=cc.vertices.length;cc.__vertexArray=new Float32Array(3*
  266. Hb);cc.__colorArray=new Float32Array(3*Hb);cc.__webglLineCount=Hb;b(cc,$b);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Pb=k;Pb.__webglVertexBuffer=e.createBuffer();Pb.__webglColorBuffer=e.createBuffer();C.info.geometries++;var Qb=k,ac=h,Ib=Qb.vertices.length;Qb.__vertexArray=new Float32Array(3*Ib);Qb.__colorArray=new Float32Array(3*Ib);Qb.__sortArray=[];Qb.__webglParticleCount=Ib;b(Qb,ac);k.__dirtyVertices=!0;k.__dirtyColors=
  267. !0}if(!h.__webglActive){if(h instanceof THREE.Mesh)if(k=h.geometry,k instanceof THREE.BufferGeometry)m(i.__webglObjects,k,h);else for(j in k.geometryGroups)o=k.geometryGroups[j],m(i.__webglObjects,o,h);else h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem?(k=h.geometry,m(i.__webglObjects,k,h)):h instanceof THREE.ImmediateRenderObject||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):
  268. h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Oa=a.__objectsRemoved[0],tc=a;Oa instanceof THREE.Mesh||Oa instanceof THREE.ParticleSystem||Oa instanceof THREE.Ribbon||Oa instanceof THREE.Line?u(tc.__webglObjects,Oa):Oa instanceof THREE.Sprite?r(tc.__webglSprites,Oa):Oa instanceof THREE.LensFlare?r(tc.__webglFlares,Oa):(Oa instanceof THREE.ImmediateRenderObject||Oa.immediateRenderCallback)&&u(tc.__webglObjectsImmediate,
  269. Oa);Oa.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Jc=0,pc=a.__webglObjects.length;Jc<pc;Jc++){var Ua=a.__webglObjects[Jc].object,R=Ua.geometry,dc=void 0,Rb=void 0,Fa=void 0;if(Ua instanceof THREE.Mesh)if(R instanceof THREE.BufferGeometry)R.__dirtyVertices=!1,R.__dirtyElements=!1,R.__dirtyUvs=!1,R.__dirtyNormals=!1,R.__dirtyColors=!1;else{for(var Kc=0,qc=R.geometryGroupsList.length;Kc<qc;Kc++)if(dc=R.geometryGroupsList[Kc],Fa=c(Ua,dc),Rb=Fa.attributes&&n(Fa),R.__dirtyVertices||R.__dirtyMorphTargets||
  270. R.__dirtyElements||R.__dirtyUvs||R.__dirtyNormals||R.__dirtyColors||R.__dirtyTangents||Rb){var O=dc,rc=Ua,Ha=e.DYNAMIC_DRAW,sc=!R.dynamic,Jb=Fa;if(O.__inittedArrays){var Yb=d(Jb),Lc=Jb.vertexColors?Jb.vertexColors:!1,Zb=f(Jb),uc=Yb===THREE.SmoothShading,v=void 0,B=void 0,Ra=void 0,y=void 0,Sb=void 0,ub=void 0,Va=void 0,vc=void 0,ob=void 0,Tb=void 0,Ub=void 0,D=void 0,E=void 0,F=void 0,Z=void 0,Xa=void 0,Ya=void 0,Za=void 0,ec=void 0,$a=void 0,ab=void 0,bb=void 0,fc=void 0,cb=void 0,db=void 0,eb=void 0,
  271. gc=void 0,fb=void 0,gb=void 0,hb=void 0,hc=void 0,ib=void 0,jb=void 0,kb=void 0,ic=void 0,vb=void 0,wb=void 0,xb=void 0,wc=void 0,yb=void 0,zb=void 0,Ab=void 0,xc=void 0,U=void 0,bc=void 0,Bb=void 0,Vb=void 0,Wb=void 0,ua=void 0,Tc=void 0,qa=void 0,ra=void 0,Cb=void 0,pb=void 0,la=0,pa=0,qb=0,rb=0,Pa=0,za=0,$=0,Da=0,ma=0,x=0,L=0,s=0,Ia=void 0,va=O.__vertexArray,jc=O.__uvArray,kc=O.__uv2Array,Qa=O.__normalArray,da=O.__tangentArray,wa=O.__colorArray,ea=O.__skinVertexAArray,fa=O.__skinVertexBArray,ga=
  272. O.__skinIndexArray,ha=O.__skinWeightArray,Mc=O.__morphTargetsArrays,Nc=O.__morphNormalsArrays,Oc=O.__webglCustomAttributesList,p=void 0,lb=O.__faceArray,Ja=O.__lineArray,Ea=rc.geometry,Ic=Ea.__dirtyElements,Uc=Ea.__dirtyUvs,ad=Ea.__dirtyNormals,bd=Ea.__dirtyTangents,cd=Ea.__dirtyColors,dd=Ea.__dirtyMorphTargets,Kb=Ea.vertices,V=O.faces3,W=O.faces4,na=Ea.faces,Pc=Ea.faceVertexUvs[0],Qc=Ea.faceVertexUvs[1],Lb=Ea.skinVerticesA,Mb=Ea.skinVerticesB,Nb=Ea.skinIndices,Db=Ea.skinWeights,Eb=Ea.morphTargets,
  273. yc=Ea.morphNormals;if(Ea.__dirtyVertices){for(v=0,B=V.length;v<B;v++)y=na[V[v]],D=Kb[y.a].position,E=Kb[y.b].position,F=Kb[y.c].position,va[pa]=D.x,va[pa+1]=D.y,va[pa+2]=D.z,va[pa+3]=E.x,va[pa+4]=E.y,va[pa+5]=E.z,va[pa+6]=F.x,va[pa+7]=F.y,va[pa+8]=F.z,pa+=9;for(v=0,B=W.length;v<B;v++)y=na[W[v]],D=Kb[y.a].position,E=Kb[y.b].position,F=Kb[y.c].position,Z=Kb[y.d].position,va[pa]=D.x,va[pa+1]=D.y,va[pa+2]=D.z,va[pa+3]=E.x,va[pa+4]=E.y,va[pa+5]=E.z,va[pa+6]=F.x,va[pa+7]=F.y,va[pa+8]=F.z,va[pa+9]=Z.x,va[pa+
  274. 10]=Z.y,va[pa+11]=Z.z,pa+=12;e.bindBuffer(e.ARRAY_BUFFER,O.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,va,Ha)}if(dd)for(ua=0,Tc=Eb.length;ua<Tc;ua++){L=0;for(v=0,B=V.length;v<B;v++){Cb=V[v];y=na[Cb];D=Eb[ua].vertices[y.a].position;E=Eb[ua].vertices[y.b].position;F=Eb[ua].vertices[y.c].position;qa=Mc[ua];qa[L]=D.x;qa[L+1]=D.y;qa[L+2]=D.z;qa[L+3]=E.x;qa[L+4]=E.y;qa[L+5]=E.z;qa[L+6]=F.x;qa[L+7]=F.y;qa[L+8]=F.z;if(Jb.morphNormals)uc?(pb=yc[ua].vertexNormals[Cb],$a=pb.a,ab=pb.b,bb=pb.c):bb=ab=$a=
  275. yc[ua].faceNormals[Cb],ra=Nc[ua],ra[L]=$a.x,ra[L+1]=$a.y,ra[L+2]=$a.z,ra[L+3]=ab.x,ra[L+4]=ab.y,ra[L+5]=ab.z,ra[L+6]=bb.x,ra[L+7]=bb.y,ra[L+8]=bb.z;L+=9}for(v=0,B=W.length;v<B;v++){Cb=W[v];y=na[Cb];D=Eb[ua].vertices[y.a].position;E=Eb[ua].vertices[y.b].position;F=Eb[ua].vertices[y.c].position;Z=Eb[ua].vertices[y.d].position;qa=Mc[ua];qa[L]=D.x;qa[L+1]=D.y;qa[L+2]=D.z;qa[L+3]=E.x;qa[L+4]=E.y;qa[L+5]=E.z;qa[L+6]=F.x;qa[L+7]=F.y;qa[L+8]=F.z;qa[L+9]=Z.x;qa[L+10]=Z.y;qa[L+11]=Z.z;if(Jb.morphNormals)uc?
  276. (pb=yc[ua].vertexNormals[Cb],$a=pb.a,ab=pb.b,bb=pb.c,fc=pb.d):fc=bb=ab=$a=yc[ua].faceNormals[Cb],ra=Nc[ua],ra[L]=$a.x,ra[L+1]=$a.y,ra[L+2]=$a.z,ra[L+3]=ab.x,ra[L+4]=ab.y,ra[L+5]=ab.z,ra[L+6]=bb.x,ra[L+7]=bb.y,ra[L+8]=bb.z,ra[L+9]=fc.x,ra[L+10]=fc.y,ra[L+11]=fc.z;L+=12}e.bindBuffer(e.ARRAY_BUFFER,O.__webglMorphTargetsBuffers[ua]);e.bufferData(e.ARRAY_BUFFER,Mc[ua],Ha);Jb.morphNormals&&(e.bindBuffer(e.ARRAY_BUFFER,O.__webglMorphNormalsBuffers[ua]),e.bufferData(e.ARRAY_BUFFER,Nc[ua],Ha))}if(Db.length){for(v=
  277. 0,B=V.length;v<B;v++)y=na[V[v]],fb=Db[y.a],gb=Db[y.b],hb=Db[y.c],ha[x]=fb.x,ha[x+1]=fb.y,ha[x+2]=fb.z,ha[x+3]=fb.w,ha[x+4]=gb.x,ha[x+5]=gb.y,ha[x+6]=gb.z,ha[x+7]=gb.w,ha[x+8]=hb.x,ha[x+9]=hb.y,ha[x+10]=hb.z,ha[x+11]=hb.w,ib=Nb[y.a],jb=Nb[y.b],kb=Nb[y.c],ga[x]=ib.x,ga[x+1]=ib.y,ga[x+2]=ib.z,ga[x+3]=ib.w,ga[x+4]=jb.x,ga[x+5]=jb.y,ga[x+6]=jb.z,ga[x+7]=jb.w,ga[x+8]=kb.x,ga[x+9]=kb.y,ga[x+10]=kb.z,ga[x+11]=kb.w,vb=Lb[y.a],wb=Lb[y.b],xb=Lb[y.c],ea[x]=vb.x,ea[x+1]=vb.y,ea[x+2]=vb.z,ea[x+3]=1,ea[x+4]=wb.x,
  278. ea[x+5]=wb.y,ea[x+6]=wb.z,ea[x+7]=1,ea[x+8]=xb.x,ea[x+9]=xb.y,ea[x+10]=xb.z,ea[x+11]=1,yb=Mb[y.a],zb=Mb[y.b],Ab=Mb[y.c],fa[x]=yb.x,fa[x+1]=yb.y,fa[x+2]=yb.z,fa[x+3]=1,fa[x+4]=zb.x,fa[x+5]=zb.y,fa[x+6]=zb.z,fa[x+7]=1,fa[x+8]=Ab.x,fa[x+9]=Ab.y,fa[x+10]=Ab.z,fa[x+11]=1,x+=12;for(v=0,B=W.length;v<B;v++)y=na[W[v]],fb=Db[y.a],gb=Db[y.b],hb=Db[y.c],hc=Db[y.d],ha[x]=fb.x,ha[x+1]=fb.y,ha[x+2]=fb.z,ha[x+3]=fb.w,ha[x+4]=gb.x,ha[x+5]=gb.y,ha[x+6]=gb.z,ha[x+7]=gb.w,ha[x+8]=hb.x,ha[x+9]=hb.y,ha[x+10]=hb.z,ha[x+
  279. 11]=hb.w,ha[x+12]=hc.x,ha[x+13]=hc.y,ha[x+14]=hc.z,ha[x+15]=hc.w,ib=Nb[y.a],jb=Nb[y.b],kb=Nb[y.c],ic=Nb[y.d],ga[x]=ib.x,ga[x+1]=ib.y,ga[x+2]=ib.z,ga[x+3]=ib.w,ga[x+4]=jb.x,ga[x+5]=jb.y,ga[x+6]=jb.z,ga[x+7]=jb.w,ga[x+8]=kb.x,ga[x+9]=kb.y,ga[x+10]=kb.z,ga[x+11]=kb.w,ga[x+12]=ic.x,ga[x+13]=ic.y,ga[x+14]=ic.z,ga[x+15]=ic.w,vb=Lb[y.a],wb=Lb[y.b],xb=Lb[y.c],wc=Lb[y.d],ea[x]=vb.x,ea[x+1]=vb.y,ea[x+2]=vb.z,ea[x+3]=1,ea[x+4]=wb.x,ea[x+5]=wb.y,ea[x+6]=wb.z,ea[x+7]=1,ea[x+8]=xb.x,ea[x+9]=xb.y,ea[x+10]=xb.z,
  280. ea[x+11]=1,ea[x+12]=wc.x,ea[x+13]=wc.y,ea[x+14]=wc.z,ea[x+15]=1,yb=Mb[y.a],zb=Mb[y.b],Ab=Mb[y.c],xc=Mb[y.d],fa[x]=yb.x,fa[x+1]=yb.y,fa[x+2]=yb.z,fa[x+3]=1,fa[x+4]=zb.x,fa[x+5]=zb.y,fa[x+6]=zb.z,fa[x+7]=1,fa[x+8]=Ab.x,fa[x+9]=Ab.y,fa[x+10]=Ab.z,fa[x+11]=1,fa[x+12]=xc.x,fa[x+13]=xc.y,fa[x+14]=xc.z,fa[x+15]=1,x+=16;0<x&&(e.bindBuffer(e.ARRAY_BUFFER,O.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,ea,Ha),e.bindBuffer(e.ARRAY_BUFFER,O.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,fa,Ha),
  281. e.bindBuffer(e.ARRAY_BUFFER,O.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,ga,Ha),e.bindBuffer(e.ARRAY_BUFFER,O.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ha,Ha))}if(cd&&Lc){for(v=0,B=V.length;v<B;v++)y=na[V[v]],Va=y.vertexColors,vc=y.color,3===Va.length&&Lc===THREE.VertexColors?(cb=Va[0],db=Va[1],eb=Va[2]):eb=db=cb=vc,wa[ma]=cb.r,wa[ma+1]=cb.g,wa[ma+2]=cb.b,wa[ma+3]=db.r,wa[ma+4]=db.g,wa[ma+5]=db.b,wa[ma+6]=eb.r,wa[ma+7]=eb.g,wa[ma+8]=eb.b,ma+=9;for(v=0,B=W.length;v<B;v++)y=na[W[v]],
  282. Va=y.vertexColors,vc=y.color,4===Va.length&&Lc===THREE.VertexColors?(cb=Va[0],db=Va[1],eb=Va[2],gc=Va[3]):gc=eb=db=cb=vc,wa[ma]=cb.r,wa[ma+1]=cb.g,wa[ma+2]=cb.b,wa[ma+3]=db.r,wa[ma+4]=db.g,wa[ma+5]=db.b,wa[ma+6]=eb.r,wa[ma+7]=eb.g,wa[ma+8]=eb.b,wa[ma+9]=gc.r,wa[ma+10]=gc.g,wa[ma+11]=gc.b,ma+=12;0<ma&&(e.bindBuffer(e.ARRAY_BUFFER,O.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,wa,Ha))}if(bd&&Ea.hasTangents){for(v=0,B=V.length;v<B;v++)y=na[V[v]],ob=y.vertexTangents,Xa=ob[0],Ya=ob[1],Za=ob[2],da[$]=
  283. Xa.x,da[$+1]=Xa.y,da[$+2]=Xa.z,da[$+3]=Xa.w,da[$+4]=Ya.x,da[$+5]=Ya.y,da[$+6]=Ya.z,da[$+7]=Ya.w,da[$+8]=Za.x,da[$+9]=Za.y,da[$+10]=Za.z,da[$+11]=Za.w,$+=12;for(v=0,B=W.length;v<B;v++)y=na[W[v]],ob=y.vertexTangents,Xa=ob[0],Ya=ob[1],Za=ob[2],ec=ob[3],da[$]=Xa.x,da[$+1]=Xa.y,da[$+2]=Xa.z,da[$+3]=Xa.w,da[$+4]=Ya.x,da[$+5]=Ya.y,da[$+6]=Ya.z,da[$+7]=Ya.w,da[$+8]=Za.x,da[$+9]=Za.y,da[$+10]=Za.z,da[$+11]=Za.w,da[$+12]=ec.x,da[$+13]=ec.y,da[$+14]=ec.z,da[$+15]=ec.w,$+=16;e.bindBuffer(e.ARRAY_BUFFER,O.__webglTangentBuffer);
  284. e.bufferData(e.ARRAY_BUFFER,da,Ha)}if(ad&&Yb){for(v=0,B=V.length;v<B;v++)if(y=na[V[v]],Sb=y.vertexNormals,ub=y.normal,3===Sb.length&&uc)for(U=0;3>U;U++)Bb=Sb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;3>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;for(v=0,B=W.length;v<B;v++)if(y=na[W[v]],Sb=y.vertexNormals,ub=y.normal,4===Sb.length&&uc)for(U=0;4>U;U++)Bb=Sb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;4>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;
  285. e.bindBuffer(e.ARRAY_BUFFER,O.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Qa,Ha)}if(Uc&&Pc&&Zb){for(v=0,B=V.length;v<B;v++)if(Ra=V[v],y=na[Ra],Tb=Pc[Ra],void 0!==Tb)for(U=0;3>U;U++)Vb=Tb[U],jc[qb]=Vb.u,jc[qb+1]=Vb.v,qb+=2;for(v=0,B=W.length;v<B;v++)if(Ra=W[v],y=na[Ra],Tb=Pc[Ra],void 0!==Tb)for(U=0;4>U;U++)Vb=Tb[U],jc[qb]=Vb.u,jc[qb+1]=Vb.v,qb+=2;0<qb&&(e.bindBuffer(e.ARRAY_BUFFER,O.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,jc,Ha))}if(Uc&&Qc&&Zb){for(v=0,B=V.length;v<B;v++)if(Ra=V[v],y=na[Ra],
  286. Ub=Qc[Ra],void 0!==Ub)for(U=0;3>U;U++)Wb=Ub[U],kc[rb]=Wb.u,kc[rb+1]=Wb.v,rb+=2;for(v=0,B=W.length;v<B;v++)if(Ra=W[v],y=na[Ra],Ub=Qc[Ra],void 0!==Ub)for(U=0;4>U;U++)Wb=Ub[U],kc[rb]=Wb.u,kc[rb+1]=Wb.v,rb+=2;0<rb&&(e.bindBuffer(e.ARRAY_BUFFER,O.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,kc,Ha))}if(Ic){for(v=0,B=V.length;v<B;v++)y=na[V[v]],lb[Pa]=la,lb[Pa+1]=la+1,lb[Pa+2]=la+2,Pa+=3,Ja[Da]=la,Ja[Da+1]=la+1,Ja[Da+2]=la,Ja[Da+3]=la+2,Ja[Da+4]=la+1,Ja[Da+5]=la+2,Da+=6,la+=3;for(v=0,B=W.length;v<B;v++)y=
  287. na[W[v]],lb[Pa]=la,lb[Pa+1]=la+1,lb[Pa+2]=la+3,lb[Pa+3]=la+1,lb[Pa+4]=la+2,lb[Pa+5]=la+3,Pa+=6,Ja[Da]=la,Ja[Da+1]=la+1,Ja[Da+2]=la,Ja[Da+3]=la+3,Ja[Da+4]=la+1,Ja[Da+5]=la+2,Ja[Da+6]=la+2,Ja[Da+7]=la+3,Da+=8,la+=4;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,O.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,lb,Ha);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,O.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ja,Ha)}if(Oc)for(U=0,bc=Oc.length;U<bc;U++)if(p=Oc[U],p.__original.needsUpdate){s=0;if(1===p.size)if(void 0===
  288. p.boundTo||"vertices"===p.boundTo){for(v=0,B=V.length;v<B;v++)y=na[V[v]],p.array[s]=p.value[y.a],p.array[s+1]=p.value[y.b],p.array[s+2]=p.value[y.c],s+=3;for(v=0,B=W.length;v<B;v++)y=na[W[v]],p.array[s]=p.value[y.a],p.array[s+1]=p.value[y.b],p.array[s+2]=p.value[y.c],p.array[s+3]=p.value[y.d],s+=4}else{if("faces"===p.boundTo){for(v=0,B=V.length;v<B;v++)Ia=p.value[V[v]],p.array[s]=Ia,p.array[s+1]=Ia,p.array[s+2]=Ia,s+=3;for(v=0,B=W.length;v<B;v++)Ia=p.value[W[v]],p.array[s]=Ia,p.array[s+1]=Ia,p.array[s+
  289. 2]=Ia,p.array[s+3]=Ia,s+=4}}else if(2===p.size)if(void 0===p.boundTo||"vertices"===p.boundTo){for(v=0,B=V.length;v<B;v++)y=na[V[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=E.x,p.array[s+3]=E.y,p.array[s+4]=F.x,p.array[s+5]=F.y,s+=6;for(v=0,B=W.length;v<B;v++)y=na[W[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],Z=p.value[y.d],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=E.x,p.array[s+3]=E.y,p.array[s+4]=F.x,p.array[s+5]=F.y,p.array[s+6]=Z.x,p.array[s+
  290. 7]=Z.y,s+=8}else{if("faces"===p.boundTo){for(v=0,B=V.length;v<B;v++)F=E=D=Ia=p.value[V[v]],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=E.x,p.array[s+3]=E.y,p.array[s+4]=F.x,p.array[s+5]=F.y,s+=6;for(v=0,B=W.length;v<B;v++)Z=F=E=D=Ia=p.value[W[v]],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=E.x,p.array[s+3]=E.y,p.array[s+4]=F.x,p.array[s+5]=F.y,p.array[s+6]=Z.x,p.array[s+7]=Z.y,s+=8}}else if(3===p.size){var Q;Q="c"===p.type?["r","g","b"]:["x","y","z"];if(void 0===p.boundTo||"vertices"===p.boundTo){for(v=
  291. 0,B=V.length;v<B;v++)y=na[V[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],p.array[s]=D[Q[0]],p.array[s+1]=D[Q[1]],p.array[s+2]=D[Q[2]],p.array[s+3]=E[Q[0]],p.array[s+4]=E[Q[1]],p.array[s+5]=E[Q[2]],p.array[s+6]=F[Q[0]],p.array[s+7]=F[Q[1]],p.array[s+8]=F[Q[2]],s+=9;for(v=0,B=W.length;v<B;v++)y=na[W[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],Z=p.value[y.d],p.array[s]=D[Q[0]],p.array[s+1]=D[Q[1]],p.array[s+2]=D[Q[2]],p.array[s+3]=E[Q[0]],p.array[s+4]=E[Q[1]],p.array[s+5]=E[Q[2]],p.array[s+
  292. 6]=F[Q[0]],p.array[s+7]=F[Q[1]],p.array[s+8]=F[Q[2]],p.array[s+9]=Z[Q[0]],p.array[s+10]=Z[Q[1]],p.array[s+11]=Z[Q[2]],s+=12}else if("faces"===p.boundTo){for(v=0,B=V.length;v<B;v++)F=E=D=Ia=p.value[V[v]],p.array[s]=D[Q[0]],p.array[s+1]=D[Q[1]],p.array[s+2]=D[Q[2]],p.array[s+3]=E[Q[0]],p.array[s+4]=E[Q[1]],p.array[s+5]=E[Q[2]],p.array[s+6]=F[Q[0]],p.array[s+7]=F[Q[1]],p.array[s+8]=F[Q[2]],s+=9;for(v=0,B=W.length;v<B;v++)Z=F=E=D=Ia=p.value[W[v]],p.array[s]=D[Q[0]],p.array[s+1]=D[Q[1]],p.array[s+2]=D[Q[2]],
  293. p.array[s+3]=E[Q[0]],p.array[s+4]=E[Q[1]],p.array[s+5]=E[Q[2]],p.array[s+6]=F[Q[0]],p.array[s+7]=F[Q[1]],p.array[s+8]=F[Q[2]],p.array[s+9]=Z[Q[0]],p.array[s+10]=Z[Q[1]],p.array[s+11]=Z[Q[2]],s+=12}}else if(4===p.size)if(void 0===p.boundTo||"vertices"===p.boundTo){for(v=0,B=V.length;v<B;v++)y=na[V[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=D.z,p.array[s+3]=D.w,p.array[s+4]=E.x,p.array[s+5]=E.y,p.array[s+6]=E.z,p.array[s+7]=E.w,p.array[s+8]=F.x,p.array[s+
  294. 9]=F.y,p.array[s+10]=F.z,p.array[s+11]=F.w,s+=12;for(v=0,B=W.length;v<B;v++)y=na[W[v]],D=p.value[y.a],E=p.value[y.b],F=p.value[y.c],Z=p.value[y.d],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=D.z,p.array[s+3]=D.w,p.array[s+4]=E.x,p.array[s+5]=E.y,p.array[s+6]=E.z,p.array[s+7]=E.w,p.array[s+8]=F.x,p.array[s+9]=F.y,p.array[s+10]=F.z,p.array[s+11]=F.w,p.array[s+12]=Z.x,p.array[s+13]=Z.y,p.array[s+14]=Z.z,p.array[s+15]=Z.w,s+=16}else if("faces"===p.boundTo){for(v=0,B=V.length;v<B;v++)F=E=D=Ia=p.value[V[v]],
  295. p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=D.z,p.array[s+3]=D.w,p.array[s+4]=E.x,p.array[s+5]=E.y,p.array[s+6]=E.z,p.array[s+7]=E.w,p.array[s+8]=F.x,p.array[s+9]=F.y,p.array[s+10]=F.z,p.array[s+11]=F.w,s+=12;for(v=0,B=W.length;v<B;v++)Z=F=E=D=Ia=p.value[W[v]],p.array[s]=D.x,p.array[s+1]=D.y,p.array[s+2]=D.z,p.array[s+3]=D.w,p.array[s+4]=E.x,p.array[s+5]=E.y,p.array[s+6]=E.z,p.array[s+7]=E.w,p.array[s+8]=F.x,p.array[s+9]=F.y,p.array[s+10]=F.z,p.array[s+11]=F.w,p.array[s+12]=Z.x,p.array[s+13]=Z.y,
  296. p.array[s+14]=Z.z,p.array[s+15]=Z.w,s+=16}e.bindBuffer(e.ARRAY_BUFFER,p.buffer);e.bufferData(e.ARRAY_BUFFER,p.array,Ha)}sc&&(delete O.__inittedArrays,delete O.__colorArray,delete O.__normalArray,delete O.__tangentArray,delete O.__uvArray,delete O.__uv2Array,delete O.__faceArray,delete O.__vertexArray,delete O.__lineArray,delete O.__skinVertexAArray,delete O.__skinVertexBArray,delete O.__skinIndexArray,delete O.__skinWeightArray)}}R.__dirtyVertices=!1;R.__dirtyMorphTargets=!1;R.__dirtyElements=!1;
  297. R.__dirtyUvs=!1;R.__dirtyNormals=!1;R.__dirtyColors=!1;R.__dirtyTangents=!1;Fa.attributes&&l(Fa)}else if(Ua instanceof THREE.Ribbon){if(R.__dirtyVertices||R.__dirtyColors){var Fb=R,Vc=e.DYNAMIC_DRAW,lc=void 0,mc=void 0,zc=void 0,Gb=void 0,Ac=void 0,Wc=Fb.vertices,Xc=Fb.colors,ed=Wc.length,fd=Xc.length,Bc=Fb.__vertexArray,Cc=Fb.__colorArray,gd=Fb.__dirtyColors;if(Fb.__dirtyVertices){for(lc=0;lc<ed;lc++)zc=Wc[lc].position,Gb=3*lc,Bc[Gb]=zc.x,Bc[Gb+1]=zc.y,Bc[Gb+2]=zc.z;e.bindBuffer(e.ARRAY_BUFFER,Fb.__webglVertexBuffer);
  298. e.bufferData(e.ARRAY_BUFFER,Bc,Vc)}if(gd){for(mc=0;mc<fd;mc++)Ac=Xc[mc],Gb=3*mc,Cc[Gb]=Ac.r,Cc[Gb+1]=Ac.g,Cc[Gb+2]=Ac.b;e.bindBuffer(e.ARRAY_BUFFER,Fb.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,Cc,Vc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1}else if(Ua instanceof THREE.Line){Fa=c(Ua,dc);Rb=Fa.attributes&&n(Fa);if(R.__dirtyVertices||R.__dirtyColors||Rb){var sb=R,Rc=e.DYNAMIC_DRAW,nc=void 0,oc=void 0,Dc=void 0,ia=void 0,Ec=void 0,Yc=sb.vertices,Zc=sb.colors,hd=Yc.length,id=Zc.length,Fc=sb.__vertexArray,
  299. Gc=sb.__colorArray,jd=sb.__dirtyColors,Sc=sb.__webglCustomAttributesList,Hc=void 0,$c=void 0,ya=void 0,Xb=void 0,Ga=void 0,ba=void 0;if(sb.__dirtyVertices){for(nc=0;nc<hd;nc++)Dc=Yc[nc].position,ia=3*nc,Fc[ia]=Dc.x,Fc[ia+1]=Dc.y,Fc[ia+2]=Dc.z;e.bindBuffer(e.ARRAY_BUFFER,sb.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Fc,Rc)}if(jd){for(oc=0;oc<id;oc++)Ec=Zc[oc],ia=3*oc,Gc[ia]=Ec.r,Gc[ia+1]=Ec.g,Gc[ia+2]=Ec.b;e.bindBuffer(e.ARRAY_BUFFER,sb.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,Gc,Rc)}if(Sc)for(Hc=
  300. 0,$c=Sc.length;Hc<$c;Hc++)if(ba=Sc[Hc],ba.needsUpdate&&(void 0===ba.boundTo||"vertices"===ba.boundTo)){ia=0;Xb=ba.value.length;if(1===ba.size)for(ya=0;ya<Xb;ya++)ba.array[ya]=ba.value[ya];else if(2===ba.size)for(ya=0;ya<Xb;ya++)Ga=ba.value[ya],ba.array[ia]=Ga.x,ba.array[ia+1]=Ga.y,ia+=2;else if(3===ba.size)if("c"===ba.type)for(ya=0;ya<Xb;ya++)Ga=ba.value[ya],ba.array[ia]=Ga.r,ba.array[ia+1]=Ga.g,ba.array[ia+2]=Ga.b,ia+=3;else for(ya=0;ya<Xb;ya++)Ga=ba.value[ya],ba.array[ia]=Ga.x,ba.array[ia+1]=Ga.y,
  301. ba.array[ia+2]=Ga.z,ia+=3;else if(4===ba.size)for(ya=0;ya<Xb;ya++)Ga=ba.value[ya],ba.array[ia]=Ga.x,ba.array[ia+1]=Ga.y,ba.array[ia+2]=Ga.z,ba.array[ia+3]=Ga.w,ia+=4;e.bindBuffer(e.ARRAY_BUFFER,ba.buffer);e.bufferData(e.ARRAY_BUFFER,ba.array,Rc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1;Fa.attributes&&l(Fa)}else if(Ua instanceof THREE.ParticleSystem)Fa=c(Ua,dc),Rb=Fa.attributes&&n(Fa),(R.__dirtyVertices||R.__dirtyColors||Ua.sortParticles||Rb)&&g(R,e.DYNAMIC_DRAW,Ua),R.__dirtyVertices=!1,R.__dirtyColors=
  302. !1,Fa.attributes&&l(Fa)}};this.initMaterial=function(a,b,c,d){var f,g,h,i,j;a instanceof THREE.MeshDepthMaterial?j="depth":a instanceof THREE.MeshNormalMaterial?j="normal":a instanceof THREE.MeshBasicMaterial?j="basic":a instanceof THREE.MeshLambertMaterial?j="lambert":a instanceof THREE.MeshPhongMaterial?j="phong":a instanceof THREE.LineBasicMaterial?j="basic":a instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);
  303. a.vertexShader=k.vertexShader;a.fragmentShader=k.fragmentShader}var l,n;g=k=0;for(l=0,n=b.length;l<n;l++)f=b[l],f.onlyShadow||(f instanceof THREE.DirectionalLight&&g++,f instanceof THREE.PointLight&&k++,f instanceof THREE.SpotLight&&k++);k+g<=S?l=g:(l=Math.ceil(S*g/(k+g)),k=S-l);f=l;g=k;var m=0;for(k=0,l=b.length;k<l;k++)n=b[k],n.castShadow&&(n instanceof THREE.SpotLight&&m++,n instanceof THREE.DirectionalLight&&!n.shadowCascade&&m++);var r=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)r=d.bones.length;
  304. var o;a:{l=a.fragmentShader;n=a.vertexShader;var k=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,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:f,maxPointLights:g,maxBones:r,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
  305. shadowMapCascade:this.shadowMapCascade,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];j?d.push(j):(d.push(l),d.push(n));for(q in c)d.push(q),d.push(c[q]);j=d.join();for(q=0,d=Sa.length;q<d;q++)if(Sa[q].code===j){o=Sa[q].program;break a}q=e.createProgram();d=["precision "+M+" float;",0<bc?"#define VERTEX_TEXTURES":"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.physicallyBasedShading?
  306. "#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?
  307. "#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":"",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");
  308. f=["precision "+M+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.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":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
  309. "#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");e.attachShader(q,w("fragment",f+l));
  310. e.attachShader(q,w("vertex",d+n));e.linkProgram(q);e.getProgramParameter(q,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(q,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");q.uniforms={};q.attributes={};var t,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(t in k)d.push(t);t=d;for(d=0,k=t.length;d<k;d++)l=t[d],q.uniforms[l]=e.getUniformLocation(q,
  311. l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(t=0;t<c.maxMorphTargets;t++)d.push("morphTarget"+t);for(t=0;t<c.maxMorphNormals;t++)d.push("morphNormal"+t);for(o in b)d.push(o);o=d;for(t=0,b=o.length;t<b;t++)c=o[t],q.attributes[c]=e.getAttribLocation(q,c);q.id=Sa.length;Sa.push({program:q,code:j});C.info.memory.programs=Sa.length;o=q}a.program=o;o=a.program.attributes;0<=o.position&&e.enableVertexAttribArray(o.position);0<=o.color&&e.enableVertexAttribArray(o.color);
  312. 0<=o.normal&&e.enableVertexAttribArray(o.normal);0<=o.tangent&&e.enableVertexAttribArray(o.tangent);a.skinning&&0<=o.skinVertexA&&0<=o.skinVertexB&&0<=o.skinIndex&&0<=o.skinWeight&&(e.enableVertexAttribArray(o.skinVertexA),e.enableVertexAttribArray(o.skinVertexB),e.enableVertexAttribArray(o.skinIndex),e.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(i in a.attributes)void 0!==o[i]&&0<=o[i]&&e.enableVertexAttribArray(o[i]);if(a.morphTargets){a.numSupportedMorphTargets=0;q="morphTarget";
  313. for(i=0;i<this.maxMorphTargets;i++)t=q+i,0<=o[t]&&(e.enableVertexAttribArray(o[t]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;q="morphNormal";for(i=0;i<this.maxMorphNormals;i++)t=q+i,0<=o[t]&&(e.enableVertexAttribArray(o[t]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(h in a.uniforms)a.uniformsList.push([a.uniforms[h],h])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?e.frontFace(e.CCW):e.frontFace(e.CW),"back"===a?e.cullFace(e.BACK):"front"===a?e.cullFace(e.FRONT):
  314. e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(xa!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),xa=a.doubleSided;if(X!==a.flipSided)a.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),X=a.flipSided};this.setDepthTest=function(a){Ka!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),Ka=a)};this.setDepthWrite=function(a){Ca!==a&&(e.depthMask(a),Ca=a)};this.setBlending=function(a,b,c,d){if(a!==Aa){switch(a){case THREE.NoBlending:e.disable(e.BLEND);
  315. break;case THREE.AdditiveBlending:e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;case THREE.CustomBlending:e.enable(e.BLEND);break;default:e.enable(e.BLEND),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,
  316. e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}Aa=a}if(a===THREE.CustomBlending){if(b!==Ma&&(e.blendEquation(G(b)),Ma=b),c!==Wa||d!==Ta)e.blendFunc(G(c),G(d)),Wa=c,Ta=d}else Ta=Wa=Ma=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),C.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=0===(c.width&
  317. c.width-1)&&0===(c.height&c.height-1),f=G(a.format),g=G(a.type);P(e.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,f,c.width,c.height,0,f,g,c.data):e.texImage2D(e.TEXTURE_2D,0,f,f,g,a.image);a.generateMipmaps&&d&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===
  318. a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=G(a.format),f=G(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture);P(e.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,
  319. 0,d,f,null);var g=a,h=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,h,g.__webglTexture,0);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=e.createFramebuffer(),a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),P(e.TEXTURE_2D,a,c),e.texImage2D(e.TEXTURE_2D,0,d,a.width,a.height,0,d,f,null),d=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),
  320. e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,d,a.__webglTexture,0),A(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=f=0):(b=null,d=Pb,a=ac,f=$b,c=Hb);b!==T&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(f,c,d,a),T=b);pc=d;qc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;
  321. this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
  322. THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type:
  323. THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
  324. 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};
  325. THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
  326. 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};
  327. 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};
  328. 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};
  329. THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
  330. THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=new THREE.Object3D;THREE.Gyroscope.prototype.constructor=THREE.Gyroscope;
  331. THREE.Gyroscope.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)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)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
  332. !1,a=!0;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;
  333. 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.Vertex(new THREE.Vector3));d.lineGeometry.colors.push(new THREE.Color(b));void 0===d.pointMap[a]&&(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",
  334. "n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);
  335. this.camera=a;this.update(a);this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THREE.LinePieces);this.add(this.lines)};THREE.CameraHelper.prototype=new THREE.Object3D;THREE.CameraHelper.prototype.constructor=THREE.CameraHelper;
  336. THREE.CameraHelper.prototype.update=function(){function a(a,d,f,g){THREE.CameraHelper.__v.set(d,f,g);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=b.pointMap[a];if(void 0!==a){d=0;for(f=a.length;d<f;d++)b.lineGeometry.vertices[a[d]].position.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",
  337. -1,-1,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.__dirtyVertices=!0};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
  338. THREE.LensFlare=function(a,b,c,d,f){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
  339. THREE.LensFlare.prototype.add=function(a,b,c,d,f,g){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===g&&(g=1);void 0===f&&(f=new THREE.Color(16777215));if(void 0===d)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:g,color:f,blending:d})};
  340. THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,f=2*-this.positionScreen.y;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=0.25*c.x*Math.PI,c.rotation+=0.25*(c.wantedRotation-c.rotation)};THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=new THREE.Object3D;
  341. THREE.ImmediateRenderObject.prototype.constructor=THREE.ImmediateRenderObject;
  342. THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(f,a.vertexShader);b.compileShader(d);b.compileShader(f);b.attachShader(c,d);b.attachShader(c,f);b.linkProgram(c);return c}var b,c,d,f,g,i,h,k,j,m,n,l,u;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);f=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=
  343. 0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;f[r++]=0;f[r++]=1;f[r++]=2;f[r++]=0;f[r++]=2;f[r++]=3;g=b.createBuffer();i=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,i);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);h=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
  344. 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,k);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);
  345. b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(j=!1,m=a(THREE.ShaderFlares.lensFlare)):(j=!0,m=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};l={};n.vertex=b.getAttribLocation(m,"position");n.uv=b.getAttribLocation(m,"uv");l.renderType=b.getUniformLocation(m,"renderType");l.map=b.getUniformLocation(m,"map");l.occlusionMap=b.getUniformLocation(m,"occlusionMap");l.opacity=b.getUniformLocation(m,"opacity");l.color=b.getUniformLocation(m,
  346. "color");l.scale=b.getUniformLocation(m,"scale");l.rotation=b.getUniformLocation(m,"rotation");l.screenPosition=b.getUniformLocation(m,"screenPosition");u=!1};this.render=function(a,d,f,z){var a=a.__webglFlares,w=a.length;if(w){var P=new THREE.Vector3,A=z/f,q=0.5*f,G=0.5*z,H=16/z,M=new THREE.Vector2(H*A,H),I=new THREE.Vector3(1,1,0),K=new THREE.Vector2(1,1),N=l,H=n;b.useProgram(m);u||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),u=!0);b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map,
  347. 1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(H.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(H.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,i);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,Y,S;for(ja=0;ja<w;ja++)if(H=16/z,M.set(H*A,H),Y=a[ja],P.set(Y.matrixWorld.n14,Y.matrixWorld.n24,Y.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(P),d.projectionMatrix.multiplyVector3(P),I.copy(P),K.x=I.x*q+q,K.y=I.y*G+G,j||0<K.x&&K.x<f&&0<K.y&&K.y<z){b.activeTexture(b.TEXTURE1);
  348. b.bindTexture(b.TEXTURE_2D,h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,K.x-8,K.y-8,16,16,0);b.uniform1i(N.renderType,0);b.uniform2f(N.scale,M.x,M.y);b.uniform3f(N.screenPosition,I.x,I.y,I.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,k);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,K.x-8,K.y-8,16,16,0);b.uniform1i(N.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
  349. h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);Y.positionScreen.copy(I);Y.customUpdateCallback?Y.customUpdateCallback(Y):Y.updateLensFlares();b.uniform1i(N.renderType,2);b.enable(b.BLEND);for(oa=0,ka=Y.lensFlares.length;oa<ka;oa++)if(S=Y.lensFlares[oa],0.0010<S.opacity&&0.0010<S.scale)I.x=S.x,I.y=S.y,I.z=S.z,H=S.size*S.scale/z,M.x=H*A,M.y=H,b.uniform3f(N.screenPosition,I.x,I.y,I.z),b.uniform2f(N.scale,M.x,M.y),b.uniform1f(N.rotation,S.rotation),b.uniform1f(N.opacity,S.opacity),b.uniform3f(N.color,
  350. S.color.r,S.color.g,S.color.b),c.setBlending(S.blending,S.blendEquation,S.blendSrc,S.blendDst),c.setTexture(S.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
  351. THREE.ShadowMapPlugin=function(){var a,b,c,d,f=new THREE.Frustum,g=new THREE.Matrix4,i=new THREE.Vector3,h=new THREE.Vector3;this.init=function(f){a=f.context;b=f;var f=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(f.uniforms);c=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g});d=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
  352. c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,j){var m,n,l,u,r,o,t,z,w,P=[];u=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(m=0,n=k.__lights.length;m<n;m++)if(l=k.__lights[m],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(r=0;r<l.shadowCascadeCount;r++){var A;if(l.shadowCascadeArray[r])A=l.shadowCascadeArray[r];else{w=l;t=r;A=new THREE.DirectionalLight;A.isVirtual=
  353. !0;A.onlyShadow=!0;A.castShadow=!0;A.shadowCameraNear=w.shadowCameraNear;A.shadowCameraFar=w.shadowCameraFar;A.shadowCameraLeft=w.shadowCameraLeft;A.shadowCameraRight=w.shadowCameraRight;A.shadowCameraBottom=w.shadowCameraBottom;A.shadowCameraTop=w.shadowCameraTop;A.shadowCameraVisible=w.shadowCameraVisible;A.shadowDarkness=w.shadowDarkness;A.shadowBias=w.shadowCascadeBias[t];A.shadowMapWidth=w.shadowCascadeWidth[t];A.shadowMapHeight=w.shadowCascadeHeight[t];A.pointsWorld=[];A.pointsFrustum=[];z=
  354. A.pointsWorld;o=A.pointsFrustum;for(var q=0;8>q;q++)z[q]=new THREE.Vector3,o[q]=new THREE.Vector3;z=w.shadowCascadeNearZ[t];w=w.shadowCascadeFarZ[t];o[0].set(-1,-1,z);o[1].set(1,-1,z);o[2].set(-1,1,z);o[3].set(1,1,z);o[4].set(-1,-1,w);o[5].set(1,-1,w);o[6].set(-1,1,w);o[7].set(1,1,w);A.originalCamera=j;o=new THREE.Gyroscope;o.position=l.shadowCascadeOffset;o.add(A);o.add(A.target);j.add(o);l.shadowCascadeArray[r]=A;console.log("Created virtualLight",A)}t=l;z=r;w=t.shadowCascadeArray[z];w.position.copy(t.position);
  355. w.target.position.copy(t.target.position);w.lookAt(w.target);w.shadowCameraVisible=t.shadowCameraVisible;w.shadowDarkness=t.shadowDarkness;w.shadowBias=t.shadowCascadeBias[z];o=t.shadowCascadeNearZ[z];t=t.shadowCascadeFarZ[z];w=w.pointsFrustum;w[0].z=o;w[1].z=o;w[2].z=o;w[3].z=o;w[4].z=t;w[5].z=t;w[6].z=t;w[7].z=t;P[u]=A;u++}else P[u]=l,u++;for(m=0,n=P.length;m<n;m++){l=P[m];if(!l.shadowMap)l.shadowMap=new THREE.WebGLRenderTarget(l.shadowMapWidth,l.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
  356. format:THREE.RGBAFormat}),l.shadowMapSize=new THREE.Vector2(l.shadowMapWidth,l.shadowMapHeight),l.shadowMatrix=new THREE.Matrix4;if(!l.shadowCamera){if(l instanceof THREE.SpotLight)l.shadowCamera=new THREE.PerspectiveCamera(l.shadowCameraFov,l.shadowMapWidth/l.shadowMapHeight,l.shadowCameraNear,l.shadowCameraFar);else if(l instanceof THREE.DirectionalLight)l.shadowCamera=new THREE.OrthographicCamera(l.shadowCameraLeft,l.shadowCameraRight,l.shadowCameraTop,l.shadowCameraBottom,l.shadowCameraNear,l.shadowCameraFar);
  357. else{console.error("Unsupported light type for shadow");continue}k.add(l.shadowCamera);b.autoUpdateScene&&k.updateMatrixWorld()}if(l.shadowCameraVisible&&!l.cameraHelper)l.cameraHelper=new THREE.CameraHelper(l.shadowCamera),l.shadowCamera.add(l.cameraHelper);if(l.isVirtual&&A.originalCamera==j){r=j;u=l.shadowCamera;o=l.pointsFrustum;w=l.pointsWorld;i.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(t=0;8>t;t++){z=w[t];z.copy(o[t]);THREE.ShadowMapPlugin.__projector.unprojectVector(z,
  358. r);u.matrixWorldInverse.multiplyVector3(z);if(z.x<i.x)i.x=z.x;if(z.x>h.x)h.x=z.x;if(z.y<i.y)i.y=z.y;if(z.y>h.y)h.y=z.y;if(z.z<i.z)i.z=z.z;if(z.z>h.z)h.z=z.z}u.left=i.x;u.right=h.x;u.top=h.y;u.bottom=i.y;u.updateProjectionMatrix()}u=l.shadowMap;o=l.shadowMatrix;r=l.shadowCamera;r.position.copy(l.matrixWorld.getPosition());r.lookAt(l.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(l.cameraHelper)l.cameraHelper.lines.visible=l.shadowCameraVisible;
  359. l.shadowCameraVisible&&l.cameraHelper.update();o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(r.projectionMatrix);o.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);g.multiply(r.projectionMatrix,r.matrixWorldInverse);f.setFromMatrix(g);b.setRenderTarget(u);
  360. b.clear();w=k.__webglObjects;for(l=0,u=w.length;l<u;l++)if(t=w[l],o=t.object,t.render=!1,o.visible&&o.castShadow&&(!(o instanceof THREE.Mesh)||!o.frustumCulled||f.contains(o)))o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),t.render=!0;for(l=0,u=w.length;l<u;l++)if(t=w[l],t.render)o=t.object,t=t.buffer,b.setObjectFaces(o),z=o.customDepthMaterial?o.customDepthMaterial:o.geometry.morphTargets.length?d:
  361. c,t instanceof THREE.BufferGeometry?b.renderBufferDirect(r,k.__lights,null,z,t,o):b.renderBuffer(r,k.__lights,null,z,t,o);w=k.__webglObjectsImmediate;for(l=0,u=w.length;l<u;l++)t=w[l],o=t.object,o.visible&&o.castShadow&&(o.matrixAutoUpdate&&o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),b.renderImmediateObject(r,k.__lights,null,c,o))}m=b.getClearColor();n=b.getClearAlpha();a.clearColor(m.r,m.g,m.b,n);
  362. a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
  363. THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,f,g,i,h,k,j,m;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++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=0;d[a++]=-1;d[a++]=1;d[a++]=0;a=d[a++]=0;f[a++]=0;f[a++]=1;f[a++]=2;f[a++]=0;f[a++]=2;f[a++]=3;g=b.createBuffer();i=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
  364. i);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,l=b.createProgram(),u=b.createShader(b.FRAGMENT_SHADER),r=b.createShader(b.VERTEX_SHADER);b.shaderSource(u,a.fragmentShader);b.shaderSource(r,a.vertexShader);b.compileShader(u);b.compileShader(r);b.attachShader(l,u);b.attachShader(l,r);b.linkProgram(l);h=l;k={};j={};k.position=b.getAttribLocation(h,"position");k.uv=b.getAttribLocation(h,"uv");j.uvOffset=b.getUniformLocation(h,"uvOffset");j.uvScale=b.getUniformLocation(h,
  365. "uvScale");j.rotation=b.getUniformLocation(h,"rotation");j.scale=b.getUniformLocation(h,"scale");j.alignment=b.getUniformLocation(h,"alignment");j.color=b.getUniformLocation(h,"color");j.map=b.getUniformLocation(h,"map");j.opacity=b.getUniformLocation(h,"opacity");j.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");j.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");j.screenPosition=b.getUniformLocation(h,"screenPosition");j.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
  366. j.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");m=!1};this.render=function(d,f,u,r){var d=d.__webglSprites,o=d.length;if(o){var t=k,z=j,w=r/u,u=0.5*u,P=0.5*r,A=!0;b.useProgram(h);m||(b.enableVertexAttribArray(t.position),b.enableVertexAttribArray(t.uv),m=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(t.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(t.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,i);b.uniformMatrix4fv(z.projectionMatrix,
  367. !1,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(z.map,0);for(var q,G=[],t=0;t<o;t++)if(q=d[t],q.visible&&0!==q.opacity)q.useScreenCoordinates?q.z=-q.position.z:(q._modelViewMatrix.multiplyToArray(f.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),q.z=-q._modelViewMatrix.n34);d.sort(a);for(t=0;t<o;t++)q=d[t],q.visible&&0!==q.opacity&&q.map&&q.map.image&&q.map.image.width&&(q.useScreenCoordinates?(b.uniform1i(z.useScreenCoordinates,1),b.uniform3f(z.screenPosition,(q.position.x-
  368. u)/u,(P-q.position.y)/P,Math.max(0,Math.min(1,q.position.z)))):(b.uniform1i(z.useScreenCoordinates,0),b.uniform1i(z.affectedByDistance,q.affectedByDistance?1:0),b.uniformMatrix4fv(z.modelViewMatrix,!1,q._modelViewMatrixArray)),f=q.map.image.width/(q.scaleByViewport?r:1),G[0]=f*w*q.scale.x,G[1]=f*q.scale.y,b.uniform2f(z.uvScale,q.uvScale.x,q.uvScale.y),b.uniform2f(z.uvOffset,q.uvOffset.x,q.uvOffset.y),b.uniform2f(z.alignment,q.alignment.x,q.alignment.y),b.uniform1f(z.opacity,q.opacity),b.uniform3f(z.color,
  369. q.color.r,q.color.g,q.color.b),b.uniform1f(z.rotation,q.rotation),b.uniform2fv(z.scale,G),q.mergeWith3D&&!A?(b.enable(b.DEPTH_TEST),A=!0):!q.mergeWith3D&&A&&(b.disable(b.DEPTH_TEST),A=!1),c.setBlending(q.blending,q.blendEquation,q.blendSrc,q.blendDst),c.setTexture(q.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
  370. 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}"},
  371. 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}"}};
  372. 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}",
  373. 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}"}};