ThreeWebGL.js 188.7 KB
Newer Older
A
alteredq 已提交
1
// ThreeWebGL.js r47dev - http://github.com/mrdoob/three.js
2
'use strict';var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;if(!self.requestAnimationFrame)self.requestAnimationFrame=function(){return self.webkitRequestAnimationFrame||self.mozRequestAnimationFrame||self.oRequestAnimationFrame||self.msRequestAnimationFrame||function(a){self.setTimeout(a,1E3/60)}}();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
3
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);
4
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,e,g;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),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=
M
Mr.doob 已提交
5
Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
A
alteredq 已提交
6 7
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},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,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)},
8 9
equals:function(a){return a.x===this.x&&a.y===this.y}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
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},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},
A
alteredq 已提交
10
addScalar:function(a){this.x+=a;this.y+=a;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-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},
11
divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):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 this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},
12 13 14
cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y);
this.y=Math.asin(a.n13);1.0E-5<Math.abs(b)?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return 1.0E-4>this.lengthSq()}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-
A
alteredq 已提交
15
b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
M
Mr.doob 已提交
16 17
normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
18 19 20 21 22 23 24 25 26 27
THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
THREE.Ray=function(a,b){function c(a,b,c){p.sub(c,a);t=p.dot(b);z=l.add(a,r.copy(b).multiplyScalar(t));return y=c.distanceTo(z)}function d(a,b,c,d){p.sub(d,b);l.sub(c,b);r.sub(a,b);K=p.dot(p);N=p.dot(l);u=p.dot(r);J=l.dot(l);H=l.dot(r);B=1/(K*J-N*N);D=(J*u-N*H)*B;M=(K*H-N*u)*B;return 0<=D&&0<=M&&1>D+M}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3;this.intersectObject=function(a){for(var b,l=[],p=0,r=a.children.length;p<r;p++)Array.prototype.push.apply(l,this.intersectObject(a.children[p]));if(a instanceof THREE.Particle){p=
c(this.origin,this.direction,a.matrixWorld.getPosition());if(p>a.scale.x)return[];b={distance:p,point:a.position,face:null,object:a};l.push(b)}else if(a instanceof THREE.Mesh){p=c(this.origin,this.direction,a.matrixWorld.getPosition());if(p>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return l;var f,t,u=a.geometry,z=u.vertices,y;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,r=u.faces.length;p<r;p++)if(b=u.faces[p],k.copy(this.origin),m.copy(this.direction),
y=a.matrixWorld,j=y.multiplyVector3(j.copy(b.centroid)).subSelf(k),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),f=m.dot(n),!(1.0E-4>Math.abs(f))&&(t=n.dot(j)/f,!(0>t)&&(a.doubleSided||(a.flipSided?0<f:0>f))))if(o.add(k,m.multiplyScalar(t)),b instanceof THREE.Face3)e=y.multiplyVector3(e.copy(z[b.a].position)),g=y.multiplyVector3(g.copy(z[b.b].position)),h=y.multiplyVector3(h.copy(z[b.c].position)),d(o,e,g,h)&&(b={distance:k.distanceTo(o),point:o.clone(),face:b,object:a},l.push(b));else if(b instanceof
THREE.Face4&&(e=y.multiplyVector3(e.copy(z[b.a].position)),g=y.multiplyVector3(g.copy(z[b.b].position)),h=y.multiplyVector3(h.copy(z[b.c].position)),i=y.multiplyVector3(i.copy(z[b.d].position)),d(o,e,g,i)||d(o,g,h,i)))b={distance:k.distanceTo(o),point:o.clone(),face:b,object:a},l.push(b)}return l};var p=new THREE.Vector3,l=new THREE.Vector3,r=new THREE.Vector3,t,z,y,K,N,u,J,H,B,D,M};
THREE.Rectangle=function(){function a(){g=d-b;h=e-c}var b,c,d,e,g,h,i=!0;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 e};this.set=function(g,h,j,n){i=!1;b=g;c=h;d=j;e=n;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,e=h):(b=b<g?b:g,c=c<h?c:h,d=d>g?d:g,e=e>h?e:h);a()};this.add3Points=
function(g,h,j,n,o,p){i?(i=!1,b=g<j?g<o?g:o:j<o?j:o,c=h<n?h<p?h:p:n<p?n:p,d=g>j?g>o?g:o:j>o?j:o,e=h>n?h>p?h:p:n>p?n:p):(b=g<j?g<o?g<b?g:b:o<b?o:b:j<o?j<b?j:b:o<b?o:b,c=h<n?h<p?h<c?h:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c,d=g>j?g>o?g>d?g:d:o>d?o:d:j>o?j>d?j:d:o>d?o:d,e=h>n?h>p?h>e?h:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),e=e>
g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=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();e=e<g.getBottom()?e:g.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
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,e){return d+(a-b)*(e-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())}};THREE.Matrix3=function(){this.m=[]};
A
alteredq 已提交
28
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
29 30 31 32 33 34 35 36 37
THREE.Matrix4=function(a,b,c,d,e,g,h,i,k,m,j,n,o,p,l,r){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==g?g:1,h||0,i||0,k||0,m||0,void 0!==j?j:1,n||0,o||0,p||0,l||0,void 0!==r?r:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,h,i,k,m,j,n,o,p,l,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=i;this.n31=k;this.n32=m;this.n33=j;this.n34=n;this.n41=o;this.n42=p;this.n43=l;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,
b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(0===g.length())g.z=1;d.cross(c,g).normalize();0===d.length()&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,i=a.n22,k=a.n23,m=a.n24,j=a.n31,n=a.n32,o=a.n33,p=a.n34,l=a.n41,r=a.n42,t=a.n43,
z=a.n44,y=b.n11,K=b.n12,N=b.n13,u=b.n14,J=b.n21,H=b.n22,B=b.n23,D=b.n24,M=b.n31,I=b.n32,Q=b.n33,ga=b.n34,xa=b.n41,A=b.n42,f=b.n43,Ga=b.n44;this.n11=c*y+d*J+e*M+g*xa;this.n12=c*K+d*H+e*I+g*A;this.n13=c*N+d*B+e*Q+g*f;this.n14=c*u+d*D+e*ga+g*Ga;this.n21=h*y+i*J+k*M+m*xa;this.n22=h*K+i*H+k*I+m*A;this.n23=h*N+i*B+k*Q+m*f;this.n24=h*u+i*D+k*ga+m*Ga;this.n31=j*y+n*J+o*M+p*xa;this.n32=j*K+n*H+o*I+p*A;this.n33=j*N+n*B+o*Q+p*f;this.n34=j*u+n*D+o*ga+p*Ga;this.n41=l*y+r*J+t*M+z*xa;this.n42=l*K+r*H+t*I+z*A;this.n43=
l*N+r*B+t*Q+z*f;this.n44=l*u+r*D+t*ga+z*Ga;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=
a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=
this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*
a.x+this.n32*a.y+this.n33*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,e=this.n21,g=this.n22,h=this.n23,i=this.n24,k=this.n31,m=this.n32,j=this.n33,n=this.n34,o=this.n41,p=this.n42,l=this.n43,r=this.n44;return d*h*m*o-c*i*m*o-d*g*j*o+b*i*j*o+c*g*n*o-b*h*n*o-d*h*k*p+c*i*k*p+d*e*j*p-a*i*j*p-c*e*n*p+a*h*n*p+d*g*k*l-b*i*k*l-d*e*m*l+a*i*m*l+b*e*n*l-a*g*n*l-c*g*k*r+b*h*k*r+c*e*m*r-a*h*m*r-
b*e*j*r+a*g*j*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},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;
38
a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=
A
alteredq 已提交
39
this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=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]=
40
this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,
41 42 43 44 45 46 47 48
0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,h=a.y,i=a.z,k=e*g,m=e*h;this.set(k*g+c,k*h-d*i,k*i+d*h,0,k*h+d*i,m*h+c,m*i-d*g,0,k*i-d*h,m*i+d*g,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,g=a.n21,h=a.n22,i=a.n23,k=a.n24,m=a.n31,j=a.n32,n=a.n33,o=a.n34,p=a.n41,l=a.n42,r=a.n43,t=a.n44;this.n11=i*o*l-k*n*l+k*j*r-h*o*r-i*j*t+h*n*t;this.n12=e*n*l-d*o*l-e*j*r+c*o*r+d*j*t-c*n*t;this.n13=d*k*l-e*i*l+e*h*r-c*k*r-d*h*t+c*i*t;this.n14=e*i*j-d*k*j-e*h*n+c*k*n+d*h*o-c*i*o;this.n21=k*n*p-i*o*p-k*m*r+g*o*r+i*m*t-g*n*t;this.n22=d*o*p-e*n*p+
e*m*r-b*o*r-d*m*t+b*n*t;this.n23=e*i*p-d*k*p-e*g*r+b*k*r+d*g*t-b*i*t;this.n24=d*k*m-e*i*m+e*g*n-b*k*n-d*g*o+b*i*o;this.n31=h*o*p-k*j*p+k*m*l-g*o*l-h*m*t+g*j*t;this.n32=e*j*p-c*o*p-e*m*l+b*o*l+c*m*t-b*j*t;this.n33=c*k*p-e*h*p+e*g*l-b*k*l-c*g*t+b*h*t;this.n34=e*h*m-c*k*m-e*g*j+b*k*j+c*g*o-b*h*o;this.n41=i*j*p-h*n*p-i*m*l+g*n*l+h*m*r-g*j*r;this.n42=c*n*p-d*j*p+d*m*l-b*n*l-c*m*r+b*j*r;this.n43=d*h*p-c*i*p-d*g*l+b*i*l+c*g*r-b*h*r;this.n44=c*i*m-d*h*m+d*g*j-b*i*j-c*g*n+b*h*n;this.multiplyScalar(1/a.determinant());
return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),h=Math.cos(d),d=Math.sin(d),i=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k=h*i,m=h*e,j=d*i,n=d*e;this.n11=k+n*c;this.n12=j*c-m;this.n13=g*d;this.n21=g*e;this.n22=g*i;this.n23=-c;this.n31=m*c-j;this.n32=n+k*c;this.n33=g*h;break;case "ZXY":k=h*i;m=h*e;j=d*i;n=d*e;this.n11=k-n*c;this.n12=-g*e;this.n13=j+m*c;this.n21=m+j*c;this.n22=g*i;this.n23=n-k*c;this.n31=-g*d;this.n32=c;this.n33=g*h;break;case "ZYX":k=
g*i;m=g*e;j=c*i;n=c*e;this.n11=h*i;this.n12=j*d-m;this.n13=k*d+n;this.n21=h*e;this.n22=n*d+k;this.n23=m*d-j;this.n31=-d;this.n32=c*h;this.n33=g*h;break;case "YZX":k=g*h;m=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=n-k*e;this.n13=j*e+m;this.n21=e;this.n22=g*i;this.n23=-c*i;this.n31=-d*i;this.n32=m*e+j;this.n33=k-n*e;break;case "XZY":k=g*h;m=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=-e;this.n13=d*i;this.n21=k*e+n;this.n22=g*i;this.n23=m*e-j;this.n31=j*e-m;this.n32=c*i;this.n33=n*e+k;break;default:k=g*i,m=g*
e,j=c*i,n=c*e,this.n11=h*i,this.n12=-h*e,this.n13=d,this.n21=m+j*d,this.n22=k-n*d,this.n23=-c*h,this.n31=n-k*d,this.n32=j+m*d,this.n33=g*h}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,i=d+d,a=b*g,k=b*h,b=b*i,m=c*h,c=c*i,d=d*i,g=e*g,h=e*h,e=e*i;this.n11=1-(m+d);this.n12=k-e;this.n13=b+h;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.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=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
49
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},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
50 51 52
a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,g=Math.sqrt(c*c+d*d+e*e),c=c/g,d=d/g,e=e/g,g=c*c,h=d*d,i=e*e,k=Math.cos(b),m=Math.sin(b),j=1-k,n=c*d*j,o=c*e*j,j=d*e*j,c=c*m,p=d*m,m=e*m,e=g+(1-g)*k,g=n+m,d=o-p,n=n-m,h=h+(1-h)*k,m=j+c,o=o+p,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,p=this.n31,l=this.n41,r=this.n12,t=this.n22,z=this.n32,y=this.n42,K=this.n13,N=this.n23,u=this.n33,J=this.n43;this.n11=e*k+g*r+d*K;this.n21=e*c+g*t+d*N;this.n31=e*p+g*z+d*u;this.n41=e*l+g*y+d*J;this.n12=n*k+h*r+m*K;this.n22=
n*c+h*t+m*N;this.n32=n*p+h*z+m*u;this.n42=n*l+h*y+m*J;this.n13=o*k+j*r+i*K;this.n23=o*c+j*t+i*N;this.n33=o*p+j*z+i*u;this.n43=o*l+j*y+i*J;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,g=this.n13,h=this.n23,i=this.n33,k=this.n43,m=Math.cos(a),a=Math.sin(a);this.n12=m*b+a*g;this.n22=m*c+a*h;this.n32=m*d+a*i;this.n42=m*e+a*k;this.n13=m*g-a*b;this.n23=m*h-a*c;this.n33=m*i-a*d;this.n43=m*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
g=this.n13,h=this.n23,i=this.n33,k=this.n43,m=Math.cos(a),a=Math.sin(a);this.n11=m*b-a*g;this.n21=m*c-a*h;this.n31=m*d-a*i;this.n41=m*e-a*k;this.n13=m*g+a*b;this.n23=m*h+a*c;this.n33=m*i+a*d;this.n43=m*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,g=this.n12,h=this.n22,i=this.n32,k=this.n42,m=Math.cos(a),a=Math.sin(a);this.n11=m*b+a*g;this.n21=m*c+a*h;this.n31=m*d+a*i;this.n41=m*e+a*k;this.n12=m*g-a*b;this.n22=m*h-a*c;this.n32=m*i-a*d;this.n42=m*k-a*e;return this},
53
translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
54 55 56
THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*h+a.n31*m;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*h;c[4]=a*i;c[5]=a*k;c[6]=a*m;c[7]=a*j;c[8]=a*n;return b};
THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var h,i,k,m;h=new THREE.Matrix4;i=b-a;k=c-d;m=g-e;h.n11=2/i;h.n12=0;h.n13=0;h.n14=-((b+a)/i);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((c+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
A
alteredq 已提交
57 58
THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;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=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
59
THREE.Object3D.prototype={constructor:THREE.Object3D,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,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(-1===
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(-1!==b){a.parent=void 0;this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.removeObject(a)}},getChildByName:function(a,b){var c,d,e;for(c=0,d=this.children.length;c<d;c++){e=this.children[c];if(e.name===
a||b&&(e=e.getChildByName(a,b),void 0!==e))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=m[k]=m[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,f=1,d=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=d&&0<=e&&0<=g&&0<=h)return!0;if(0>d&&0>e||0>g&&0>h)return!1;0>d?c=Math.max(c,d/(d-e)):0>e&&(f=Math.min(f,d/(d-e)));0>g?c=Math.max(c,g/(g-h)):0>h&&(f=Math.min(f,g/(g-h)));if(f<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-f);return!0}
var e,g,h=[],i,k,m=[],j,n,o=[],p,l=[],r,t,z=[],y,K,N=[],u={objects:[],sprites:[],lights:[],elements:[]},J=new THREE.Vector3,H=new THREE.Vector4,B=new THREE.Matrix4,D=new THREE.Matrix4,M=new THREE.Frustum,I=new THREE.Vector4,Q=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);B.multiply(b.projectionMatrix,b.matrixWorldInverse);B.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);B.multiply(b.matrixWorld,
b.projectionMatrixInverse);B.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(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||M.contains(b))?(B.multiplyVector3(J.copy(b.position)),e=a(),e.object=
b,e.z=J.z,u.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(B.multiplyVector3(J.copy(b.position)),e=a(),e.object=b,e.z=J.z,u.sprites.push(e)):b instanceof THREE.Light&&u.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)h(b.children[c])}};h(b);d&&u.objects.sort(c);return u};this.projectScene=function(a,e,g){var f=e.near,h=e.far,J,sa,L,ma,V,na,ha,W,Z,va,Ka,Ra,lb,Ma,gb,Na;K=t=p=n=0;u.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);B.multiply(e.projectionMatrix,e.matrixWorldInverse);M.setFromMatrix(B);u=this.projectGraph(a,!1);for(a=0,J=u.objects.length;a<J;a++)if(Z=u.objects[a].object,va=Z.matrixWorld,Ra=Z.material,k=0,Z instanceof THREE.Mesh){Ka=Z.geometry;lb=Z.geometry.materials;ma=Ka.vertices;Ma=Ka.faces;gb=Ka.faceVertexUvs;Ka=Z.matrixRotationWorld.extractRotation(va);for(sa=0,L=ma.length;sa<L;sa++)i=b(),i.positionWorld.copy(ma[sa].position),
va.multiplyVector3(i.positionWorld),i.positionScreen.copy(i.positionWorld),B.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>f&&i.positionScreen.z<h;for(ma=0,sa=Ma.length;ma<sa;ma++){L=Ma[ma];if(L instanceof THREE.Face3)if(V=m[L.a],na=m[L.b],ha=m[L.c],V.visible&&na.visible&&ha.visible&&(Z.doubleSided||Z.flipSided!=0>(ha.positionScreen.x-V.positionScreen.x)*(na.positionScreen.y-V.positionScreen.y)-(ha.positionScreen.y-
V.positionScreen.y)*(na.positionScreen.x-V.positionScreen.x)))W=o[n]=o[n]||new THREE.RenderableFace3,n++,j=W,j.v1.copy(V),j.v2.copy(na),j.v3.copy(ha);else continue;else if(L instanceof THREE.Face4)if(V=m[L.a],na=m[L.b],ha=m[L.c],W=m[L.d],V.visible&&na.visible&&ha.visible&&W.visible&&(Z.doubleSided||Z.flipSided!=(0>(W.positionScreen.x-V.positionScreen.x)*(na.positionScreen.y-V.positionScreen.y)-(W.positionScreen.y-V.positionScreen.y)*(na.positionScreen.x-V.positionScreen.x)||0>(na.positionScreen.x-
ha.positionScreen.x)*(W.positionScreen.y-ha.positionScreen.y)-(na.positionScreen.y-ha.positionScreen.y)*(W.positionScreen.x-ha.positionScreen.x))))Na=l[p]=l[p]||new THREE.RenderableFace4,p++,j=Na,j.v1.copy(V),j.v2.copy(na),j.v3.copy(ha),j.v4.copy(W);else continue;j.normalWorld.copy(L.normal);Ka.multiplyVector3(j.normalWorld);j.centroidWorld.copy(L.centroid);va.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);B.multiplyVector3(j.centroidScreen);ha=L.vertexNormals;for(V=0,na=
ha.length;V<na;V++)W=j.vertexNormalsWorld[V],W.copy(ha[V]),Ka.multiplyVector3(W);for(V=0,na=gb.length;V<na;V++)if(Na=gb[V][ma])for(ha=0,W=Na.length;ha<W;ha++)j.uvs[V][ha]=Na[ha];j.material=Ra;j.faceMaterial=null!==L.materialIndex?lb[L.materialIndex]:null;j.z=j.centroidScreen.z;u.elements.push(j)}}else if(Z instanceof THREE.Line){D.multiply(B,va);ma=Z.geometry.vertices;V=b();V.positionScreen.copy(ma[0].position);D.multiplyVector4(V.positionScreen);for(sa=1,L=ma.length;sa<L;sa++)if(V=b(),V.positionScreen.copy(ma[sa].position),
D.multiplyVector4(V.positionScreen),na=m[k-2],I.copy(V.positionScreen),Q.copy(na.positionScreen),d(I,Q))I.multiplyScalar(1/I.w),Q.multiplyScalar(1/Q.w),Z=z[t]=z[t]||new THREE.RenderableLine,t++,r=Z,r.v1.positionScreen.copy(I),r.v2.positionScreen.copy(Q),r.z=Math.max(I.z,Q.z),r.material=Ra,u.elements.push(r)}for(a=0,J=u.sprites.length;a<J;a++)if(Z=u.sprites[a].object,va=Z.matrixWorld,Z instanceof THREE.Particle&&(H.set(va.n14,va.n24,va.n34,1),B.multiplyVector4(H),H.z/=H.w,0<H.z&&1>H.z))f=N[K]=N[K]||
new THREE.RenderableParticle,K++,y=f,y.x=H.x/H.w,y.y=H.y/H.w,y.z=H.z,y.rotation=Z.rotation.z,y.scale.x=Z.scale.x*Math.abs(y.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),y.scale.y=Z.scale.y*Math.abs(y.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),y.material=Z.material,u.elements.push(y);g&&u.elements.sort(c);return u}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
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,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),h=a*b,i=d*e;this.w=h*g-i*c;this.x=h*c+i*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
75 76
this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
77 78 79 80 81
this.x,c=this.y,d=this.z,e=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+e*g+c*i-d*h;this.y=c*a+e*h+d*g-b*i;this.z=d*a+e*i+b*h-c*g;this.w=e*a-b*g-c*h-d*i;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},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,h=this.y,i=this.z,k=this.w,m=k*c+h*e-i*d,j=k*d+i*c-g*e,n=k*e+g*d-h*c,c=-g*
c-h*d-i*e;b.x=m*k+c*-g+j*-i-n*-h;b.y=j*k+c*-h+n*-g-m*-i;b.z=n*k+c*-i+m*-h-j*-g;return b}};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
THREE.Face4=function(a,b,c,d,e,g,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
A
alteredq 已提交
82 83
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},clone:function(){return new THREE.UV(this.u,this.v)}};
THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
84
THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(d=this.faces.length;c<d;c++){var e=this.faces[c];b.multiplyVector3(e.normal);for(var g=0,h=e.vertexNormals.length;g<h;g++)b.multiplyVector3(e.vertexNormals[g]);a.multiplyVector3(e.centroid)}},computeCentroids:function(){var a,b,c;for(a=0,b=this.faces.length;a<
85
b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(){var a,
86
b,c,d,e,g,h=new THREE.Vector3,i=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],g=this.vertices[c.c],h.sub(g.position,e.position),i.sub(d.position,e.position),h.crossSelf(i),h.isZero()||h.normalize(),c.normal.copy(h)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=
87 88
this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;for(a=0,b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),
d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
89 90 91 92 93 94 95 96
b,c,f,d,e,g){i=a.vertices[b].position;k=a.vertices[c].position;m=a.vertices[f].position;j=h[d];n=h[e];o=h[g];p=k.x-i.x;l=m.x-i.x;r=k.y-i.y;t=m.y-i.y;z=k.z-i.z;y=m.z-i.z;K=n.u-j.u;N=o.u-j.u;u=n.v-j.v;J=o.v-j.v;H=1/(K*J-N*u);I.set((J*p-u*l)*H,(J*r-u*t)*H,(J*z-u*y)*H);Q.set((K*l-N*p)*H,(K*t-N*r)*H,(K*y-N*z)*H);D[b].addSelf(I);D[c].addSelf(I);D[f].addSelf(I);M[b].addSelf(Q);M[c].addSelf(Q);M[f].addSelf(Q)}var b,c,d,e,g,h,i,k,m,j,n,o,p,l,r,t,z,y,K,N,u,J,H,B,D=[],M=[],I=new THREE.Vector3,Q=new THREE.Vector3,
ga=new THREE.Vector3,xa=new THREE.Vector3,A=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)D[b]=new THREE.Vector3,M[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var f=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)A.copy(g.vertexNormals[d]),e=g[f[d]],
B=D[e],ga.copy(B),ga.subSelf(A.multiplyScalar(A.dot(B))).normalize(),xa.cross(g.vertexNormals[d],B),e=xa.dot(M[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(ga.x,ga.y,ga.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<
e;d++){a=this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),g,h;for(g=0,h=this.vertices.length;g<h;g++)d=this.vertices[g].position,d=[Math.round(d.x*e),Math.round(d.y*e),
Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=g,b.push(this.vertices[g]),c[g]=b.length-1):c[g]=c[a[d]];for(g=0,h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
THREE.Spline=function(a){function b(a,b,c,d,e,g,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,h,i,k,m,j,n,o;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){e=(this.points.length-1)*a;g=Math.floor(e);h=e-g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>this.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;m=this.points[c[0]];j=this.points[c[1]];
n=this.points[c[2]];o=this.points[c[3]];i=h*h;k=h*i;d.x=b(m.x,j.x,n.x,o.x,h,i,k);d.y=b(m.y,j.y,n.y,o.y,h,i,k);d.z=b(m.z,j.z,n.z,o.z,h,i,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=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=a/c,d=this.getPoint(b),h.copy(d),j+=h.distanceTo(g),
g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,e,g,h,i=[],j=new THREE.Vector3,m=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=m.chunks[b]-m.chunks[b-1];h=Math.ceil(a*c/m.total);e=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<h-1;c++)d=e+c*(1/h)*(g-e),d=this.getPoint(d),i.push(j.copy(d).clone());i.push(j.copy(this.points[b]).clone())}this.points=
97
i}};THREE.Edge=function(a,b,c,d){this.vertices=[a,b];this.vertexIndices=[c,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
98
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.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,g){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:0.1;this.far=void 0!==g?g:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
99
THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:0.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
100
THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
101
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
A
alteredq 已提交
102
this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
103
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=new THREE.Light;
104
THREE.PointLight.prototype.constructor=THREE.PointLight;
105
THREE.SpotLight=function(a,b,c,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.castShadow=void 0!==d?d:!1;this.onlyShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};
106
THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
107 108 109 110 111
THREE.Material=function(a){a=a||{};this.name="";this.id=THREE.MaterialCount++;this.opacity=void 0!==a.opacity?a.opacity:1;this.transparent=void 0!==a.transparent?a.transparent:!1;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.depthTest=void 0!==a.depthTest?a.depthTest:!0;this.depthWrite=void 0!==a.depthWrite?a.depthWrite:!0;this.polygonOffset=void 0!==a.polygonOffset?a.polygonOffset:!1;this.polygonOffsetFactor=void 0!==a.polygonOffsetFactor?a.polygonOffsetFactor:0;this.polygonOffsetUnits=
void 0!==a.polygonOffsetUnits?a.polygonOffsetUnits:0;this.alphaTest=void 0!==a.alphaTest?a.alphaTest:0;this.overdraw=void 0!==a.overdraw?a.overdraw:!1};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;
THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=void 0!==a.linewidth?a.linewidth:1;this.linecap=void 0!==a.linecap?a.linecap:"round";this.linejoin=void 0!==a.linejoin?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1;this.fog=void 0!==a.fog?a.fog:!0};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:
!0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:
A
alteredq 已提交
112
!1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
113 114 115 116 117 118 119
THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(328965);this.wrapAround=void 0!==a.wrapAround?a.wrapAround:!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;
this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:!0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:
"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1};THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(328965);this.specular=void 0!==a.specular?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=void 0!==a.shininess?a.shininess:30;this.metal=void 0!==a.metal?a.metal:!1;this.perPixel=void 0!==a.perPixel?a.perPixel:!1;this.wrapAround=void 0!==a.wrapAround?a.wrapAround:
!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=void 0!==a.envMap?a.envMap:null;this.combine=void 0!==a.combine?a.combine:THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity:1;this.refractionRatio=void 0!==a.refractionRatio?a.refractionRatio:0.98;this.fog=void 0!==a.fog?a.fog:!0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:
!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;
THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
A
alteredq 已提交
120 121
THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().");return new THREE.ShaderMaterial(a)};
122 123 124
THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:null;this.size=void 0!==a.size?a.size:1;this.sizeAttenuation=void 0!==a.sizeAttenuation?a.sizeAttenuation:!0;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.fog=void 0!==a.fog?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=void 0!==a.fragmentShader?a.fragmentShader:"void main() {}";this.vertexShader=void 0!==a.vertexShader?a.vertexShader:"void main() {}";this.uniforms=void 0!==a.uniforms?a.uniforms:{};this.attributes=a.attributes;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.fog=void 0!==
a.fog?a.fog:!1;this.lights=void 0!==a.lights?a.lights:!1;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
125
THREE.Texture=function(a,b,c,d,e,g,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==g?g:THREE.LinearMipMapLinearFilter;this.format=void 0!==h?h:THREE.RGBAFormat;this.type=void 0!==i?i:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
126
!0;this.needsUpdate=!1;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};
127
THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=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;
128
THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,e,g,h,i,k,m){THREE.Texture.call(this,null,g,h,i,k,m,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
129
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;
130
THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.sortParticles=!1;if(this.geometry)this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius;this.frustumCulled=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
131
THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
A
alteredq 已提交
132
THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATED: Mesh material can no longer be an Array. Using material at index 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};
133 134 135
for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};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;
THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
136 137
THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,e,g,h,i;if(void 0!==this.geometry.bones){for(c=0;c<this.geometry.bones.length;c++)e=this.geometry.bones[c],g=e.pos,h=e.rotq,i=e.scl,d=this.addBone(),d.name=e.name,d.position.set(g[0],g[1],g[2]),d.quaternion.set(h[0],h[1],h[2],h[3]),d.useQuaternion=!0,void 0!==i?d.scale.set(i[0],i[1],i[2]):d.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)e=this.geometry.bones[c],
d=this.bones[c],-1===e.parent?this.add(d):this.bones[e.parent].add(d);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){void 0===a&&(a=new THREE.Bone(this));this.bones.push(a);return a};
138 139
THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,!1):c.updateMatrixWorld(!0)}for(var b=this.bones.length,c=this.bones,d=this.boneMatrices,a=0;a<b;a++)c[a].skinMatrix.flattenToArrayOffset(d,
16*a)};
140 141
THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);b.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,16*c)}if(void 0===this.geometry.skinVerticesA){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,e=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y,d=
new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[e].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[g].multiplyVector3(d));1!==this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y&&(c=0.5*(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y)),this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
142 143 144 145 146
THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length&&!(b<this.LODs[c].visibleAtDistance);c++);this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
THREE.LOD.prototype.update=function(a){if(1<this.LODs.length){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=!1}};
THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.useScreenCoordinates=void 0!==a.useScreenCoordinates?a.useScreenCoordinates:!0;this.mergeWith3D=void 0!==a.mergeWith3D?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=void 0!==a.affectedByDistance?a.affectedByDistance:
!this.useScreenCoordinates;this.scaleByViewport=void 0!==a.scaleByViewport?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;
THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(1!==this.scale.x||1!==this.scale.y)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
A
alteredq 已提交
147 148
THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
149 150 151
THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===this.lights.indexOf(a)&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.objects.indexOf(a)){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.addObject(a.children[b])};
THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);-1!==b&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),-1!==b&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};
A
alteredq 已提交
152 153 154
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",
envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\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",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",
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",
155
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 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
156 157
lights_lambert_vertex:"vLightWeighting = vec3( 0.0 );\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 );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );\nvec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );\n#endif\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\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 );\n#ifdef WRAP_AROUND\nfloat pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );\nfloat pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );\nvec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );\n#else\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\n#endif\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;",
lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif",
158
lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
159
lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse  = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\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\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 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\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse  = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 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\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
A
alteredq 已提交
160 161
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 * viewMatrix * objectMatrix * gl_Position;\n#endif",
morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
162
default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
163
shadowmap_fragment:"#ifdef USE_SHADOWMAP\nvec3 shadowColor = vec3( 1.0 );\nfloat fDepth;\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nif ( shadowCoord.z <= 1.0 ) {\nshadowCoord.z += shadowBias[ i ];\nbvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nif ( all( shadowTest ) ) {\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}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
164 165
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",
linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
166
THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;b<a.length;b++)for(c in d=this.clone(a[b]),d)e[c]=d[c];return e},clone:function(a){var b,c,d,e={};for(b in a)for(c in e[b]={},a[b])d=a[b][c],e[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 e}};
A
alteredq 已提交
167
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",
168
value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",
169
value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:6,texture:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}};
A
alteredq 已提交
170 171
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",
value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( 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,
A
alteredq 已提交
172 173
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,
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,
174 175 176 177 178 179 180 181 182 183 184
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(328965)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vLightWeighting;",
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,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,
"vec3 transformedNormal = normalize( normalMatrix * normal );",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 vLightWeighting;",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,"gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;",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(328965)},specular:{type:"c",value:new THREE.Color(1118481)},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 );",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;\nvec3 transformedNormal = normalMatrix * normal;\nvNormal = transformedNormal;",
THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 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 );",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;",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,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 );",
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}"}};
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var g=d.attributes[e];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var h=1;"v2"===g.type?h=2:"v3"===g.type?h=3:"v4"===g.type?h=4:"c"===g.type&&(h=3);g.size=h;g.array=new Float32Array(c*h);g.buffer=f.createBuffer();g.buffer.belongsToAttribute=e;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}}
function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c){var d,e,g,h,i=a.vertices;h=i.length;
var j=a.colors,m=j.length,n=a.__vertexArray,l=a.__colorArray,k=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){Sa.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)e=i[d].position,Oa.copy(e),Sa.multiplyVector3(Oa),k[d]=[Oa.z,d];k.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++)e=i[k[d][1]].position,g=3*d,n[g]=e.x,n[g+1]=e.y,n[g+2]=e.z;for(d=0;d<m;d++)g=3*d,e=j[k[d][1]],l[g]=e.r,l[g+1]=e.g,l[g+2]=e.b;if(r)for(j=0,m=r.length;j<m;j++)if(i=r[j],
void 0===i.boundTo||"vertices"===i.boundTo)if(g=0,e=i.value.length,1===i.size)for(d=0;d<e;d++)h=k[d][1],i.array[d]=i.value[h];else if(2===i.size)for(d=0;d<e;d++)h=k[d][1],h=i.value[h],i.array[g]=h.x,i.array[g+1]=h.y,g+=2;else if(3===i.size)if("c"===i.type)for(d=0;d<e;d++)h=k[d][1],h=i.value[h],i.array[g]=h.r,i.array[g+1]=h.g,i.array[g+2]=h.b,g+=3;else for(d=0;d<e;d++)h=k[d][1],h=i.value[h],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,g+=3;else if(4===i.size)for(d=0;d<e;d++)h=k[d][1],h=i.value[h],
i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,i.array[g+3]=h.w,g+=4}else{if(o)for(d=0;d<h;d++)e=i[d].position,g=3*d,n[g]=e.x,n[g+1]=e.y,n[g+2]=e.z;if(p)for(d=0;d<m;d++)e=j[d],g=3*d,l[g]=e.r,l[g+1]=e.g,l[g+2]=e.b;if(r)for(j=0,m=r.length;j<m;j++)if(i=r[j],i.needsUpdate&&(void 0===i.boundTo||"vertices"===i.boundTo))if(e=i.value.length,g=0,1===i.size)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(2===i.size)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,g+=2;else if(3===i.size)if("c"===
i.type)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.r,i.array[g+1]=h.g,i.array[g+2]=h.b,g+=3;else for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,g+=3;else if(4===i.size)for(d=0;d<e;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+=4}if(o||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,n,b);if(p||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,
l,b);if(r)for(j=0,m=r.length;j<m;j++)if(i=r[j],i.needsUpdate||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,i.buffer),f.bufferData(f.ARRAY_BUFFER,i.array,b)}function h(a,b){return b.z-a.z}function i(a,b,c){if(a.length)for(var d=0,f=a.length;d<f;d++)fb=null,L=ma=va=Z=W=-1,a[d].render(b,c,Nb,ac),fb=null,L=ma=va=Z=W=-1}function k(a,b,c,d,f,e,g,h){var i,j,m,n;b?(j=a.length-1,n=b=-1):(j=0,b=a.length,n=1);for(var l=j;l!==b;l+=n)if(i=a[l],i.render){j=i.object;m=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
g&&A.setBlending(i.blending);A.setDepthTest(i.depthTest);A.setDepthWrite(i.depthWrite);z(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}A.setObjectFaces(j);m instanceof THREE.BufferGeometry?A.renderBufferDirect(d,f,e,i,m,j):A.renderBuffer(d,f,e,i,m,j)}}function m(a,b,c,d,f,e,g){for(var h,i,j=0,m=a.length;j<m;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;e&&A.setBlending(h.blending);A.setDepthTest(h.depthTest);A.setDepthWrite(h.depthWrite);z(h.polygonOffset,h.polygonOffsetFactor,
h.polygonOffsetUnits)}A.renderImmediateObject(c,d,f,h,i)}}function j(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function o(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function p(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function l(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){d.program||A.initMaterial(d,b,c,e);if(d.morphTargets&&
!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(A.maxMorphTargets);for(var g=0,h=A.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==fb&&(f.useProgram(g),fb=g,i=!0);if(d.id!==L)L=d.id,i=!0;if(i){f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(j.fogColor.value=c.color,c instanceof THREE.Fog)j.fogNear.value=c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=
c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var m,n,l=0,k=0,o=0,p,r,t=bc,u=t.directional.colors,z=t.directional.positions,y=t.point.colors,B=t.point.positions,N=t.point.distances,D=0,I=0,M=r=0;for(c=0,i=b.length;c<i;c++)if(m=b[c],n=m.color,p=m.intensity,r=m.distance,m instanceof THREE.AmbientLight)A.gammaInput?(l+=n.r*n.r,k+=n.g*n.g,o+=n.b*n.b):(l+=n.r,k+=n.g,o+=n.b);else if(m instanceof THREE.DirectionalLight)r=3*D,A.gammaInput?(u[r]=n.r*n.r*
p*p,u[r+1]=n.g*n.g*p*p,u[r+2]=n.b*n.b*p*p):(u[r]=n.r*p,u[r+1]=n.g*p,u[r+2]=n.b*p),m=m.matrixWorld.getPosition(),n=1/m.length(),z[r]=m.x*n,z[r+1]=m.y*n,z[r+2]=m.z*n,D+=1;else if(m instanceof THREE.SpotLight&&!m.onlyShadow)r=3*D,A.gammaInput?(u[r]=n.r*n.r*p*p,u[r+1]=n.g*n.g*p*p,u[r+2]=n.b*n.b*p*p):(u[r]=n.r*p,u[r+1]=n.g*p,u[r+2]=n.b*p),m=m.matrixWorld.getPosition(),n=1/m.length(),z[r]=m.x*n,z[r+1]=m.y*n,z[r+2]=m.z*n,D+=1;else if(m instanceof THREE.PointLight)M=3*I,A.gammaInput?(y[M]=n.r*n.r*p*p,y[M+
1]=n.g*n.g*p*p,y[M+2]=n.b*n.b*p*p):(y[M]=n.r*p,y[M+1]=n.g*p,y[M+2]=n.b*p),m=m.matrixWorld.getPosition(),B[M]=m.x,B[M+1]=m.y,B[M+2]=m.z,N[I]=r,I+=1;for(c=3*D,i=u.length;c<i;c++)u[c]=0;for(c=3*I,i=y.length;c<i;c++)y[c]=0;t.point.length=I;t.directional.length=D;t.ambient[0]=l;t.ambient[1]=k;t.ambient[2]=o;c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=
c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,A.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 THREE.LineBasicMaterial)j.diffuse.value=d.color,j.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)j.psColor.value=d.color,j.opacity.value=d.opacity,j.size.value=d.size,j.scale.value=H.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=
d.shininess,A.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.specular.value.copyGammaToLinear(d.specular)):(j.ambient.value=d.ambient,j.specular.value=d.specular),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)A.gammaInput?j.ambient.value.copyGammaToLinear(d.ambient):j.ambient.value=d.ambient,d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=d.opacity;
else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&j.shadowMatrix){i=c=0;for(l=b.length;i<l;i++)if(k=b[i],k.castShadow&&k instanceof THREE.SpotLight)j.shadowMap.texture[c]=k.shadowMap,j.shadowMapSize.value[c]=k.shadowMapSize,j.shadowMatrix.value[c]=k.shadowMatrix,j.shadowDarkness.value[c]=k.shadowDarkness,j.shadowBias.value[c]=k.shadowBias,c++}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(k=g.uniforms[b[j][1]])if(i=b[j][0],o=i.type,l=i.value,
"i"===o)f.uniform1i(k,l);else if("f"===o)f.uniform1f(k,l);else if("v2"===o)f.uniform2f(k,l.x,l.y);else if("v3"===o)f.uniform3f(k,l.x,l.y,l.z);else if("v4"===o)f.uniform4f(k,l.x,l.y,l.z,l.w);else if("c"===o)f.uniform3f(k,l.r,l.g,l.b);else if("fv1"===o)f.uniform1fv(k,l);else if("fv"===o)f.uniform3fv(k,l);else if("v2v"===o){if(!i._array)i._array=new Float32Array(2*l.length);for(o=0,t=l.length;o<t;o++)u=2*o,i._array[u]=l[o].x,i._array[u+1]=l[o].y;f.uniform2fv(k,i._array)}else if("v3v"===o){if(!i._array)i._array=
new Float32Array(3*l.length);for(o=0,t=l.length;o<t;o++)u=3*o,i._array[u]=l[o].x,i._array[u+1]=l[o].y,i._array[u+2]=l[o].z;f.uniform3fv(k,i._array)}else if("m4"===o){if(!i._array)i._array=new Float32Array(16);l.flattenToArray(i._array);f.uniformMatrix4fv(k,!1,i._array)}else if("m4v"===o){if(!i._array)i._array=new Float32Array(16*l.length);for(o=0,t=l.length;o<t;o++)l[o].flattenToArrayOffset(i._array,16*o);f.uniformMatrix4fv(k,!1,i._array)}else if("t"===o){if(f.uniform1i(k,l),k=i.texture)if(k.image instanceof
Array&&6===k.image.length){if(i=k,6===i.image.length)if(i.needsUpdate){if(!i.image.__webglTextureCube)i.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube);l=[];for(k=0;6>k;k++){o=l;t=k;if(A.autoScaleCubemaps){if(u=i.image[k],y=rc,!(u.width<=y&&u.height<=y))B=Math.max(u.width,u.height),z=Math.floor(u.width*y/B),y=Math.floor(u.height*y/B),B=document.createElement("canvas"),B.width=z,B.height=y,B.getContext("2d").drawImage(u,
0,0,u.width,u.height,0,0,z,y),u=B}else u=i.image[k];o[t]=u}k=l[0];o=0===(k.width&k.width-1)&&0===(k.height&k.height-1);t=J(i.format);u=J(i.type);K(f.TEXTURE_CUBE_MAP,i,o);for(k=0;6>k;k++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,t,t,u,l[k]);i.generateMipmaps&&o&&f.generateMipmap(f.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(i=k,f.activeTexture(f.TEXTURE0+
l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):A.setTexture(k,l)}else if("tv"===o){if(!i._array){i._array=[];for(o=0,t=i.texture.length;o<t;o++)i._array[o]=l+o}f.uniform1iv(k,i._array);for(o=0,t=i.texture.length;o<t;o++)(k=i.texture[o])&&A.setTexture(k,i._array[o])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==h.cameraPosition&&f.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof
THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==h.viewMatrix&&f.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(f.uniformMatrix4fv(h.cameraInverseMatrix,!1,a._viewMatrixArray),f.uniformMatrix4fv(h.boneGlobalMatrices,!1,e.boneMatrices))}f.uniformMatrix4fv(h.modelViewMatrix,!1,e._modelViewMatrixArray);h.normalMatrix&&f.uniformMatrix3fv(h.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&
null!==h.objectMatrix&&f.uniformMatrix4fv(h.objectMatrix,!1,e._objectMatrixArray);return g}function t(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function z(a,b,c){Ka!==a&&(a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),Ka=a);if(a&&(Ra!==b||lb!==c))f.polygonOffset(b,c),Ra=b,lb=c}function y(a,b){var c;"fragment"===a?c=f.createShader(f.FRAGMENT_SHADER):
"vertex"===a&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,b);f.compileShader(c);return!f.getShaderParameter(c,f.COMPILE_STATUS)?(console.error(f.getShaderInfoLog(c)),console.error(b),null):c}function K(a,b,c){c?(f.texParameteri(a,f.TEXTURE_WRAP_S,J(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,J(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,J(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,J(b.minFilter))):(f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_WRAP_T,
f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_MAG_FILTER,u(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,u(b.minFilter)))}function N(a,b){f.bindRenderbuffer(f.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,
f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,a)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height)}function u(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function J(a){switch(a){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;
case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;
case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var a=a||{},H=void 0!==a.canvas?a.canvas:document.createElement("canvas"),B=void 0!==a.precision?a.precision:"mediump",D=void 0!==a.antialias?a.antialias:!1,M=void 0!==a.stencil?a.stencil:!0,I=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,Q=void 0!==a.clearColor?new THREE.Color(a.clearColor):
new THREE.Color(0),ga=void 0!==a.clearAlpha?a.clearAlpha:0,xa=void 0!==a.maxLights?a.maxLights:4;this.domElement=H;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.autoScaleCubemaps=!0;this.renderPluginsPre=
[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var A=this,f,Ga=[],fb=null,sa=null,L=-1,ma=null,V=0,na=null,ha=null,W=null,Z=null,va=null,Ka=null,Ra=null,lb=null,Ma=null,gb=0,Na=0,yb=0,Db=0,Nb=0,ac=0,Ob=new THREE.Frustum,Sa=new THREE.Matrix4,Oa=new THREE.Vector4,bc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};f=function(){var a;try{if(!(a=H.getContext("experimental-webgl",
{antialias:D,stencil:M,preserveDrawingBuffer:I})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);
f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(Q.r,Q.g,Q.b,ga);this.context=f;var cc=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS);f.getParameter(f.TEXTURE_SIZE);var rc=f.getParameter(f.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return f};this.supportsVertexTextures=function(){return 0<cc};this.setSize=function(a,b){H.width=a;H.height=b;this.setViewport(0,0,H.width,H.height)};this.setViewport=function(a,b,c,d){gb=a;Na=b;yb=c;Db=d;f.viewport(gb,Na,yb,Db)};this.setScissor=
function(a,b,c,d){f.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(a,b){Q.setHex(a);ga=b;f.clearColor(Q.r,Q.g,Q.b,ga)};this.setClearColor=function(a,b){Q.copy(a);ga=b;f.clearColor(Q.r,Q.g,Q.b,ga)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return ga};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=f.COLOR_BUFFER_BIT;if(void 0===b||b)d|=f.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=
f.STENCIL_BUFFER_BIT;f.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=
a.geometry.geometryGroups[b];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);f.deleteBuffer(c.__webglTangentBuffer);f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=
0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)f.deleteBuffer(c.__webglCustomAttributesList[d].buffer);A.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),A.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),
A.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),A.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,f.deleteTexture(a.__webglTexture),A.info.memory.textures--};this.updateShadowMap=function(a,b){fb=null;L=ma=va=Z=W=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=f.createBuffer();
if(!a.__webglNormalBuffer)a.__webglNormalBuffer=f.createBuffer();a.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,a.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(b.attributes.position),f.vertexAttribPointer(b.attributes.position,3,f.FLOAT,!1,0,0));if(a.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,h,i,j,n,m,k,l,o=3*a.count;for(l=0;l<o;l+=9)c=a.normalArray,d=c[l],e=c[l+1],g=c[l+2],h=c[l+3],j=c[l+
4],m=c[l+5],i=c[l+6],n=c[l+7],k=c[l+8],d=(d+h+i)/3,e=(e+j+n)/3,g=(g+m+k)/3,c[l]=d,c[l+1]=e,c[l+2]=g,c[l+3]=d,c[l+4]=e,c[l+5]=g,c[l+6]=d,c[l+7]=e,c[l+8]=g}f.bufferData(f.ARRAY_BUFFER,a.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.normal);f.vertexAttribPointer(b.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,g){if(0!==d.opacity&&(c=r(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?
1:0),d!==ma&&(ma=d,b=!0),g instanceof THREE.Mesh)){g=e.offsets;d=0;for(c=g.length;d<c;++d)b&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexPositionBuffer),f.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,f.FLOAT,!1,0,12*g[d].index),0<=a.normal&&e.vertexNormalBuffer&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexNormalBuffer),f.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,f.FLOAT,!1,0,12*g[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(f.bindBuffer(f.ARRAY_BUFFER,e.vertexUvBuffer),
f.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,f.FLOAT,!1,0,8*g[d].index),f.enableVertexAttribArray(a.uv)):f.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexColorBuffer),f.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,f.FLOAT,!1,0,16*g[d].index)),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),f.drawElements(f.TRIANGLES,g[d].count,f.UNSIGNED_SHORT,2*g[d].start),A.info.render.calls++,A.info.render.vertices+=g[d].count,
A.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var h,i,c=r(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==ma&&(ma=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),f.vertexAttribPointer(c.position,
3,f.FLOAT,!1,0,0)):0<=c.position&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j[h]]),f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],l=-1,n=0;i=g.morphTargetInfluences;var m,
k=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(m=0;m<k;m++)!j[m]&&i[m]>l&&(n=m,l=i[n]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[n]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=l;j[n]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(h=0,i=
e.__webglCustomAttributesList.length;h<i;h++)c=e.__webglCustomAttributesList[h],0<=b[c.buffer.belongsToAttribute]&&(f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,f.FLOAT,!1,0,0));0<=b.color&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));0<=b.normal&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));0<=b.tangent&&(f.bindBuffer(f.ARRAY_BUFFER,
e.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));0<=b.uv&&(e.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglUVBuffer),f.vertexAttribPointer(b.uv,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));0<=b.uv2&&(e.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):f.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&
0<=b.skinIndex&&0<=b.skinWeight&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?
(d=d.wireframeLinewidth,d!==Ma&&(f.lineWidth(d),Ma=d),a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),f.drawElements(f.LINES,e.__webglLineCount,f.UNSIGNED_SHORT,0)):(a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),f.drawElements(f.TRIANGLES,e.__webglFaceCount,f.UNSIGNED_SHORT,0)),A.info.render.calls++,A.info.render.vertices+=e.__webglFaceCount,A.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES,d=d.linewidth,d!==
Ma&&(f.lineWidth(d),Ma=d),f.drawArrays(g,0,e.__webglLineCount),A.info.render.calls++):g instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,e.__webglParticleCount),A.info.render.calls++,A.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,e.__webglVertexCount),A.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,j,l,n=a.lights,o=a.fog;L=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);A.info.render.calls=0;A.info.render.vertices=0;A.info.render.faces=0;A.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Sa.multiply(b.projectionMatrix,
b.matrixWorldInverse);Ob.setFromMatrix(Sa);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;for(d=0,e=l.length;d<e;d++)if(g=l[d],j=g.object,g.render=!1,j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||Ob.contains(j))){j.matrixWorld.flattenToArray(j._objectMatrixArray);t(j,b);var p=g,r=p.object,u=p.buffer,y=void 0,y=y=void 0,y=r.material;if(y instanceof THREE.MeshFaceMaterial){if(y=
u.materialIndex,0<=y)y=r.geometry.materials[y],y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null)}else if(y)y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null);g.render=!0;if(this.sortObjects)j.renderDepth?g.z=j.renderDepth:(Oa.copy(j.position),Sa.multiplyVector3(Oa),g.z=Oa.z)}this.sortObjects&&l.sort(h);l=a.__webglObjectsImmediate;for(d=0,e=l.length;d<e;d++)if(g=l[d],j=g.object,j.visible)j.matrixAutoUpdate&&j.matrixWorld.flattenToArray(j._objectMatrixArray),
t(j,b),j=g.object.material,j.transparent?(g.transparent=j,g.opaque=null):(g.opaque=j,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),this.setDepthWrite(a.overrideMaterial.depthWrite),z(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,n,o,!0,a.overrideMaterial),m(a.__webglObjectsImmediate,"",b,n,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
k(a.__webglObjects,!0,"opaque",b,n,o,!1),m(a.__webglObjectsImmediate,"opaque",b,n,o,!1),k(a.__webglObjects,!1,"transparent",b,n,o,!0),m(a.__webglObjectsImmediate,"transparent",b,n,o,!0));i(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,c.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,
c.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var g=r(a,b,c,d,e);ma=-1;A.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Ob):e.render(function(a){A.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var h=
a.__objectsAdded[0],i=a,m=void 0,k=void 0,r=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var t=k,u=void 0,y=void 0,z=void 0,B=void 0,H=void 0,K=void 0,D=void 0,J={},N=t.morphTargets.length;
t.geometryGroups={};for(u=0,y=t.faces.length;u<y;u++)z=t.faces[u],B=z.materialIndex,K=void 0!==B?B:-1,void 0===J[K]&&(J[K]={hash:K,counter:0}),D=J[K].hash+"_"+J[K].counter,void 0===t.geometryGroups[D]&&(t.geometryGroups[D]={faces3:[],faces4:[],materialIndex:B,vertices:0,numMorphTargets:N}),H=z instanceof THREE.Face3?3:4,65535<t.geometryGroups[D].vertices+H&&(J[K].counter+=1,D=J[K].hash+"_"+J[K].counter,void 0===t.geometryGroups[D]&&(t.geometryGroups[D]={faces3:[],faces4:[],materialIndex:B,vertices:0,
numMorphTargets:N})),z instanceof THREE.Face3?t.geometryGroups[D].faces3.push(u):t.geometryGroups[D].faces4.push(u),t.geometryGroups[D].vertices+=H;t.geometryGroupsList=[];var M=void 0;for(M in t.geometryGroups)t.geometryGroups[M].id=V++,t.geometryGroupsList.push(t.geometryGroups[M])}for(m in k.geometryGroups)if(r=k.geometryGroups[m],!r.__webglVertexBuffer){var I=r;I.__webglVertexBuffer=f.createBuffer();I.__webglNormalBuffer=f.createBuffer();I.__webglTangentBuffer=f.createBuffer();I.__webglColorBuffer=
f.createBuffer();I.__webglUVBuffer=f.createBuffer();I.__webglUV2Buffer=f.createBuffer();I.__webglSkinVertexABuffer=f.createBuffer();I.__webglSkinVertexBBuffer=f.createBuffer();I.__webglSkinIndicesBuffer=f.createBuffer();I.__webglSkinWeightsBuffer=f.createBuffer();I.__webglFaceBuffer=f.createBuffer();I.__webglLineBuffer=f.createBuffer();if(I.numMorphTargets){var Q=void 0,Z=void 0;I.__webglMorphTargetsBuffers=[];for(Q=0,Z=I.numMorphTargets;Q<Z;Q++)I.__webglMorphTargetsBuffers.push(f.createBuffer())}A.info.memory.geometries++;
var L=r,ha=h,ga=ha.geometry,ma=L.faces3,na=L.faces4,W=3*ma.length+4*na.length,va=1*ma.length+2*na.length,xa=3*ma.length+4*na.length,sa=c(ha,L),Ga=e(sa),Ka=d(sa),Na=sa.vertexColors?sa.vertexColors:!1;L.__vertexArray=new Float32Array(3*W);if(Ka)L.__normalArray=new Float32Array(3*W);if(ga.hasTangents)L.__tangentArray=new Float32Array(4*W);if(Na)L.__colorArray=new Float32Array(3*W);if(Ga){if(0<ga.faceUvs.length||0<ga.faceVertexUvs.length)L.__uvArray=new Float32Array(2*W);if(1<ga.faceUvs.length||1<ga.faceVertexUvs.length)L.__uv2Array=
new Float32Array(2*W)}if(ha.geometry.skinWeights.length&&ha.geometry.skinIndices.length)L.__skinVertexAArray=new Float32Array(4*W),L.__skinVertexBArray=new Float32Array(4*W),L.__skinIndexArray=new Float32Array(4*W),L.__skinWeightArray=new Float32Array(4*W);L.__faceArray=new Uint16Array(3*va);L.__lineArray=new Uint16Array(2*xa);if(L.numMorphTargets){L.__morphTargetsArrays=[];for(var Ma=0,gb=L.numMorphTargets;Ma<gb;Ma++)L.__morphTargetsArrays.push(new Float32Array(3*W))}L.__webglFaceCount=3*va;L.__webglLineCount=
2*xa;if(sa.attributes){if(void 0===L.__webglCustomAttributesList)L.__webglCustomAttributesList=[];var Ra=void 0;for(Ra in sa.attributes){var Oa=sa.attributes[Ra],Da={},fb;for(fb in Oa)Da[fb]=Oa[fb];if(!Da.__webglInitialized||Da.createUniqueBuffers){Da.__webglInitialized=!0;var Eb=1;"v2"===Da.type?Eb=2:"v3"===Da.type?Eb=3:"v4"===Da.type?Eb=4:"c"===Da.type&&(Eb=3);Da.size=Eb;Da.array=new Float32Array(W*Eb);Da.buffer=f.createBuffer();Da.buffer.belongsToAttribute=Ra;Oa.needsUpdate=!0;Da.__original=Oa}L.__webglCustomAttributesList.push(Da)}}L.__inittedArrays=
!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}}else if(h instanceof THREE.Ribbon){if(k=h.geometry,!k.__webglVertexBuffer){var lb=k;lb.__webglVertexBuffer=f.createBuffer();lb.__webglColorBuffer=f.createBuffer();A.info.memory.geometries++;var Sa=k,yb=Sa.vertices.length;Sa.__vertexArray=new Float32Array(3*yb);Sa.__colorArray=new Float32Array(3*yb);Sa.__webglVertexCount=yb;k.__dirtyVertices=!0;k.__dirtyColors=
!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Db=k;Db.__webglVertexBuffer=f.createBuffer();Db.__webglColorBuffer=f.createBuffer();A.info.memory.geometries++;var Pb=k,Ob=h,sc=Pb.vertices.length;Pb.__vertexArray=new Float32Array(3*sc);Pb.__colorArray=new Float32Array(3*sc);Pb.__webglLineCount=sc;b(Pb,Ob);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Nb=k;Nb.__webglVertexBuffer=f.createBuffer();
Nb.__webglColorBuffer=f.createBuffer();A.info.geometries++;var Fb=k,ac=h,tc=Fb.vertices.length;Fb.__vertexArray=new Float32Array(3*tc);Fb.__colorArray=new Float32Array(3*tc);Fb.__sortArray=[];Fb.__webglParticleCount=tc;b(Fb,ac);k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!h.__webglActive){if(h instanceof THREE.Mesh)if(k=h.geometry,k instanceof THREE.BufferGeometry)j(i.__webglObjects,k,h);else for(m in k.geometryGroups)r=k.geometryGroups[m],j(i.__webglObjects,r,h);else h instanceof THREE.Ribbon||h instanceof
THREE.Line||h instanceof THREE.ParticleSystem?(k=h.geometry,j(i.__webglObjects,k,h)):void 0!==THREE.MarchingCubes&&h instanceof THREE.MarchingCubes||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=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Ha=a.__objectsRemoved[0],dc=a;Ha instanceof THREE.Mesh||Ha instanceof
THREE.ParticleSystem||Ha instanceof THREE.Ribbon||Ha instanceof THREE.Line?p(dc.__webglObjects,Ha):Ha instanceof THREE.Sprite?l(dc.__webglSprites,Ha):Ha instanceof THREE.LensFlare?l(dc.__webglFlares,Ha):(Ha instanceof THREE.MarchingCubes||Ha.immediateRenderCallback)&&p(dc.__webglObjectsImmediate,Ha);Ha.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var uc=0,bc=a.__webglObjects.length;uc<bc;uc++){var Pa=a.__webglObjects[uc].object,R=Pa.geometry,Qb=void 0,Gb=void 0,za=void 0;if(Pa instanceof THREE.Mesh)if(R instanceof
THREE.BufferGeometry)R.__dirtyVertices=!1,R.__dirtyElements=!1,R.__dirtyUvs=!1,R.__dirtyNormals=!1,R.__dirtyColors=!1;else{for(var vc=0,cc=R.geometryGroupsList.length;vc<cc;vc++)if(Qb=R.geometryGroupsList[vc],za=c(Pa,Qb),Gb=za.attributes&&n(za),R.__dirtyVertices||R.__dirtyMorphTargets||R.__dirtyElements||R.__dirtyUvs||R.__dirtyNormals||R.__dirtyColors||R.__dirtyTangents||Gb){var O=Qb,rc=Pa,Ea=f.DYNAMIC_DRAW,Pc=!R.dynamic,ec=za;if(O.__inittedArrays){var Dc=d(ec),wc=ec.vertexColors?ec.vertexColors:
!1,Ec=e(ec),Fc=Dc===THREE.SmoothShading,v=void 0,C=void 0,La=void 0,x=void 0,Hb=void 0,mb=void 0,Qa=void 0,fc=void 0,hb=void 0,Ib=void 0,Jb=void 0,E=void 0,F=void 0,G=void 0,X=void 0,Ta=void 0,Ua=void 0,Va=void 0,Rb=void 0,Wa=void 0,Xa=void 0,Ya=void 0,Sb=void 0,Za=void 0,$a=void 0,ab=void 0,Tb=void 0,bb=void 0,cb=void 0,db=void 0,Ub=void 0,nb=void 0,ob=void 0,pb=void 0,gc=void 0,qb=void 0,rb=void 0,sb=void 0,hc=void 0,S=void 0,Gc=void 0,tb=void 0,Kb=void 0,Lb=void 0,Fa=void 0,Hc=void 0,pa=void 0,
ia=0,oa=0,ib=0,jb=0,Ia=0,ua=0,Y=0,wa=0,ja=0,w=0,ka=0,s=0,Ba=void 0,qa=O.__vertexArray,Vb=O.__uvArray,Wb=O.__uv2Array,Ja=O.__normalArray,aa=O.__tangentArray,ra=O.__colorArray,ba=O.__skinVertexAArray,ca=O.__skinVertexBArray,da=O.__skinIndexArray,ea=O.__skinWeightArray,xc=O.__morphTargetsArrays,yc=O.__webglCustomAttributesList,q=void 0,eb=O.__faceArray,Ca=O.__lineArray,ya=rc.geometry,Qc=ya.__dirtyElements,Ic=ya.__dirtyUvs,Rc=ya.__dirtyNormals,Sc=ya.__dirtyTangents,Tc=ya.__dirtyColors,Uc=ya.__dirtyMorphTargets,
zb=ya.vertices,T=O.faces3,U=O.faces4,la=ya.faces,zc=ya.faceVertexUvs[0],Ac=ya.faceVertexUvs[1],Ab=ya.skinVerticesA,Bb=ya.skinVerticesB,Cb=ya.skinIndices,ub=ya.skinWeights,vb=ya.morphTargets;if(ya.__dirtyVertices){for(v=0,C=T.length;v<C;v++)x=la[T[v]],E=zb[x.a].position,F=zb[x.b].position,G=zb[x.c].position,qa[oa]=E.x,qa[oa+1]=E.y,qa[oa+2]=E.z,qa[oa+3]=F.x,qa[oa+4]=F.y,qa[oa+5]=F.z,qa[oa+6]=G.x,qa[oa+7]=G.y,qa[oa+8]=G.z,oa+=9;for(v=0,C=U.length;v<C;v++)x=la[U[v]],E=zb[x.a].position,F=zb[x.b].position,
G=zb[x.c].position,X=zb[x.d].position,qa[oa]=E.x,qa[oa+1]=E.y,qa[oa+2]=E.z,qa[oa+3]=F.x,qa[oa+4]=F.y,qa[oa+5]=F.z,qa[oa+6]=G.x,qa[oa+7]=G.y,qa[oa+8]=G.z,qa[oa+9]=X.x,qa[oa+10]=X.y,qa[oa+11]=X.z,oa+=12;f.bindBuffer(f.ARRAY_BUFFER,O.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,qa,Ea)}if(Uc)for(Fa=0,Hc=vb.length;Fa<Hc;Fa++){ka=0;for(v=0,C=T.length;v<C;v++)x=la[T[v]],E=vb[Fa].vertices[x.a].position,F=vb[Fa].vertices[x.b].position,G=vb[Fa].vertices[x.c].position,pa=xc[Fa],pa[ka]=E.x,pa[ka+1]=E.y,pa[ka+
2]=E.z,pa[ka+3]=F.x,pa[ka+4]=F.y,pa[ka+5]=F.z,pa[ka+6]=G.x,pa[ka+7]=G.y,pa[ka+8]=G.z,ka+=9;for(v=0,C=U.length;v<C;v++)x=la[U[v]],E=vb[Fa].vertices[x.a].position,F=vb[Fa].vertices[x.b].position,G=vb[Fa].vertices[x.c].position,X=vb[Fa].vertices[x.d].position,pa=xc[Fa],pa[ka]=E.x,pa[ka+1]=E.y,pa[ka+2]=E.z,pa[ka+3]=F.x,pa[ka+4]=F.y,pa[ka+5]=F.z,pa[ka+6]=G.x,pa[ka+7]=G.y,pa[ka+8]=G.z,pa[ka+9]=X.x,pa[ka+10]=X.y,pa[ka+11]=X.z,ka+=12;f.bindBuffer(f.ARRAY_BUFFER,O.__webglMorphTargetsBuffers[Fa]);f.bufferData(f.ARRAY_BUFFER,
xc[Fa],Ea)}if(ub.length){for(v=0,C=T.length;v<C;v++)x=la[T[v]],Za=ub[x.a],$a=ub[x.b],ab=ub[x.c],ea[w]=Za.x,ea[w+1]=Za.y,ea[w+2]=Za.z,ea[w+3]=Za.w,ea[w+4]=$a.x,ea[w+5]=$a.y,ea[w+6]=$a.z,ea[w+7]=$a.w,ea[w+8]=ab.x,ea[w+9]=ab.y,ea[w+10]=ab.z,ea[w+11]=ab.w,bb=Cb[x.a],cb=Cb[x.b],db=Cb[x.c],da[w]=bb.x,da[w+1]=bb.y,da[w+2]=bb.z,da[w+3]=bb.w,da[w+4]=cb.x,da[w+5]=cb.y,da[w+6]=cb.z,da[w+7]=cb.w,da[w+8]=db.x,da[w+9]=db.y,da[w+10]=db.z,da[w+11]=db.w,nb=Ab[x.a],ob=Ab[x.b],pb=Ab[x.c],ba[w]=nb.x,ba[w+1]=nb.y,ba[w+
2]=nb.z,ba[w+3]=1,ba[w+4]=ob.x,ba[w+5]=ob.y,ba[w+6]=ob.z,ba[w+7]=1,ba[w+8]=pb.x,ba[w+9]=pb.y,ba[w+10]=pb.z,ba[w+11]=1,qb=Bb[x.a],rb=Bb[x.b],sb=Bb[x.c],ca[w]=qb.x,ca[w+1]=qb.y,ca[w+2]=qb.z,ca[w+3]=1,ca[w+4]=rb.x,ca[w+5]=rb.y,ca[w+6]=rb.z,ca[w+7]=1,ca[w+8]=sb.x,ca[w+9]=sb.y,ca[w+10]=sb.z,ca[w+11]=1,w+=12;for(v=0,C=U.length;v<C;v++)x=la[U[v]],Za=ub[x.a],$a=ub[x.b],ab=ub[x.c],Tb=ub[x.d],ea[w]=Za.x,ea[w+1]=Za.y,ea[w+2]=Za.z,ea[w+3]=Za.w,ea[w+4]=$a.x,ea[w+5]=$a.y,ea[w+6]=$a.z,ea[w+7]=$a.w,ea[w+8]=ab.x,
ea[w+9]=ab.y,ea[w+10]=ab.z,ea[w+11]=ab.w,ea[w+12]=Tb.x,ea[w+13]=Tb.y,ea[w+14]=Tb.z,ea[w+15]=Tb.w,bb=Cb[x.a],cb=Cb[x.b],db=Cb[x.c],Ub=Cb[x.d],da[w]=bb.x,da[w+1]=bb.y,da[w+2]=bb.z,da[w+3]=bb.w,da[w+4]=cb.x,da[w+5]=cb.y,da[w+6]=cb.z,da[w+7]=cb.w,da[w+8]=db.x,da[w+9]=db.y,da[w+10]=db.z,da[w+11]=db.w,da[w+12]=Ub.x,da[w+13]=Ub.y,da[w+14]=Ub.z,da[w+15]=Ub.w,nb=Ab[x.a],ob=Ab[x.b],pb=Ab[x.c],gc=Ab[x.d],ba[w]=nb.x,ba[w+1]=nb.y,ba[w+2]=nb.z,ba[w+3]=1,ba[w+4]=ob.x,ba[w+5]=ob.y,ba[w+6]=ob.z,ba[w+7]=1,ba[w+8]=
pb.x,ba[w+9]=pb.y,ba[w+10]=pb.z,ba[w+11]=1,ba[w+12]=gc.x,ba[w+13]=gc.y,ba[w+14]=gc.z,ba[w+15]=1,qb=Bb[x.a],rb=Bb[x.b],sb=Bb[x.c],hc=Bb[x.d],ca[w]=qb.x,ca[w+1]=qb.y,ca[w+2]=qb.z,ca[w+3]=1,ca[w+4]=rb.x,ca[w+5]=rb.y,ca[w+6]=rb.z,ca[w+7]=1,ca[w+8]=sb.x,ca[w+9]=sb.y,ca[w+10]=sb.z,ca[w+11]=1,ca[w+12]=hc.x,ca[w+13]=hc.y,ca[w+14]=hc.z,ca[w+15]=1,w+=16;0<w&&(f.bindBuffer(f.ARRAY_BUFFER,O.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,ba,Ea),f.bindBuffer(f.ARRAY_BUFFER,O.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,
ca,Ea),f.bindBuffer(f.ARRAY_BUFFER,O.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,da,Ea),f.bindBuffer(f.ARRAY_BUFFER,O.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ea,Ea))}if(Tc&&wc){for(v=0,C=T.length;v<C;v++)x=la[T[v]],Qa=x.vertexColors,fc=x.color,3===Qa.length&&wc===THREE.VertexColors?(Wa=Qa[0],Xa=Qa[1],Ya=Qa[2]):Ya=Xa=Wa=fc,ra[ja]=Wa.r,ra[ja+1]=Wa.g,ra[ja+2]=Wa.b,ra[ja+3]=Xa.r,ra[ja+4]=Xa.g,ra[ja+5]=Xa.b,ra[ja+6]=Ya.r,ra[ja+7]=Ya.g,ra[ja+8]=Ya.b,ja+=9;for(v=0,C=U.length;v<C;v++)x=
la[U[v]],Qa=x.vertexColors,fc=x.color,4===Qa.length&&wc===THREE.VertexColors?(Wa=Qa[0],Xa=Qa[1],Ya=Qa[2],Sb=Qa[3]):Sb=Ya=Xa=Wa=fc,ra[ja]=Wa.r,ra[ja+1]=Wa.g,ra[ja+2]=Wa.b,ra[ja+3]=Xa.r,ra[ja+4]=Xa.g,ra[ja+5]=Xa.b,ra[ja+6]=Ya.r,ra[ja+7]=Ya.g,ra[ja+8]=Ya.b,ra[ja+9]=Sb.r,ra[ja+10]=Sb.g,ra[ja+11]=Sb.b,ja+=12;0<ja&&(f.bindBuffer(f.ARRAY_BUFFER,O.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,ra,Ea))}if(Sc&&ya.hasTangents){for(v=0,C=T.length;v<C;v++)x=la[T[v]],hb=x.vertexTangents,Ta=hb[0],Ua=hb[1],Va=hb[2],
aa[Y]=Ta.x,aa[Y+1]=Ta.y,aa[Y+2]=Ta.z,aa[Y+3]=Ta.w,aa[Y+4]=Ua.x,aa[Y+5]=Ua.y,aa[Y+6]=Ua.z,aa[Y+7]=Ua.w,aa[Y+8]=Va.x,aa[Y+9]=Va.y,aa[Y+10]=Va.z,aa[Y+11]=Va.w,Y+=12;for(v=0,C=U.length;v<C;v++)x=la[U[v]],hb=x.vertexTangents,Ta=hb[0],Ua=hb[1],Va=hb[2],Rb=hb[3],aa[Y]=Ta.x,aa[Y+1]=Ta.y,aa[Y+2]=Ta.z,aa[Y+3]=Ta.w,aa[Y+4]=Ua.x,aa[Y+5]=Ua.y,aa[Y+6]=Ua.z,aa[Y+7]=Ua.w,aa[Y+8]=Va.x,aa[Y+9]=Va.y,aa[Y+10]=Va.z,aa[Y+11]=Va.w,aa[Y+12]=Rb.x,aa[Y+13]=Rb.y,aa[Y+14]=Rb.z,aa[Y+15]=Rb.w,Y+=16;f.bindBuffer(f.ARRAY_BUFFER,
O.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,aa,Ea)}if(Rc&&Dc){for(v=0,C=T.length;v<C;v++)if(x=la[T[v]],Hb=x.vertexNormals,mb=x.normal,3===Hb.length&&Fc)for(S=0;3>S;S++)tb=Hb[S],Ja[ua]=tb.x,Ja[ua+1]=tb.y,Ja[ua+2]=tb.z,ua+=3;else for(S=0;3>S;S++)Ja[ua]=mb.x,Ja[ua+1]=mb.y,Ja[ua+2]=mb.z,ua+=3;for(v=0,C=U.length;v<C;v++)if(x=la[U[v]],Hb=x.vertexNormals,mb=x.normal,4===Hb.length&&Fc)for(S=0;4>S;S++)tb=Hb[S],Ja[ua]=tb.x,Ja[ua+1]=tb.y,Ja[ua+2]=tb.z,ua+=3;else for(S=0;4>S;S++)Ja[ua]=mb.x,Ja[ua+1]=
mb.y,Ja[ua+2]=mb.z,ua+=3;f.bindBuffer(f.ARRAY_BUFFER,O.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ja,Ea)}if(Ic&&zc&&Ec){for(v=0,C=T.length;v<C;v++)if(La=T[v],x=la[La],Ib=zc[La],void 0!==Ib)for(S=0;3>S;S++)Kb=Ib[S],Vb[ib]=Kb.u,Vb[ib+1]=Kb.v,ib+=2;for(v=0,C=U.length;v<C;v++)if(La=U[v],x=la[La],Ib=zc[La],void 0!==Ib)for(S=0;4>S;S++)Kb=Ib[S],Vb[ib]=Kb.u,Vb[ib+1]=Kb.v,ib+=2;0<ib&&(f.bindBuffer(f.ARRAY_BUFFER,O.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,Vb,Ea))}if(Ic&&Ac&&Ec){for(v=0,C=T.length;v<
C;v++)if(La=T[v],x=la[La],Jb=Ac[La],void 0!==Jb)for(S=0;3>S;S++)Lb=Jb[S],Wb[jb]=Lb.u,Wb[jb+1]=Lb.v,jb+=2;for(v=0,C=U.length;v<C;v++)if(La=U[v],x=la[La],Jb=Ac[La],void 0!==Jb)for(S=0;4>S;S++)Lb=Jb[S],Wb[jb]=Lb.u,Wb[jb+1]=Lb.v,jb+=2;0<jb&&(f.bindBuffer(f.ARRAY_BUFFER,O.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,Wb,Ea))}if(Qc){for(v=0,C=T.length;v<C;v++)x=la[T[v]],eb[Ia]=ia,eb[Ia+1]=ia+1,eb[Ia+2]=ia+2,Ia+=3,Ca[wa]=ia,Ca[wa+1]=ia+1,Ca[wa+2]=ia,Ca[wa+3]=ia+2,Ca[wa+4]=ia+1,Ca[wa+5]=ia+2,wa+=6,ia+=3;
for(v=0,C=U.length;v<C;v++)x=la[U[v]],eb[Ia]=ia,eb[Ia+1]=ia+1,eb[Ia+2]=ia+3,eb[Ia+3]=ia+1,eb[Ia+4]=ia+2,eb[Ia+5]=ia+3,Ia+=6,Ca[wa]=ia,Ca[wa+1]=ia+1,Ca[wa+2]=ia,Ca[wa+3]=ia+3,Ca[wa+4]=ia+1,Ca[wa+5]=ia+2,Ca[wa+6]=ia+2,Ca[wa+7]=ia+3,wa+=8,ia+=4;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,O.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,eb,Ea);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,O.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ca,Ea)}if(yc)for(S=0,Gc=yc.length;S<Gc;S++)if(q=yc[S],q.__original.needsUpdate){s=
0;if(1===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(v=0,C=T.length;v<C;v++)x=la[T[v]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],s+=3;for(v=0,C=U.length;v<C;v++)x=la[U[v]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],q.array[s+3]=q.value[x.d],s+=4}else{if("faces"===q.boundTo){for(v=0,C=T.length;v<C;v++)Ba=q.value[T[v]],q.array[s]=Ba,q.array[s+1]=Ba,q.array[s+2]=Ba,s+=3;for(v=0,C=U.length;v<C;v++)Ba=q.value[U[v]],q.array[s]=
Ba,q.array[s+1]=Ba,q.array[s+2]=Ba,q.array[s+3]=Ba,s+=4}}else if(2===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(v=0,C=T.length;v<C;v++)x=la[T[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=F.x,q.array[s+3]=F.y,q.array[s+4]=G.x,q.array[s+5]=G.y,s+=6;for(v=0,C=U.length;v<C;v++)x=la[U[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],X=q.value[x.d],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=F.x,q.array[s+3]=F.y,q.array[s+4]=G.x,q.array[s+
5]=G.y,q.array[s+6]=X.x,q.array[s+7]=X.y,s+=8}else{if("faces"===q.boundTo){for(v=0,C=T.length;v<C;v++)G=F=E=Ba=q.value[T[v]],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=F.x,q.array[s+3]=F.y,q.array[s+4]=G.x,q.array[s+5]=G.y,s+=6;for(v=0,C=U.length;v<C;v++)X=G=F=E=Ba=q.value[U[v]],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=F.x,q.array[s+3]=F.y,q.array[s+4]=G.x,q.array[s+5]=G.y,q.array[s+6]=X.x,q.array[s+7]=X.y,s+=8}}else if(3===q.size){var P;P="c"===q.type?["r","g","b"]:["x","y","z"];if(void 0===
q.boundTo||"vertices"===q.boundTo){for(v=0,C=T.length;v<C;v++)x=la[T[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],q.array[s]=E[P[0]],q.array[s+1]=E[P[1]],q.array[s+2]=E[P[2]],q.array[s+3]=F[P[0]],q.array[s+4]=F[P[1]],q.array[s+5]=F[P[2]],q.array[s+6]=G[P[0]],q.array[s+7]=G[P[1]],q.array[s+8]=G[P[2]],s+=9;for(v=0,C=U.length;v<C;v++)x=la[U[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],X=q.value[x.d],q.array[s]=E[P[0]],q.array[s+1]=E[P[1]],q.array[s+2]=E[P[2]],q.array[s+3]=F[P[0]],q.array[s+4]=
F[P[1]],q.array[s+5]=F[P[2]],q.array[s+6]=G[P[0]],q.array[s+7]=G[P[1]],q.array[s+8]=G[P[2]],q.array[s+9]=X[P[0]],q.array[s+10]=X[P[1]],q.array[s+11]=X[P[2]],s+=12}else if("faces"===q.boundTo){for(v=0,C=T.length;v<C;v++)G=F=E=Ba=q.value[T[v]],q.array[s]=E[P[0]],q.array[s+1]=E[P[1]],q.array[s+2]=E[P[2]],q.array[s+3]=F[P[0]],q.array[s+4]=F[P[1]],q.array[s+5]=F[P[2]],q.array[s+6]=G[P[0]],q.array[s+7]=G[P[1]],q.array[s+8]=G[P[2]],s+=9;for(v=0,C=U.length;v<C;v++)X=G=F=E=Ba=q.value[U[v]],q.array[s]=E[P[0]],
q.array[s+1]=E[P[1]],q.array[s+2]=E[P[2]],q.array[s+3]=F[P[0]],q.array[s+4]=F[P[1]],q.array[s+5]=F[P[2]],q.array[s+6]=G[P[0]],q.array[s+7]=G[P[1]],q.array[s+8]=G[P[2]],q.array[s+9]=X[P[0]],q.array[s+10]=X[P[1]],q.array[s+11]=X[P[2]],s+=12}}else if(4===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(v=0,C=T.length;v<C;v++)x=la[T[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=E.z,q.array[s+3]=E.w,q.array[s+4]=F.x,q.array[s+5]=F.y,q.array[s+6]=
F.z,q.array[s+7]=F.w,q.array[s+8]=G.x,q.array[s+9]=G.y,q.array[s+10]=G.z,q.array[s+11]=G.w,s+=12;for(v=0,C=U.length;v<C;v++)x=la[U[v]],E=q.value[x.a],F=q.value[x.b],G=q.value[x.c],X=q.value[x.d],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=E.z,q.array[s+3]=E.w,q.array[s+4]=F.x,q.array[s+5]=F.y,q.array[s+6]=F.z,q.array[s+7]=F.w,q.array[s+8]=G.x,q.array[s+9]=G.y,q.array[s+10]=G.z,q.array[s+11]=G.w,q.array[s+12]=X.x,q.array[s+13]=X.y,q.array[s+14]=X.z,q.array[s+15]=X.w,s+=16}else if("faces"===q.boundTo){for(v=
0,C=T.length;v<C;v++)G=F=E=Ba=q.value[T[v]],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=E.z,q.array[s+3]=E.w,q.array[s+4]=F.x,q.array[s+5]=F.y,q.array[s+6]=F.z,q.array[s+7]=F.w,q.array[s+8]=G.x,q.array[s+9]=G.y,q.array[s+10]=G.z,q.array[s+11]=G.w,s+=12;for(v=0,C=U.length;v<C;v++)X=G=F=E=Ba=q.value[U[v]],q.array[s]=E.x,q.array[s+1]=E.y,q.array[s+2]=E.z,q.array[s+3]=E.w,q.array[s+4]=F.x,q.array[s+5]=F.y,q.array[s+6]=F.z,q.array[s+7]=F.w,q.array[s+8]=G.x,q.array[s+9]=G.y,q.array[s+10]=G.z,q.array[s+
11]=G.w,q.array[s+12]=X.x,q.array[s+13]=X.y,q.array[s+14]=X.z,q.array[s+15]=X.w,s+=16}f.bindBuffer(f.ARRAY_BUFFER,q.buffer);f.bufferData(f.ARRAY_BUFFER,q.array,Ea)}Pc&&(delete O.__inittedArrays,delete O.__colorArray,delete O.__normalArray,delete O.__tangentArray,delete O.__uvArray,delete O.__uv2Array,delete O.__faceArray,delete O.__vertexArray,delete O.__lineArray,delete O.__skinVertexAArray,delete O.__skinVertexBArray,delete O.__skinIndexArray,delete O.__skinWeightArray)}}R.__dirtyVertices=!1;R.__dirtyMorphTargets=
!1;R.__dirtyElements=!1;R.__dirtyUvs=!1;R.__dirtyNormals=!1;R.__dirtyColors=!1;R.__dirtyTangents=!1;za.attributes&&o(za)}else if(Pa instanceof THREE.Ribbon){if(R.__dirtyVertices||R.__dirtyColors){var wb=R,Jc=f.DYNAMIC_DRAW,Xb=void 0,Yb=void 0,ic=void 0,xb=void 0,jc=void 0,Kc=wb.vertices,Lc=wb.colors,Vc=Kc.length,Wc=Lc.length,kc=wb.__vertexArray,lc=wb.__colorArray,Xc=wb.__dirtyColors;if(wb.__dirtyVertices){for(Xb=0;Xb<Vc;Xb++)ic=Kc[Xb].position,xb=3*Xb,kc[xb]=ic.x,kc[xb+1]=ic.y,kc[xb+2]=ic.z;f.bindBuffer(f.ARRAY_BUFFER,
wb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,kc,Jc)}if(Xc){for(Yb=0;Yb<Wc;Yb++)jc=Lc[Yb],xb=3*Yb,lc[xb]=jc.r,lc[xb+1]=jc.g,lc[xb+2]=jc.b;f.bindBuffer(f.ARRAY_BUFFER,wb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,lc,Jc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1}else if(Pa instanceof THREE.Line){za=c(Pa,Qb);Gb=za.attributes&&n(za);if(R.__dirtyVertices||R.__dirtyColors||Gb){var kb=R,Bc=f.DYNAMIC_DRAW,Zb=void 0,$b=void 0,mc=void 0,fa=void 0,nc=void 0,Mc=kb.vertices,Nc=kb.colors,Yc=Mc.length,
Zc=Nc.length,oc=kb.__vertexArray,pc=kb.__colorArray,$c=kb.__dirtyColors,Cc=kb.__webglCustomAttributesList,qc=void 0,Oc=void 0,ta=void 0,Mb=void 0,Aa=void 0,$=void 0;if(kb.__dirtyVertices){for(Zb=0;Zb<Yc;Zb++)mc=Mc[Zb].position,fa=3*Zb,oc[fa]=mc.x,oc[fa+1]=mc.y,oc[fa+2]=mc.z;f.bindBuffer(f.ARRAY_BUFFER,kb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,oc,Bc)}if($c){for($b=0;$b<Zc;$b++)nc=Nc[$b],fa=3*$b,pc[fa]=nc.r,pc[fa+1]=nc.g,pc[fa+2]=nc.b;f.bindBuffer(f.ARRAY_BUFFER,kb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,
pc,Bc)}if(Cc)for(qc=0,Oc=Cc.length;qc<Oc;qc++)if($=Cc[qc],$.needsUpdate&&(void 0===$.boundTo||"vertices"===$.boundTo)){fa=0;Mb=$.value.length;if(1===$.size)for(ta=0;ta<Mb;ta++)$.array[ta]=$.value[ta];else if(2===$.size)for(ta=0;ta<Mb;ta++)Aa=$.value[ta],$.array[fa]=Aa.x,$.array[fa+1]=Aa.y,fa+=2;else if(3===$.size)if("c"===$.type)for(ta=0;ta<Mb;ta++)Aa=$.value[ta],$.array[fa]=Aa.r,$.array[fa+1]=Aa.g,$.array[fa+2]=Aa.b,fa+=3;else for(ta=0;ta<Mb;ta++)Aa=$.value[ta],$.array[fa]=Aa.x,$.array[fa+1]=Aa.y,
$.array[fa+2]=Aa.z,fa+=3;else if(4===$.size)for(ta=0;ta<Mb;ta++)Aa=$.value[ta],$.array[fa]=Aa.x,$.array[fa+1]=Aa.y,$.array[fa+2]=Aa.z,$.array[fa+3]=Aa.w,fa+=4;f.bindBuffer(f.ARRAY_BUFFER,$.buffer);f.bufferData(f.ARRAY_BUFFER,$.array,Bc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1;za.attributes&&o(za)}else if(Pa instanceof THREE.ParticleSystem)za=c(Pa,Qb),Gb=za.attributes&&n(za),(R.__dirtyVertices||R.__dirtyColors||Pa.sortParticles||Gb)&&g(R,f.DYNAMIC_DRAW,Pa),R.__dirtyVertices=!1,R.__dirtyColors=!1,
za.attributes&&o(za)}};this.initMaterial=function(a,b,c,d){var e,g,h,i,j;a instanceof THREE.MeshDepthMaterial?j="depth":a instanceof THREE.MeshNormalMaterial?j="normal":a instanceof THREE.MeshBasicMaterial?j="basic":a instanceof THREE.MeshLambertMaterial?j="lambert":a instanceof THREE.MeshPhongMaterial?j="phong":a instanceof THREE.LineBasicMaterial?j="basic":a instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);
a.vertexShader=k.vertexShader;a.fragmentShader=k.fragmentShader}var l,n;g=k=0;for(l=0,n=b.length;l<n;l++)e=b[l],e instanceof THREE.SpotLight&&!e.onlyShadow&&g++,e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&k++;k+g<=xa?l=g:(l=Math.ceil(xa*g/(k+g)),k=xa-l);e=l;g=k;var m=0;for(k=0,l=b.length;k<l;k++)n=b[k],n instanceof THREE.SpotLight&&n.castShadow&&m++;var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;var p;a:{l=a.fragmentShader;n=a.vertexShader;var k=
a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:e,maxPointLights:g,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},r,d=[];j?d.push(j):(d.push(l),
d.push(n));for(r in c)d.push(r),d.push(c[r]);j=d.join();for(r=0,d=Ga.length;r<d;r++)if(Ga[r].code===j){p=Ga[r].program;break a}r=f.createProgram();d=[0<cc?"#define VERTEX_TEXTURES":"",A.gammaInput?"#define GAMMA_INPUT":"",A.gammaOutput?"#define GAMMA_OUTPUT":"",A.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":
"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\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;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
e=["precision "+B+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",A.gammaInput?"#define GAMMA_INPUT":"",A.gammaOutput?"#define GAMMA_OUTPUT":"",A.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(r,y("fragment",e+l));f.attachShader(r,y("vertex",d+n));f.linkProgram(r);f.getProgramParameter(r,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+
f.getProgramParameter(r,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");r.uniforms={};r.attributes={};var t,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,cameraInverseMatrix,boneGlobalMatrices,morphTargetInfluences".split(",");for(t in k)d.push(t);t=d;for(d=0,k=t.length;d<k;d++)l=t[d],r.uniforms[l]=f.getUniformLocation(r,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(t=0;t<c.maxMorphTargets;t++)d.push("morphTarget"+
t);for(p in b)d.push(p);p=d;for(t=0,b=p.length;t<b;t++)c=p[t],r.attributes[c]=f.getAttribLocation(r,c);r.id=Ga.length;Ga.push({program:r,code:j});A.info.memory.programs=Ga.length;p=r}a.program=p;p=a.program.attributes;0<=p.position&&f.enableVertexAttribArray(p.position);0<=p.color&&f.enableVertexAttribArray(p.color);0<=p.normal&&f.enableVertexAttribArray(p.normal);0<=p.tangent&&f.enableVertexAttribArray(p.tangent);a.skinning&&0<=p.skinVertexA&&0<=p.skinVertexB&&0<=p.skinIndex&&0<=p.skinWeight&&(f.enableVertexAttribArray(p.skinVertexA),
f.enableVertexAttribArray(p.skinVertexB),f.enableVertexAttribArray(p.skinIndex),f.enableVertexAttribArray(p.skinWeight));if(a.attributes)for(i in a.attributes)void 0!==p[i]&&0<=p[i]&&f.enableVertexAttribArray(p[i]);if(a.morphTargets)for(i=a.numSupportedMorphTargets=0;i<this.maxMorphTargets;i++)t="morphTarget"+i,0<=p[t]&&(f.enableVertexAttribArray(p[t]),a.numSupportedMorphTargets++);a.uniformsList=[];for(h in a.uniforms)a.uniformsList.push([a.uniforms[h],h])};this.setFaceCulling=function(a,b){a?(!b||
"ccw"===b?f.frontFace(f.CCW):f.frontFace(f.CW),"back"===a?f.cullFace(f.BACK):"front"===a?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK),f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.setObjectFaces=function(a){if(na!==a.doubleSided)a.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),na=a.doubleSided;if(ha!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),ha=a.flipSided};this.setDepthTest=function(a){Z!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),Z=a)};this.setDepthWrite=
function(a){va!==a&&(f.depthMask(a),va=a)};this.setBlending=function(a){if(a!==W){switch(a){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,
f.ONE_MINUS_SRC_ALPHA)}W=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),A.info.memory.textures++;f.activeTexture(f.TEXTURE0+b);f.bindTexture(f.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=J(a.format),g=J(a.type);K(f.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,e,c.width,c.height,0,e,g,c.data):f.texImage2D(f.TEXTURE_2D,0,e,e,g,a.image);a.generateMipmaps&&
d&&f.generateMipmap(f.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else f.activeTexture(f.TEXTURE0+b),f.bindTexture(f.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=!0;a.__webglTexture=f.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=J(a.format),e=J(a.type);if(b){a.__webglFramebuffer=
[];a.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,a.__webglTexture);K(f.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=f.createFramebuffer();a.__webglRenderbuffer[c]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+c;f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer[c]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,g.__webglTexture,0);N(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=
f.createFramebuffer(),a.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),K(f.TEXTURE_2D,a,c),f.texImage2D(f.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,a.__webglTexture,0),N(a.__webglRenderbuffer,a);b?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,
null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=yb,a=Db,e=gb,c=Na);b!==sa&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),sa=b);Nb=d;ac=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
301
THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type:
302
THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
303
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};
304 305 306 307
THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
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};
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};
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};
308
THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
309 310 311
THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
THREE.LensFlare.prototype.add=function(a,b,c,d,e,g){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===g&&(g=1);void 0===e&&(e=new THREE.Color(16777215));if(void 0===d)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:g,color:e,blending:d})};
THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+e*c.distance,c.wantedRotation=0.25*c.x*Math.PI,c.rotation+=0.25*(c.wantedRotation-c.rotation)};
312
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(3*this.size3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=0;this.hasNormal=
313 314 315 316 317 318 319 320 321 322 323 324
this.hasPos=!1;this.positionArray=new Float32Array(3*this.maxCount);this.normalArray=new Float32Array(3*this.maxCount)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i+h*this.delta;b[g+1]=k;b[g+2]=m;e[g]=this.lerp(j[a],j[a+3],h);e[g+1]=this.lerp(j[a+1],j[a+4],h);e[g+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k+h*this.delta;b[g+2]=m;b=a+3*this.yd;
e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k;b[g+2]=m+h*this.delta;b=a+3*this.zd;e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.compNorm=function(a){var b=3*a;0===this.normal_cache[b]&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,g,h,i){var k=g+1,m=g+this.yd,j=g+this.zd,n=k+this.yd,o=k+this.zd,p=g+this.yd+this.zd,l=k+this.yd+this.zd,r=0,t=this.field[g],z=this.field[k],y=this.field[m],K=this.field[n],N=this.field[j],u=this.field[o],J=this.field[p],H=this.field[l];t<h&&(r|=1);z<h&&(r|=2);y<h&&(r|=8);K<h&&(r|=4);N<h&&(r|=16);u<h&&(r|=32);J<h&&(r|=128);H<h&&(r|=64);var B=THREE.edgeTable[r];if(0===B)return 0;var D=this.delta,M=a+
D,I=b+D,D=e+D;B&1&&(this.compNorm(g),this.compNorm(k),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,t,z));B&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,M,b,e,z,K));B&4&&(this.compNorm(m),this.compNorm(n),this.VIntX(3*m,this.vlist,this.nlist,6,h,a,I,e,y,K));B&8&&(this.compNorm(g),this.compNorm(m),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,t,y));B&16&&(this.compNorm(j),this.compNorm(o),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,D,N,u));B&32&&(this.compNorm(o),
this.compNorm(l),this.VIntY(3*o,this.vlist,this.nlist,15,h,M,b,D,u,H));B&64&&(this.compNorm(p),this.compNorm(l),this.VIntX(3*p,this.vlist,this.nlist,18,h,a,I,D,J,H));B&128&&(this.compNorm(j),this.compNorm(p),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,D,N,J));B&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,t,N));B&512&&(this.compNorm(k),this.compNorm(o),this.VIntZ(3*k,this.vlist,this.nlist,27,h,M,b,e,z,u));B&1024&&(this.compNorm(n),this.compNorm(l),this.VIntZ(3*
n,this.vlist,this.nlist,30,h,M,I,e,K,H));B&2048&&(this.compNorm(m),this.compNorm(p),this.VIntZ(3*m,this.vlist,this.nlist,33,h,a,I,e,y,J));r<<=4;for(h=g=0;-1!=THREE.triTable[r+h];)a=r+h,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],i),h+=3,g++;return g};this.posnormtriv=function(a,b,e,g,h,i){var k=3*this.count;this.positionArray[k]=a[e];this.positionArray[k+1]=a[e+1];this.positionArray[k+2]=a[e+2];this.positionArray[k+3]=a[g];this.positionArray[k+
4]=a[g+1];this.positionArray[k+5]=a[g+2];this.positionArray[k+6]=a[h];this.positionArray[k+7]=a[h+1];this.positionArray[k+8]=a[h+2];this.normalArray[k]=b[e];this.normalArray[k+1]=b[e+1];this.normalArray[k+2]=b[e+2];this.normalArray[k+3]=b[g];this.normalArray[k+4]=b[g+1];this.normalArray[k+5]=b[g+2];this.normalArray[k+6]=b[h];this.normalArray[k+7]=b[h+1];this.normalArray[k+8]=b[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&i(this)};this.begin=function(){this.count=0;
this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,g,h){var i=this.size*Math.sqrt(g/h),k=e*this.size,m=b*this.size,j=a*this.size,n=Math.floor(k-i);1>n&&(n=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var o=Math.floor(m-i);1>o&&(o=1);m=Math.floor(m+i);m>this.size-1&&(m=this.size-1);var p=Math.floor(j-i);1>p&&(p=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
1);for(var l,r,t,z,y,K,N,j=n;j<k;j++){t=this.size2*j;y=j/this.size-e;K=y*y;for(n=o;n<m;n++){r=t+this.size*n;l=n/this.size-b;N=l*l;for(l=p;l<i;l++)z=l/this.size-a,z=g/(1.0E-6+z*z+N+K)-h,0<z&&(this.field[r+l]+=z)}}};this.addPlaneX=function(a,b){var e,g,h,i,k,m=this.size,j=this.yd,n=this.zd,o=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(e=0;e<p;e++)if(g=e/m,g*=g,i=a/(1.0E-4+g)-b,0<i)for(g=0;g<m;g++){k=e+g*j;for(h=0;h<m;h++)o[n*h+k]+=i}};this.addPlaneY=function(a,b){var e,g,h,i,k,m,j=this.size,n=this.yd,
o=this.zd,p=this.field,l=j*Math.sqrt(a/b);l>j&&(l=j);for(g=0;g<l;g++)if(e=g/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=g*n;for(e=0;e<j;e++){m=k+e;for(h=0;h<j;h++)p[o*h+m]+=i}}};this.addPlaneZ=function(a,b){var e,g,h,i,k,m,j=this.size,n=this.yd,o=this.zd,p=this.field,l=j*Math.sqrt(a/b);l>j&&(l=j);for(h=0;h<l;h++)if(e=h/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=o*h;for(g=0;g<j;g++){m=k+g*n;for(e=0;e<j;e++)p[m+e]+=i}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[3*a]=0,this.field[a]=0};this.render=
function(a){this.begin();var b,e,g,h,i,k,m,j,n,o=this.size-2;for(h=1;h<o;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<o;g++){j=n+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<o;e++)i=(e-this.halfsize)/this.halfsize,b=j+e,this.polygonize(i,k,m,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(g){var h,i,k,m,j,n,o,p;for(h=0;h<g.count;h++)o=3*h,j=o+1,p=o+2,i=g.positionArray[o],k=g.positionArray[j],m=
g.positionArray[p],n=new THREE.Vector3(i,k,m),i=g.normalArray[o],k=g.normalArray[j],m=g.normalArray[p],o=new THREE.Vector3(i,k,m),o.normalize(),j=new THREE.Vertex(n),b.vertices.push(j),e.push(o);n=g.count/3;for(h=0;h<n;h++)o=3*(a+h),j=o+1,p=o+2,i=e[o],k=e[j],m=e[p],o=new THREE.Face3(o,j,p,[i,k,m]),b.faces.push(o);a+=n;g.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
349 350 351
THREE.VisibleCamera=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.lineGeometry.vertices.push(new THREE.Vertex(new THREE.Vector3));d.lineGeometry.colors.push(new THREE.Color(b));void 0===d.pointMap[a]&&(d.pointMap[a]=[]);d.pointMap[a].push(d.lineGeometry.vertices.length-1)}THREE.Object3D.call(this);var d=this;this.lineGeometry=new THREE.Geometry;this.lineMaterial=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors});this.pointMap={};b("n1","n2",16755200);b("n2",
"n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);
this.update(a);this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THREE.LinePieces);this.add(this.lines)};THREE.VisibleCamera.prototype=new THREE.Object3D;THREE.VisibleCamera.prototype.constructor=THREE.VisibleCamera;
A
alteredq 已提交
352 353
THREE.VisibleCamera.prototype.update=function(a){function b(a,b,g,h){THREE.VisibleCamera.__v.set(b,g,h);THREE.VisibleCamera.__projector.unprojectVector(THREE.VisibleCamera.__v,THREE.VisibleCamera.__c);a=c.pointMap[a];if(void 0!==a){b=0;for(g=a.length;b<g;b++)c.lineGeometry.vertices[a[b]].position.copy(THREE.VisibleCamera.__v)}}var c=this;THREE.VisibleCamera.__c.projectionMatrix.copy(a.projectionMatrix);b("c",0,0,-1);b("t",0,0,1);b("n1",-1,-1,-1);b("n2",1,-1,-1);b("n3",-1,1,-1);b("n4",1,1,-1);b("f1",
-1,-1,1);b("f2",1,-1,1);b("f3",-1,1,1);b("f4",1,1,1);b("u1",0.7,1.1,-1);b("u2",-0.7,1.1,-1);b("u3",0,2,-1);b("cf1",-1,0,1);b("cf2",1,0,1);b("cf3",0,-1,1);b("cf4",0,1,1);b("cn1",-1,0,-1);b("cn2",1,0,-1);b("cn3",0,-1,-1);b("cn4",0,1,-1);this.lineGeometry.__dirtyVertices=!0};THREE.VisibleCamera.__projector=new THREE.Projector;THREE.VisibleCamera.__v=new THREE.Vector3;THREE.VisibleCamera.__c=new THREE.Camera;
354 355
THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,g,h,i,k,m,j,n,o,p;this.init=function(l){b=l.context;c=l;d=new Float32Array(16);e=new Uint16Array(6);l=0;d[l++]=-1;d[l++]=-1;d[l++]=0;d[l++]=0;d[l++]=1;d[l++]=-1;d[l++]=1;d[l++]=
0;d[l++]=1;d[l++]=1;d[l++]=1;d[l++]=1;d[l++]=-1;d[l++]=1;d[l++]=0;d[l++]=1;l=0;e[l++]=0;e[l++]=1;e[l++]=2;e[l++]=0;e[l++]=2;e[l++]=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,e,b.STATIC_DRAW);i=b.createTexture();k=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,
356
b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
357 358 359 360 361 362 363 364
b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(m=!1,j=a(THREE.ShaderFlares.lensFlare)):(m=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};o={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");o.renderType=b.getUniformLocation(j,"renderType");o.map=b.getUniformLocation(j,"map");o.occlusionMap=b.getUniformLocation(j,"occlusionMap");o.opacity=b.getUniformLocation(j,"opacity");o.color=b.getUniformLocation(j,
"color");o.scale=b.getUniformLocation(j,"scale");o.rotation=b.getUniformLocation(j,"rotation");o.screenPosition=b.getUniformLocation(j,"screenPosition");p=!1};this.render=function(a,d,e,z){var a=a.__webglFlares,y=a.length;if(y){var K=new THREE.Vector3,N=z/e,u=0.5*e,J=0.5*z,H=16/z,B=new THREE.Vector2(H*N,H),D=new THREE.Vector3(1,1,0),M=new THREE.Vector2(1,1),I=o,H=n;b.useProgram(j);p||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),p=!0);b.uniform1i(I.occlusionMap,0);b.uniform1i(I.map,
1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(H.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(H.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var Q,ga,xa,A,f;for(Q=0;Q<y;Q++)if(H=16/z,B.set(H*N,H),A=a[Q],K.set(A.matrixWorld.n14,A.matrixWorld.n24,A.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(K),d.projectionMatrix.multiplyVector3(K),D.copy(K),M.x=D.x*u+u,M.y=D.y*J+J,m||0<M.x&&M.x<e&&0<M.y&&M.y<z){b.activeTexture(b.TEXTURE1);
b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,M.x-8,M.y-8,16,16,0);b.uniform1i(I.renderType,0);b.uniform2f(I.scale,B.x,B.y);b.uniform3f(I.screenPosition,D.x,D.y,D.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,k);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,M.x-8,M.y-8,16,16,0);b.uniform1i(I.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(D);A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares();b.uniform1i(I.renderType,2);b.enable(b.BLEND);for(ga=0,xa=A.lensFlares.length;ga<xa;ga++)if(f=A.lensFlares[ga],0.0010<f.opacity&&0.0010<f.scale)D.x=f.x,D.y=f.y,D.z=f.z,H=f.size*f.scale/z,B.x=H*N,B.y=H,b.uniform3f(I.screenPosition,D.x,D.y,D.z),b.uniform2f(I.scale,B.x,B.y),b.uniform1f(I.rotation,f.rotation),b.uniform1f(I.opacity,f.opacity),b.uniform3f(I.color,
f.color.r,f.color.g,f.color.b),c.setBlending(f.blending),c.setTexture(f.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,g=new THREE.Matrix4;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&
this.update(a,c)};this.update=function(h){var i,k,m,j,n,o,p,l,r,t=h.lights;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(i=0,k=t.length;i<k;i++)if(l=t[i],l.castShadow&&l instanceof THREE.SpotLight){if(!l.shadowMap)l.shadowMap=new THREE.WebGLRenderTarget(l.shadowMapWidth,l.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),l.shadowMapSize=new THREE.Vector2(l.shadowMapWidth,l.shadowMapHeight),
365 366
l.shadowCamera=new THREE.PerspectiveCamera(l.shadowCameraFov,l.shadowMapWidth/l.shadowMapHeight,l.shadowCameraNear,l.shadowCameraFar),l.shadowMatrix=new THREE.Matrix4,h.add(l.shadowCamera),b.autoUpdateScene&&h.updateMatrixWorld();if(l.shadowCameraVisible&&!l.visibleCamera)l.visibleCamera=new THREE.VisibleCamera(l.shadowCamera),l.shadowCamera.add(l.visibleCamera);m=l.shadowMap;j=l.shadowMatrix;n=l.shadowCamera;n.position.copy(l.matrixWorld.getPosition());n.lookAt(l.target.matrixWorld.getPosition());
n.matrixWorldInverse.getInverse(n.matrixWorld);if(l.visibleCamera)l.visibleCamera.lines.visible=l.shadowCameraVisible;l.shadowCameraVisible&&l.visibleCamera.update(l.shadowCamera);j.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);j.multiplySelf(n.projectionMatrix);j.multiplySelf(n.matrixWorldInverse);if(!n._viewMatrixArray)n._viewMatrixArray=new Float32Array(16);n.matrixWorldInverse.flattenToArray(n._viewMatrixArray);if(!n._projectionMatrixArray)n._projectionMatrixArray=new Float32Array(16);n.projectionMatrix.flattenToArray(n._projectionMatrixArray);
367 368 369 370 371 372 373 374 375 376
g.multiply(n.projectionMatrix,n.matrixWorldInverse);e.setFromMatrix(g);b.setRenderTarget(m);b.clear();r=h.__webglObjects;for(m=0,j=r.length;m<j;m++)if(o=r[m],l=o.object,o.render=!1,l.visible&&l.castShadow&&(!(l instanceof THREE.Mesh)||!l.frustumCulled||e.contains(l)))l.matrixWorld.flattenToArray(l._objectMatrixArray),l._modelViewMatrix.multiplyToArray(n.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray),o.render=!0;for(m=0,j=r.length;m<j;m++)if(o=r[m],o.render)l=o.object,o=o.buffer,b.setObjectFaces(l),
p=l.customDepthMaterial?l.customDepthMaterial:l.geometry.morphTargets.length?d:c,o instanceof THREE.BufferGeometry?b.renderBufferDirect(n,t,null,p,o,l):b.renderBuffer(n,t,null,p,o,l);r=h.__webglObjectsImmediate;for(m=0,j=r.length;m<j;m++)o=r[m],l=o.object,l.visible&&l.castShadow&&(l.matrixAutoUpdate&&l.matrixWorld.flattenToArray(l._objectMatrixArray),l._modelViewMatrix.multiplyToArray(n.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray),b.renderImmediateObject(n,t,null,c,l))}h=b.getClearColor();
i=b.getClearAlpha();a.clearColor(h.r,h.g,h.b,i);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};
THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,h,i,k,m,j;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);e=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;e[a++]=0;e[a++]=1;e[a++]=2;e[a++]=0;e[a++]=2;e[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,
h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,o=b.createProgram(),p=b.createShader(b.FRAGMENT_SHADER),l=b.createShader(b.VERTEX_SHADER);b.shaderSource(p,a.fragmentShader);b.shaderSource(l,a.vertexShader);b.compileShader(p);b.compileShader(l);b.attachShader(o,p);b.attachShader(o,l);b.linkProgram(o);i=o;k={};m={};k.position=b.getAttribLocation(i,"position");k.uv=b.getAttribLocation(i,"uv");m.uvOffset=b.getUniformLocation(i,"uvOffset");m.uvScale=b.getUniformLocation(i,
"uvScale");m.rotation=b.getUniformLocation(i,"rotation");m.scale=b.getUniformLocation(i,"scale");m.alignment=b.getUniformLocation(i,"alignment");m.color=b.getUniformLocation(i,"color");m.map=b.getUniformLocation(i,"map");m.opacity=b.getUniformLocation(i,"opacity");m.useScreenCoordinates=b.getUniformLocation(i,"useScreenCoordinates");m.affectedByDistance=b.getUniformLocation(i,"affectedByDistance");m.screenPosition=b.getUniformLocation(i,"screenPosition");m.modelViewMatrix=b.getUniformLocation(i,"modelViewMatrix");
m.projectionMatrix=b.getUniformLocation(i,"projectionMatrix");j=!1};this.render=function(d,e,p,l){var d=d.__webglSprites,r=d.length;if(r){var t=k,z=m,y=l/p,p=0.5*p,K=0.5*l,N=!0;b.useProgram(i);j||(b.enableVertexAttribArray(t.position),b.enableVertexAttribArray(t.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(t.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(t.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.uniformMatrix4fv(z.projectionMatrix,
!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(z.map,0);for(var u,J=[],t=0;t<r;t++)if(u=d[t],u.visible&&0!==u.opacity)u.useScreenCoordinates?u.z=-u.position.z:(u._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,u.matrixWorld,u._modelViewMatrixArray),u.z=-u._modelViewMatrix.n34);d.sort(a);for(t=0;t<r;t++)u=d[t],u.visible&&0!==u.opacity&&u.map&&u.map.image&&u.map.image.width&&(u.useScreenCoordinates?(b.uniform1i(z.useScreenCoordinates,1),b.uniform3f(z.screenPosition,(u.position.x-
p)/p,(K-u.position.y)/K,Math.max(0,Math.min(1,u.position.z)))):(b.uniform1i(z.useScreenCoordinates,0),b.uniform1i(z.affectedByDistance,u.affectedByDistance?1:0),b.uniformMatrix4fv(z.modelViewMatrix,!1,u._modelViewMatrixArray)),e=u.map.image.width/(u.scaleByViewport?l:1),J[0]=e*y*u.scale.x,J[1]=e*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),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,J),u.mergeWith3D&&!N?(b.enable(b.DEPTH_TEST),N=!0):!u.mergeWith3D&&N&&(b.disable(b.DEPTH_TEST),N=!1),c.setBlending(u.blending),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(!0)}}};
377 378
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}"},
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}"}};
A
alteredq 已提交
379
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}",
A
alteredq 已提交
380
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}"}};
381 382 383 384
THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],g=new THREE.Texture(e,b);e.loadCount=0;for(b=0,d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(6===e.loadCount)g.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return g},getNormalMap:function(a,b){var c=function(a){var b=
Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,g=document.createElement("canvas");g.width=d;g.height=e;var h=g.getContext("2d");h.drawImage(a,0,0);for(var i=h.getImageData(0,0,d,e).data,k=h.createImageData(d,e),m=k.data,j=0;j<d;j++)for(var n=1;n<e;n++){var o=0>n-1?e-1:n-1,p=(n+1)%e,l=0>j-1?d-1:j-1,r=(j+1)%d,t=[],z=[0,0,i[4*(n*d+j)]/255*b];t.push([-1,0,i[4*(n*d+l)]/255*b]);t.push([-1,-1,i[4*(o*d+l)]/255*b]);t.push([0,-1,i[4*(o*d+j)]/255*b]);t.push([1,
-1,i[4*(o*d+r)]/255*b]);t.push([1,0,i[4*(n*d+r)]/255*b]);t.push([1,1,i[4*(p*d+r)]/255*b]);t.push([0,1,i[4*(p*d+j)]/255*b]);t.push([-1,1,i[4*(p*d+l)]/255*b]);o=[];l=t.length;for(p=0;p<l;p++){var r=t[p],y=t[(p+1)%l],r=[r[0]-z[0],r[1]-z[1],r[2]-z[2]],y=[y[0]-z[0],y[1]-z[1],y[2]-z[2]];o.push(c([r[1]*y[2]-r[2]*y[1],r[2]*y[0]-r[0]*y[2],r[0]*y[1]-r[1]*y[0]]))}t=[0,0,0];for(p=0;p<o.length;p++)t[0]+=o[p][0],t[1]+=o[p][1],t[2]+=o[p][2];t[0]/=o.length;t[1]/=o.length;t[2]/=o.length;z=4*(n*d+j);m[z]=255*((t[0]+
1)/2)|0;m[z+1]=255*(t[1]+0.5)|0;m[z+2]=255*t[2]|0;m[z+3]=255}h.putImageData(k,0,0);return g}};