ThreeWebGL.js 194 KB

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