Three.js 384.6 KB
Newer Older
M
Mr.doob 已提交
1
// Three.js - http://github.com/mrdoob/three.js
2
'use strict';var THREE=THREE||{REVISION:"49dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
3
(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
4
function(a){clearTimeout(a)}})();THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};
5
THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
6
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);
7
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,f;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),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;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=f;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=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
8 9
Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
A
alteredq 已提交
10 11 12 13 14 15 16
THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,
0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,
b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},isZero:function(){return 1.0E-4>this.lengthSq()},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},
sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):
this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=
(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.n14;this.y=
17
a.n24;this.z=a.n34;return this},getRotationFromMatrix:function(a,b){var c=b?b.x:1,d=b?b.y:1,e=b?b.z:1,f=a.n11/c,g=a.n12/d,c=a.n21/c,d=a.n22/d,h=a.n23/e,k=a.n33/e;this.y=Math.asin(a.n13/e);e=Math.cos(this.y);1.0E-5<Math.abs(e)?(this.x=Math.atan2(-h/e,k/e),this.z=Math.atan2(-g/e,f/e)):(this.x=0,this.z=Math.atan2(c,d));return this},getScaleFromMatrix:function(a){var b=this.set(a.n11,a.n21,a.n31).length(),c=this.set(a.n12,a.n22,a.n32).length(),a=this.set(a.n13,a.n23,a.n33).length();this.x=b;this.y=c;
A
alteredq 已提交
18 19 20 21
this.z=a},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},isZero:function(){return 1.0E-4>this.lengthSq()},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=
a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},
setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
M
Mr.doob 已提交
22
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))};
Z
zz85 已提交
23
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;
24 25 26 27 28 29 30
THREE.Ray=function(a,b){function c(a,b,c){q.sub(c,a);s=q.dot(b);v=m.add(a,r.copy(b).multiplyScalar(s));return u=c.distanceTo(v)}function d(a,b,c,d){q.sub(d,b);m.sub(c,b);r.sub(a,b);t=q.dot(q);w=q.dot(m);y=q.dot(r);H=m.dot(m);F=m.dot(r);C=1/(t*H-w*w);J=(H*y-w*F)*C;O=(t*F-w*y)*C;return 0<=J&&0<=O&&1>J+O}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;var e=1.0E-4;this.setPrecision=function(a){e=a};var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,
i=new THREE.Vector3,l=new THREE.Vector3,p=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3;this.intersectObject=function(a){var b,m=[];if(a instanceof THREE.Particle){var q=c(this.origin,this.direction,a.matrixWorld.getPosition());if(q>a.scale.x)return[];b={distance:q,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){var q=c(this.origin,this.direction,a.matrixWorld.getPosition()),r=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),
a.matrixWorld.getColumnZ().length());if(q>a.geometry.boundingSphere.radius*Math.max(r.x,Math.max(r.y,r.z)))return m;var s,j,t=a.geometry,u=t.vertices,D;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(q=0,r=t.faces.length;q<r;q++)if(b=t.faces[q],i.copy(this.origin),l.copy(this.direction),D=a.matrixWorld,p=D.multiplyVector3(p.copy(b.centroid)).subSelf(i),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),s=l.dot(n),!(Math.abs(s)<e)&&(j=n.dot(p)/s,!(0>j)&&(a.doubleSided||(a.flipSided?
0<s:0>s))))if(o.add(i,l.multiplyScalar(j)),b instanceof THREE.Face3)f=D.multiplyVector3(f.copy(u[b.a].position)),g=D.multiplyVector3(g.copy(u[b.b].position)),h=D.multiplyVector3(h.copy(u[b.c].position)),d(o,f,g,h)&&(b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(f=D.multiplyVector3(f.copy(u[b.a].position)),g=D.multiplyVector3(g.copy(u[b.b].position)),h=D.multiplyVector3(h.copy(u[b.c].position)),k=D.multiplyVector3(k.copy(u[b.d].position)),
d(o,f,g,k)||d(o,g,h,k)))b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},m.push(b)}return m};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(function(a,b){return a.distance-b.distance});return b};var q=new THREE.Vector3,m=new THREE.Vector3,r=new THREE.Vector3,s,v,u,t,w,y,H,F,C,J,O};
THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,p){h=!1;b=f;c=g;d=l;e=p;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
function(f,g,l,p,n,o){h?(h=!1,b=f<l?f<n?f:n:l<n?l:n,c=g<p?g<o?g:o:p<o?p:o,d=f>l?f>n?f:n:l>n?l:n,e=g>p?g>o?g:o:p>o?p:o):(b=f<l?f<n?f<b?f:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b,c=g<p?g<o?g<c?g:c:o<c?o:c:p<o?p<c?p:c:o<c?o:c,d=f>l?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>p?g>o?g>e?g:e:o>e?o:e:p>o?p>e?p:e:o>e?o:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
31
f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
Z
zz85 已提交
32
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())},sign:function(a){return 0>a?-1:0<a?1:0}};THREE.Matrix3=function(){this.m=[]};
33 34 35 36 37
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,k,i,l,p,n,o,q,m){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,k||0,i||0,void 0!==l?l:1,p||0,n||0,o||0,q||0,void 0!==m?m:1);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,i,l,p,n,o,q,m){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=k;this.n32=i;this.n33=l;this.n34=p;this.n41=n;this.n42=o;this.n43=q;this.n44=m;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,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d);this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,k=a.n23,i=a.n24,l=a.n31,p=a.n32,n=a.n33,o=a.n34,q=a.n41,m=a.n42,r=a.n43,s=a.n44,v=b.n11,
u=b.n12,t=b.n13,w=b.n14,y=b.n21,H=b.n22,F=b.n23,C=b.n24,J=b.n31,O=b.n32,Q=b.n33,S=b.n34,M=b.n41,A=b.n42,L=b.n43,B=b.n44;this.n11=c*v+d*y+e*J+f*M;this.n12=c*u+d*H+e*O+f*A;this.n13=c*t+d*F+e*Q+f*L;this.n14=c*w+d*C+e*S+f*B;this.n21=g*v+h*y+k*J+i*M;this.n22=g*u+h*H+k*O+i*A;this.n23=g*t+h*F+k*Q+i*L;this.n24=g*w+h*C+k*S+i*B;this.n31=l*v+p*y+n*J+o*M;this.n32=l*u+p*H+n*O+o*A;this.n33=l*t+p*F+n*Q+o*L;this.n34=l*w+p*C+n*S+o*B;this.n41=q*v+m*y+r*J+s*M;this.n42=q*u+m*H+r*O+s*A;this.n43=q*t+m*F+r*Q+s*L;this.n44=
q*w+m*C+r*S+s*B;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;
Z
zz85 已提交
38 39
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+
40
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,f=this.n22,g=this.n23,h=this.n24,k=this.n31,i=this.n32,l=this.n33,p=this.n34,n=this.n41,o=this.n42,q=this.n43,m=this.n44;return d*g*i*n-c*h*i*n-d*f*l*n+b*h*l*n+c*f*p*n-b*g*p*n-d*g*k*o+c*h*k*o+d*e*l*o-a*h*l*o-c*e*p*o+a*g*p*o+d*f*k*q-b*h*k*q-d*e*i*q+a*h*i*q+b*e*p*q-a*f*p*q-c*f*k*m+b*g*k*m+c*e*i*m-a*g*i*m-b*e*l*m+a*f*l*m},transpose:function(){var a;
41 42
a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n34=a;return this},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=
this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=
43 44 45 46 47 48 49
Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,k=e*f,i=e*g;this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,i*g+c,i*h-d*f,0,k*h-d*g,i*h+d*f,e*h*h+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,f=a.n21,g=a.n22,h=a.n23,k=a.n24,i=a.n31,l=
a.n32,p=a.n33,n=a.n34,o=a.n41,q=a.n42,m=a.n43,r=a.n44;this.n11=h*n*q-k*p*q+k*l*m-g*n*m-h*l*r+g*p*r;this.n12=e*p*q-d*n*q-e*l*m+c*n*m+d*l*r-c*p*r;this.n13=d*k*q-e*h*q+e*g*m-c*k*m-d*g*r+c*h*r;this.n14=e*h*l-d*k*l-e*g*p+c*k*p+d*g*n-c*h*n;this.n21=k*p*o-h*n*o-k*i*m+f*n*m+h*i*r-f*p*r;this.n22=d*n*o-e*p*o+e*i*m-b*n*m-d*i*r+b*p*r;this.n23=e*h*o-d*k*o-e*f*m+b*k*m+d*f*r-b*h*r;this.n24=d*k*i-e*h*i+e*f*p-b*k*p-d*f*n+b*h*n;this.n31=g*n*o-k*l*o+k*i*q-f*n*q-g*i*r+f*l*r;this.n32=e*l*o-c*n*o-e*i*q+b*n*q+c*i*r-b*l*
r;this.n33=c*k*o-e*g*o+e*f*q-b*k*q-c*f*r+b*g*r;this.n34=e*g*i-c*k*i-e*f*l+b*k*l+c*f*n-b*g*n;this.n41=h*l*o-g*p*o-h*i*q+f*p*q+g*i*m-f*l*m;this.n42=c*p*o-d*l*o+d*i*q-b*p*q-c*i*m+b*l*m;this.n43=d*g*o-c*h*o-d*f*q+b*h*q+c*f*m-b*g*m;this.n44=c*h*i-d*g*i+d*f*l-b*h*l-c*f*p+b*g*p;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k=g*h,i=g*e,
l=d*h,p=d*e;this.n11=k+p*c;this.n12=l*c-i;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=i*c-l;this.n32=p+k*c;this.n33=f*g;break;case "ZXY":k=g*h;i=g*e;l=d*h;p=d*e;this.n11=k-p*c;this.n12=-f*e;this.n13=l+i*c;this.n21=i+l*c;this.n22=f*h;this.n23=p-k*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":k=f*h;i=f*e;l=c*h;p=c*e;this.n11=g*h;this.n12=l*d-i;this.n13=k*d+p;this.n21=g*e;this.n22=p*d+k;this.n23=i*d-l;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":k=f*g;i=f*d;l=c*g;
p=c*d;this.n11=g*h;this.n12=p-k*e;this.n13=l*e+i;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=i*e+l;this.n33=k-p*e;break;case "XZY":k=f*g;i=f*d;l=c*g;p=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=k*e+p;this.n22=f*h;this.n23=i*e-l;this.n31=l*e-i;this.n32=c*h;this.n33=p*e+k;break;default:k=f*h,i=f*e,l=c*h,p=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=i+l*d,this.n22=k-p*d,this.n23=-c*g,this.n31=p-k*d,this.n32=l+i*d,this.n33=f*g}return this},setRotationFromQuaternion:function(a){var b=
a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,h=d+d,a=b*f,k=b*g,b=b*h,i=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(i+d);this.n12=k-e;this.n13=b+g;this.n21=k+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);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;
50 51
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,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.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=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=
52 53 54 55
a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,k=Math.cos(b),i=Math.sin(b),l=1-k,p=c*d*l,n=c*e*l,l=d*e*l,c=c*i,o=d*i,i=e*i,e=
f+(1-f)*k,f=p+i,d=n-o,p=p-i,g=g+(1-g)*k,i=l+c,n=n+o,l=l-c,h=h+(1-h)*k,k=this.n11,c=this.n21,o=this.n31,q=this.n41,m=this.n12,r=this.n22,s=this.n32,v=this.n42,u=this.n13,t=this.n23,w=this.n33,y=this.n43;this.n11=e*k+f*m+d*u;this.n21=e*c+f*r+d*t;this.n31=e*o+f*s+d*w;this.n41=e*q+f*v+d*y;this.n12=p*k+g*m+i*u;this.n22=p*c+g*r+i*t;this.n32=p*o+g*s+i*w;this.n42=p*q+g*v+i*y;this.n13=n*k+l*m+h*u;this.n23=n*c+l*r+h*t;this.n33=n*o+l*s+h*w;this.n43=n*q+l*v+h*y;return this},rotateX:function(a){var b=this.n12,
c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n12=i*b+a*f;this.n22=i*c+a*g;this.n32=i*d+a*h;this.n42=i*e+a*k;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n11=i*b-a*f;this.n21=i*c-a*g;this.n31=i*d-a*h;this.n41=i*e-a*k;this.n13=i*f+a*b;this.n23=i*g+a*c;this.n33=
i*h+a*d;this.n43=i*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,k=this.n42,i=Math.cos(a),a=Math.sin(a);this.n11=i*b+a*f;this.n21=i*c+a*g;this.n31=i*d+a*h;this.n41=i*e+a*k;this.n12=i*f-a*b;this.n22=i*g-a*c;this.n32=i*h-a*d;this.n42=i*k-a*e;return this},translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*
56
c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this},clone:function(){return new THREE.Matrix4(this.n11,this.n12,this.n13,this.n14,this.n21,this.n22,this.n23,this.n24,this.n31,this.n32,this.n33,this.n34,this.n41,this.n42,this.n43,this.n44)}};
57
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,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,p=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*i;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*l;c[8]=a*p;return b};
58
THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};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)};
59
THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,h,k,i;g=new THREE.Matrix4;h=b-a;k=c-d;i=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((c+d)/k);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};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;
60
THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=!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=
A
alteredq 已提交
61
!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};
62 63
THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiply(a,this.matrix);this.scale.getScaleFromMatrix(this.matrix);this.rotation.getRotationFromMatrix(this.matrix,this.scale);this.position.getPositionFromMatrix(this.matrix)},translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,
this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)},add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(-1===this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=
Z
zz85 已提交
64
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,
65 66
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;
67 68 69 70 71 72 73 74 75 76 77
THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=i[k]=i[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
var e,f,g=[],h,k,i=[],l,p,n=[],o,q=[],m,r,s=[],v,u,t=[],w={objects:[],sprites:[],lights:[],elements:[]},y=new THREE.Vector3,H=new THREE.Vector4,F=new THREE.Matrix4,C=new THREE.Matrix4,J=new THREE.Frustum,O=new THREE.Vector4,Q=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);F.multiply(b.projectionMatrix,b.matrixWorldInverse);F.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);F.multiply(b.matrixWorld,
b.projectionMatrixInverse);F.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){f=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||J.contains(b))?(y.copy(b.matrixWorld.getPosition()),F.multiplyVector3(y),
e=a(),e.object=b,e.z=y.z,w.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(y.copy(b.matrixWorld.getPosition()),F.multiplyVector3(y),e=a(),e.object=b,e.z=y.z,w.sprites.push(e)):b instanceof THREE.Light&&w.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&w.objects.sort(c);return w};this.projectScene=function(a,e,f){var g=e.near,B=e.far,j=!1,y,G,D,V,E,ga,da,ea,R,$,W,ba,ia,sa,Ha;u=r=o=p=0;w.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);F.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(F);w=this.projectGraph(a,!1);for(a=0,y=w.objects.length;a<y;a++)if(R=w.objects[a].object,$=R.matrixWorld,k=0,R instanceof THREE.Mesh){W=R.geometry;ba=R.geometry.materials;V=W.vertices;ia=W.faces;sa=W.faceVertexUvs;W=R.matrixRotationWorld.extractRotation($);for(G=0,D=V.length;G<D;G++)h=b(),h.positionWorld.copy(V[G].position),$.multiplyVector3(h.positionWorld),
h.positionScreen.copy(h.positionWorld),F.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<B;for(V=0,G=ia.length;V<G;V++){D=ia[V];if(D instanceof THREE.Face3)if(E=i[D.a],ga=i[D.b],da=i[D.c],E.visible&&ga.visible&&da.visible)if(j=0>(da.positionScreen.x-E.positionScreen.x)*(ga.positionScreen.y-E.positionScreen.y)-(da.positionScreen.y-E.positionScreen.y)*(ga.positionScreen.x-E.positionScreen.x),
R.doubleSided||j!=R.flipSided)ea=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ea,l.v1.copy(E),l.v2.copy(ga),l.v3.copy(da);else continue;else continue;else if(D instanceof THREE.Face4)if(E=i[D.a],ga=i[D.b],da=i[D.c],ea=i[D.d],E.visible&&ga.visible&&da.visible&&ea.visible)if(j=0>(ea.positionScreen.x-E.positionScreen.x)*(ga.positionScreen.y-E.positionScreen.y)-(ea.positionScreen.y-E.positionScreen.y)*(ga.positionScreen.x-E.positionScreen.x)||0>(ga.positionScreen.x-da.positionScreen.x)*(ea.positionScreen.y-
da.positionScreen.y)-(ga.positionScreen.y-da.positionScreen.y)*(ea.positionScreen.x-da.positionScreen.x),R.doubleSided||j!=R.flipSided)Ha=q[o]=q[o]||new THREE.RenderableFace4,o++,l=Ha,l.v1.copy(E),l.v2.copy(ga),l.v3.copy(da),l.v4.copy(ea);else continue;else continue;l.normalWorld.copy(D.normal);!j&&(R.flipSided||R.doubleSided)&&l.normalWorld.negate();W.multiplyVector3(l.normalWorld);l.centroidWorld.copy(D.centroid);$.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);F.multiplyVector3(l.centroidScreen);
da=D.vertexNormals;for(E=0,ga=da.length;E<ga;E++)ea=l.vertexNormalsWorld[E],ea.copy(da[E]),!j&&(R.flipSided||R.doubleSided)&&ea.negate(),W.multiplyVector3(ea);for(E=0,ga=sa.length;E<ga;E++)if(Ha=sa[E][V])for(da=0,ea=Ha.length;da<ea;da++)l.uvs[E][da]=Ha[da];l.material=R.material;l.faceMaterial=null!==D.materialIndex?ba[D.materialIndex]:null;l.z=l.centroidScreen.z;w.elements.push(l)}}else if(R instanceof THREE.Line){C.multiply(F,$);V=R.geometry.vertices;E=b();E.positionScreen.copy(V[0].position);C.multiplyVector4(E.positionScreen);
for(G=1,D=V.length;G<D;G++)if(E=b(),E.positionScreen.copy(V[G].position),C.multiplyVector4(E.positionScreen),ga=i[k-2],O.copy(E.positionScreen),Q.copy(ga.positionScreen),d(O,Q))O.multiplyScalar(1/O.w),Q.multiplyScalar(1/Q.w),$=s[r]=s[r]||new THREE.RenderableLine,r++,m=$,m.v1.positionScreen.copy(O),m.v2.positionScreen.copy(Q),m.z=Math.max(O.z,Q.z),m.material=R.material,w.elements.push(m)}for(a=0,y=w.sprites.length;a<y;a++)if(R=w.sprites[a].object,$=R.matrixWorld,R instanceof THREE.Particle&&(H.set($.n14,
$.n24,$.n34,1),F.multiplyVector4(H),H.z/=H.w,0<H.z&&1>H.z))g=t[u]=t[u]||new THREE.RenderableParticle,u++,v=g,v.x=H.x/H.w,v.y=H.y/H.w,v.z=H.z,v.rotation=R.rotation.z,v.scale.x=R.scale.x*Math.abs(v.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),v.scale.y=R.scale.y*Math.abs(v.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),v.material=R.material,w.elements.push(v);f&&w.elements.sort(c);return w}};
78
THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
79
THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
80 81
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},multiply:function(a,
82 83 84
b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,i=k*c+g*e-h*d,l=k*d+h*c-f*e,p=k*e+f*
d-g*c,c=-f*c-g*d-h*e;b.x=i*k+c*-f+l*-h-p*-g;b.y=l*k+c*-g+p*-f-i*-h;b.z=p*k+c*-h+i*-g-l*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
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 f=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)*f)/e;d=Math.sin(d*f)/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};
85
THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,f){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=f;this.centroid=new THREE.Vector3};
86
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
87
return a}};THREE.Face4=function(a,b,c,d,e,f,g){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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
88
THREE.Face4.prototype={constructor:THREE.Face4,clone:function(){var a=new THREE.Face4(this.a,this.b,this.c,this.d);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
89
return a}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},lerpSelf:function(a,b){this.u+=(a.u-this.u)*b;this.v+=(a.v-this.v)*b;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
A
alteredq 已提交
90
THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
91 92 93
THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a);for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(d=this.faces.length;c<d;c++){var e=this.faces[c];b.multiplyVector3(e.normal);for(var f=0,g=e.vertexNormals.length;f<g;f++)b.multiplyVector3(e.vertexNormals[f]);a.multiplyVector3(e.centroid)}},computeCentroids:function(){var a,b,c;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,
0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(){var a,b,c,d,e,f,g=new THREE.Vector3,
h=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],f=this.vertices[c.c],g.sub(f.position,e.position),h.sub(d.position,e.position),g.crossSelf(h),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof
A
alteredq 已提交
94
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),
Z
zz85 已提交
95
d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeMorphNormals:function(){var a,b,c,d,e;for(c=0,d=this.faces.length;c<
96
d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};
97 98 99 100 101
this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var g=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,k,i;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],k=new THREE.Vector3,i=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},g.push(k),h.push(i)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();
f.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],k=g.faceNormals[c],i=g.vertexNormals[c],k.copy(e.normal),e instanceof THREE.Face3?(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2])):(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2]),i.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
b,c,d,e,f,E){h=a.vertices[b].position;k=a.vertices[c].position;i=a.vertices[d].position;l=g[e];p=g[f];n=g[E];o=k.x-h.x;q=i.x-h.x;m=k.y-h.y;r=i.y-h.y;s=k.z-h.z;v=i.z-h.z;u=p.u-l.u;t=n.u-l.u;w=p.v-l.v;y=n.v-l.v;H=1/(u*y-t*w);O.set((y*o-w*q)*H,(y*m-w*r)*H,(y*s-w*v)*H);Q.set((u*q-t*o)*H,(u*r-t*m)*H,(u*v-t*s)*H);C[b].addSelf(O);C[c].addSelf(O);C[d].addSelf(O);J[b].addSelf(Q);J[c].addSelf(Q);J[d].addSelf(Q)}var b,c,d,e,f,g,h,k,i,l,p,n,o,q,m,r,s,v,u,t,w,y,H,F,C=[],J=[],O=new THREE.Vector3,Q=new THREE.Vector3,
S=new THREE.Vector3,M=new THREE.Vector3,A=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)C[b]=new THREE.Vector3,J[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var L=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)A.copy(f.vertexNormals[d]),e=f[L[d]],
F=C[e],S.copy(F),S.subSelf(A.multiplyScalar(A.dot(F))).normalize(),M.cross(f.vertexNormals[d],F),e=M.dot(J[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(S.x,S.y,S.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<
Z
zz85 已提交
102
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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,
103
4),f,g;for(f=0,g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];for(f=0,g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
104 105 106 107
THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,i,l,p,n;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:
f+2;i=this.points[c[0]];l=this.points[c[1]];p=this.points[c[2]];n=this.points[c[3]];h=g*g;k=g*h;d.x=b(i.x,l.x,p.x,n.x,g,h,k);d.y=b(i.y,l.y,p.y,n.y,g,h,k);d.z=b(i.z,l.z,p.z,n.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],k=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
a/c,d=this.getPoint(b),g.copy(d),k+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=k,e=b);h[h.length]=k;return{chunks:h,total:k}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],k=new THREE.Vector3,i=this.getLength();h.push(k.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=i.chunks[b]-i.chunks[b-1];g=Math.ceil(a*c/i.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),
h.push(k.copy(d).clone());h.push(k.copy(this.points[b]).clone())}this.points=h}};THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)};
108
THREE.OrthographicCamera=function(a,b,c,d,e,f){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!==f?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};
109
THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:0.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};
110
THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
111
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=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 已提交
112
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;
A
alteredq 已提交
113
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
114
!1;this.shadowCascadeOffset=new THREE.Vector3(0,0,-1E3);this.shadowCascadeCount=2;this.shadowCascadeBias=[0,0,0];this.shadowCascadeWidth=[512,512,512];this.shadowCascadeHeight=[512,512,512];this.shadowCascadeNearZ=[-1,0.99,0.998];this.shadowCascadeFarZ=[0.99,0.998,1];this.shadowCascadeArray=[];this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
A
alteredq 已提交
115
THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
A
alteredq 已提交
116
THREE.SpotLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};
117
THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
118 119 120 121
THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=void 0!==a.opacity?a.opacity:1;this.transparent=void 0!==a.transparent?a.transparent:!1;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.blendSrc=void 0!==a.blendSrc?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=void 0!==a.blendDst?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=void 0!==a.blendEquation?a.blendEquation:THREE.AddEquation;this.depthTest=void 0!==a.depthTest?a.depthTest:
!0;this.depthWrite=void 0!==a.depthWrite?a.depthWrite:!0;this.polygonOffset=void 0!==a.polygonOffset?a.polygonOffset:!1;this.polygonOffsetFactor=void 0!==a.polygonOffsetFactor?a.polygonOffsetFactor:0;this.polygonOffsetUnits=void 0!==a.polygonOffsetUnits?a.polygonOffsetUnits:0;this.alphaTest=void 0!==a.alphaTest?a.alphaTest:0;this.overdraw=void 0!==a.overdraw?a.overdraw:!1;this.needsUpdate=!0};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;
THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;THREE.AdditiveAlphaBlending=5;THREE.CustomBlending=6;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;
THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;
122 123
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:
124 125
!0;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?
a.morphTargets:!1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
126 127
THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=void 0!==a.emissive?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=void 0!==a.wrapAround?a.wrapAround:!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=void 0!==a.map?a.map:null;this.lightMap=void 0!==a.lightMap?a.lightMap:null;this.envMap=
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?
128
a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
129 130
THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=void 0!==a.ambient?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=void 0!==a.emissive?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=void 0!==a.specular?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=void 0!==a.shininess?a.shininess:30;this.metal=void 0!==a.metal?a.metal:!1;this.perPixel=
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!==
131 132
a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.wireframeLinecap=void 0!==a.wireframeLinecap?a.wireframeLinecap:"round";this.wireframeLinejoin=void 0!==a.wireframeLinejoin?a.wireframeLinejoin:"round";this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:
!1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;
133
THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
134 135 136
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.ParticleCanvasMaterial=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.program=void 0!==a.program?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};
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!==
137
a.fog?a.fog:!1;this.lights=void 0!==a.lights?a.lights:!1;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:THREE.NoColors;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1;this.morphNormals=void 0!==a.morphNormals?a.morphNormals:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
138
THREE.Texture=function(a,b,c,d,e,f,g,h){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
139 140 141
!0;this.needsUpdate=this.premultiplyAlpha=!1;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
THREE.LatitudeReflectionMapping=function(){};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;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,f,g,h,k,i){THREE.Texture.call(this,null,f,g,h,k,i,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
142
THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
143 144 145 146 147 148
THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.ParticleBasicMaterial({color:16777215*Math.random()});this.sortParticles=!1;if(this.geometry)this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius;this.frustumCulled=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()});this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random(),wireframe:!0});if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),
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)};
149
THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,e,f,g,h;if(void 0!==this.geometry.bones){for(c=0;c<this.geometry.bones.length;c++)e=this.geometry.bones[c],f=e.pos,g=e.rotq,h=e.scl,d=this.addBone(),d.name=e.name,d.position.set(f[0],f[1],f[2]),d.quaternion.set(g[0],g[1],g[2],g[3]),d.useQuaternion=!0,void 0!==h?d.scale.set(h[0],h[1],h[2]):d.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)e=this.geometry.bones[c],
Z
zz85 已提交
150
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};
151
THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!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,
152
16*a)};
153 154
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,f=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[f].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)}}};
155 156
THREE.MorphAnimMesh=function(a,b){THREE.Mesh.call(this,a,b);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1;this.setFrameRange(0,this.geometry.morphTargets.length-1)};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
THREE.MorphAnimMesh.prototype.setFrameRange=function(a,b){this.startKeyframe=a;this.endKeyframe=b;this.length=this.endKeyframe-this.startKeyframe+1};THREE.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1;this.directionBackwards=!0};
157
THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;if(!a.animations)a.animations={};for(var b,c=a.animations,d=/([a-z]+)(\d+)/,e=0,f=a.morphTargets.length;e<f;e++){var g=a.morphTargets[e].name.match(d);if(g&&1<g.length){g=g[1];c[g]||(c[g]={start:Infinity,end:-Infinity});var h=c[g];if(e<h.start)h.start=e;if(e>h.end)h.end=e;b||(b=g)}}a.firstAnimation=b};
158
THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){if(!this.geometry.animations)this.geometry.animations={};this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=1E3*((c.end-c.start)/b),this.time=0):console.warn("animation["+a+"] undefined")};
159
THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||0>this.time){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(0>this.time)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1);if(a!==this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
160
0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
161
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)};
162
THREE.LOD.prototype.update=function(a){if(1<this.LODs.length){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.matrixWorld.n14+a.n32*this.matrixWorld.n24+a.n33*this.matrixWorld.n34+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=!1}};
163 164 165 166 167
THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:new THREE.Texture;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.blendSrc=void 0!==a.blendSrc?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=void 0!==a.blendDst?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=void 0!==a.blendEquation?a.blendEquation:THREE.AddEquation;this.useScreenCoordinates=void 0!==a.useScreenCoordinates?
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);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;
168 169
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])};
170
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};
171 172 173 174 175 176 177 178 179 180 181 182 183 184 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
THREE.DOMRenderer=function(){var a,b,c,d,e,f,g,h=new THREE.Projector;g=function(a){for(var b=document.documentElement,c=0;c<a.length;c++)if("string"===typeof b.style[a[c]])return a[c];return null}(["transform","MozTransform","WebkitTransform","msTransform","OTransform"]);this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var l,p,n,o,q,m;a=h.projectScene(c,d);b=a.elements;for(l=0,p=b.length;l<p;l++)if(n=b[l],n instanceof THREE.RenderableParticle&&
n.material instanceof THREE.ParticleDOMMaterial)o=n.material.domElement,q=n.x*e+e-(o.offsetWidth>>1),m=n.y*f+f-(o.offsetHeight>>1),o.style.left=q+"px",o.style.top=m+"px",o.style.zIndex=Math.abs(Math.floor((1-n.z)*d.far/d.near)),g&&(o.style[g]="scale("+n.scale.x*e+","+n.scale.y*f+")")}};
THREE.CanvasRenderer=function(a){function b(a){if(v!=a)m.globalAlpha=v=a}function c(a){if(u!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}u=a}}function d(a){if(t!=a)m.strokeStyle=t=a}function e(a){if(w!=a)m.fillStyle=w=a}var a=a||{},f=this,g,h,k,i=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
p,n,o,q,m=l.getContext("2d"),r=new THREE.Color(0),s=0,v=1,u=0,t=null,w=null,y=null,H=null,F=null,C,J,O,Q,S=new THREE.RenderableVertex,M=new THREE.RenderableVertex,A,L,B,j,T,G,D,V,E,ga,da,ea,R=new THREE.Color,$=new THREE.Color,W=new THREE.Color,ba=new THREE.Color,ia=new THREE.Color,sa=[],Ha=[],Ra,Na,va,pa,Ya,jb,fb,bb,gb,ob,Va=new THREE.Rectangle,wa=new THREE.Rectangle,ta=new THREE.Rectangle,Ia=!1,la=new THREE.Color,Ka=new THREE.Color,Da=new THREE.Color,P=new THREE.Vector3,aa,ja,Sc,Za,oc,Bc,a=16;aa=
document.createElement("canvas");aa.width=aa.height=2;ja=aa.getContext("2d");ja.fillStyle="rgba(0,0,0,1)";ja.fillRect(0,0,2,2);Sc=ja.getImageData(0,0,2,2);Za=Sc.data;oc=document.createElement("canvas");oc.width=oc.height=a;Bc=oc.getContext("2d");Bc.translate(-a/2,-a/2);Bc.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;n=b;o=Math.floor(p/2);q=Math.floor(n/2);l.width=p;l.height=n;Va.set(-o,
-q,o,q);wa.set(-o,-q,o,q);v=1;u=0;F=H=y=w=t=null};this.setClearColor=function(a,b){r.copy(a);s=b;wa.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;wa.set(-o,-q,o,q)};this.clear=function(){m.setTransform(1,0,0,-1,o,q);wa.isEmpty()||(wa.minSelf(Va),wa.inflate(2),1>s&&m.clearRect(Math.floor(wa.getX()),Math.floor(wa.getY()),Math.floor(wa.getWidth()),Math.floor(wa.getHeight())),0<s&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*r.r)+","+Math.floor(255*r.g)+","+Math.floor(255*
r.b)+","+s+")"),m.fillRect(Math.floor(wa.getX()),Math.floor(wa.getY()),Math.floor(wa.getWidth()),Math.floor(wa.getHeight()))),wa.empty())};this.render=function(a,l){function n(a){var b,c,d,e;la.setRGB(0,0,0);Ka.setRGB(0,0,0);Da.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(la.r+=e.r,la.g+=e.g,la.b+=e.b):d instanceof THREE.DirectionalLight?(Ka.r+=e.r,Ka.g+=e.g,Ka.b+=e.b):d instanceof THREE.PointLight&&(Da.r+=e.r,Da.g+=e.g,Da.b+=e.b)}function p(a,b,c,d){var e,
f,g,aa,h,j;for(e=0,f=a.length;e<f;e++)g=a[e],aa=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),j=c.dot(h),0>=j||(j*=g.intensity,d.r+=aa.r*j,d.g+=aa.g*j,d.b+=aa.b*j)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),j=c.dot(P.sub(h,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=aa.r*j,d.g+=aa.g*j,d.b+=aa.b*j)))}function r(a,f,g){b(g.opacity);c(g.blending);var aa,h,j,k,i,l;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)k=
g.map.image,i=k.width>>1,l=k.height>>1,g=f.scale.x*o,j=f.scale.y*q,aa=g*i,h=j*l,ta.set(a.x-aa,a.y-h,a.x+aa,a.y+h),Va.intersects(ta)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-j),m.translate(-i,-l),m.drawImage(k,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(aa=f.scale.x*o,h=f.scale.y*q,ta.set(a.x-aa,a.y-h,a.x+aa,a.y+h),Va.intersects(ta)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(aa,
h),g.program(m),m.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)m.lineWidth=y=a;a=g.linecap;if(H!=a)m.lineCap=H=a;a=g.linejoin;if(F!=a)m.lineJoin=F=a;d(g.color.getContextStyle());m.stroke();ta.inflate(2*g.linewidth)}}function t(a,d,e,g,aa,h,i,m){f.info.render.vertices+=3;f.info.render.faces++;b(m.opacity);
c(m.blending);A=a.positionScreen.x;L=a.positionScreen.y;B=d.positionScreen.x;j=d.positionScreen.y;T=e.positionScreen.x;G=e.positionScreen.y;v(A,L,B,j,T,G);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(pa=i.uvs[0],Tc(A,L,B,j,T,G,pa[g].u,pa[g].v,pa[aa].u,pa[aa].v,pa[h].u,pa[h].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,P.copy(i.vertexNormalsWorld[g]),Ya=0.5*(P.x*a.n11+P.y*a.n12+P.z*
a.n13)+0.5,jb=0.5*-(P.x*a.n21+P.y*a.n22+P.z*a.n23)+0.5,P.copy(i.vertexNormalsWorld[aa]),fb=0.5*(P.x*a.n11+P.y*a.n12+P.z*a.n13)+0.5,bb=0.5*-(P.x*a.n21+P.y*a.n22+P.z*a.n23)+0.5,P.copy(i.vertexNormalsWorld[h]),gb=0.5*(P.x*a.n11+P.y*a.n12+P.z*a.n13)+0.5,ob=0.5*-(P.x*a.n21+P.y*a.n22+P.z*a.n23)+0.5,Tc(A,L,B,j,T,G,Ya,jb,fb,bb,gb,ob,m.envMap)}else m.wireframe?Lb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Fb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&
(m.map.mapping instanceof THREE.UVMapping&&(pa=i.uvs[0],Tc(A,L,B,j,T,G,pa[g].u,pa[g].v,pa[aa].u,pa[aa].v,pa[h].u,pa[h].v,m.map)),c(THREE.SubtractiveBlending)),Ia?!m.wireframe&&m.shading==THREE.SmoothShading&&3==i.vertexNormalsWorld.length?($.r=W.r=ba.r=la.r,$.g=W.g=ba.g=la.g,$.b=W.b=ba.b=la.b,p(k,i.v1.positionWorld,i.vertexNormalsWorld[0],$),p(k,i.v2.positionWorld,i.vertexNormalsWorld[1],W),p(k,i.v3.positionWorld,i.vertexNormalsWorld[2],ba),$.r=Math.max(0,Math.min(m.color.r*$.r,1)),$.g=Math.max(0,
Math.min(m.color.g*$.g,1)),$.b=Math.max(0,Math.min(m.color.b*$.b,1)),W.r=Math.max(0,Math.min(m.color.r*W.r,1)),W.g=Math.max(0,Math.min(m.color.g*W.g,1)),W.b=Math.max(0,Math.min(m.color.b*W.b,1)),ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),ia.r=0.5*(W.r+ba.r),ia.g=0.5*(W.g+ba.g),ia.b=0.5*(W.b+ba.b),va=Cc($,W,ba,ia),fc(A,L,B,j,T,G,0,0,1,0,0,1,va)):(R.r=la.r,R.g=la.g,R.b=la.b,p(k,i.centroidWorld,i.normalWorld,R),
R.r=Math.max(0,Math.min(m.color.r*R.r,1)),R.g=Math.max(0,Math.min(m.color.g*R.g,1)),R.b=Math.max(0,Math.min(m.color.b*R.b,1)),m.wireframe?Lb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Fb(R)):m.wireframe?Lb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Fb(m.color);else if(m instanceof THREE.MeshDepthMaterial)Ra=l.near,Na=l.far,$.r=$.g=$.b=1-$b(a.positionScreen.z,Ra,Na),W.r=W.g=W.b=1-$b(d.positionScreen.z,Ra,Na),ba.r=ba.g=ba.b=1-$b(e.positionScreen.z,Ra,Na),
ia.r=0.5*(W.r+ba.r),ia.g=0.5*(W.g+ba.g),ia.b=0.5*(W.b+ba.b),va=Cc($,W,ba,ia),fc(A,L,B,j,T,G,0,0,1,0,0,1,va);else if(m instanceof THREE.MeshNormalMaterial)R.r=gc(i.normalWorld.x),R.g=gc(i.normalWorld.y),R.b=gc(i.normalWorld.z),m.wireframe?Lb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Fb(R)}function u(a,d,e,g,aa,h,m,i,ja){f.info.render.vertices+=4;f.info.render.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)t(a,d,g,0,1,3,m,i,ja),t(aa,e,h,1,2,3,m,i,ja);else if(A=a.positionScreen.x,
L=a.positionScreen.y,B=d.positionScreen.x,j=d.positionScreen.y,T=e.positionScreen.x,G=e.positionScreen.y,D=g.positionScreen.x,V=g.positionScreen.y,E=aa.positionScreen.x,ga=aa.positionScreen.y,da=h.positionScreen.x,ea=h.positionScreen.y,i instanceof THREE.MeshBasicMaterial)w(A,L,B,j,T,G,D,V),i.wireframe?Lb(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):Fb(i.color);else if(i instanceof THREE.MeshLambertMaterial)Ia?!i.wireframe&&i.shading==THREE.SmoothShading&&4==m.vertexNormalsWorld.length?
($.r=W.r=ba.r=ia.r=la.r,$.g=W.g=ba.g=ia.g=la.g,$.b=W.b=ba.b=ia.b=la.b,p(k,m.v1.positionWorld,m.vertexNormalsWorld[0],$),p(k,m.v2.positionWorld,m.vertexNormalsWorld[1],W),p(k,m.v4.positionWorld,m.vertexNormalsWorld[3],ba),p(k,m.v3.positionWorld,m.vertexNormalsWorld[2],ia),$.r=Math.max(0,Math.min(i.color.r*$.r,1)),$.g=Math.max(0,Math.min(i.color.g*$.g,1)),$.b=Math.max(0,Math.min(i.color.b*$.b,1)),W.r=Math.max(0,Math.min(i.color.r*W.r,1)),W.g=Math.max(0,Math.min(i.color.g*W.g,1)),W.b=Math.max(0,Math.min(i.color.b*
W.b,1)),ba.r=Math.max(0,Math.min(i.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(i.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(i.color.b*ba.b,1)),ia.r=Math.max(0,Math.min(i.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(i.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(i.color.b*ia.b,1)),va=Cc($,W,ba,ia),v(A,L,B,j,D,V),fc(A,L,B,j,D,V,0,0,1,0,0,1,va),v(E,ga,T,G,da,ea),fc(E,ga,T,G,da,ea,1,0,1,1,0,1,va)):(R.r=la.r,R.g=la.g,R.b=la.b,p(k,m.centroidWorld,m.normalWorld,R),R.r=Math.max(0,Math.min(i.color.r*R.r,1)),R.g=Math.max(0,
Math.min(i.color.g*R.g,1)),R.b=Math.max(0,Math.min(i.color.b*R.b,1)),w(A,L,B,j,T,G,D,V),i.wireframe?Lb(R,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):Fb(R)):(w(A,L,B,j,T,G,D,V),i.wireframe?Lb(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):Fb(i.color));else if(i instanceof THREE.MeshNormalMaterial)R.r=gc(m.normalWorld.x),R.g=gc(m.normalWorld.y),R.b=gc(m.normalWorld.z),w(A,L,B,j,T,G,D,V),i.wireframe?Lb(R,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):
Fb(R);else if(i instanceof THREE.MeshDepthMaterial)Ra=l.near,Na=l.far,$.r=$.g=$.b=1-$b(a.positionScreen.z,Ra,Na),W.r=W.g=W.b=1-$b(d.positionScreen.z,Ra,Na),ba.r=ba.g=ba.b=1-$b(g.positionScreen.z,Ra,Na),ia.r=ia.g=ia.b=1-$b(e.positionScreen.z,Ra,Na),va=Cc($,W,ba,ia),v(A,L,B,j,D,V),fc(A,L,B,j,D,V,0,0,1,0,0,1,va),v(E,ga,T,G,da,ea),fc(E,ga,T,G,da,ea,1,0,1,1,0,1,va)}function v(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function w(a,b,c,d,e,f,g,aa){m.beginPath();
m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,aa);m.lineTo(a,b);m.closePath()}function Lb(a,b,c,e){if(y!=b)m.lineWidth=y=b;if(H!=c)m.lineCap=H=c;if(F!=e)m.lineJoin=F=e;d(a.getContextStyle());m.stroke();ta.inflate(2*b)}function Fb(a){e(a.getContextStyle());m.fill()}function Tc(a,b,c,d,f,g,aa,h,j,i,k,l,ja){if(0!=ja.image.width){if(!0==ja.needsUpdate||void 0==sa[ja.id]){var n=ja.wrapS==THREE.RepeatWrapping,o=ja.wrapT==THREE.RepeatWrapping;sa[ja.id]=m.createPattern(ja.image,n&&o?"repeat":n&&!o?
"repeat-x":!n&&o?"repeat-y":"no-repeat");ja.needsUpdate=!1}e(sa[ja.id]);var n=ja.offset.x/ja.repeat.x,o=ja.offset.y/ja.repeat.y,P=ja.image.width*ja.repeat.x,Za=ja.image.height*ja.repeat.y,aa=(aa+n)*P,h=(h+o)*Za,c=c-a,d=d-b,f=f-a,g=g-b,j=(j+n)*P-aa,i=(i+o)*Za-h,k=(k+n)*P-aa,l=(l+o)*Za-h,n=j*l-k*i;if(0==n){if(void 0===Ha[ja.id])b=document.createElement("canvas"),b.width=ja.image.width,b.height=ja.image.height,b=b.getContext("2d"),b.drawImage(ja.image,0,0),Ha[ja.id]=b.getImageData(0,0,ja.image.width,
ja.image.height).data;b=Ha[ja.id];aa=4*(Math.floor(aa)+Math.floor(h)*ja.image.width);R.setRGB(b[aa]/255,b[aa+1]/255,b[aa+2]/255);Fb(R)}else n=1/n,ja=(l*c-i*f)*n,i=(l*d-i*g)*n,c=(j*f-k*c)*n,d=(j*g-k*d)*n,a=a-ja*aa-c*h,aa=b-i*aa-d*h,m.save(),m.transform(ja,i,c,d,a,aa),m.fill(),m.restore()}}function fc(a,b,c,d,e,f,g,aa,h,j,i,k,ja){var l,n;l=ja.width-1;n=ja.height-1;g*=l;aa*=n;c-=a;d-=b;e-=a;f-=b;h=h*l-g;j=j*n-aa;i=i*l-g;k=k*n-aa;n=1/(h*k-i*j);l=(k*c-j*e)*n;j=(k*d-j*f)*n;c=(h*e-i*c)*n;d=(h*f-i*d)*n;a=
a-l*g-c*aa;b=b-j*g-d*aa;m.save();m.transform(l,j,c,d,a,b);m.clip();m.drawImage(ja,0,0);m.restore()}function Cc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),j=~~(255*c.r),i=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),m=~~(255*d.g),d=~~(255*d.b);Za[0]=0>e?0:255<e?255:e;Za[1]=0>f?0:255<f?255:f;Za[2]=0>a?0:255<a?255:a;Za[4]=0>g?0:255<g?255:g;Za[5]=0>h?0:255<h?255:h;Za[6]=0>b?0:255<b?255:b;Za[8]=0>j?0:255<j?255:j;Za[9]=0>i?0:255<i?255:i;Za[10]=0>c?0:255<
c?255:c;Za[12]=0>k?0:255<k?255:k;Za[13]=0>m?0:255<m?255:m;Za[14]=0>d?0:255<d?255:d;ja.putImageData(Sc,0,0);Bc.drawImage(aa,0,0);return oc}function $b(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function gc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Mb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Dc,cd,Sa,kb;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,q);f.info.render.vertices=0;f.info.render.faces=0;g=i.projectScene(a,l,this.sortElements);
h=g.elements;k=g.lights;(Ia=0<k.length)&&n(k);for(Dc=0,cd=h.length;Dc<cd;Dc++)if(Sa=h[Dc],kb=Sa.material,kb=kb instanceof THREE.MeshFaceMaterial?Sa.faceMaterial:kb,!(null==kb||0==kb.opacity)){ta.empty();if(Sa instanceof THREE.RenderableParticle)C=Sa,C.x*=o,C.y*=q,r(C,Sa,kb,a);else if(Sa instanceof THREE.RenderableLine)C=Sa.v1,J=Sa.v2,C.positionScreen.x*=o,C.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,ta.addPoint(C.positionScreen.x,C.positionScreen.y),ta.addPoint(J.positionScreen.x,
J.positionScreen.y),Va.intersects(ta)&&s(C,J,Sa,kb,a);else if(Sa instanceof THREE.RenderableFace3)C=Sa.v1,J=Sa.v2,O=Sa.v3,C.positionScreen.x*=o,C.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,O.positionScreen.x*=o,O.positionScreen.y*=q,kb.overdraw&&(Mb(C.positionScreen,J.positionScreen),Mb(J.positionScreen,O.positionScreen),Mb(O.positionScreen,C.positionScreen)),ta.add3Points(C.positionScreen.x,C.positionScreen.y,J.positionScreen.x,J.positionScreen.y,O.positionScreen.x,O.positionScreen.y),
Va.intersects(ta)&&t(C,J,O,0,1,2,Sa,kb,a);else if(Sa instanceof THREE.RenderableFace4)C=Sa.v1,J=Sa.v2,O=Sa.v3,Q=Sa.v4,C.positionScreen.x*=o,C.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,O.positionScreen.x*=o,O.positionScreen.y*=q,Q.positionScreen.x*=o,Q.positionScreen.y*=q,S.positionScreen.copy(J.positionScreen),M.positionScreen.copy(Q.positionScreen),kb.overdraw&&(Mb(C.positionScreen,J.positionScreen),Mb(J.positionScreen,Q.positionScreen),Mb(Q.positionScreen,C.positionScreen),
Mb(O.positionScreen,S.positionScreen),Mb(O.positionScreen,M.positionScreen)),ta.addPoint(C.positionScreen.x,C.positionScreen.y),ta.addPoint(J.positionScreen.x,J.positionScreen.y),ta.addPoint(O.positionScreen.x,O.positionScreen.y),ta.addPoint(Q.positionScreen.x,Q.positionScreen.y),Va.intersects(ta)&&u(C,J,O,Q,S,M,Sa,kb,a);wa.addRectangle(ta)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,k;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),k=c.dot(i),0>=k||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(C.sub(i,b).normalize()),0>=k||(k*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=k&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){null==J[a]&&(J[a]=document.createElementNS("http://www.w3.org/2000/svg",
"path"),0==A&&J[a].setAttribute("shape-rendering","crispEdges"));return J[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}var d=this,e,f,g,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,p,n,o,q,m,r,s=new THREE.Rectangle,v=new THREE.Rectangle,u=!1,t=new THREE.Color,w=new THREE.Color,y=new THREE.Color,H=new THREE.Color,F,C=new THREE.Vector3,J=[],O=[],Q,S,M,A=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
faces:0}};this.setQuality=function(a){switch(a){case "high":A=1;break;case "low":A=0}};this.setSize=function(a,b){i=a;l=b;p=i/2;n=l/2;k.setAttribute("viewBox",-p+" "+-n+" "+i+" "+l);k.setAttribute("width",i);k.setAttribute("height",l);s.set(-p,-n,p,n)};this.clear=function(){for(;0<k.childNodes.length;)k.removeChild(k.childNodes[0])};this.render=function(i,l){var j,C,G,D;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(i,l,this.sortElements);f=e.elements;
g=e.lights;M=S=0;if(u=0<g.length){w.setRGB(0,0,0);y.setRGB(0,0,0);H.setRGB(0,0,0);for(j=0,C=g.length;j<C;j++)D=g[j],G=D.color,D instanceof THREE.AmbientLight?(w.r+=G.r,w.g+=G.g,w.b+=G.b):D instanceof THREE.DirectionalLight?(y.r+=G.r,y.g+=G.g,y.b+=G.b):D instanceof THREE.PointLight&&(H.r+=G.r,H.g+=G.g,H.b+=G.b)}for(j=0,C=f.length;j<C;j++)if(G=f[j],D=G.material,D=D instanceof THREE.MeshFaceMaterial?G.faceMaterial:D,!(null==D||0==D.opacity))if(v.empty(),G instanceof THREE.RenderableParticle)o=G,o.x*=
p,o.y*=-n;else if(G instanceof THREE.RenderableLine){if(o=G.v1,q=G.v2,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,v.addPoint(o.positionScreen.x,o.positionScreen.y),v.addPoint(q.positionScreen.x,q.positionScreen.y),s.intersects(v)){G=o;var V=q,E=M++;null==O[E]&&(O[E]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==A&&O[E].setAttribute("shape-rendering","crispEdges"));Q=O[E];Q.setAttribute("x1",G.positionScreen.x);Q.setAttribute("y1",G.positionScreen.y);
Q.setAttribute("x2",V.positionScreen.x);Q.setAttribute("y2",V.positionScreen.y);D instanceof THREE.LineBasicMaterial&&(Q.setAttribute("style","fill: none; stroke: "+D.color.getContextStyle()+"; stroke-width: "+D.linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.linecap+"; stroke-linejoin: "+D.linejoin),k.appendChild(Q))}}else if(G instanceof THREE.RenderableFace3){if(o=G.v1,q=G.v2,m=G.v3,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,m.positionScreen.x*=
p,m.positionScreen.y*=-n,v.addPoint(o.positionScreen.x,o.positionScreen.y),v.addPoint(q.positionScreen.x,q.positionScreen.y),v.addPoint(m.positionScreen.x,m.positionScreen.y),s.intersects(v)){var V=o,E=q,J=m;d.info.render.vertices+=3;d.info.render.faces++;Q=b(S++);Q.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+E.positionScreen.x+" "+E.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");D instanceof THREE.MeshBasicMaterial?t.copy(D.color):D instanceof THREE.MeshLambertMaterial?
u?(t.r=w.r,t.g=w.g,t.b=w.b,a(g,G.centroidWorld,G.normalWorld,t),t.r=Math.max(0,Math.min(D.color.r*t.r,1)),t.g=Math.max(0,Math.min(D.color.g*t.g,1)),t.b=Math.max(0,Math.min(D.color.b*t.b,1))):t.copy(D.color):D instanceof THREE.MeshDepthMaterial?(F=1-D.__2near/(D.__farPlusNear-G.z*D.__farMinusNear),t.setRGB(F,F,F)):D instanceof THREE.MeshNormalMaterial&&t.setRGB(c(G.normalWorld.x),c(G.normalWorld.y),c(G.normalWorld.z));D.wireframe?Q.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+
D.wireframeLinewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframeLinecap+"; stroke-linejoin: "+D.wireframeLinejoin):Q.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+D.opacity);k.appendChild(Q)}}else if(G instanceof THREE.RenderableFace4&&(o=G.v1,q=G.v2,m=G.v3,r=G.v4,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,m.positionScreen.x*=p,m.positionScreen.y*=-n,r.positionScreen.x*=p,r.positionScreen.y*=-n,v.addPoint(o.positionScreen.x,
o.positionScreen.y),v.addPoint(q.positionScreen.x,q.positionScreen.y),v.addPoint(m.positionScreen.x,m.positionScreen.y),v.addPoint(r.positionScreen.x,r.positionScreen.y),s.intersects(v))){var V=o,E=q,J=m,da=r;d.info.render.vertices+=4;d.info.render.faces++;Q=b(S++);Q.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+E.positionScreen.x+" "+E.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");D instanceof THREE.MeshBasicMaterial?
t.copy(D.color):D instanceof THREE.MeshLambertMaterial?u?(t.r=w.r,t.g=w.g,t.b=w.b,a(g,G.centroidWorld,G.normalWorld,t),t.r=Math.max(0,Math.min(D.color.r*t.r,1)),t.g=Math.max(0,Math.min(D.color.g*t.g,1)),t.b=Math.max(0,Math.min(D.color.b*t.b,1))):t.copy(D.color):D instanceof THREE.MeshDepthMaterial?(F=1-D.__2near/(D.__farPlusNear-G.z*D.__farMinusNear),t.setRGB(F,F,F)):D instanceof THREE.MeshNormalMaterial&&t.setRGB(c(G.normalWorld.x),c(G.normalWorld.y),c(G.normalWorld.z));D.wireframe?Q.setAttribute("style",
"fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+D.wireframeLinewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframeLinecap+"; stroke-linejoin: "+D.wireframeLinejoin):Q.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+D.opacity);k.appendChild(Q)}}};
A
alteredq 已提交
213
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",
214 215
envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#endif\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\n}\n#endif",
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",
A
alteredq 已提交
216
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",
217 218
lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
219
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",
220
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;",
221
lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse  = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse  = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
A
alteredq 已提交
222
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * modelViewMatrix * gl_Position;\n#endif",
A
alteredq 已提交
223
morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
224
default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal +=  ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal +=  ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal +=  ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal +=  ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\nvec3 transformedNormal = normalMatrix * morphedNormal;\n#else\nvec3 transformedNormal = normalMatrix * normal;\n#endif",
A
alteredq 已提交
225
shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
226 227
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"};
Z
zz85 已提交
228
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 已提交
229
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",
230
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",
231
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 已提交
232
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",
233
value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalMatrix * normal;\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,
A
alteredq 已提交
234 235
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,
236 237 238 239 240 241 242 243 244
THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,
1,1)}}]),vertexShader:["varying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,
THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",
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;",THREE.ShaderChunk.morphnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;",
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;",
245 246
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}"}};
247
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 f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=j.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}
248
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 f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;
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 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
var i=a.colors,k=i.length,m=a.__vertexArray,l=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,P=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){ta.copy(wa);ta.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,Ia.copy(e),ta.multiplyVector3(Ia),n[d]=[Ia.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[n[d][1]].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;for(d=0;d<k;d++)f=3*d,e=i[n[d][1]],l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(p)for(i=0,k=p.length;i<k;i++)if(h=
p[i],void 0===h.boundTo||"vertices"===h.boundTo)if(f=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(2===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],
h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;if(P)for(d=0;d<k;d++)e=i[d],f=3*d,l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(p)for(i=0,k=p.length;i<k;i++)if(h=p[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,f=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===
h.type)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,m,b);if(P||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,
l,b);if(p)for(i=0,k=p.length;i<k;i++)if(h=p[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}function g(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)ga=G=null,V=E=Ha=sa=$=-1,a[d].render(b,c,gb,ob),ga=G=null,V=E=Ha=sa=$=-1}function k(a,b,c,d,e,f,g,h){var j,i,k,m;b?(i=a.length-1,m=b=-1):(i=0,b=a.length,m=1);for(var l=i;l!==b;l+=m)if(j=a[l],j.render){i=j.object;k=j.buffer;if(h)j=h;else{j=j[c];if(!j)continue;
g&&B.setBlending(j.blending,j.blendEquation,j.blendSrc,j.blendDst);B.setDepthTest(j.depthTest);B.setDepthWrite(j.depthWrite);s(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}B.setObjectFaces(i);k instanceof THREE.BufferGeometry?B.renderBufferDirect(d,e,f,j,k,i):B.renderBuffer(d,e,f,j,k,i)}}function i(a,b,c,d,e,f,g){for(var h,j,i=0,k=a.length;i<k;i++)if(h=a[i],j=h.object,j.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&B.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);B.setDepthTest(h.depthTest);
B.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}B.renderImmediateObject(c,d,e,h,j)}}function l(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function n(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function q(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,
1)}function m(a,b,c,d,e){if(!d.program||d.needsUpdate)B.initMaterial(d,b,c,e),d.needsUpdate=!1;if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(B.maxMorphTargets);for(var f=0,g=B.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==G&&(j.useProgram(f),G=f,h=!0);if(d.id!==V)V=d.id,h=!0;if(h||a!==ga)j.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray),a!==ga&&(ga=a);if(h){if(c&&
d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var k,m=0,l=0,n=0,o,p,q,r=Ka,s=r.directional.colors,t=r.directional.positions,D=r.point.colors,v=r.point.positions,E=r.point.distances,w=0,F=0,C=q=0;for(c=0,h=b.length;c<h;c++)if(k=b[c],!k.onlyShadow)if(o=k.color,p=k.intensity,q=k.distance,k instanceof
THREE.AmbientLight)B.gammaInput?(m+=o.r*o.r,l+=o.g*o.g,n+=o.b*o.b):(m+=o.r,l+=o.g,n+=o.b);else if(k instanceof THREE.DirectionalLight)q=3*w,B.gammaInput?(s[q]=o.r*o.r*p*p,s[q+1]=o.g*o.g*p*p,s[q+2]=o.b*o.b*p*p):(s[q]=o.r*p,s[q+1]=o.g*p,s[q+2]=o.b*p),la.copy(k.matrixWorld.getPosition()),la.subSelf(k.target.matrixWorld.getPosition()),la.normalize(),t[q]=la.x,t[q+1]=la.y,t[q+2]=la.z,w+=1;else if(k instanceof THREE.PointLight||k instanceof THREE.SpotLight)C=3*F,B.gammaInput?(D[C]=o.r*o.r*p*p,D[C+1]=o.g*
o.g*p*p,D[C+2]=o.b*o.b*p*p):(D[C]=o.r*p,D[C+1]=o.g*p,D[C+2]=o.b*p),k=k.matrixWorld.getPosition(),v[C]=k.x,v[C+1]=k.y,v[C+2]=k.z,E[F]=q,F+=1;for(c=3*w,h=s.length;c<h;c++)s[c]=0;for(c=3*F,h=D.length;c<h;c++)D[c]=0;r.point.length=F;r.directional.length=w;r.ambient[0]=m;r.ambient[1]=l;r.ambient[2]=n;c=Ka;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=
c.point.positions;i.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,B.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?
1:-1,i.reflectivity.value=d.reflectivity,i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=H.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=
d.shininess,B.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.emissive.value.copyGammaToLinear(d.emissive),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive,i.specular.value=d.specular),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)B.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.emissive.value.copyGammaToLinear(d.emissive)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive),
d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){h=c=0;for(m=b.length;h<m;h++)if(l=b[h],l.castShadow&&(l instanceof THREE.SpotLight||l instanceof THREE.DirectionalLight&&!l.shadowCascade))i.shadowMap.texture[c]=l.shadowMap,i.shadowMapSize.value[c]=l.shadowMapSize,i.shadowMatrix.value[c]=
l.shadowMatrix,i.shadowDarkness.value[c]=l.shadowDarkness,i.shadowBias.value[c]=l.shadowBias,c++}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(l=f.uniforms[b[i][1]])if(h=b[i][0],n=h.type,m=h.value,"i"===n)j.uniform1i(l,m);else if("f"===n)j.uniform1f(l,m);else if("v2"===n)j.uniform2f(l,m.x,m.y);else if("v3"===n)j.uniform3f(l,m.x,m.y,m.z);else if("v4"===n)j.uniform4f(l,m.x,m.y,m.z,m.w);else if("c"===n)j.uniform3f(l,m.r,m.g,m.b);else if("fv1"===n)j.uniform1fv(l,m);else if("fv"===n)j.uniform3fv(l,m);
else if("v2v"===n){if(!h._array)h._array=new Float32Array(2*m.length);for(n=0,r=m.length;n<r;n++)s=2*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y;j.uniform2fv(l,h._array)}else if("v3v"===n){if(!h._array)h._array=new Float32Array(3*m.length);for(n=0,r=m.length;n<r;n++)s=3*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y,h._array[s+2]=m[n].z;j.uniform3fv(l,h._array)}else if("v4v"==n){if(!h._array)h._array=new Float32Array(4*m.length);for(n=0,r=m.length;n<r;n++)s=4*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y,h._array[s+
2]=m[n].z,h._array[s+3]=m[n].w;j.uniform4fv(l,h._array)}else if("m4"===n){if(!h._array)h._array=new Float32Array(16);m.flattenToArray(h._array);j.uniformMatrix4fv(l,!1,h._array)}else if("m4v"===n){if(!h._array)h._array=new Float32Array(16*m.length);for(n=0,r=m.length;n<r;n++)m[n].flattenToArrayOffset(h._array,16*n);j.uniformMatrix4fv(l,!1,h._array)}else if("t"===n){if(j.uniform1i(l,m),l=h.texture)if(l.image instanceof Array&&6===l.image.length){if(h=l,6===h.image.length)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=
j.createTexture();j.activeTexture(j.TEXTURE0+m);j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);m=[];for(l=0;6>l;l++){n=m;r=l;if(B.autoScaleCubemaps){if(s=h.image[l],D=P,!(s.width<=D&&s.height<=D))v=Math.max(s.width,s.height),t=Math.floor(s.width*D/v),D=Math.floor(s.height*D/v),v=document.createElement("canvas"),v.width=t,v.height=D,v.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,D),s=v}else s=h.image[l];n[r]=s}l=m[0];n=0===(l.width&l.width-1)&&0===(l.height&l.height-1);r=y(h.format);
s=y(h.type);u(j.TEXTURE_CUBE_MAP,h,n);for(l=0;6>l;l++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,r,r,s,m[l]);h.generateMipmaps&&n&&j.generateMipmap(j.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdate)h.onUpdate()}else j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else l instanceof THREE.WebGLRenderTargetCube?(h=l,j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):B.setTexture(l,m)}else if("tv"===n){if(!h._array){h._array=
[];for(n=0,r=h.texture.length;n<r;n++)h._array[n]=m+n}j.uniform1iv(l,h._array);for(n=0,r=h.texture.length;n<r;n++)(l=h.texture[n])&&B.setTexture(l,h._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==g.cameraPosition)b=a.matrixWorld.getPosition(),j.uniform3f(g.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==g.viewMatrix&&j.uniformMatrix4fv(g.viewMatrix,
!1,a._viewMatrixArray);d.skinning&&j.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices)}j.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&j.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==g.objectMatrix&&j.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);
var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function s(a,b,c){Ra!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),Ra=a);if(a&&(Na!==b||va!==c))j.polygonOffset(b,c),Na=b,va=c}function v(a,b){var c;"fragment"===a?c=j.createShader(j.FRAGMENT_SHADER):"vertex"===a&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);return!j.getShaderParameter(c,j.COMPILE_STATUS)?(console.error(j.getShaderInfoLog(c)),
console.error(b),null):c}function u(a,b,c){c?(j.texParameteri(a,j.TEXTURE_WRAP_S,y(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,y(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,y(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,y(b.minFilter))):(j.texParameteri(a,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_MAG_FILTER,w(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,w(b.minFilter)))}function t(a,b){j.bindRenderbuffer(j.RENDERBUFFER,
a);b.depthBuffer&&!b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_COMPONENT16,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a)):j.renderbufferStorage(j.RENDERBUFFER,j.RGBA4,b.width,b.height)}function w(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;
default:return j.LINEAR}}function y(a){switch(a){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;case THREE.NearestFilter:return j.NEAREST;case THREE.NearestMipMapNearestFilter:return j.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return j.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return j.LINEAR;case THREE.LinearMipMapNearestFilter:return j.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return j.LINEAR_MIPMAP_LINEAR;
case THREE.ByteType:return j.BYTE;case THREE.UnsignedByteType:return j.UNSIGNED_BYTE;case THREE.ShortType:return j.SHORT;case THREE.UnsignedShortType:return j.UNSIGNED_SHORT;case THREE.IntType:return j.INT;case THREE.UnsignedIntType:return j.UNSIGNED_INT;case THREE.FloatType:return j.FLOAT;case THREE.AlphaFormat:return j.ALPHA;case THREE.RGBFormat:return j.RGB;case THREE.RGBAFormat:return j.RGBA;case THREE.LuminanceFormat:return j.LUMINANCE;case THREE.LuminanceAlphaFormat:return j.LUMINANCE_ALPHA;
case THREE.AddEquation:return j.FUNC_ADD;case THREE.SubtractEquation:return j.FUNC_SUBTRACT;case THREE.ReverseSubtractEquation:return j.FUNC_REVERSE_SUBTRACT;case THREE.ZeroFactor:return j.ZERO;case THREE.OneFactor:return j.ONE;case THREE.SrcColorFactor:return j.SRC_COLOR;case THREE.OneMinusSrcColorFactor:return j.ONE_MINUS_SRC_COLOR;case THREE.SrcAlphaFactor:return j.SRC_ALPHA;case THREE.OneMinusSrcAlphaFactor:return j.ONE_MINUS_SRC_ALPHA;case THREE.DstAlphaFactor:return j.DST_ALPHA;case THREE.OneMinusDstAlphaFactor:return j.ONE_MINUS_DST_ALPHA;
case THREE.DstColorFactor:return j.DST_COLOR;case THREE.OneMinusDstColorFactor:return j.ONE_MINUS_DST_COLOR;case THREE.SrcAlphaSaturateFactor:return j.SRC_ALPHA_SATURATE}return 0}var a=a||{},H=void 0!==a.canvas?a.canvas:document.createElement("canvas"),F=void 0!==a.precision?a.precision:"highp",C=void 0!==a.alpha?a.alpha:!0,J=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,O=void 0!==a.antialias?a.antialias:!1,Q=void 0!==a.stencil?a.stencil:!0,S=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:
!1,M=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),A=void 0!==a.clearAlpha?a.clearAlpha:0,L=void 0!==a.maxLights?a.maxLights:4;this.domElement=H;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=
this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var B=this,j,T=[],G=null,D=null,V=-1,E=null,ga=null,da=0,ea=null,R=null,$=null,W=null,ba=null,ia=null,sa=null,Ha=null,Ra=null,Na=null,va=null,pa=null,Ya=0,jb=0,fb=0,bb=0,gb=0,ob=0,Va=new THREE.Frustum,wa=new THREE.Matrix4,ta=new THREE.Matrix4,Ia=new THREE.Vector4,
la=new THREE.Vector3,Ka={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};j=function(){var a;try{if(!(a=H.getContext("experimental-webgl",{alpha:C,premultipliedAlpha:J,antialias:O,stencil:Q,preserveDrawingBuffer:S})))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}();
j.clearColor(0,0,0,1);j.clearDepth(1);j.clearStencil(0);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA);j.clearColor(M.r,M.g,M.b,A);this.context=j;var Da=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);j.getParameter(j.MAX_TEXTURE_SIZE);var P=j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return j};this.supportsVertexTextures=
function(){return 0<Da};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){Ya=a;jb=b;fb=c;bb=d;j.viewport(Ya,jb,fb,bb)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){M.setHex(a);A=b;j.clearColor(M.r,M.g,M.b,A)};this.setClearColor=function(a,b){M.copy(a);A=b;j.clearColor(M.r,M.g,M.b,A)};this.getClearColor=
function(){return M};this.getClearAlpha=function(){return A};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=j.COLOR_BUFFER_BIT;if(void 0===b||b)d|=j.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=j.STENCIL_BUFFER_BIT;j.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];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer);
j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets)for(d=0,e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.numMorphNormals)for(d=0,e=c.numMorphNormals;d<e;d++)j.deleteBuffer(c.__webglMorphNormalsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);
B.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--};this.deallocateTexture=
function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),B.info.memory.textures--};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture)if(j.deleteTexture(a.__webglTexture),a instanceof THREE.WebGLRenderTargetCube)for(var b=0;6>b;b++)j.deleteFramebuffer(a.__webglFramebuffer[b]),j.deleteRenderbuffer(a.__webglRenderbuffer[b]);else j.deleteFramebuffer(a.__webglFramebuffer),j.deleteRenderbuffer(a.__webglRenderbuffer)};this.updateShadowMap=function(a,b){G=null;V=E=Ha=sa=
$=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);
if(c===THREE.FlatShading){var d,e,f,g,h,i,m,k,l,n,o=3*a.count;for(n=0;n<o;n+=9)c=a.normalArray,d=c[n],e=c[n+1],f=c[n+2],g=c[n+3],i=c[n+4],k=c[n+5],h=c[n+6],m=c[n+7],l=c[n+8],d=(d+g+h)/3,e=(e+i+m)/3,f=(f+k+l)/3,c[n]=d,c[n+1]=e,c[n+2]=f,c[n+3]=d,c[n+4]=e,c[n+5]=f,c[n+6]=d,c[n+7]=e,c[n+8]=f}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0};
this.renderBufferDirect=function(a,b,c,d,e,f){if(0!==d.opacity&&(c=m(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==E&&(E=d,b=!0),f instanceof THREE.Mesh)){f=e.offsets;d=0;for(c=f.length;d<c;++d)b&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexPositionBuffer),j.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,j.FLOAT,!1,0,12*f[d].index),0<=a.normal&&e.vertexNormalBuffer&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexNormalBuffer),j.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,
j.FLOAT,!1,0,12*f[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.vertexUvBuffer),j.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,j.FLOAT,!1,0,8*f[d].index),j.enableVertexAttribArray(a.uv)):j.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer),j.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,j.FLOAT,!1,0,16*f[d].index)),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),j.drawElements(j.TRIANGLES,
f[d].count,j.UNSIGNED_SHORT,2*f[d].start),B.info.render.calls++,B.info.render.vertices+=f[d].count,B.info.render.faces+=f[d].count/3}};this.renderBuffer=function(a,b,c,d,e,f){if(0!==d.opacity){var g,h,c=m(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==E&&(E=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;-1!==f.morphTargetBase?
(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):0<=c.position&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,
!1,0,0),d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[g]]),j.vertexAttribPointer(c["morphNormal"+g],3,j.FLOAT,!1,0,0)),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],k=-1,l=0;h=f.morphTargetInfluences;var n,o=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(n=0;n<o;n++)!i[n]&&h[n]>k&&(l=n,k=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,
!1,0,0);d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]),j.vertexAttribPointer(c["morphNormal"+g],3,j.FLOAT,!1,0,0));f.__webglMorphTargetInfluences[g]=k;i[l]=1;k=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],0<=b[c.buffer.belongsToAttribute]&&(j.bindBuffer(j.ARRAY_BUFFER,
c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0));0<=b.color&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));0<=b.normal&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));0<=b.tangent&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));0<=b.uv&&(e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),
j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));0<=b.uv2&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&0<=b.skinIndex&&0<=b.skinWeight&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,
e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==pa&&(j.lineWidth(d),pa=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,
0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),B.info.render.calls++,B.info.render.vertices+=e.__webglFaceCount,B.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==pa&&(j.lineWidth(d),pa=d),j.drawArrays(f,0,e.__webglLineCount),B.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),B.info.render.calls++,
B.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),B.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,m,l,n=a.__lights,o=a.fog;V=-1;void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);
b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);wa.multiply(b.projectionMatrix,b.matrixWorldInverse);Va.setFromMatrix(wa);this.autoUpdateObjects&&this.initWebGLObjects(a);h(this.renderPluginsPre,a,b);B.info.render.calls=0;B.info.render.vertices=0;B.info.render.faces=0;B.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,
this.autoClearStencil);l=a.__webglObjects;for(d=0,e=l.length;d<e;d++)if(f=l[d],m=f.object,f.render=!1,m.visible&&(!(m instanceof THREE.Mesh||m instanceof THREE.ParticleSystem)||!m.frustumCulled||Va.contains(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);r(m,b);var P=f,p=P.object,q=P.buffer,t=void 0,t=t=void 0,t=p.material;if(t instanceof THREE.MeshFaceMaterial){if(t=q.materialIndex,0<=t)t=p.geometry.materials[t],t.transparent?(P.transparent=t,P.opaque=null):(P.opaque=t,P.transparent=null)}else if(t)t.transparent?
(P.transparent=t,P.opaque=null):(P.opaque=t,P.transparent=null);f.render=!0;if(this.sortObjects)m.renderDepth?f.z=m.renderDepth:(Ia.copy(m.matrixWorld.getPosition()),wa.multiplyVector3(Ia),f.z=Ia.z)}this.sortObjects&&l.sort(g);l=a.__webglObjectsImmediate;for(d=0,e=l.length;d<e;d++)if(f=l[d],m=f.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=f.object.material,m.transparent?(f.transparent=m,f.opaque=null):(f.opaque=m,f.transparent=null);a.overrideMaterial?
(d=a.overrideMaterial,this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst),this.setDepthTest(d.depthTest),this.setDepthWrite(d.depthWrite),s(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,n,o,!0,d),i(a.__webglObjectsImmediate,"",b,n,o,!1,d)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,n,o,!1),i(a.__webglObjectsImmediate,"opaque",b,n,o,!1),k(a.__webglObjects,!1,"transparent",b,n,o,!0),i(a.__webglObjectsImmediate,"transparent",
b,n,o,!0));h(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(j.bindTexture(j.TEXTURE_CUBE_MAP,c.__webglTexture),j.generateMipmap(j.TEXTURE_CUBE_MAP),j.bindTexture(j.TEXTURE_CUBE_MAP,null)):(j.bindTexture(j.TEXTURE_2D,c.__webglTexture),j.generateMipmap(j.TEXTURE_2D),j.bindTexture(j.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,
c,d,e){var f=m(a,b,c,d,e);E=-1;B.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,j,Va):e.render(function(a){B.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var g=a.__objectsAdded[0],h=a,i=void 0,m=void 0,k=void 0;if(!g.__webglInit)if(g.__webglInit=!0,g._modelViewMatrix=new THREE.Matrix4,g._normalMatrixArray=
new Float32Array(9),g._modelViewMatrixArray=new Float32Array(16),g._objectMatrixArray=new Float32Array(16),g.matrixWorld.flattenToArray(g._objectMatrixArray),g instanceof THREE.Mesh){if(m=g.geometry,m instanceof THREE.Geometry){if(void 0===m.geometryGroups){var P=m,r=void 0,s=void 0,t=void 0,D=void 0,v=void 0,u=void 0,E=void 0,w={},G=P.morphTargets.length,C=P.morphNormals.length;P.geometryGroups={};for(r=0,s=P.faces.length;r<s;r++)t=P.faces[r],D=t.materialIndex,u=void 0!==D?D:-1,void 0===w[u]&&(w[u]=
{hash:u,counter:0}),E=w[u].hash+"_"+w[u].counter,void 0===P.geometryGroups[E]&&(P.geometryGroups[E]={faces3:[],faces4:[],materialIndex:D,vertices:0,numMorphTargets:G,numMorphNormals:C}),v=t instanceof THREE.Face3?3:4,65535<P.geometryGroups[E].vertices+v&&(w[u].counter+=1,E=w[u].hash+"_"+w[u].counter,void 0===P.geometryGroups[E]&&(P.geometryGroups[E]={faces3:[],faces4:[],materialIndex:D,vertices:0,numMorphTargets:G,numMorphNormals:C})),t instanceof THREE.Face3?P.geometryGroups[E].faces3.push(r):P.geometryGroups[E].faces4.push(r),
P.geometryGroups[E].vertices+=v;P.geometryGroupsList=[];var F=void 0;for(F in P.geometryGroups)P.geometryGroups[F].id=da++,P.geometryGroupsList.push(P.geometryGroups[F])}for(i in m.geometryGroups)if(k=m.geometryGroups[i],!k.__webglVertexBuffer){var y=k;y.__webglVertexBuffer=j.createBuffer();y.__webglNormalBuffer=j.createBuffer();y.__webglTangentBuffer=j.createBuffer();y.__webglColorBuffer=j.createBuffer();y.__webglUVBuffer=j.createBuffer();y.__webglUV2Buffer=j.createBuffer();y.__webglSkinVertexABuffer=
j.createBuffer();y.__webglSkinVertexBBuffer=j.createBuffer();y.__webglSkinIndicesBuffer=j.createBuffer();y.__webglSkinWeightsBuffer=j.createBuffer();y.__webglFaceBuffer=j.createBuffer();y.__webglLineBuffer=j.createBuffer();var V=void 0,H=void 0;if(y.numMorphTargets){y.__webglMorphTargetsBuffers=[];for(V=0,H=y.numMorphTargets;V<H;V++)y.__webglMorphTargetsBuffers.push(j.createBuffer())}if(y.numMorphNormals){y.__webglMorphNormalsBuffers=[];for(V=0,H=y.numMorphNormals;V<H;V++)y.__webglMorphNormalsBuffers.push(j.createBuffer())}B.info.memory.geometries++;
var A=k,L=g,$=L.geometry,J=A.faces3,ga=A.faces4,M=3*J.length+4*ga.length,W=1*J.length+2*ga.length,O=3*J.length+4*ga.length,R=c(L,A),Q=e(R),ba=d(R),ia=R.vertexColors?R.vertexColors:!1;A.__vertexArray=new Float32Array(3*M);if(ba)A.__normalArray=new Float32Array(3*M);if($.hasTangents)A.__tangentArray=new Float32Array(4*M);if(ia)A.__colorArray=new Float32Array(3*M);if(Q){if(0<$.faceUvs.length||0<$.faceVertexUvs.length)A.__uvArray=new Float32Array(2*M);if(1<$.faceUvs.length||1<$.faceVertexUvs.length)A.__uv2Array=
new Float32Array(2*M)}if(L.geometry.skinWeights.length&&L.geometry.skinIndices.length)A.__skinVertexAArray=new Float32Array(4*M),A.__skinVertexBArray=new Float32Array(4*M),A.__skinIndexArray=new Float32Array(4*M),A.__skinWeightArray=new Float32Array(4*M);A.__faceArray=new Uint16Array(3*W);A.__lineArray=new Uint16Array(2*O);var S=void 0,T=void 0;if(A.numMorphTargets){A.__morphTargetsArrays=[];for(S=0,T=A.numMorphTargets;S<T;S++)A.__morphTargetsArrays.push(new Float32Array(3*M))}if(A.numMorphNormals){A.__morphNormalsArrays=
[];for(S=0,T=A.numMorphNormals;S<T;S++)A.__morphNormalsArrays.push(new Float32Array(3*M))}A.__webglFaceCount=3*W;A.__webglLineCount=2*O;if(R.attributes){if(void 0===A.__webglCustomAttributesList)A.__webglCustomAttributesList=[];var ea=void 0;for(ea in R.attributes){var Ra=R.attributes[ea],sa={},Ha;for(Ha in Ra)sa[Ha]=Ra[Ha];if(!sa.__webglInitialized||sa.createUniqueBuffers){sa.__webglInitialized=!0;var va=1;"v2"===sa.type?va=2:"v3"===sa.type?va=3:"v4"===sa.type?va=4:"c"===sa.type&&(va=3);sa.size=
va;sa.array=new Float32Array(M*va);sa.buffer=j.createBuffer();sa.buffer.belongsToAttribute=ea;Ra.needsUpdate=!0;sa.__original=Ra}A.__webglCustomAttributesList.push(sa)}}A.__inittedArrays=!0;m.__dirtyVertices=!0;m.__dirtyMorphTargets=!0;m.__dirtyElements=!0;m.__dirtyUvs=!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}}}else if(g instanceof THREE.Ribbon){if(m=g.geometry,!m.__webglVertexBuffer){var Na=m;Na.__webglVertexBuffer=j.createBuffer();Na.__webglColorBuffer=j.createBuffer();B.info.memory.geometries++;
var pa=m,la=pa.vertices.length;pa.__vertexArray=new Float32Array(3*la);pa.__colorArray=new Float32Array(3*la);pa.__webglVertexCount=la;m.__dirtyVertices=!0;m.__dirtyColors=!0}}else if(g instanceof THREE.Line){if(m=g.geometry,!m.__webglVertexBuffer){var wa=m;wa.__webglVertexBuffer=j.createBuffer();wa.__webglColorBuffer=j.createBuffer();B.info.memory.geometries++;var ta=m,Ia=g,Ka=ta.vertices.length;ta.__vertexArray=new Float32Array(3*Ka);ta.__colorArray=new Float32Array(3*Ka);ta.__webglLineCount=Ka;
b(ta,Ia);m.__dirtyVertices=!0;m.__dirtyColors=!0}}else if(g instanceof THREE.ParticleSystem&&(m=g.geometry,!m.__webglVertexBuffer)){var Va=m;Va.__webglVertexBuffer=j.createBuffer();Va.__webglColorBuffer=j.createBuffer();B.info.geometries++;var Ya=m,jb=g,fb=Ya.vertices.length;Ya.__vertexArray=new Float32Array(3*fb);Ya.__colorArray=new Float32Array(3*fb);Ya.__sortArray=[];Ya.__webglParticleCount=fb;b(Ya,jb);m.__dirtyVertices=!0;m.__dirtyColors=!0}if(!g.__webglActive){if(g instanceof THREE.Mesh)if(m=
g.geometry,m instanceof THREE.BufferGeometry)l(h.__webglObjects,m,g);else for(i in m.geometryGroups)k=m.geometryGroups[i],l(h.__webglObjects,k,g);else g instanceof THREE.Ribbon||g instanceof THREE.Line||g instanceof THREE.ParticleSystem?(m=g.geometry,l(h.__webglObjects,m,g)):g instanceof THREE.ImmediateRenderObject||g.immediateRenderCallback?h.__webglObjectsImmediate.push({object:g,opaque:null,transparent:null}):g instanceof THREE.Sprite?h.__webglSprites.push(g):g instanceof THREE.LensFlare&&h.__webglFlares.push(g);
g.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Da=a.__objectsRemoved[0],bb=a;Da instanceof THREE.Mesh||Da instanceof THREE.ParticleSystem||Da instanceof THREE.Ribbon||Da instanceof THREE.Line?o(bb.__webglObjects,Da):Da instanceof THREE.Sprite?q(bb.__webglSprites,Da):Da instanceof THREE.LensFlare?q(bb.__webglFlares,Da):(Da instanceof THREE.ImmediateRenderObject||Da.immediateRenderCallback)&&o(bb.__webglObjectsImmediate,Da);Da.__webglActive=!1;a.__objectsRemoved.splice(0,
1)}for(var gb=0,ob=a.__webglObjects.length;gb<ob;gb++){var mb=a.__webglObjects[gb].object,ka=mb.geometry,pc=void 0,hc=void 0,$a=void 0;if(mb instanceof THREE.Mesh)if(ka instanceof THREE.BufferGeometry)ka.__dirtyVertices=!1,ka.__dirtyElements=!1,ka.__dirtyUvs=!1,ka.__dirtyNormals=!1,ka.__dirtyColors=!1;else{for(var Uc=0,od=ka.geometryGroupsList.length;Uc<od;Uc++)if(pc=ka.geometryGroupsList[Uc],$a=c(mb,pc),hc=$a.attributes&&p($a),ka.__dirtyVertices||ka.__dirtyMorphTargets||ka.__dirtyElements||ka.__dirtyUvs||
ka.__dirtyNormals||ka.__dirtyColors||ka.__dirtyTangents||hc){var fa=pc,pd=mb,cb=j.DYNAMIC_DRAW,qd=!ka.dynamic,ac=$a;if(fa.__inittedArrays){var dd=d(ac),Vc=ac.vertexColors?ac.vertexColors:!1,ed=e(ac),Ec=dd===THREE.SmoothShading,I=void 0,U=void 0,lb=void 0,N=void 0,ic=void 0,Nb=void 0,nb=void 0,Fc=void 0,Gb=void 0,jc=void 0,kc=void 0,X=void 0,Y=void 0,Z=void 0,qa=void 0,pb=void 0,qb=void 0,rb=void 0,qc=void 0,sb=void 0,tb=void 0,ub=void 0,rc=void 0,vb=void 0,wb=void 0,xb=void 0,sc=void 0,yb=void 0,
zb=void 0,Ab=void 0,tc=void 0,Bb=void 0,Cb=void 0,Db=void 0,uc=void 0,Ob=void 0,Pb=void 0,Qb=void 0,Gc=void 0,Rb=void 0,Sb=void 0,Tb=void 0,Hc=void 0,ma=void 0,fd=void 0,Ub=void 0,lc=void 0,mc=void 0,Oa=void 0,gd=void 0,La=void 0,Ma=void 0,Vb=void 0,Hb=void 0,Ea=0,Ja=0,Ib=0,Jb=0,hb=0,Ua=0,ra=0,Wa=0,Fa=0,K=0,ca=0,z=0,db=void 0,Pa=fa.__vertexArray,vc=fa.__uvArray,wc=fa.__uv2Array,ib=fa.__normalArray,xa=fa.__tangentArray,Qa=fa.__colorArray,ya=fa.__skinVertexAArray,za=fa.__skinVertexBArray,Aa=fa.__skinIndexArray,
Ba=fa.__skinWeightArray,Wc=fa.__morphTargetsArrays,Xc=fa.__morphNormalsArrays,Yc=fa.__webglCustomAttributesList,x=void 0,Eb=fa.__faceArray,eb=fa.__lineArray,Xa=pd.geometry,rd=Xa.__dirtyElements,hd=Xa.__dirtyUvs,sd=Xa.__dirtyNormals,td=Xa.__dirtyTangents,ud=Xa.__dirtyColors,vd=Xa.__dirtyMorphTargets,bc=Xa.vertices,na=fa.faces3,oa=fa.faces4,Ga=Xa.faces,Zc=Xa.faceVertexUvs[0],$c=Xa.faceVertexUvs[1],cc=Xa.skinVerticesA,dc=Xa.skinVerticesB,ec=Xa.skinIndices,Wb=Xa.skinWeights,Xb=Xa.morphTargets,Ic=Xa.morphNormals;
if(Xa.__dirtyVertices){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],X=bc[N.a].position,Y=bc[N.b].position,Z=bc[N.c].position,Pa[Ja]=X.x,Pa[Ja+1]=X.y,Pa[Ja+2]=X.z,Pa[Ja+3]=Y.x,Pa[Ja+4]=Y.y,Pa[Ja+5]=Y.z,Pa[Ja+6]=Z.x,Pa[Ja+7]=Z.y,Pa[Ja+8]=Z.z,Ja+=9;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],X=bc[N.a].position,Y=bc[N.b].position,Z=bc[N.c].position,qa=bc[N.d].position,Pa[Ja]=X.x,Pa[Ja+1]=X.y,Pa[Ja+2]=X.z,Pa[Ja+3]=Y.x,Pa[Ja+4]=Y.y,Pa[Ja+5]=Y.z,Pa[Ja+6]=Z.x,Pa[Ja+7]=Z.y,Pa[Ja+8]=Z.z,Pa[Ja+9]=qa.x,Pa[Ja+10]=qa.y,
Pa[Ja+11]=qa.z,Ja+=12;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Pa,cb)}if(vd)for(Oa=0,gd=Xb.length;Oa<gd;Oa++){ca=0;for(I=0,U=na.length;I<U;I++){Vb=na[I];N=Ga[Vb];X=Xb[Oa].vertices[N.a].position;Y=Xb[Oa].vertices[N.b].position;Z=Xb[Oa].vertices[N.c].position;La=Wc[Oa];La[ca]=X.x;La[ca+1]=X.y;La[ca+2]=X.z;La[ca+3]=Y.x;La[ca+4]=Y.y;La[ca+5]=Y.z;La[ca+6]=Z.x;La[ca+7]=Z.y;La[ca+8]=Z.z;if(ac.morphNormals)Ec?(Hb=Ic[Oa].vertexNormals[Vb],sb=Hb.a,tb=Hb.b,ub=Hb.c):ub=
tb=sb=Ic[Oa].faceNormals[Vb],Ma=Xc[Oa],Ma[ca]=sb.x,Ma[ca+1]=sb.y,Ma[ca+2]=sb.z,Ma[ca+3]=tb.x,Ma[ca+4]=tb.y,Ma[ca+5]=tb.z,Ma[ca+6]=ub.x,Ma[ca+7]=ub.y,Ma[ca+8]=ub.z;ca+=9}for(I=0,U=oa.length;I<U;I++){Vb=oa[I];N=Ga[Vb];X=Xb[Oa].vertices[N.a].position;Y=Xb[Oa].vertices[N.b].position;Z=Xb[Oa].vertices[N.c].position;qa=Xb[Oa].vertices[N.d].position;La=Wc[Oa];La[ca]=X.x;La[ca+1]=X.y;La[ca+2]=X.z;La[ca+3]=Y.x;La[ca+4]=Y.y;La[ca+5]=Y.z;La[ca+6]=Z.x;La[ca+7]=Z.y;La[ca+8]=Z.z;La[ca+9]=qa.x;La[ca+10]=qa.y;La[ca+
11]=qa.z;if(ac.morphNormals)Ec?(Hb=Ic[Oa].vertexNormals[Vb],sb=Hb.a,tb=Hb.b,ub=Hb.c,rc=Hb.d):rc=ub=tb=sb=Ic[Oa].faceNormals[Vb],Ma=Xc[Oa],Ma[ca]=sb.x,Ma[ca+1]=sb.y,Ma[ca+2]=sb.z,Ma[ca+3]=tb.x,Ma[ca+4]=tb.y,Ma[ca+5]=tb.z,Ma[ca+6]=ub.x,Ma[ca+7]=ub.y,Ma[ca+8]=ub.z,Ma[ca+9]=rc.x,Ma[ca+10]=rc.y,Ma[ca+11]=rc.z;ca+=12}j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphTargetsBuffers[Oa]);j.bufferData(j.ARRAY_BUFFER,Wc[Oa],cb);ac.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphNormalsBuffers[Oa]),j.bufferData(j.ARRAY_BUFFER,
Xc[Oa],cb))}if(Wb.length){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],yb=Wb[N.a],zb=Wb[N.b],Ab=Wb[N.c],Ba[K]=yb.x,Ba[K+1]=yb.y,Ba[K+2]=yb.z,Ba[K+3]=yb.w,Ba[K+4]=zb.x,Ba[K+5]=zb.y,Ba[K+6]=zb.z,Ba[K+7]=zb.w,Ba[K+8]=Ab.x,Ba[K+9]=Ab.y,Ba[K+10]=Ab.z,Ba[K+11]=Ab.w,Bb=ec[N.a],Cb=ec[N.b],Db=ec[N.c],Aa[K]=Bb.x,Aa[K+1]=Bb.y,Aa[K+2]=Bb.z,Aa[K+3]=Bb.w,Aa[K+4]=Cb.x,Aa[K+5]=Cb.y,Aa[K+6]=Cb.z,Aa[K+7]=Cb.w,Aa[K+8]=Db.x,Aa[K+9]=Db.y,Aa[K+10]=Db.z,Aa[K+11]=Db.w,Ob=cc[N.a],Pb=cc[N.b],Qb=cc[N.c],ya[K]=Ob.x,ya[K+1]=Ob.y,
ya[K+2]=Ob.z,ya[K+3]=1,ya[K+4]=Pb.x,ya[K+5]=Pb.y,ya[K+6]=Pb.z,ya[K+7]=1,ya[K+8]=Qb.x,ya[K+9]=Qb.y,ya[K+10]=Qb.z,ya[K+11]=1,Rb=dc[N.a],Sb=dc[N.b],Tb=dc[N.c],za[K]=Rb.x,za[K+1]=Rb.y,za[K+2]=Rb.z,za[K+3]=1,za[K+4]=Sb.x,za[K+5]=Sb.y,za[K+6]=Sb.z,za[K+7]=1,za[K+8]=Tb.x,za[K+9]=Tb.y,za[K+10]=Tb.z,za[K+11]=1,K+=12;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],yb=Wb[N.a],zb=Wb[N.b],Ab=Wb[N.c],tc=Wb[N.d],Ba[K]=yb.x,Ba[K+1]=yb.y,Ba[K+2]=yb.z,Ba[K+3]=yb.w,Ba[K+4]=zb.x,Ba[K+5]=zb.y,Ba[K+6]=zb.z,Ba[K+7]=zb.w,Ba[K+8]=
Ab.x,Ba[K+9]=Ab.y,Ba[K+10]=Ab.z,Ba[K+11]=Ab.w,Ba[K+12]=tc.x,Ba[K+13]=tc.y,Ba[K+14]=tc.z,Ba[K+15]=tc.w,Bb=ec[N.a],Cb=ec[N.b],Db=ec[N.c],uc=ec[N.d],Aa[K]=Bb.x,Aa[K+1]=Bb.y,Aa[K+2]=Bb.z,Aa[K+3]=Bb.w,Aa[K+4]=Cb.x,Aa[K+5]=Cb.y,Aa[K+6]=Cb.z,Aa[K+7]=Cb.w,Aa[K+8]=Db.x,Aa[K+9]=Db.y,Aa[K+10]=Db.z,Aa[K+11]=Db.w,Aa[K+12]=uc.x,Aa[K+13]=uc.y,Aa[K+14]=uc.z,Aa[K+15]=uc.w,Ob=cc[N.a],Pb=cc[N.b],Qb=cc[N.c],Gc=cc[N.d],ya[K]=Ob.x,ya[K+1]=Ob.y,ya[K+2]=Ob.z,ya[K+3]=1,ya[K+4]=Pb.x,ya[K+5]=Pb.y,ya[K+6]=Pb.z,ya[K+7]=1,ya[K+
8]=Qb.x,ya[K+9]=Qb.y,ya[K+10]=Qb.z,ya[K+11]=1,ya[K+12]=Gc.x,ya[K+13]=Gc.y,ya[K+14]=Gc.z,ya[K+15]=1,Rb=dc[N.a],Sb=dc[N.b],Tb=dc[N.c],Hc=dc[N.d],za[K]=Rb.x,za[K+1]=Rb.y,za[K+2]=Rb.z,za[K+3]=1,za[K+4]=Sb.x,za[K+5]=Sb.y,za[K+6]=Sb.z,za[K+7]=1,za[K+8]=Tb.x,za[K+9]=Tb.y,za[K+10]=Tb.z,za[K+11]=1,za[K+12]=Hc.x,za[K+13]=Hc.y,za[K+14]=Hc.z,za[K+15]=1,K+=16;0<K&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ya,cb),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexBBuffer),
j.bufferData(j.ARRAY_BUFFER,za,cb),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,Aa,cb),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,Ba,cb))}if(ud&&Vc){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],nb=N.vertexColors,Fc=N.color,3===nb.length&&Vc===THREE.VertexColors?(vb=nb[0],wb=nb[1],xb=nb[2]):xb=wb=vb=Fc,Qa[Fa]=vb.r,Qa[Fa+1]=vb.g,Qa[Fa+2]=vb.b,Qa[Fa+3]=wb.r,Qa[Fa+4]=wb.g,Qa[Fa+5]=wb.b,Qa[Fa+6]=xb.r,Qa[Fa+7]=xb.g,Qa[Fa+8]=xb.b,
Fa+=9;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],nb=N.vertexColors,Fc=N.color,4===nb.length&&Vc===THREE.VertexColors?(vb=nb[0],wb=nb[1],xb=nb[2],sc=nb[3]):sc=xb=wb=vb=Fc,Qa[Fa]=vb.r,Qa[Fa+1]=vb.g,Qa[Fa+2]=vb.b,Qa[Fa+3]=wb.r,Qa[Fa+4]=wb.g,Qa[Fa+5]=wb.b,Qa[Fa+6]=xb.r,Qa[Fa+7]=xb.g,Qa[Fa+8]=xb.b,Qa[Fa+9]=sc.r,Qa[Fa+10]=sc.g,Qa[Fa+11]=sc.b,Fa+=12;0<Fa&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Qa,cb))}if(td&&Xa.hasTangents){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],Gb=
N.vertexTangents,pb=Gb[0],qb=Gb[1],rb=Gb[2],xa[ra]=pb.x,xa[ra+1]=pb.y,xa[ra+2]=pb.z,xa[ra+3]=pb.w,xa[ra+4]=qb.x,xa[ra+5]=qb.y,xa[ra+6]=qb.z,xa[ra+7]=qb.w,xa[ra+8]=rb.x,xa[ra+9]=rb.y,xa[ra+10]=rb.z,xa[ra+11]=rb.w,ra+=12;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],Gb=N.vertexTangents,pb=Gb[0],qb=Gb[1],rb=Gb[2],qc=Gb[3],xa[ra]=pb.x,xa[ra+1]=pb.y,xa[ra+2]=pb.z,xa[ra+3]=pb.w,xa[ra+4]=qb.x,xa[ra+5]=qb.y,xa[ra+6]=qb.z,xa[ra+7]=qb.w,xa[ra+8]=rb.x,xa[ra+9]=rb.y,xa[ra+10]=rb.z,xa[ra+11]=rb.w,xa[ra+12]=qc.x,xa[ra+
13]=qc.y,xa[ra+14]=qc.z,xa[ra+15]=qc.w,ra+=16;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,xa,cb)}if(sd&&dd){for(I=0,U=na.length;I<U;I++)if(N=Ga[na[I]],ic=N.vertexNormals,Nb=N.normal,3===ic.length&&Ec)for(ma=0;3>ma;ma++)Ub=ic[ma],ib[Ua]=Ub.x,ib[Ua+1]=Ub.y,ib[Ua+2]=Ub.z,Ua+=3;else for(ma=0;3>ma;ma++)ib[Ua]=Nb.x,ib[Ua+1]=Nb.y,ib[Ua+2]=Nb.z,Ua+=3;for(I=0,U=oa.length;I<U;I++)if(N=Ga[oa[I]],ic=N.vertexNormals,Nb=N.normal,4===ic.length&&Ec)for(ma=0;4>ma;ma++)Ub=ic[ma],
ib[Ua]=Ub.x,ib[Ua+1]=Ub.y,ib[Ua+2]=Ub.z,Ua+=3;else for(ma=0;4>ma;ma++)ib[Ua]=Nb.x,ib[Ua+1]=Nb.y,ib[Ua+2]=Nb.z,Ua+=3;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,ib,cb)}if(hd&&Zc&&ed){for(I=0,U=na.length;I<U;I++)if(lb=na[I],N=Ga[lb],jc=Zc[lb],void 0!==jc)for(ma=0;3>ma;ma++)lc=jc[ma],vc[Ib]=lc.u,vc[Ib+1]=lc.v,Ib+=2;for(I=0,U=oa.length;I<U;I++)if(lb=oa[I],N=Ga[lb],jc=Zc[lb],void 0!==jc)for(ma=0;4>ma;ma++)lc=jc[ma],vc[Ib]=lc.u,vc[Ib+1]=lc.v,Ib+=2;0<Ib&&(j.bindBuffer(j.ARRAY_BUFFER,
fa.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,vc,cb))}if(hd&&$c&&ed){for(I=0,U=na.length;I<U;I++)if(lb=na[I],N=Ga[lb],kc=$c[lb],void 0!==kc)for(ma=0;3>ma;ma++)mc=kc[ma],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;for(I=0,U=oa.length;I<U;I++)if(lb=oa[I],N=Ga[lb],kc=$c[lb],void 0!==kc)for(ma=0;4>ma;ma++)mc=kc[ma],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;0<Jb&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,wc,cb))}if(rd){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],Eb[hb]=Ea,Eb[hb+1]=Ea+1,Eb[hb+
2]=Ea+2,hb+=3,eb[Wa]=Ea,eb[Wa+1]=Ea+1,eb[Wa+2]=Ea,eb[Wa+3]=Ea+2,eb[Wa+4]=Ea+1,eb[Wa+5]=Ea+2,Wa+=6,Ea+=3;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],Eb[hb]=Ea,Eb[hb+1]=Ea+1,Eb[hb+2]=Ea+3,Eb[hb+3]=Ea+1,Eb[hb+4]=Ea+2,Eb[hb+5]=Ea+3,hb+=6,eb[Wa]=Ea,eb[Wa+1]=Ea+1,eb[Wa+2]=Ea,eb[Wa+3]=Ea+3,eb[Wa+4]=Ea+1,eb[Wa+5]=Ea+2,eb[Wa+6]=Ea+2,eb[Wa+7]=Ea+3,Wa+=8,Ea+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,fa.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,Eb,cb);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,fa.__webglLineBuffer);
j.bufferData(j.ELEMENT_ARRAY_BUFFER,eb,cb)}if(Yc)for(ma=0,fd=Yc.length;ma<fd;ma++)if(x=Yc[ma],x.__original.needsUpdate){z=0;if(1===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],x.array[z]=x.value[N.a],x.array[z+1]=x.value[N.b],x.array[z+2]=x.value[N.c],z+=3;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],x.array[z]=x.value[N.a],x.array[z+1]=x.value[N.b],x.array[z+2]=x.value[N.c],x.array[z+3]=x.value[N.d],z+=4}else{if("faces"===x.boundTo){for(I=0,U=na.length;I<
U;I++)db=x.value[na[I]],x.array[z]=db,x.array[z+1]=db,x.array[z+2]=db,z+=3;for(I=0,U=oa.length;I<U;I++)db=x.value[oa[I]],x.array[z]=db,x.array[z+1]=db,x.array[z+2]=db,x.array[z+3]=db,z+=4}}else if(2===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],X=x.value[N.a],Y=x.value[N.b],Z=x.value[N.c],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=Y.x,x.array[z+3]=Y.y,x.array[z+4]=Z.x,x.array[z+5]=Z.y,z+=6;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],X=x.value[N.a],Y=
x.value[N.b],Z=x.value[N.c],qa=x.value[N.d],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=Y.x,x.array[z+3]=Y.y,x.array[z+4]=Z.x,x.array[z+5]=Z.y,x.array[z+6]=qa.x,x.array[z+7]=qa.y,z+=8}else{if("faces"===x.boundTo){for(I=0,U=na.length;I<U;I++)Z=Y=X=db=x.value[na[I]],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=Y.x,x.array[z+3]=Y.y,x.array[z+4]=Z.x,x.array[z+5]=Z.y,z+=6;for(I=0,U=oa.length;I<U;I++)qa=Z=Y=X=db=x.value[oa[I]],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=Y.x,x.array[z+3]=Y.y,x.array[z+
4]=Z.x,x.array[z+5]=Z.y,x.array[z+6]=qa.x,x.array[z+7]=qa.y,z+=8}}else if(3===x.size){var ha;ha="c"===x.type?["r","g","b"]:["x","y","z"];if(void 0===x.boundTo||"vertices"===x.boundTo){for(I=0,U=na.length;I<U;I++)N=Ga[na[I]],X=x.value[N.a],Y=x.value[N.b],Z=x.value[N.c],x.array[z]=X[ha[0]],x.array[z+1]=X[ha[1]],x.array[z+2]=X[ha[2]],x.array[z+3]=Y[ha[0]],x.array[z+4]=Y[ha[1]],x.array[z+5]=Y[ha[2]],x.array[z+6]=Z[ha[0]],x.array[z+7]=Z[ha[1]],x.array[z+8]=Z[ha[2]],z+=9;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],
X=x.value[N.a],Y=x.value[N.b],Z=x.value[N.c],qa=x.value[N.d],x.array[z]=X[ha[0]],x.array[z+1]=X[ha[1]],x.array[z+2]=X[ha[2]],x.array[z+3]=Y[ha[0]],x.array[z+4]=Y[ha[1]],x.array[z+5]=Y[ha[2]],x.array[z+6]=Z[ha[0]],x.array[z+7]=Z[ha[1]],x.array[z+8]=Z[ha[2]],x.array[z+9]=qa[ha[0]],x.array[z+10]=qa[ha[1]],x.array[z+11]=qa[ha[2]],z+=12}else if("faces"===x.boundTo){for(I=0,U=na.length;I<U;I++)Z=Y=X=db=x.value[na[I]],x.array[z]=X[ha[0]],x.array[z+1]=X[ha[1]],x.array[z+2]=X[ha[2]],x.array[z+3]=Y[ha[0]],
x.array[z+4]=Y[ha[1]],x.array[z+5]=Y[ha[2]],x.array[z+6]=Z[ha[0]],x.array[z+7]=Z[ha[1]],x.array[z+8]=Z[ha[2]],z+=9;for(I=0,U=oa.length;I<U;I++)qa=Z=Y=X=db=x.value[oa[I]],x.array[z]=X[ha[0]],x.array[z+1]=X[ha[1]],x.array[z+2]=X[ha[2]],x.array[z+3]=Y[ha[0]],x.array[z+4]=Y[ha[1]],x.array[z+5]=Y[ha[2]],x.array[z+6]=Z[ha[0]],x.array[z+7]=Z[ha[1]],x.array[z+8]=Z[ha[2]],x.array[z+9]=qa[ha[0]],x.array[z+10]=qa[ha[1]],x.array[z+11]=qa[ha[2]],z+=12}}else if(4===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(I=
0,U=na.length;I<U;I++)N=Ga[na[I]],X=x.value[N.a],Y=x.value[N.b],Z=x.value[N.c],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=X.z,x.array[z+3]=X.w,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=Y.z,x.array[z+7]=Y.w,x.array[z+8]=Z.x,x.array[z+9]=Z.y,x.array[z+10]=Z.z,x.array[z+11]=Z.w,z+=12;for(I=0,U=oa.length;I<U;I++)N=Ga[oa[I]],X=x.value[N.a],Y=x.value[N.b],Z=x.value[N.c],qa=x.value[N.d],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=X.z,x.array[z+3]=X.w,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=
Y.z,x.array[z+7]=Y.w,x.array[z+8]=Z.x,x.array[z+9]=Z.y,x.array[z+10]=Z.z,x.array[z+11]=Z.w,x.array[z+12]=qa.x,x.array[z+13]=qa.y,x.array[z+14]=qa.z,x.array[z+15]=qa.w,z+=16}else if("faces"===x.boundTo){for(I=0,U=na.length;I<U;I++)Z=Y=X=db=x.value[na[I]],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=X.z,x.array[z+3]=X.w,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=Y.z,x.array[z+7]=Y.w,x.array[z+8]=Z.x,x.array[z+9]=Z.y,x.array[z+10]=Z.z,x.array[z+11]=Z.w,z+=12;for(I=0,U=oa.length;I<U;I++)qa=Z=Y=X=
db=x.value[oa[I]],x.array[z]=X.x,x.array[z+1]=X.y,x.array[z+2]=X.z,x.array[z+3]=X.w,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=Y.z,x.array[z+7]=Y.w,x.array[z+8]=Z.x,x.array[z+9]=Z.y,x.array[z+10]=Z.z,x.array[z+11]=Z.w,x.array[z+12]=qa.x,x.array[z+13]=qa.y,x.array[z+14]=qa.z,x.array[z+15]=qa.w,z+=16}j.bindBuffer(j.ARRAY_BUFFER,x.buffer);j.bufferData(j.ARRAY_BUFFER,x.array,cb)}qd&&(delete fa.__inittedArrays,delete fa.__colorArray,delete fa.__normalArray,delete fa.__tangentArray,delete fa.__uvArray,
delete fa.__uv2Array,delete fa.__faceArray,delete fa.__vertexArray,delete fa.__lineArray,delete fa.__skinVertexAArray,delete fa.__skinVertexBArray,delete fa.__skinIndexArray,delete fa.__skinWeightArray)}}ka.__dirtyVertices=!1;ka.__dirtyMorphTargets=!1;ka.__dirtyElements=!1;ka.__dirtyUvs=!1;ka.__dirtyNormals=!1;ka.__dirtyColors=!1;ka.__dirtyTangents=!1;$a.attributes&&n($a)}else if(mb instanceof THREE.Ribbon){if(ka.__dirtyVertices||ka.__dirtyColors){var Yb=ka,id=j.DYNAMIC_DRAW,xc=void 0,yc=void 0,Jc=
void 0,Zb=void 0,Kc=void 0,jd=Yb.vertices,kd=Yb.colors,wd=jd.length,xd=kd.length,Lc=Yb.__vertexArray,Mc=Yb.__colorArray,yd=Yb.__dirtyColors;if(Yb.__dirtyVertices){for(xc=0;xc<wd;xc++)Jc=jd[xc].position,Zb=3*xc,Lc[Zb]=Jc.x,Lc[Zb+1]=Jc.y,Lc[Zb+2]=Jc.z;j.bindBuffer(j.ARRAY_BUFFER,Yb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Lc,id)}if(yd){for(yc=0;yc<xd;yc++)Kc=kd[yc],Zb=3*yc,Mc[Zb]=Kc.r,Mc[Zb+1]=Kc.g,Mc[Zb+2]=Kc.b;j.bindBuffer(j.ARRAY_BUFFER,Yb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,
Mc,id)}}ka.__dirtyVertices=!1;ka.__dirtyColors=!1}else if(mb instanceof THREE.Line){$a=c(mb,pc);hc=$a.attributes&&p($a);if(ka.__dirtyVertices||ka.__dirtyColors||hc){var Kb=ka,ad=j.DYNAMIC_DRAW,zc=void 0,Ac=void 0,Nc=void 0,Ca=void 0,Oc=void 0,ld=Kb.vertices,md=Kb.colors,zd=ld.length,Ad=md.length,Pc=Kb.__vertexArray,Qc=Kb.__colorArray,Bd=Kb.__dirtyColors,bd=Kb.__webglCustomAttributesList,Rc=void 0,nd=void 0,Ta=void 0,nc=void 0,ab=void 0,ua=void 0;if(Kb.__dirtyVertices){for(zc=0;zc<zd;zc++)Nc=ld[zc].position,
Ca=3*zc,Pc[Ca]=Nc.x,Pc[Ca+1]=Nc.y,Pc[Ca+2]=Nc.z;j.bindBuffer(j.ARRAY_BUFFER,Kb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Pc,ad)}if(Bd){for(Ac=0;Ac<Ad;Ac++)Oc=md[Ac],Ca=3*Ac,Qc[Ca]=Oc.r,Qc[Ca+1]=Oc.g,Qc[Ca+2]=Oc.b;j.bindBuffer(j.ARRAY_BUFFER,Kb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Qc,ad)}if(bd)for(Rc=0,nd=bd.length;Rc<nd;Rc++)if(ua=bd[Rc],ua.needsUpdate&&(void 0===ua.boundTo||"vertices"===ua.boundTo)){Ca=0;nc=ua.value.length;if(1===ua.size)for(Ta=0;Ta<nc;Ta++)ua.array[Ta]=ua.value[Ta];
else if(2===ua.size)for(Ta=0;Ta<nc;Ta++)ab=ua.value[Ta],ua.array[Ca]=ab.x,ua.array[Ca+1]=ab.y,Ca+=2;else if(3===ua.size)if("c"===ua.type)for(Ta=0;Ta<nc;Ta++)ab=ua.value[Ta],ua.array[Ca]=ab.r,ua.array[Ca+1]=ab.g,ua.array[Ca+2]=ab.b,Ca+=3;else for(Ta=0;Ta<nc;Ta++)ab=ua.value[Ta],ua.array[Ca]=ab.x,ua.array[Ca+1]=ab.y,ua.array[Ca+2]=ab.z,Ca+=3;else if(4===ua.size)for(Ta=0;Ta<nc;Ta++)ab=ua.value[Ta],ua.array[Ca]=ab.x,ua.array[Ca+1]=ab.y,ua.array[Ca+2]=ab.z,ua.array[Ca+3]=ab.w,Ca+=4;j.bindBuffer(j.ARRAY_BUFFER,
ua.buffer);j.bufferData(j.ARRAY_BUFFER,ua.array,ad)}}ka.__dirtyVertices=!1;ka.__dirtyColors=!1;$a.attributes&&n($a)}else if(mb instanceof THREE.ParticleSystem)$a=c(mb,pc),hc=$a.attributes&&p($a),(ka.__dirtyVertices||ka.__dirtyColors||mb.sortParticles||hc)&&f(ka,j.DYNAMIC_DRAW,mb),ka.__dirtyVertices=!1,ka.__dirtyColors=!1,$a.attributes&&n($a)}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof
THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var m=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(m.uniforms);a.vertexShader=m.vertexShader;a.fragmentShader=m.fragmentShader}var k,l;f=m=0;for(k=0,l=b.length;k<l;k++)e=b[k],e.onlyShadow||(e instanceof THREE.DirectionalLight&&f++,e instanceof
THREE.PointLight&&m++,e instanceof THREE.SpotLight&&m++);m+f<=L?k=f:(k=Math.ceil(L*f/(m+f)),m=L-k);e=k;f=m;var n=0;for(m=0,k=b.length;m<k;m++)l=b[m],l.castShadow&&(l instanceof THREE.SpotLight&&n++,l instanceof THREE.DirectionalLight&&!l.shadowCascade&&n++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;var P;a:{k=a.fragmentShader;l=a.vertexShader;var m=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,
355
sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},
356
p,d=[];i?d.push(i):(d.push(k),d.push(l));for(p in c)d.push(p),d.push(c[p]);i=d.join();for(p=0,d=T.length;p<d;p++)if(T[p].code===i){P=T[p].program;break a}p=j.createProgram();d=["precision "+F+" float;",0<Da?"#define VERTEX_TEXTURES":"",B.gammaInput?"#define GAMMA_INPUT":"",B.gammaOutput?"#define GAMMA_OUTPUT":"",B.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+
A
alteredq 已提交
357 358
c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":
"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
M
Mr.doob 已提交
359
e=["precision "+F+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",B.gammaInput?"#define GAMMA_INPUT":"",B.gammaOutput?"#define GAMMA_OUTPUT":"",B.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
360 361 362 363 364 365 366 367 368 369 370 371 372
"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(p,v("fragment",e+k));
j.attachShader(p,v("vertex",d+l));j.linkProgram(p);j.getProgramParameter(p,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(p,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");p.uniforms={};p.attributes={};var q,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(q in m)d.push(q);q=d;for(d=0,m=q.length;d<m;d++)k=q[d],p.uniforms[k]=j.getUniformLocation(p,
k);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(q=0;q<c.maxMorphTargets;q++)d.push("morphTarget"+q);for(q=0;q<c.maxMorphNormals;q++)d.push("morphNormal"+q);for(P in b)d.push(P);P=d;for(q=0,b=P.length;q<b;q++)c=P[q],p.attributes[c]=j.getAttribLocation(p,c);p.id=T.length;T.push({program:p,code:i});B.info.memory.programs=T.length;P=p}a.program=P;P=a.program.attributes;0<=P.position&&j.enableVertexAttribArray(P.position);0<=P.color&&j.enableVertexAttribArray(P.color);
0<=P.normal&&j.enableVertexAttribArray(P.normal);0<=P.tangent&&j.enableVertexAttribArray(P.tangent);a.skinning&&0<=P.skinVertexA&&0<=P.skinVertexB&&0<=P.skinIndex&&0<=P.skinWeight&&(j.enableVertexAttribArray(P.skinVertexA),j.enableVertexAttribArray(P.skinVertexB),j.enableVertexAttribArray(P.skinIndex),j.enableVertexAttribArray(P.skinWeight));if(a.attributes)for(h in a.attributes)void 0!==P[h]&&0<=P[h]&&j.enableVertexAttribArray(P[h]);if(a.morphTargets){a.numSupportedMorphTargets=0;p="morphTarget";
for(h=0;h<this.maxMorphTargets;h++)q=p+h,0<=P[q]&&(j.enableVertexAttribArray(P[q]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;p="morphNormal";for(h=0;h<this.maxMorphNormals;h++)q=p+h,0<=P[q]&&(j.enableVertexAttribArray(P[q]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(g in a.uniforms)a.uniformsList.push([a.uniforms[g],g])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?j.frontFace(j.CCW):j.frontFace(j.CW),"back"===a?j.cullFace(j.BACK):"front"===a?j.cullFace(j.FRONT):
j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if(ea!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),ea=a.doubleSided;if(R!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),R=a.flipSided};this.setDepthTest=function(a){sa!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),sa=a)};this.setDepthWrite=function(a){Ha!==a&&(j.depthMask(a),Ha=a)};this.setBlending=function(a,b,c,d){if(a!==$){switch(a){case THREE.NoBlending:j.disable(j.BLEND);
break;case THREE.AdditiveBlending:j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;case THREE.CustomBlending:j.enable(j.BLEND);break;default:j.enable(j.BLEND),j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,
j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}$=a}if(a===THREE.CustomBlending){if(b!==W&&(j.blendEquation(y(b)),W=b),c!==ba||d!==ia)j.blendFunc(y(c),y(d)),ba=c,ia=d}else ia=ba=W=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),B.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=0===(c.width&
c.width-1)&&0===(c.height&c.height-1),e=y(a.format),f=y(a.type);u(j.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.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=j.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=y(a.format),e=y(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);u(j.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,
0,d,e,null);var f=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,f.__webglTexture,0);t(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),u(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),
j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),t(a.__webglRenderbuffer,a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=fb,a=bb,e=Ya,c=jb);b!==D&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),D=b);gb=d;ob=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;
this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
373
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:
374
THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
375
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};
A
alteredq 已提交
376 377 378 379
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};
380
THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;0>c&&(c+=1);1<c&&(c-=1)}void 0===b&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}};
A
alteredq 已提交
381
THREE.ColorUtils.__hsv={h:0,s:0,v:0};
382 383 384
THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,i=f.faces,l=a.faceVertexUvs[0],p=f.faceVertexUvs[0],n={},o=0;o<a.materials.length;o++)n[a.materials[o].id]=o;if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale);for(var o=0,q=h.length;o<q;o++){var m=h[o].clone();c&&c.multiplyVector3(m.position);g.push(m)}for(o=0,q=i.length;o<q;o++){var g=
i[o],r,s,v=g.vertexNormals,u=g.vertexColors;g instanceof THREE.Face3?r=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(r=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));r.normal.copy(g.normal);d&&d.multiplyVector3(r.normal);h=0;for(m=v.length;h<m;h++)s=v[h].clone(),d&&d.multiplyVector3(s),r.vertexNormals.push(s);r.color.copy(g.color);h=0;for(m=u.length;h<m;h++)s=u[h],r.vertexColors.push(s.clone());if(void 0!==g.materialIndex){h=f.materials[g.materialIndex];m=h.id;u=n[m];if(void 0===u)u=a.materials.length,
n[m]=u,a.materials.push(h);r.materialIndex=u}r.centroid.copy(g.centroid);c&&c.multiplyVector3(r.centroid);k.push(r)}for(o=0,q=p.length;o<q;o++){c=p[o];d=[];h=0;for(m=c.length;h<m;h++)d.push(new THREE.UV(c[h].u,c[h].v));l.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();for(a=0,c=d.length;a<c;a++)b.vertices.push(d[a].clone());for(a=0,c=e.length;a<c;a++)b.faces.push(e[a].clone());for(a=0,c=f.length;a<c;a++){for(var d=
385 386
f[a],e=[],g=0,h=d.length;g<h;g++)e.push(new THREE.UV(d[g].u,d[g].v));b.faceVertexUvs[0].push(e)}return b},randomPointInTriangle:function(a,b,c){var d,e,f,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();1<d+e&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,
e=b.vertices[a.b].position,f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*
387 388
(c+g)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return i[e]>a?b(c,e-1):i[e]<a?b(e+1,d):e}return b(0,i.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,k=0,i=[],l,p,n,o;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)l=g[d.a].position,p=g[d.b].position,n=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(l,p,n);else if(d instanceof
THREE.Face4)l=g[d.a].position,p=g[d.b].position,n=g[d.c].position,o=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(l,p,o),d._area2=THREE.GeometryUtils.triangleArea(p,n,o),d._area=d._area1+d._area2;k+=d._area;i[e]=k}d=[];for(e=0;e<b;e++)g=THREE.GeometryUtils.random()*k,g=c(g),d[e]=THREE.GeometryUtils.randomPointInFace(f[g],a,!0);return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();b=0.5*(d+a+c);return Math.sqrt(b*
389
(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)1!==d[e].u&&(d[e].u-=Math.floor(d[e].u)),1!==d[e].v&&(d[e].v-=Math.floor(d[e].v))},triangulateQuads:function(a){var b,c,d,e,f=[],g=[],h=[];for(b=0,
390 391 392 393 394 395 396 397 398 399 400 401 402
c=a.faceUvs.length;b<c;b++)g[b]=[];for(b=0,c=a.faceVertexUvs.length;b<c;b++)h[b]=[];for(b=0,c=a.faces.length;b<c;b++)if(d=a.faces[b],d instanceof THREE.Face4){e=d.a;var k=d.b,i=d.c,l=d.d,p=new THREE.Face3,n=new THREE.Face3;p.color.copy(d.color);n.color.copy(d.color);p.materialIndex=d.materialIndex;n.materialIndex=d.materialIndex;p.a=e;p.b=k;p.c=l;n.a=k;n.b=i;n.c=l;4===d.vertexColors.length&&(p.vertexColors[0]=d.vertexColors[0].clone(),p.vertexColors[1]=d.vertexColors[1].clone(),p.vertexColors[2]=
d.vertexColors[3].clone(),n.vertexColors[0]=d.vertexColors[1].clone(),n.vertexColors[1]=d.vertexColors[2].clone(),n.vertexColors[2]=d.vertexColors[3].clone());f.push(p,n);for(d=0,e=a.faceVertexUvs.length;d<e;d++)a.faceVertexUvs[d].length&&(p=a.faceVertexUvs[d][b],k=p[1],i=p[2],l=p[3],p=[p[0].clone(),k.clone(),l.clone()],k=[k.clone(),i.clone(),l.clone()],h[d].push(p,k));for(d=0,e=a.faceUvs.length;d<e;d++)a.faceUvs[d].length&&(k=a.faceUvs[d][b],g[d].push(k,k))}else{f.push(d);for(d=0,e=a.faceUvs.length;d<
e;d++)g[d].push(a.faceUvs[d]);for(d=0,e=a.faceVertexUvs.length;d<e;d++)h[d].push(a.faceVertexUvs[d])}a.faces=f;a.faceUvs=g;a.faceVertexUvs=h;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=[],c=0,d=a.faces.length;c<d;c++){var e=b.length,f=a.faces[c];if(f instanceof THREE.Face4){var g=f.a,h=f.b,k=f.c,g=a.vertices[g],h=a.vertices[h],k=a.vertices[k],i=a.vertices[f.d];b.push(g.clone());b.push(h.clone());b.push(k.clone());
b.push(i.clone());f.a=e;f.b=e+1;f.c=e+2;f.d=e+3}else g=f.a,h=f.b,k=f.c,g=a.vertices[g],h=a.vertices[h],k=a.vertices[k],b.push(g.clone()),b.push(h.clone()),b.push(k.clone()),f.a=e,f.b=e+1,f.c=e+2}a.vertices=b;delete a.__tmpVertices},tessellate:function(a,b){var c,d,e,f,g,h,k,i,l,p,n,o,q,m,r,s,v,u,t,w=[],y=[];for(c=0,d=a.faceVertexUvs.length;c<d;c++)y[c]=[];for(c=0,d=a.faces.length;c<d;c++)if(e=a.faces[c],e instanceof THREE.Face3)if(f=e.a,g=e.b,h=e.c,i=a.vertices[f],l=a.vertices[g],p=a.vertices[h],
o=i.position.distanceTo(l.position),q=l.position.distanceTo(p.position),n=i.position.distanceTo(p.position),o>b||q>b||n>b){k=a.vertices.length;u=e.clone();t=e.clone();o>=q&&o>=n?(i=i.clone(),i.position.lerpSelf(l.position,0.5),u.a=f,u.b=k,u.c=h,t.a=k,t.b=g,t.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),u.vertexNormals[1].copy(f),t.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),
u.vertexColors[1].copy(f),t.vertexColors[0].copy(f)),e=0):q>=o&&q>=n?(i=l.clone(),i.position.lerpSelf(p.position,0.5),u.a=f,u.b=g,u.c=k,t.a=k,t.b=h,t.c=f,3===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),t.vertexNormals[0].copy(f),t.vertexNormals[1].copy(e.vertexNormals[2]),t.vertexNormals[2].copy(e.vertexNormals[0])),3===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),
t.vertexColors[0].copy(f),t.vertexColors[1].copy(e.vertexColors[2]),t.vertexColors[2].copy(e.vertexColors[0])),e=1):(i=i.clone(),i.position.lerpSelf(p.position,0.5),u.a=f,u.b=g,u.c=k,t.a=k,t.b=g,t.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),t.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),t.vertexColors[0].copy(f)),e=2);w.push(u,
t);a.vertices.push(i);for(f=0,g=a.faceVertexUvs.length;f<g;f++)a.faceVertexUvs[f].length&&(i=a.faceVertexUvs[f][c],t=i[0],h=i[1],u=i[2],0===e?(l=t.clone(),l.lerpSelf(h,0.5),i=[t.clone(),l.clone(),u.clone()],h=[l.clone(),h.clone(),u.clone()]):1===e?(l=h.clone(),l.lerpSelf(u,0.5),i=[t.clone(),h.clone(),l.clone()],h=[l.clone(),u.clone(),t.clone()]):(l=t.clone(),l.lerpSelf(u,0.5),i=[t.clone(),h.clone(),l.clone()],h=[l.clone(),h.clone(),u.clone()]),y[f].push(i,h))}else{w.push(e);for(f=0,g=a.faceVertexUvs.length;f<
g;f++)y[f].push(a.faceVertexUvs[f])}else if(f=e.a,g=e.b,h=e.c,k=e.d,i=a.vertices[f],l=a.vertices[g],p=a.vertices[h],n=a.vertices[k],o=i.position.distanceTo(l.position),q=l.position.distanceTo(p.position),m=p.position.distanceTo(n.position),r=i.position.distanceTo(n.position),o>b||q>b||m>b||r>b){s=a.vertices.length;v=a.vertices.length+1;u=e.clone();t=e.clone();o>=q&&o>=m&&o>=r||m>=q&&m>=o&&m>=r?(o=i.clone(),o.position.lerpSelf(l.position,0.5),l=p.clone(),l.position.lerpSelf(n.position,0.5),u.a=f,u.b=
s,u.c=v,u.d=k,t.a=s,t.b=g,t.c=h,t.d=v,4===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),g=e.vertexNormals[2].clone(),g.lerpSelf(e.vertexNormals[3],0.5),u.vertexNormals[1].copy(f),u.vertexNormals[2].copy(g),t.vertexNormals[0].copy(f),t.vertexNormals[3].copy(g)),4===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),u.vertexColors[1].copy(f),u.vertexColors[2].copy(g),
t.vertexColors[0].copy(f),t.vertexColors[3].copy(g)),e=0):(o=l.clone(),o.position.lerpSelf(p.position,0.5),l=n.clone(),l.position.lerpSelf(i.position,0.5),u.a=f,u.b=g,u.c=s,u.d=v,t.a=v,t.b=s,t.c=h,t.d=k,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),u.vertexNormals[2].copy(f),u.vertexNormals[3].copy(g),t.vertexNormals[0].copy(g),t.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),
f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),u.vertexColors[2].copy(f),u.vertexColors[3].copy(g),t.vertexColors[0].copy(g),t.vertexColors[1].copy(f)),e=1);w.push(u,t);a.vertices.push(o,l);for(f=0,g=a.faceVertexUvs.length;f<g;f++)a.faceVertexUvs[f].length&&(i=a.faceVertexUvs[f][c],t=i[0],h=i[1],u=i[2],i=i[3],0===e?(l=t.clone(),l.lerpSelf(h,0.5),p=u.clone(),p.lerpSelf(i,0.5),t=[t.clone(),l.clone(),p.clone(),i.clone()],h=[l.clone(),h.clone(),u.clone(),
p.clone()]):(l=h.clone(),l.lerpSelf(u,0.5),p=i.clone(),p.lerpSelf(t,0.5),t=[t.clone(),h.clone(),l.clone(),p.clone()],h=[p.clone(),l.clone(),u.clone(),i.clone()]),y[f].push(t,h))}else{w.push(e);for(f=0,g=a.faceVertexUvs.length;f<g;f++)y[f].push(a.faceVertexUvs[f])}a.faces=w;a.faceVertexUvs=y}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
403
THREE.ImageUtils={crossOrigin:"anonymous",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=[],f=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)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin=this.crossOrigin,e[b].src=a[b];return f},getNormalMap:function(a,
404 405 406
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,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,k=g.createImageData(d,e),i=k.data,l=0;l<d;l++)for(var p=1;p<e;p++){var n=0>p-1?e-1:p-1,o=(p+1)%e,q=0>l-1?d-1:l-1,m=(l+1)%d,r=[],s=[0,0,h[4*(p*d+l)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(n*d+q)]/255*b]);r.push([0,-1,
h[4*(n*d+l)]/255*b]);r.push([1,-1,h[4*(n*d+m)]/255*b]);r.push([1,0,h[4*(p*d+m)]/255*b]);r.push([1,1,h[4*(o*d+m)]/255*b]);r.push([0,1,h[4*(o*d+l)]/255*b]);r.push([-1,1,h[4*(o*d+q)]/255*b]);n=[];q=r.length;for(o=0;o<q;o++){var m=r[o],v=r[(o+1)%q],m=[m[0]-s[0],m[1]-s[1],m[2]-s[2]],v=[v[0]-s[0],v[1]-s[1],v[2]-s[2]];n.push(c([m[1]*v[2]-m[2]*v[1],m[2]*v[0]-m[0]*v[2],m[0]*v[1]-m[1]*v[0]]))}r=[0,0,0];for(o=0;o<n.length;o++)r[0]+=n[o][0],r[1]+=n[o][1],r[2]+=n[o][2];r[0]/=n.length;r[1]/=n.length;r[2]/=n.length;
s=4*(p*d+l);i[s]=255*((r[0]+1)/2)|0;i[s+1]=255*(r[1]+0.5)|0;i[s+2]=255*r[2]|0;i[s+3]=255}g.putImageData(k,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);a.needsUpdate=!0;return a}};
407
THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,e=a.children.length;for(d=0;d<e;d++)c=a.children[d],b(c),THREE.SceneUtils.traverseHierarchy(c,b)},createMultiMaterialObject:function(a,b){var c,d=b.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(a,b[c]);e.add(f)}return e},cloneObject:function(a){var b;a instanceof THREE.MorphAnimMesh?(b=new THREE.MorphAnimMesh(a.geometry,a.material),
408 409
b.duration=a.duration,b.mirroredLoop=a.mirroredLoop,b.time=a.time,b.lastKeyframe=a.lastKeyframe,b.currentKeyframe=a.currentKeyframe,b.direction=a.direction,b.directionBackwards=a.directionBackwards):a instanceof THREE.SkinnedMesh?b=new THREE.SkinnedMesh(a.geometry,a.material):a instanceof THREE.Mesh?b=new THREE.Mesh(a.geometry,a.material):a instanceof THREE.Line?b=new THREE.Line(a.geometry,a.material,a.type):a instanceof THREE.Ribbon?b=new THREE.Ribbon(a.geometry,a.material):a instanceof THREE.ParticleSystem?
(b=new THREE.ParticleSystem(a.geometry,a.material),b.sortParticles=a.sortParticles):a instanceof THREE.Particle?b=new THREE.Particle(a.material):a instanceof THREE.Sprite?(b=new THREE.Sprite({}),b.color.copy(a.color),b.map=a.map,b.blending=a.blending,b.useScreenCoordinates=a.useScreenCoordinates,b.mergeWith3D=a.mergeWith3D,b.affectedByDistance=a.affectedByDistance,b.scaleByViewport=a.scaleByViewport,b.alignment=a.alignment,b.rotation3d.copy(a.rotation3d),b.rotation=a.rotation,b.opacity=a.opacity,
410 411
b.uvOffset.copy(a.uvOffset),b.uvScale.copy(a.uvScale)):a instanceof THREE.LOD?b=new THREE.LOD:a instanceof THREE.MarchingCubes?(b=new THREE.MarchingCubes(a.resolution,a.material),b.field.set(a.field),b.isolation=a.isolation):a instanceof THREE.Object3D&&(b=new THREE.Object3D);b.name=a.name;b.parent=a.parent;b.up.copy(a.up);b.position.copy(a.position);b.rotation instanceof THREE.Vector3&&b.rotation.copy(a.rotation);b.eulerOrder=a.eulerOrder;b.scale.copy(a.scale);b.dynamic=a.dynamic;b.doubleSided=a.doubleSided;
b.flipSided=a.flipSided;b.renderDepth=a.renderDepth;b.rotationAutoUpdate=a.rotationAutoUpdate;b.matrix.copy(a.matrix);b.matrixWorld.copy(a.matrixWorld);b.matrixRotationWorld.copy(a.matrixRotationWorld);b.matrixAutoUpdate=a.matrixAutoUpdate;b.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;b.quaternion.copy(a.quaternion);b.useQuaternion=a.useQuaternion;b.boundRadius=a.boundRadius;b.boundRadiusScale=a.boundRadiusScale;b.visible=a.visible;b.castShadow=a.castShadow;b.receiveShadow=a.receiveShadow;b.frustumCulled=
A
alteredq 已提交
412
a.frustumCulled;for(var c=0;c<a.children.length;c++){var d=THREE.SceneUtils.cloneObject(a.children[c]);b.children[c]=d;d.parent=b}if(a instanceof THREE.LOD)for(c=0;c<a.LODs.length;c++)b.LODs[c]={visibleAtDistance:a.LODs[c].visibleAtDistance,object3D:b.children[c]};return b},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);b.remove(a);c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};
A
alteredq 已提交
413 414 415
if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
416 417
value:1},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",value:new THREE.Color(16777215)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(16777215)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1},uReflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),
fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform float uNormalScale;\nuniform float uReflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;",
418
THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse ) {\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( tDiffuse, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n#endif\n}\nif( enableAO ) {\n#ifdef GAMMA_INPUT\nvec4 aoColor = texture2D( tAO, vUv );\naoColor.xyz *= aoColor.xyz;\ngl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n#endif\n}\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nfloat pointDistance = vPointLight[ i ].w;\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n#endif\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\nvec3 pointHalfVector = normalize( pointVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n#else\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\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\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;\nif ( enableReflection ) {\nvec3 wPos = cameraPosition - vViewPosition;\nvec3 vReflect = reflect( normalize( wPos ), normal );\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );\n}",
419
THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
A
alteredq 已提交
420
THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\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 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
A
alteredq 已提交
421
THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
422
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(){}};
423
THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
424
THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b};
425
THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0;this.getLengths()};THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,k;g<=h;)if(d=Math.floor(g+(h-g)/2),k=c[d]-f,0>k)g=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
Z
zz85 已提交
426
THREE.Curve.prototype.getTangent=function(a){var b=a-1.0E-4,a=a+1.0E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){return this.getTangent(this.getUtoTmapping(a))};THREE.LineCurve=function(a,b){a instanceof THREE.Vector2?(this.v1=a,this.v2=b):THREE.LineCurve.oldConstructor.apply(this,arguments)};
427 428 429
THREE.LineCurve.oldConstructor=function(a,b,c,d){this.constructor(new THREE.Vector2(a,b),new THREE.Vector2(c,d))};THREE.LineCurve.prototype=new THREE.Curve;THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};
THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a};THREE.QuadraticBezierCurve=function(a,b,c){if(!(b instanceof THREE.Vector2))var d=Array.prototype.slice.call(arguments),a=new THREE.Vector2(d[0],d[1]),b=new THREE.Vector2(d[2],d[3]),c=new THREE.Vector2(d[4],d[5]);this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};
Z
zz85 已提交
430
THREE.CubicBezierCurve=function(a,b,c,d){if(!(b instanceof THREE.Vector2))var e=Array.prototype.slice.call(arguments),a=new THREE.Vector2(e[0],e[1]),b=new THREE.Vector2(e[2],e[3]),c=new THREE.Vector2(e[4],e[5]),d=new THREE.Vector2(e[6],e[7]);this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
431
THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};
432
THREE.SplineCurve=function(a){this.points=void 0==a?[]:a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
Z
zz85 已提交
433
THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,e;e=(d.length-1)*a;a=Math.floor(e);e-=a;c[0]=0==a?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};
434 435
THREE.ArcCurve=function(a,b,c,d,e,f){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=d;this.aEndAngle=e;this.aClockwise=f};THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);b=this.aStartAngle+a*b;a=this.aX+this.aRadius*Math.cos(b);b=this.aY+this.aRadius*Math.sin(b);return new THREE.Vector2(a,b)};
THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=0.5*(c-a),d=0.5*(d-b),f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}};
436 437 438
THREE.Curve.create=function(a,b){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(this.v1);return b});
THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});
THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});
439
THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e,a=(d.length-1)*a;e=Math.floor(a);a-=e;c[0]=0==e?e:e-1;c[1]=e;c[2]=e>d.length-2?d.length-1:e+1;c[3]=e>d.length-3?d.length-1:e+2;e=d[c[0]];var f=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(e.x,f.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(e.y,f.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(e.z,f.z,g.z,c.z,a);return b});
Z
zz85 已提交
440 441 442
THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=Math.floor(e);e-=a;a+=0<a?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length;c[0]=(a-1)%d.length;c[1]=a%d.length;c[2]=(a+1)%d.length;c[3]=(a+2)%d.length;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,
d[c[1]].z,d[c[2]].z,d[c[3]].z,e);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=!1};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};
THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a<c.length;){if(c[a]>=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
443
THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a};
444
THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),b,c,d,e;b=c=Number.NEGATIVE_INFINITY;d=e=Number.POSITIVE_INFINITY;var f,g,h,k;k=new THREE.Vector2;for(g=0,h=a.length;g<h;g++){f=a[g];if(f.x>b)b=f.x;else if(f.x<d)d=f.x;if(f.y>c)c=f.y;else if(f.y<c)e=f.y;k.addSelf(f.x,f.y)}return{minX:d,minY:e,maxX:b,maxY:c,centroid:k.divideScalar(h)}};THREE.CurvePath.prototype.createPointsGeometry=function(a){return this.createGeometry(this.getPoints(a,!0))};
445
THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){return this.createGeometry(this.getSpacedPoints(a,!0))};THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0;c<a.length;c++)b.vertices.push(new THREE.Vertex(new THREE.Vector3(a[c].x,a[c].y,0)));return b};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
Z
zz85 已提交
446
THREE.CurvePath.prototype.getTransformedPoints=function(a,b){var c=this.getPoints(a),d,e;if(!b)b=this.bends;for(d=0,e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,b){var c=this.getSpacedPoints(a),d,e;if(!b)b=this.bends;for(d=0,e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c};
447
THREE.CurvePath.prototype.getWrapPoints=function(a,b){var c=this.getBoundingBox(),d,e,f,g,h,k;for(d=0,e=a.length;d<e;d++)f=a[d],g=f.x,h=f.y,k=g/c.maxX,k=b.getUtoTmapping(k,g),g=b.getPoint(k),h=b.getNormalVector(k).multiplyScalar(h),f.x=g.x+h.x,f.y=g.y+h.y;return a};
448
THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){void 0==a[b]&&(a[b]=[]);-1===a[b].indexOf(c)&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=new THREE.Object3D;THREE.Gyroscope.prototype.constructor=THREE.Gyroscope;
A
alteredq 已提交
449 450 451 452
THREE.Gyroscope.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?(this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(this.translationWorld,this.rotationWorld,this.scaleWorld),this.matrix.decompose(this.translationObject,this.rotationObject,this.scaleObject),this.matrixWorld.compose(this.translationWorld,this.rotationObject,this.scaleWorld)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)};THREE.Gyroscope.prototype.translationWorld=new THREE.Vector3;THREE.Gyroscope.prototype.translationObject=new THREE.Vector3;THREE.Gyroscope.prototype.rotationWorld=new THREE.Quaternion;THREE.Gyroscope.prototype.rotationObject=new THREE.Quaternion;THREE.Gyroscope.prototype.scaleWorld=new THREE.Vector3;THREE.Gyroscope.prototype.scaleObject=new THREE.Vector3;
THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
THREE.Path.prototype.moveTo=function(a,b){var c=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:c})};THREE.Path.prototype.lineTo=function(a,b){var c=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args;this.curves.push(new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,b)));this.actions.push({action:THREE.PathActions.LINE_TO,args:c})};
453 454
THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args;this.curves.push(new THREE.QuadraticBezierCurve(new THREE.Vector2(f[f.length-2],f[f.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d)));this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:e})};
THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
455
THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};
456 457
THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1],h=new THREE.ArcCurve(h.x+a,h.y+b,c,d,e,f);this.curves.push(h);h=h.getPoint(f?1:0);g.push(h.x);g.push(h.y);this.actions.push({action:THREE.PathActions.ARC,args:g})};
THREE.Path.prototype.absarc=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=new THREE.ArcCurve(a,b,c,d,e,f);this.curves.push(h);h=h.getPoint(f?1:0);g.push(h.x);g.push(h.y);this.actions.push({action:THREE.PathActions.ARC,args:g})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
458 459 460 461
THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints)return console.log("tata"),this.getSpacedPoints(a,b);var a=a||12,c=[],d,e,f,g,h,k,i,l,p,n,o,q,m;for(d=0,e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.MOVE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];k=f[3];p=f[0];n=f[1];0<c.length?(g=c[c.length-1],o=g.x,
q=g.y):(g=this.actions[d-1].args,o=g[g.length-2],q=g[g.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b2(m,o,p,h),m=THREE.Shape.Utils.b2(m,q,n,k),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];k=f[5];p=f[0];n=f[1];i=f[2];l=f[3];0<c.length?(g=c[c.length-1],o=g.x,q=g.y):(g=this.actions[d-1].args,o=g[g.length-2],q=g[g.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b3(m,o,p,i,h),m=THREE.Shape.Utils.b3(m,q,n,l,k),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.CSPLINE_THRU:g=
this.actions[d-1].args;m=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;m=m.concat(f[0]);m=new THREE.SplineCurve(m);for(f=1;f<=g;f++)c.push(m.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];k=f[1];i=f[2];p=f[3];n=!!f[5];l=f[4]-p;o=2*a;for(f=1;f<=o;f++)m=f/o,n||(m=1-m),m=p+m*l,g=h+i*Math.cos(m),m=k+i*Math.sin(m),c.push(new THREE.Vector2(g,m))}d=c[c.length-1];1.0E-10>Math.abs(d.x-c[0].x)&&1.0E-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c};
THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};THREE.Path.prototype.nltransform=function(a,b,c,d,e,f){var g=this.getPoints(),h,k,i,l,p;for(h=0,k=g.length;h<k;h++)i=g[h],l=i.x,p=i.y,i.x=a*l+b*p+c,i.y=d*p+e*l+f;return g};
Z
zz85 已提交
462 463
THREE.Path.prototype.debug=function(a){var b=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,d,e;for(a=0,c=this.actions.length;a<c;a++)d=this.actions[a],e=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&b[d].apply(b,e);b.stroke();b.closePath();b.strokeStyle="red";d=
this.getPoints();for(a=0,c=d.length;a<c;a++)e=d[a],b.beginPath(),b.arc(e.x,e.y,1.5,0,2*Math.PI,!1),b.stroke(),b.closePath()};
464 465
THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;for(a=0,b=this.actions.length;a<b;a++)c=this.actions[a],d=c.args,c=c.action,c==THREE.PathActions.MOVE_TO&&0!=f.actions.length&&(e.push(f),f=new THREE.Path),f[c].apply(f,d);0!=f.actions.length&&e.push(f);if(0==e.length)return[];var g;d=[];a=!THREE.Shape.Utils.isClockWise(e[0].getPoints());if(1==e.length)return f=e[0],g=new THREE.Shape,g.actions=f.actions,g.curves=f.curves,d.push(g),d;if(a){g=new THREE.Shape;for(a=0,b=e.length;a<
b;a++)f=e[a],THREE.Shape.Utils.isClockWise(f.getPoints())?(g.actions=f.actions,g.curves=f.curves,d.push(g),g=new THREE.Shape):g.holes.push(f)}else{for(a=0,b=e.length;a<b;a++)f=e[a],THREE.Shape.Utils.isClockWise(f.getPoints())?(g&&d.push(g),g=new THREE.Shape,g.actions=f.actions,g.curves=f.curves):g.holes.push(f);d.push(g)}return d};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;
M
Mr.doob 已提交
466
THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};
M
Mr.doob 已提交
467
THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.useSpacedPoints?this.extractAllSpacedPoints(a):this.extractAllPoints(a)};THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
468 469 470
THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,k,i,l,p,n,o,q=[];for(k=0;k<b.length;k++){i=b[k];Array.prototype.push.apply(d,i);f=Number.POSITIVE_INFINITY;for(e=0;e<i.length;e++){n=i[e];o=[];for(p=0;p<c.length;p++)l=c[p],l=n.distanceToSquared(l),o.push(l),l<f&&(f=l,g=e,h=p)}e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:i.length-1;var m=[i[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(m);var r=[i[g],i[f],c[h]];n=THREE.FontUtils.Triangulate.area(r);o=h;l=g;h+=1;g+=-1;0>
h&&(h+=c.length);h%=c.length;0>g&&(g+=i.length);g%=i.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:i.length-1;m=[i[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);r=[i[g],i[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+n>m+r&&(h=o,g=l,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=i.length),g%=i.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:i.length-1);p=c.slice(0,h);n=c.slice(h);o=i.slice(g);l=i.slice(0,g);f=[i[g],i[f],c[h]];q.push([i[g],c[h],c[e]]);q.push(f);c=p.concat(o).concat(l).concat(n)}return{shape:c,
isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),f,g,h,k,i={};for(f=0,g=d.length;f<g;f++)k=d[f].x+":"+d[f].y,void 0!==i[k]&&console.log("Duplicate point",k),i[k]=f;for(f=0,g=c.length;f<g;f++){h=c[f];for(d=0;3>d;d++)k=h[d].x+":"+h[d].y,k=i[k],void 0!==k&&(h[d]=k)}for(f=0,g=e.length;f<g;f++){h=e[f];for(d=0;3>d;d++)k=h[d].x+":"+h[d].y,k=i[k],void 0!==k&&(h[d]=k)}return c.concat(e)},
Z
zz85 已提交
471
isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
472
this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){b=b||this.parameters;this.text=a;var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",f=void 0!==b.style?b.style:"normal";THREE.FontUtils.size=void 0!==b.size?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f};
473
THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,a[c].toShapes());return b};
474
THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){-1===a.indexOf(b)&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);-1!==b&&a.splice(b,1)},add:function(a){void 0!==b[a.name]&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(!0!==a.initialized){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(0>a.hierarchy[c].keys[d].time)a.hierarchy[c].keys[d].time=
475 476
0;if(void 0!==a.hierarchy[c].keys[d].rot&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&void 0!==a.hierarchy[c].keys[0].morphTargets){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var k=0;k<a.hierarchy[c].keys[d].morphTargets.length;k++){var i=a.hierarchy[c].keys[d].morphTargets[k];h[i]=-1}a.hierarchy[c].usedMorphTargets=h;for(d=0;d<a.hierarchy[c].keys.length;d++){var l=
{};for(i in h){for(k=0;k<a.hierarchy[c].keys[d].morphTargets.length;k++)if(a.hierarchy[c].keys[d].morphTargets[k]===i){l[i]=a.hierarchy[c].keys[d].morphTargetsInfluences[k];break}k===a.hierarchy[c].keys[d].morphTargets.length&&(l[i]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=l}}for(d=1;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time&&(a.hierarchy[c].keys.splice(d,1),d--);for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=d}d=parseInt(a.length*
477 478
a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if("string"===typeof a){if(b[a])return b[a];console.log("THREE.AnimationHandler.get: Couldn't find animation "+a);return null}},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=0;c.CATMULLROM=
1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,d){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=void 0!==c?c:THREE.AnimationHandler.LINEAR;this.JITCompile=void 0!==d?d:!0;this.points=[];this.target=new THREE.Vector3};
Z
zz85 已提交
479
THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;var c,d=this.hierarchy.length,e;for(c=0;c<d;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(void 0===e.animationCache)e.animationCache={},e.animationCache.prevKey={pos:0,rot:0,scl:0},e.animationCache.nextKey={pos:0,rot:0,scl:0},e.animationCache.originalMatrix=e instanceof
480
THREE.Bone?e.skinMatrix:e.matrix;var f=e.animationCache.prevKey;e=e.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
A
alteredq 已提交
481
THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
482
THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(void 0!==this.hierarchy[a].animationCache)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
483 484 485
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,k,i,l=this.data.JIT.hierarchy,p,n;n=this.currentTime+=a*this.timeScale;p=this.currentTime%=this.data.length;i=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,q=this.hierarchy.length;o<q;o++)if(a=this.hierarchy[o],k=a.animationCache,this.JITCompile&&void 0!==l[o][i])a instanceof THREE.Bone?(a.skinMatrix=l[o][i],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1):(a.matrix=
l[o][i],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var m=0;3>m;m++){c=b[m];g=k.prevKey[c];h=k.nextKey[c];if(h.time<=n){if(p<n)if(this.loop){g=this.data.hierarchy[o].keys[0];for(h=this.getNextKeyWith(c,o,1);h.time<p;)g=h,h=this.getNextKeyWith(c,o,h.index+1)}else{this.stop();return}else{do g=h,h=this.getNextKeyWith(c,o,h.index+1);while(h.time<p)}k.prevKey[c]=
g;k.nextKey[c]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(p-g.time)/(h.time-g.time);e=g[c];f=h[c];if(0>d||1<d)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+o),d=0>d?0:1;if("pos"===c)if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
486
this.getPrevKeyWith("pos",o,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",o,h.index+1).pos,d=0.33*d+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,1.01*d),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if("rot"===
487 488
c)THREE.Quaternion.slerp(e,f,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&void 0===l[0][i]){this.hierarchy[0].updateMatrixWorld(!0);for(o=0;o<this.hierarchy.length;o++)l[o][i]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,k,i;e=(a.length-1)*b;f=Math.floor(e);e-=f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];k=a[c[2]];i=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],k[0],i[0],e,c,g);d[1]=this.interpolate(f[1],h[1],k[1],i[1],e,c,g);d[2]=this.interpolate(f[2],h[2],k[2],i[2],e,c,g);return d};
489
THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
490
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
491
THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
M
Mr.doob 已提交
492
d.matrixWorldNeedsUpdate=!0}}};
493 494
THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=!0;if(void 0===f.animationCache)f.animationCache={},f.animationCache.prevKey=null,f.animationCache.nextKey=null,f.animationCache.originalMatrix=e instanceof THREE.Bone?e.skinMatrix:
e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0],f.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
A
alteredq 已提交
495
THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.data.hierarchy.length;a++){var b=this.hierarchy[a],c=this.data.hierarchy[a];if(void 0!==c.animationCache){var d=c.animationCache.originalMatrix;b instanceof THREE.Bone?(d.copy(b.skinMatrix),b.skinMatrix=d):(d.copy(b.matrix),b.matrix=d);delete c.animationCache}}};
496 497 498
THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,k;h=this.currentTime+=a*this.timeScale;g=this.currentTime%=this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;e=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((k=g<h)&&!this.loop){for(var a=0,i=this.hierarchy.length;a<i;a++){var l=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=l.length-1;e=this.hierarchy[a];if(l.length){for(l=
0;l<f.length;l++)g=f[l],(h=this.getPrevKeyWith(g,a,d))&&h.apply(g);this.data.hierarchy[a].node.updateMatrix();e.matrixWorldNeedsUpdate=!0}}this.stop()}else if(!(g<this.startTime)){a=0;for(i=this.hierarchy.length;a<i;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var l=b.keys,p=b.animationCache;if(this.JITCompile&&void 0!==f[a][e])d instanceof THREE.Bone?(d.skinMatrix=f[a][e],d.matrixWorldNeedsUpdate=!1):(d.matrix=f[a][e],d.matrixWorldNeedsUpdate=!0);else if(l.length){if(this.JITCompile&&p)d instanceof
THREE.Bone?d.skinMatrix=p.originalMatrix:d.matrix=p.originalMatrix;b=p.prevKey;c=p.nextKey;if(b&&c){if(c.time<=h){if(k&&this.loop){b=l[0];for(c=l[1];c.time<g;)b=c,c=l[b.index+1]}else if(!k)for(var n=l.length-1;c.time<g&&c.index!==n;)b=c,c=l[b.index+1];p.prevKey=b;p.nextKey=c}c.time>=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a<this.hierarchy.length;a++)f[a][e]=
A
alteredq 已提交
499
this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=0<=c?c:c+b.length;0<=c;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
500
THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
A
alteredq 已提交
501 502
this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+=
503 504 505
1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var c=this.renderTarget,d=c.generateMipmaps;c.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,
c);c.activeCubeFace=3;a.render(b,this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.generateMipmaps=d;c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;
THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1};
506
THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0};
507
THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){var c=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
A
alteredq 已提交
508 509
THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
510
THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
A
alteredq 已提交
511 512 513
0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
A
alteredq 已提交
514 515 516 517
!1;break;case 70:this.moveDown=!1}};this.update=function(a){var b=0;if(!this.freeze){this.heightSpeed?(b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin,this.autoSpeedFactor=a*b*this.heightCoef):this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b);
this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);a*=this.lookSpeed;this.activeLook||(a=0);this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&
(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};
518
THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,s=0;f=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<r-1;f++)s=d*h.chunks[f]/h.total,b.keys[f]={time:s,pos:g[f]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
519
return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function f(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=void 0!==b?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=
520
new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/
521
2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var g=2*Math.PI,h=Math.PI/180;this.update=function(a){var b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%g;this.phi=0<=a?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
522 523
b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement===
document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
524 525
c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
this.debugPath,b=this.spline,g=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),o=0;o<b.points.length;o++)c=new THREE.Mesh(g,h),c.position.copy(b.points[o]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
A
alteredq 已提交
526
!1)}};THREE.PathControlsIdCounter=0;
527
THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
528
0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
A
alteredq 已提交
529 530
1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
531
!0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||0<this.mouseStatus){var b=this.getContainerDimensions(),c=b.size[0]/2,g=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-g)/g;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=
532
!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed,a=a*this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);
A
alteredq 已提交
533
this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
534 535
-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,
this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
536 537
THREE.RollControls=function(a,b){this.object=a;this.domElement=void 0!==b?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=!1,h=1,k=0,i=0,l=0,p=0,n=0,o=window.innerWidth/2,q=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed;
this.rotateHorizontally(b*p);this.rotateVertically(b*n)}b=a*this.movementSpeed;this.object.translateZ(-b*(0<k||this.autoForward&&!(0>k)?1:k));this.object.translateX(b*i);this.object.translateY(b*l);g&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();e.copy(this.forward);d.set(0,1,0);c.cross(d,
538
e).normalize();d.cross(e,c).normalize();this.object.matrix.n11=c.x;this.object.matrix.n12=d.x;this.object.matrix.n13=e.x;this.object.matrix.n21=c.y;this.object.matrix.n22=d.y;this.object.matrix.n23=e.y;this.object.matrix.n31=c.z;this.object.matrix.n32=d.z;this.object.matrix.n33=e.z;f.identity();f.n11=Math.cos(this.roll);f.n12=-Math.sin(this.roll);f.n21=Math.sin(this.roll);f.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(f);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
A
alteredq 已提交
539
this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
540
a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
541 542
function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){p=(a.clientX-o)/window.innerWidth;n=(a.clientY-q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:k=1;break;case 2:k=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:k=0;break;case 2:k=0}},!1);this.domElement.addEventListener("keydown",
function(a){switch(a.keyCode){case 38:case 87:k=1;break;case 37:case 65:i=-1;break;case 40:case 83:k=-1;break;case 39:case 68:i=1;break;case 81:g=!0;h=1;break;case 69:g=!0;h=-1;break;case 82:l=1;break;case 70:l=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:k=0;break;case 37:case 65:i=0;break;case 40:case 83:k=0;break;case 39:case 68:i=0;break;case 81:g=!1;break;case 69:g=!1;break;case 82:l=0;break;case 70:l=0}},!1)};
M
Mr.doob 已提交
543
THREE.TrackballControls=function(a,b){THREE.EventTarget.call(this);var c=this;this.object=a;this.domElement=void 0!==b?b:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=this.noRotate=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=
544 545 546
new THREE.Vector3;var d=new THREE.Vector3,e=!1,f=-1,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector2,l=new THREE.Vector2,p=new THREE.Vector2,n=new THREE.Vector2,o={type:"change"};this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2(0.5*((a-c.screen.offsetLeft)/c.radius),0.5*((b-c.screen.offsetTop)/c.radius))};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-
0.5*c.screen.width-c.screen.offsetLeft)/c.radius,(0.5*c.screen.height+c.screen.offsetTop-b)/c.radius,0),e=d.length();1<e?d.normalize():d.z=Math.sqrt(1-e*e);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(k)/h.length()/k.length());if(a){var b=(new THREE.Vector3).cross(h,k).normalize(),d=new THREE.Quaternion,a=a*c.rotateSpeed;
d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(k);c.staticMoving?h=k:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(l.y-i.y)*c.zoomSpeed;1!==a&&0<a&&(g.multiplyScalar(a),c.staticMoving?i=l:i.y+=(l.y-i.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=n.clone().subSelf(p);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.clone().crossSelf(c.object.up).setLength(a.x);
547
b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?p=n:p.addSelf(a.sub(n,p).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),g.lengthSq()<c.minDistance*c.minDistance&&c.object.position.add(c.target,g.setLength(c.minDistance))};this.update=function(){g.copy(c.object.position).subSelf(c.target);
548 549
c.noRotate||c.rotateCamera();c.noZoom||c.zoomCamera();c.noPan||c.panCamera();c.object.position.add(c.target,g);c.checkDistances();c.object.lookAt(c.target);0<d.distanceTo(c.object.position)&&(c.dispatchEvent(o),d.copy(c.object.position))};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){c.enabled&&(e&&(h=k=c.getMouseProjectionOnBall(a.clientX,a.clientY),i=l=c.getMouseOnScreen(a.clientX,a.clientY),p=n=c.getMouseOnScreen(a.clientX,
a.clientY),e=!1),-1!==f&&(0===f&&!c.noRotate?k=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===f&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):2===f&&!c.noPan&&(n=c.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(c.enabled&&(a.preventDefault(),a.stopPropagation(),-1===f))f=a.button,0===f&&!c.noRotate?h=k=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===f&&!c.noZoom?i=l=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(p=n=
550
c.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){c.enabled&&(a.preventDefault(),a.stopPropagation(),f=-1)},!1);window.addEventListener("keydown",function(a){c.enabled&&-1===f&&(a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2),-1!==f&&(e=!0))},!1);window.addEventListener("keyup",function(){c.enabled&&-1!==f&&(f=-1)},!1)};
551 552 553
THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function k(a,b,c,g,h,m,k,n){var l,o=d||1,p=e||1,q=h/2,r=m/2,s=i.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)l="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)l="y",p=f||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)l="x",o=f||1;var j=o+1,u=p+1,v=h/o,D=m/p,V=new THREE.Vector3;V[l]=0<k?1:-1;for(h=0;h<u;h++)for(m=0;m<j;m++){var E=new THREE.Vector3;E[a]=(m*v-q)*c;E[b]=(h*D-r)*g;E[l]=k;i.vertices.push(new THREE.Vertex(E))}for(h=0;h<p;h++)for(m=0;m<o;m++)a=
new THREE.Face4(m+j*h+s,m+j*(h+1)+s,m+1+j*(h+1)+s,m+1+j*h+s),a.normal.copy(V),a.vertexNormals.push(V.clone(),V.clone(),V.clone(),V.clone()),a.materialIndex=n,i.faces.push(a),i.faceVertexUvs[0].push([new THREE.UV(m/o,h/p),new THREE.UV(m/o,(h+1)/p),new THREE.UV((m+1)/o,(h+1)/p),new THREE.UV((m+1)/o,h/p)])}THREE.Geometry.call(this);var i=this,l=a/2,p=b/2,n=c/2,o,q,m,r,s,v;if(void 0!==g){if(g instanceof Array)this.materials=g;else{this.materials=[];for(o=0;6>o;o++)this.materials.push(g)}o=0;r=1;q=2;s=
3;m=4;v=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var u in h)void 0!==this.sides[u]&&(this.sides[u]=h[u]);this.sides.px&&k("z","y",-1,-1,c,b,l,o);this.sides.nx&&k("z","y",1,-1,c,b,-l,r);this.sides.py&&k("x","z",1,1,a,c,p,q);this.sides.ny&&k("x","z",1,-1,a,c,-p,s);this.sides.pz&&k("x","y",1,-1,a,b,n,m);this.sides.nz&&k("x","y",-1,-1,a,b,-n,v);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
M
Mr.doob 已提交
554
THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
555 556 557 558
THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,g=c/2,d=d||8,e=e||1,h,k,i=[],l=[];for(k=0;k<=e;k++){var p=[],n=[],o=k/e,q=o*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,r=q*Math.sin(2*m*Math.PI),s=-o*c+g,v=q*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(r,s,v)));p.push(this.vertices.length-1);n.push(new THREE.UV(m,o))}i.push(p);l.push(n)}for(k=0;k<e;k++)for(h=0;h<d;h++){var c=i[k][h],p=i[k+1][h],
n=i[k+1][h+1],o=i[k][h+1],q=this.vertices[c].position.clone().setY(0).normalize(),m=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[n].position.clone().setY(0).normalize(),s=this.vertices[o].position.clone().setY(0).normalize(),v=l[k][h].clone(),u=l[k+1][h].clone(),t=l[k+1][h+1].clone(),w=l[k][h+1].clone();this.faces.push(new THREE.Face4(c,p,n,o,[q,m,r,s]));this.faceVertexUvs[0].push([v,u,t,w])}if(!f&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=
0;h<d;h++)c=i[0][h],p=i[0][h+1],n=this.vertices.length-1,q=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,1,0),v=l[0][h].clone(),u=l[0][h+1].clone(),t=new THREE.UV(u.u,0),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([v,u,t])}if(!f&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=i[k][h+1],p=i[k][h],n=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),r=new THREE.Vector3(0,-1,
0),v=l[k][h+1].clone(),u=l[k][h].clone(),t=new THREE.UV(u.u,1),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([v,u,t])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
A
alteredq 已提交
559
THREE.ExtrudeGeometry=function(a,b){if("undefined"!==typeof a)THREE.Geometry.call(this),a=a instanceof Array?a:[a],this.shapebb=a[a.length-1].getBoundingBox(),this.addShapeList(a,b),this.computeCentroids(),this.computeFaceNormals()};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
560 561 562 563 564 565 566 567
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,j=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);j.copy(a).addSelf(g);if(h.equals(j))return g.clone();
h.copy(b).addSelf(f);j.copy(c).addSelf(g);f=d.dot(g);g=j.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return 0>g?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(E=c.length;0<=--E;){e=E;f=E-1;0>f&&(f=c.length-1);
for(var g=0,h=n+2*l,g=0;g<h;g++){var j=G*g,i=G*(g+1),m=d+e+j,j=d+f+j,k=d+f+i,i=d+e+i,o=c,p=g,q=h,m=m+O,j=j+O,k=k+O,i=i+O;J.faces.push(new THREE.Face4(m,j,k,i,null,null,v));m=R.generateSideWallUV(J,a,o,b,m,j,k,i,p,q);J.faceVertexUvs[0].push(m)}}}function f(a,b,c){J.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(c,d,e,f){c+=O;d+=O;e+=O;J.faces.push(new THREE.Face3(c,d,e,null,null,s));c=f?R.generateBottomUV(J,a,b,c,d,e):R.generateTopUV(J,a,b,c,d,e);J.faceVertexUvs[0].push(c)}var h=
void 0!==b.amount?b.amount:100,k=void 0!==b.bevelThickness?b.bevelThickness:6,i=void 0!==b.bevelSize?b.bevelSize:k-2,l=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,n=void 0!==b.steps?b.steps:1,o=b.bendPath,q=b.extrudePath,m,r=!1,s=b.material,v=b.extrudeMaterial,u,t,w,y;q&&(m=q.getSpacedPoints(n),r=!0,p=!1,u=new THREE.TubeGeometry(q,n,1,1,!1,!1),t=new THREE.Vector3,w=new THREE.Vector3,y=new THREE.Vector3);p||(i=k=l=0);var H,F,C,J=this,O=this.vertices.length;
o&&a.addWrapPath(o);var q=a.extractPoints(),o=q.shape,Q=q.holes;if(q=!THREE.Shape.Utils.isClockWise(o)){o=o.reverse();for(F=0,C=Q.length;F<C;F++)H=Q[F],THREE.Shape.Utils.isClockWise(H)&&(Q[F]=H.reverse());q=!1}var S=THREE.Shape.Utils.triangulateShape(o,Q),M=o;for(F=0,C=Q.length;F<C;F++)H=Q[F],o=o.concat(H);var A,L,B,j,T,G=o.length,D,V=S.length,q=[],E=0;B=M.length;A=B-1;for(L=E+1;E<B;E++,A++,L++)A===B&&(A=0),L===B&&(L=0),q[E]=d(M[E],M[A],M[L]);var ga=[],da,ea=q.concat();for(F=0,C=Q.length;F<C;F++){H=
Q[F];da=[];for(E=0,B=H.length,A=B-1,L=E+1;E<B;E++,A++,L++)A===B&&(A=0),L===B&&(L=0),da[E]=d(H[E],H[A],H[L]);ga.push(da);ea=ea.concat(da)}for(A=0;A<l;A++){B=A/l;j=k*(1-B);L=i*Math.sin(B*Math.PI/2);for(E=0,B=M.length;E<B;E++)T=c(M[E],q[E],L),f(T.x,T.y,-j);for(F=0,C=Q.length;F<C;F++){H=Q[F];da=ga[F];for(E=0,B=H.length;E<B;E++)T=c(H[E],da[E],L),f(T.x,T.y,-j)}}L=i;for(E=0;E<G;E++)T=p?c(o[E],ea[E],L):o[E],r?(w.copy(u.normals[0]).multiplyScalar(T.x),t.copy(u.binormals[0]).multiplyScalar(T.y),y.copy(m[0]).addSelf(w).addSelf(t),
f(y.x,y.y,y.z)):f(T.x,T.y,0);for(B=1;B<=n;B++)for(E=0;E<G;E++)T=p?c(o[E],ea[E],L):o[E],r?(w.copy(u.normals[B]).multiplyScalar(T.x),t.copy(u.binormals[B]).multiplyScalar(T.y),y.copy(m[B]).addSelf(w).addSelf(t),f(y.x,y.y,y.z)):f(T.x,T.y,h/n*B);for(A=l-1;0<=A;A--){B=A/l;j=k*(1-B);L=i*Math.sin(B*Math.PI/2);for(E=0,B=M.length;E<B;E++)T=c(M[E],q[E],L),f(T.x,T.y,h+j);for(F=0,C=Q.length;F<C;F++){H=Q[F];da=ga[F];for(E=0,B=H.length;E<B;E++)T=c(H[E],da[E],L),r?f(T.x,T.y+m[n-1].y,m[n-1].x+j):f(T.x,T.y,h+j)}}var R=
THREE.ExtrudeGeometry.WorldUVGenerator;(function(){if(p){var a;a=0*G;for(E=0;E<V;E++)D=S[E],g(D[2]+a,D[1]+a,D[0]+a,!0);a=n+2*l;a*=G;for(E=0;E<V;E++)D=S[E],g(D[0]+a,D[1]+a,D[2]+a,!1)}else{for(E=0;E<V;E++)D=S[E],g(D[2],D[1],D[0],!0);for(E=0;E<V;E++)D=S[E],g(D[0]+G*n,D[1]+G*n,D[2]+G*n,!1)}})();(function(){var a=0;e(M,a);a+=M.length;for(F=0,C=Q.length;F<C;F++)H=Q[F],e(H,a),a+=H.length})()};
568
THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d,e,f){b=a.vertices[e].position.x;e=a.vertices[e].position.y;c=a.vertices[f].position.x;f=a.vertices[f].position.y;return[new THREE.UV(a.vertices[d].position.x,1-a.vertices[d].position.y),new THREE.UV(b,1-e),new THREE.UV(c,1-f)]},generateBottomUV:function(a,b,c,d,e,f){return this.generateTopUV(a,b,c,d,e,f)},generateSideWallUV:function(a,b,c,d,e,f,g,h){var b=a.vertices[e].position.x,c=a.vertices[e].position.y,e=a.vertices[e].position.z,
569
d=a.vertices[f].position.x,k=a.vertices[f].position.y,f=a.vertices[f].position.z,i=a.vertices[g].position.x,l=a.vertices[g].position.y,g=a.vertices[g].position.z,p=a.vertices[h].position.x,n=a.vertices[h].position.y,a=a.vertices[h].position.z;return 0.01>Math.abs(c-k)?[new THREE.UV(b,e),new THREE.UV(d,f),new THREE.UV(i,g),new THREE.UV(p,a)]:[new THREE.UV(c,e),new THREE.UV(k,f),new THREE.UV(l,g),new THREE.UV(n,a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
A
alteredq 已提交
570
THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
571 572 573
THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var k=0;k<=this.angle+0.0010;k+=b){for(h=0;h<c.length;h++)k<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;0==k&&(f=d);
for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,h/a.length),new THREE.UV(1-k/this.angle,(h+1)/a.length),new THREE.UV(1-(k-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(k-b)/this.angle,h/a.length)]);d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,k=a/c,i=b/d,l=new THREE.Vector3(0,1,0),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*k-e,0,a*i-f)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a),e.normal.copy(l),e.vertexNormals.push(l.clone(),l.clone(),l.clone(),l.clone()),this.faces.push(e),this.faceVertexUvs[0].push([new THREE.UV(b/c,a/d),new THREE.UV(b/c,(a+
A
alteredq 已提交
574
1)/d),new THREE.UV((b+1)/c,(a+1)/d),new THREE.UV((b+1)/c,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
575 576 577
THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);var a=a||50,d=void 0!==d?d:0,e=void 0!==e?e:2*Math.PI,f=void 0!==f?f:0,g=void 0!==g?g:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,k,i=[],l=[];for(k=0;k<=c;k++){var p=[],n=[];for(h=0;h<=b;h++){var o=h/b,q=k/c,m=-a*Math.cos(d+o*e)*Math.sin(f+q*g),r=a*Math.cos(f+q*g),s=a*Math.sin(d+o*e)*Math.sin(f+q*g);this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,r,s)));p.push(this.vertices.length-1);n.push(new THREE.UV(o,
q))}i.push(p);l.push(n)}for(k=0;k<c;k++)for(h=0;h<b;h++){var d=i[k][h+1],e=i[k][h],f=i[k+1][h],g=i[k+1][h+1],p=this.vertices[d].position.clone().normalize(),n=this.vertices[e].position.clone().normalize(),o=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),m=l[k][h+1].clone(),r=l[k][h].clone(),s=l[k+1][h].clone(),v=l[k+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[p,o,q])),this.faceVertexUvs[0].push([m,
s,v])):Math.abs(this.vertices[f].position.y)==a?(this.faces.push(new THREE.Face3(d,e,f,[p,n,o])),this.faceVertexUvs[0].push([m,r,s])):(this.faces.push(new THREE.Face4(d,e,f,g,[p,n,o,q])),this.faceVertexUvs[0].push([m,r,s,v]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
578
THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=void 0!==b.height?b.height:50;if(void 0===b.bevelThickness)b.bevelThickness=10;if(void 0===b.bevelSize)b.bevelSize=8;if(void 0===b.bevelEnabled)b.bevelEnabled=!1;if(b.bend){var d=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
A
alteredq 已提交
579
THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
580
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
581 582 583 584 585 586
0,e=(""+a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,k,i,l,p,n,o,q,m,r,s=b.glyphs[a]||b.glyphs["?"];if(s){if(s.o){b=s._cachedOutline||(s._cachedOutline=s.o.split(" "));i=b.length;for(a=0;a<i;)switch(k=b[a++],k){case "m":k=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(k,l));e.moveTo(k,l);break;case "l":k=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(k,
l));e.lineTo(k,l);break;case "q":k=b[a++]*c+d;l=b[a++]*c;o=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(o,q,k,l);if(g=f[f.length-1]){p=g.x;n=g.y;for(g=1,h=this.divisions;g<=h;g++){var v=g/h,u=THREE.Shape.Utils.b2(v,p,o,k),v=THREE.Shape.Utils.b2(v,n,q,l);f.push(new THREE.Vector2(u,v))}}break;case "b":if(k=b[a++]*c+d,l=b[a++]*c,o=b[a++]*c+d,q=b[a++]*-c,m=b[a++]*c+d,r=b[a++]*-c,e.bezierCurveTo(k,l,o,q,m,r),g=f[f.length-1]){p=g.x;n=g.y;for(g=1,h=this.divisions;g<=h;g++)v=g/h,u=THREE.Shape.Utils.b3(v,p,o,
m,k),v=THREE.Shape.Utils.b3(v,n,q,r,l),f.push(new THREE.Vector2(u,v))}}}return{offset:s.ha*c,points:f,path:e}}}};
(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var f=[],g=[],h=[],k,i,l;if(0<b(a))for(i=0;i<e;i++)g[i]=i;else for(i=0;i<e;i++)g[i]=e-1-i;var p=2*e;for(i=e-1;2<e;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");break}k=i;e<=k&&(k=0);i=k+1;e<=i&&(i=0);l=i+1;e<=l&&(l=0);var n;a:{n=a;var o=k,q=i,m=l,r=e,s=g,v=void 0,u=void 0,t=void 0,w=void 0,y=void 0,
H=void 0,F=void 0,C=void 0,J=void 0,u=n[s[o]].x,t=n[s[o]].y,w=n[s[q]].x,y=n[s[q]].y,H=n[s[m]].x,F=n[s[m]].y;if(1.0E-10>(w-u)*(F-t)-(y-t)*(H-u))n=!1;else{for(v=0;v<r;v++)if(!(v==o||v==q||v==m)){var C=n[s[v]].x,J=n[s[v]].y,O=void 0,Q=void 0,S=void 0,M=void 0,A=void 0,L=void 0,B=void 0,j=void 0,T=void 0,G=void 0,D=void 0,V=void 0,O=S=A=void 0,O=H-w,Q=F-y,S=u-H,M=t-F,A=w-u,L=y-t,B=C-u,j=J-t,T=C-w,G=J-y,D=C-H,V=J-F,O=O*G-Q*T,A=A*j-L*B,S=S*V-M*D;if(0<=O&&0<=S&&0<=A){n=!1;break a}}n=!0}}if(n){f.push([a[g[k]],
a[g[i]],a[g[l]]]);h.push([g[k],g[i],g[l]]);for(k=i,l=i+1;l<e;k++,l++)g[k]=g[l];e--;p=2*e}}return d?h:f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
587
THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=e||2*Math.PI;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var f=d/this.segmentsT*this.arc,g=2*c/this.segmentsR*Math.PI;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*Math.cos(g))*Math.sin(f);h.z=
588
this.tube*Math.sin(g);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var e=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,k=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);k.normal.addSelf(b[e]);k.normal.addSelf(b[f]);k.normal.addSelf(b[g]);k.normal.addSelf(b[h]);k.normal.normalize();this.faces.push(k);
589 590
this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){var g=Math.cos(a);Math.cos(b);b=Math.sin(a);a*=c/d;c=Math.cos(a);g*=0.5*e*(2+c);b=0.5*e*(2+c)*b;e=0.5*f*e*Math.sin(a);return new THREE.Vector3(g,b,e)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=
591 592
Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var k=2*(a/this.segmentsR)*this.p*Math.PI,g=2*(b/this.segmentsT)*Math.PI,f=h(k,g,this.q,this.p,this.radius,this.heightScale),k=h(k+0.01,g,this.q,this.p,this.radius,this.heightScale);c.sub(k,f);d.add(k,f);e.cross(c,d);d.cross(e,c);e.normalize();d.normalize();k=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=k*d.x+g*e.x;f.y+=k*d.y+g*e.y;f.z+=k*d.z+g*e.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=
0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var e=(a+1)%this.segmentsR,f=(b+1)%this.segmentsT,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=new THREE.UV(a/this.segmentsR,b/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(c,d,e,f));this.faceVertexUvs[0].push([g,k,i,l])}this.computeCentroids();this.computeFaceNormals();
A
alteredq 已提交
593
this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;
594 595 596 597 598 599 600 601
THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.segmentsRadius=d||8;this.closed=e||!1;if(f)this.debug=new THREE.Object3D;this.grid=[];var b=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,b=new THREE.Vector3,g=new THREE.Matrix4,d=[],f=[],k=[],i=this.segments+1,l,p,n,o;this.tangents=d;this.normals=f;this.binormals=k;for(a=0;a<i;a++)h=a/(i-1),d[a]=this.path.getTangentAt(h),d[a].normalize();f[0]=new THREE.Vector3;k[0]=
new THREE.Vector3;a=Number.MAX_VALUE;h=Math.abs(d[0].x);l=Math.abs(d[0].y);p=Math.abs(d[0].z);h<=a&&(a=h,b.set(1,0,0));l<=a&&(a=l,b.set(0,1,0));p<=a&&b.set(0,0,1);f[0].cross(d[0],b);k[0].cross(d[0],f[0]);for(a=1;a<i;a++)f[a]=f[a-1].clone(),k[a]=k[a-1].clone(),b.cross(d[a-1],d[a]),1.0E-4<b.length()&&(b.normalize(),h=Math.acos(d[a-1].dot(d[a])),g.setRotationAxis(b,h).multiplyVector3(f[a])),k[a].cross(d[a],f[a]);if(this.closed){h=Math.acos(f[0].dot(f[i-1]));h/=i-1;0<d[0].dot(b.cross(f[0],f[i-1]))&&(h=
-h);for(a=1;a<i;a++)g.setRotationAxis(d[a],h*a).multiplyVector3(f[a]),k[a].cross(d[a],f[a])}for(a=0;a<i;a++){this.grid[a]=[];h=a/(i-1);l=this.path.getPointAt(h);b=d[a];g=f[a];h=k[a];this.debug&&(this.debug.add(new THREE.ArrowHelper(b,l,c,255)),this.debug.add(new THREE.ArrowHelper(g,l,c,16711680)),this.debug.add(new THREE.ArrowHelper(h,l,c,65280)));for(b=0;b<this.segmentsRadius;b++)n=2*(b/this.segmentsRadius)*Math.PI,p=-this.radius*Math.cos(n),n=this.radius*Math.sin(n),o=(new THREE.Vector3).copy(l),
o.x+=p*g.x+n*h.x,o.y+=p*g.y+n*h.y,o.z+=p*g.z+n*h.z,this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z)))-1}for(a=0;a<this.segments;a++)for(b=0;b<this.segmentsRadius;b++)f=e?(a+1)%this.segments:a+1,k=(b+1)%this.segmentsRadius,c=this.grid[a][b],d=this.grid[f][b],f=this.grid[f][k],k=this.grid[a][k],i=new THREE.UV(a/this.segments,b/this.segmentsRadius),g=new THREE.UV((a+1)/this.segments,b/this.segmentsRadius),h=new THREE.UV((a+1)/this.segments,(b+1)/this.segmentsRadius),
l=new THREE.UV(a/this.segments,(b+1)/this.segmentsRadius),this.faces.push(new THREE.Face4(c,d,f,k)),this.faceVertexUvs[0].push([i,g,h,l]);this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=new THREE.Geometry;THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry;
THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=new THREE.Vertex(a.normalize());b.index=k.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+0.5,a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+0.5;b.uv=new THREE.UV(c,a);return b}function f(a,b,c,d){1>d?(d=new THREE.Face3(a.index,b.index,c.index,[a.position.clone(),b.position.clone(),c.position.clone()]),d.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),d.normal=d.centroid.clone().normalize(),
k.faces.push(d),d=Math.atan2(d.centroid.z,-d.centroid.x),k.faceVertexUvs[0].push([h(a.uv,a.position,d),h(b.uv,b.position,d),h(c.uv,c.position,d)])):(d-=1,f(a,g(a,b),g(a,c),d),f(g(a,b),b,g(b,c),d),f(g(a,c),g(b,c),c,d),f(g(a,b),g(b,c),g(a,c),d))}function g(a,b){p[a.index]||(p[a.index]=[]);p[b.index]||(p[b.index]=[]);var c=p[a.index][b.index];void 0===c&&(p[a.index][b.index]=p[b.index][a.index]=c=e((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return c}function h(a,b,c){0>c&&1===a.u&&
(a=new THREE.UV(a.u-1,a.v));0===b.x&&0===b.z&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);for(var c=c||1,d=d||0,k=this,i=0,l=a.length;i<l;i++)e(new THREE.Vector3(a[i][0],a[i][1],a[i][2]));for(var p=[],a=this.vertices,i=0,l=b.length;i<l;i++)f(a[b[i][0]],a[b[i][1]],a[b[i][2]],d);this.mergeVertices();i=0;for(l=this.vertices.length;i<l;i++)this.vertices[i].position.multiplyScalar(c);this.computeCentroids();this.boundingSphere={radius:c}};
A
alteredq 已提交
602 603 604 605
THREE.PolyhedronGeometry.prototype=new THREE.Geometry;THREE.PolyhedronGeometry.prototype.constructor=THREE.PolyhedronGeometry;
THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[[-1,c,0],[1,c,0],[-1,-c,0],[1,-c,0],[0,-1,c],[0,1,c],[0,-1,-c],[0,1,-c],[c,0,-1],[c,0,1],[-c,0,-1],[-c,0,1]],[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]],a,b)};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
THREE.OctahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],[[0,2,4],[0,4,3],[0,3,5],[0,5,2],[1,2,5],[1,5,3],[1,3,4],[1,4,2]],a,b)};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],[[2,1,0],[0,3,2],[1,3,0],[2,3,1]],a,b)};
THREE.TetrahedronGeometry.prototype=new THREE.Geometry;THREE.TetrahedronGeometry.prototype.constructor=THREE.TetrahedronGeometry;
M
r47  
Mr.doob 已提交
606 607
THREE.AxisHelper=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var b=new THREE.CylinderGeometry(0,5,25,5,1),c;c=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));
this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.AxisHelper.prototype=new THREE.Object3D;THREE.AxisHelper.prototype.constructor=THREE.AxisHelper;
A
alteredq 已提交
608 609 610
THREE.ArrowHelper=function(a,b,c,d){THREE.Object3D.call(this);void 0===d&&(d=16776960);void 0===c&&(c=20);var e=new THREE.Geometry;e.vertices.push(new THREE.Vertex(new THREE.Vector3(0,0,0)));e.vertices.push(new THREE.Vertex(new THREE.Vector3(0,1,0)));this.line=new THREE.Line(e,new THREE.LineBasicMaterial({color:d}));this.add(this.line);e=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);
if(b instanceof THREE.Vector3)this.position=b;this.setDirection(a);this.setLength(c)};THREE.ArrowHelper.prototype=new THREE.Object3D;THREE.ArrowHelper.prototype.constructor=THREE.ArrowHelper;THREE.ArrowHelper.prototype.setDirection=function(a){var b=(new THREE.Vector3(0,1,0)).crossSelf(a),a=Math.acos((new THREE.Vector3(0,1,0)).dot(a.clone().normalize()));this.matrix=(new THREE.Matrix4).setRotationAxis(b.normalize(),a);this.rotation.getRotationFromMatrix(this.matrix,this.scale)};
THREE.ArrowHelper.prototype.setLength=function(a){this.scale.set(a,a,a)};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};
A
alteredq 已提交
611 612
THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.lineGeometry.vertices.push(new THREE.Vertex(new THREE.Vector3));d.lineGeometry.colors.push(new THREE.Color(b));void 0===d.pointMap[a]&&(d.pointMap[a]=[]);d.pointMap[a].push(d.lineGeometry.vertices.length-1)}THREE.Object3D.call(this);var d=this;this.lineGeometry=new THREE.Geometry;this.lineMaterial=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors});this.pointMap={};b("n1","n2",16755200);b("n2",
"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);
A
alteredq 已提交
613 614 615
this.camera=a;this.update(a);this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THREE.LinePieces);this.add(this.lines)};THREE.CameraHelper.prototype=new THREE.Object3D;THREE.CameraHelper.prototype.constructor=THREE.CameraHelper;
THREE.CameraHelper.prototype.update=function(){function a(a,d,e,f){THREE.CameraHelper.__v.set(d,e,f);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=b.pointMap[a];if(void 0!==a){d=0;for(e=a.length;d<e;d++)b.lineGeometry.vertices[a[d]].position.copy(THREE.CameraHelper.__v)}}var b=this;THREE.CameraHelper.__c.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",
-1,-1,1);a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",0.7,1.1,-1);a("u2",-0.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);this.lineGeometry.__dirtyVertices=!0};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
A
alteredq 已提交
616
THREE.SubdivisionModifier=function(a){this.subdivisions=void 0===a?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;0<b--;)this.smooth(a)};
617 618 619 620 621 622 623
THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var m=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){m.vertexColors=[];for(var k,l,o,p=0;4>p;p++){o=i[p];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q<o.length;q++)l=h.vertexColors[o[q]-1],k.r+=l.r,k.g+=l.g,k.b+=l.b;k.r/=o.length;k.g/=o.length;k.b/=o.length;m.vertexColors[p]=k}}e.push(m);(!g.supportUVs||0!=n.length)&&f.push([n[a],n[b],n[c],n[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
b)}var d=[],e=[],f=[],g=this,h=a.vertices,d=a.faces,k=h.concat(),i=[],l={},p={},n=[],o,q,m,r,s,v=a.faceVertexUvs[0];for(o=0,q=v.length;o<q;o++)for(m=0,r=v[o].length;m<r;m++)s=d[o]["abcd".charAt(m)],n[s]||(n[s]=v[o][m]);var u;for(o=0,q=d.length;o<q;o++)if(s=d[o],i.push(s.centroid),k.push(new THREE.Vertex(s.centroid)),g.supportUVs&&0!=n.length){u=new THREE.UV;if(s instanceof THREE.Face3)u.u=n[s.a].u+n[s.b].u+n[s.c].u,u.v=n[s.a].v+n[s.b].v+n[s.c].v,u.u/=3,u.v/=3;else if(s instanceof THREE.Face4)u.u=
n[s.a].u+n[s.b].u+n[s.c].u+n[s.d].u,u.v=n[s.a].v+n[s.b].v+n[s.c].v+n[s.d].v,u.u/=4,u.v/=4;n.push(u)}q=function(a){function b(a,c,d){void 0===a[c]&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};for(d=0,e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var t=0,v=h.length,w,y,H={},F={},C=function(a,
b){void 0===H[a]&&(H[a]=[]);H[a].push(b)},J=function(a,b){void 0===F[a]&&(F[a]={});F[a][b]=null};for(o in q){u=q[o];w=o.split("_");y=w[0];w=w[1];C(y,[y,w]);C(w,[y,w]);for(m=0,r=u.length;m<r;m++)s=u[m],J(y,s,o),J(w,s,o);2>u.length&&(p[o]=!0)}for(o in q)if(u=q[o],s=u[0],u=u[1],w=o.split("_"),y=w[0],w=w[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[y].position),r.addSelf(h[w].position),r.multiplyScalar(0.5)):(r.addSelf(i[s]),r.addSelf(i[u]),r.addSelf(h[y].position),r.addSelf(h[w].position),r.multiplyScalar(0.25)),
l[o]=v+d.length+t,k.push(new THREE.Vertex(r)),t++,g.supportUVs&&0!=n.length)u=new THREE.UV,u.u=n[y].u+n[w].u,u.v=n[y].v+n[w].v,u.u/=2,u.v/=2,n.push(u);var O,Q;w=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],J=["1234","12","2","23"],S=["1234","23","3","34"],M=["1234","34","4","41"],A=["1234","41","1","12"];for(o=0,q=i.length;o<q;o++)s=d[o],u=v+o,s instanceof THREE.Face3?(t=c(s.a,s.b),y=c(s.b,s.c),O=c(s.c,s.a),b(u,l[t],s.b,l[y],s,w),b(u,l[y],s.c,l[O],s,r),b(u,l[O],s.a,l[t],
s,C)):s instanceof THREE.Face4?(t=c(s.a,s.b),y=c(s.b,s.c),O=c(s.c,s.d),Q=c(s.d,s.a),b(u,l[t],s.b,l[y],s,J),b(u,l[y],s.c,l[O],s,S),b(u,l[O],s.d,l[Q],s,M),b(u,l[Q],s.a,l[t],s,A)):console.log("face should be a face!",s);d=k;k=new THREE.Vector3;l=new THREE.Vector3;for(o=0,q=h.length;o<q;o++)if(void 0!==H[o]){k.set(0,0,0);l.set(0,0,0);s=new THREE.Vector3(0,0,0);u=0;for(m in F[o])k.addSelf(i[m]),u++;t=0;v=H[o].length;for(m=0;m<v;m++)p[c(H[o][m][0],H[o][m][1])]&&t++;if(2!=t){k.divideScalar(u);for(m=0;m<
v;m++)u=H[o][m],u=h[u[0]].position.clone().addSelf(h[u[1]].position).divideScalar(2),l.addSelf(u);l.divideScalar(v);s.addSelf(h[o].position);s.multiplyScalar(v-3);s.addSelf(k);s.addSelf(l.multiplyScalar(2));s.divideScalar(v);d[o].position=s}}a.vertices=d;a.faces=e;a.faceVertexUvs[0]=f;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
A
alteredq 已提交
624
THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
625
THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
M
Mr.doob 已提交
626
a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(1>a.length?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=
627
Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function e(a,b){var e=new Image;e.onload=function(){if(!c(this.width)||!c(this.height)){var b=d(this.width),e=d(this.height);a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,b,e)}else a.image=this;a.needsUpdate=!0};e.crossOrigin=h.crossOrigin;e.src=b}function f(a,c,d,f,g,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=d;
628 629 630 631 632
if(f){a[c].repeat.set(f[0],f[1]);if(1!=f[0])a[c].wrapS=THREE.RepeatWrapping;if(1!=f[1])a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==f[h[0]])a[c].wrapS=f[h[0]];if(void 0!==f[h[1]])a[c].wrapT=f[h[1]]}e(a[c],b+"/"+d)}function g(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var h=this,k="MeshLambertMaterial",i={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};if(a.shading){var l=
a.shading.toLowerCase();"phong"===l?k="MeshPhongMaterial":"basic"===l&&(k="MeshBasicMaterial")}if(void 0!==a.blending&&void 0!==THREE[a.blending])i.blending=THREE[a.blending];if(void 0!==a.transparent||1>a.opacity)i.transparent=a.transparent;if(void 0!==a.depthTest)i.depthTest=a.depthTest;if(void 0!==a.depthWrite)i.depthWrite=a.depthWrite;if(void 0!==a.vertexColors)if("face"==a.vertexColors)i.vertexColors=THREE.FaceColors;else if(a.vertexColors)i.vertexColors=THREE.VertexColors;if(a.colorDiffuse)i.color=
g(a.colorDiffuse);else if(a.DbgColor)i.color=a.DbgColor;if(a.colorSpecular)i.specular=g(a.colorSpecular);if(a.colorAmbient)i.ambient=g(a.colorAmbient);if(a.transparency)i.opacity=a.transparency;if(a.specularCoef)i.shininess=a.specularCoef;a.mapDiffuse&&b&&f(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&f(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&f(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,
a.mapNormalWrap);a.mapSpecular&&b&&f(i,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){k=THREE.ShaderUtils.lib.normal;l=THREE.UniformsUtils.clone(k.uniforms);l.tNormal.texture=i.normalMap;if(a.mapNormalFactor)l.uNormalScale.value=a.mapNormalFactor;if(i.map)l.tDiffuse.texture=i.map,l.enableDiffuse.value=!0;if(i.specularMap)l.tSpecular.texture=i.specularMap,l.enableSpecular.value=!0;if(i.lightMap)l.tAO.texture=i.lightMap,l.enableAO.value=!0;l.uDiffuseColor.value.setHex(i.color);
l.uSpecularColor.value.setHex(i.specular);l.uAmbientColor.value.setHex(i.ambient);l.uShininess.value=i.shininess;if(void 0!==i.opacity)l.uOpacity.value=i.opacity;i=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:l,lights:!0,fog:!0})}else i=new THREE[k](i);if(void 0!==a.DbgName)i.name=a.DbgName;return i}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
633
THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
634 635 636
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status){var h=JSON.parse(g.responseText);a.loadAjaxBuffers(h,c,e,d,f)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,!0);g.overrideMimeType&&g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){4==f.readyState?200==f.status||0==f.status?THREE.BinaryLoader.prototype.createBinModel(f.response,b,d,a.materials):console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+f.status+"]"):3==f.readyState?e&&(0==h&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):2==f.readyState&&(h=f.getResponseHeader("Content-Length"))};
f.open("GET",g,!0);f.responseType="arraybuffer";f.send(null)};
637 638 639 640 641 642 643 644 645 646 647 648 649
THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,k,i,l,p,n,o,q,m,r,s,v,u,t;function w(a){return a%4?4-a%4:0}function y(a,b){return(new Uint8Array(a,b,1))[0]}function H(a,b){return(new Uint32Array(a,b,1))[0]}function F(b,c){var d,e,f,g,h,i,j,m,k=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=k[3*d];f=k[3*d+1];g=k[3*d+2];h=B[2*e];e=B[2*e+1];i=B[2*f];j=B[2*f+1];f=B[2*g];m=B[2*g+1];g=M.faceVertexUvs[0];var l=[];l.push(new THREE.UV(h,e));l.push(new THREE.UV(i,j));l.push(new THREE.UV(f,
m));g.push(l)}}function C(b,c){var d,e,f,g,h,i,j,m,k,l,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[4*d];f=n[4*d+1];g=n[4*d+2];h=n[4*d+3];i=B[2*e];e=B[2*e+1];j=B[2*f];k=B[2*f+1];m=B[2*g];l=B[2*g+1];g=B[2*h];f=B[2*h+1];h=M.faceVertexUvs[0];var o=[];o.push(new THREE.UV(i,e));o.push(new THREE.UV(j,k));o.push(new THREE.UV(m,l));o.push(new THREE.UV(g,f));h.push(o)}}function J(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],f=c[3*d+1],g=c[3*d+2],h=i[d],
M.faces.push(new THREE.Face3(e,f,g,null,null,h))}function O(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],f=c[4*d+1],g=c[4*d+2],h=c[4*d+3],i=j[d],M.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function Q(b,c,d,e){for(var f,g,h,i,j,m,k,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),l=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];j=d[3*e];m=d[3*e+1];k=d[3*e+2];i=l[e];var n=L[3*m],o=L[3*m+1];m=L[3*m+2];var p=L[3*k],q=
L[3*k+1];k=L[3*k+2];M.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(L[3*j],L[3*j+1],L[3*j+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(p,q,k)],null,i))}}function S(b,c,d,e){for(var f,g,h,i,j,m,k,l,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[4*e];g=c[4*e+1];h=c[4*e+2];i=c[4*e+3];m=d[4*e];k=d[4*e+1];l=d[4*e+2];n=d[4*e+3];j=o[e];var p=L[3*k],q=L[3*k+1];k=L[3*k+2];var r=L[3*l],s=L[3*l+1];l=L[3*l+2];var t=L[3*n],u=L[3*n+1];n=L[3*n+2];M.faces.push(new THREE.Face4(f,
g,h,i,[new THREE.Vector3(L[3*m],L[3*m+1],L[3*m+2]),new THREE.Vector3(p,q,k),new THREE.Vector3(r,s,l),new THREE.Vector3(t,u,n)],null,j))}}var M=this,A=0,L=[],B=[],j,T,G;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(M,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d})(a,A,12);c=y(a,A+12);y(a,A+13);y(a,A+14);y(a,A+15);e=y(a,A+16);k=y(a,A+17);i=y(a,A+18);l=y(a,A+19);p=H(a,A+20);n=H(a,A+20+4);o=H(a,A+20+8);b=H(a,A+20+12);q=
H(a,A+20+16);m=H(a,A+20+20);r=H(a,A+20+24);s=H(a,A+20+28);v=H(a,A+20+32);u=H(a,A+20+36);t=H(a,A+20+40);A+=c;c=3*e+l;G=4*e+l;j=b*c;T=q*(c+3*k);e=m*(c+3*i);l=r*(c+3*k+3*i);c=s*G;k=v*(G+4*k);i=u*(G+4*i);A+=function(b){var b=new Float32Array(a,b,3*p),c,d,e,f;for(c=0;c<p;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],M.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*p*Float32Array.BYTES_PER_ELEMENT}(A);A+=function(b){if(n){var b=new Int8Array(a,b,3*n),c,d,e,f;for(c=0;c<n;c++)d=b[3*c],e=b[3*c+1],
f=b[3*c+2],L.push(d/127,e/127,f/127)}return 3*n*Int8Array.BYTES_PER_ELEMENT}(A);A+=w(3*n);A+=function(b){if(o){var b=new Float32Array(a,b,2*o),c,d,e;for(c=0;c<o;c++)d=b[2*c],e=b[2*c+1],B.push(d,e)}return 2*o*Float32Array.BYTES_PER_ELEMENT}(A);j=A+j+w(2*b);T=j+T+w(2*q);e=T+e+w(2*m);l=e+l+w(2*r);c=l+c+w(2*s);k=c+k+w(2*v);i=k+i+w(2*u);(function(a){if(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;J(m,a,b+3*m*Uint32Array.BYTES_PER_ELEMENT);F(m,b)}})(T);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT,
c=b+3*r*Uint32Array.BYTES_PER_ELEMENT;Q(r,a,b,c+3*r*Uint32Array.BYTES_PER_ELEMENT);F(r,c)}})(e);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;O(u,a,b+4*u*Uint32Array.BYTES_PER_ELEMENT);C(u,b)}})(k);(function(a){if(t){var b=a+4*t*Uint32Array.BYTES_PER_ELEMENT,c=b+4*t*Uint32Array.BYTES_PER_ELEMENT;S(t,a,b,c+4*t*Uint32Array.BYTES_PER_ELEMENT);C(t,c)}})(i);b&&J(b,A,A+3*b*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(q){var b=a+3*q*Uint32Array.BYTES_PER_ELEMENT;Q(q,a,b,b+3*q*Uint32Array.BYTES_PER_ELEMENT)}})(j);
s&&O(s,l,l+4*s*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT;S(v,a,b,b+4*v*Uint32Array.BYTES_PER_ELEMENT)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
THREE.ColladaLoader=function(){function a(a,d,e){W=a;d=d||sa;void 0!==e&&(a=e.split("/"),a.pop(),ob=(1>a.length?".":a.join("/"))+"/");if((a=W.evaluate("//dae:asset",W,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":la=i.textContent.charAt(0)}}if(!Ia.convertUpAxis||la===Ia.upAxis)Ka=null;else switch(la){case "X":Ka="Y"===
Ia.upAxis?"XtoY":"XtoZ";break;case "Y":Ka="X"===Ia.upAxis?"YtoX":"YtoZ";break;case "Z":Ka="X"===Ia.upAxis?"ZtoX":"ZtoY"}Ra=b("//dae:library_images/dae:image",g,"image");Ya=b("//dae:library_materials/dae:material",F,"material");jb=b("//dae:library_effects/dae:effect",S,"effect");pa=b("//dae:library_geometries/dae:geometry",r,"geometry");fb=b(".//dae:library_cameras/dae:camera",T,"camera");va=b("//dae:library_controllers/dae:controller",h,"controller");Na=b("//dae:library_animations/dae:animation",
A,"animation");gb=b(".//dae:library_visual_scenes/dae:visual_scene",l,"visual_scene");Va=[];wa=[];(a=W.evaluate(".//dae:scene/dae:instance_visual_scene",W,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ia=gb[0<a.length?a:"visual_scene0"]):ia=null;ba=new THREE.Object3D;for(a=0;a<ia.nodes.length;a++)ba.add(f(ia.nodes[a]));bb=[];c(ba);a={scene:ba,morphs:Va,skins:wa,animations:bb,dae:{images:Ra,materials:Ya,cameras:fb,effects:jb,geometries:pa,controllers:va,
animations:Na,visualScenes:gb,scene:ia}};d&&d(a);return a}function b(a,b,c){for(var a=W.evaluate(a,W,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=ia.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};bb.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,
650
b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e,
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
f=va[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var c=1E6,g=-c,h=0;for(e in Na)for(var i=Na[e],j=0;j<i.sampler.length;j++){var m=i.sampler[j];m.create();c=Math.min(c,m.startTime);g=Math.max(g,m.endTime);h=Math.max(h,m.input.length)}e=h;for(var b=ia.getChildById(b.skeleton[0],!0)||ia.getChildBySid(b.skeleton[0],!0),k,l,g=new THREE.Vector3,n,
j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;m=f.skin;for(l=0;l<j.length;l++)if(k=j[l],n=-1,"JOINT"==k.type){for(var o=0;o<m.joints.length;o++)if(k.sid==m.joints[o]){n=o;break}if(0<=n){o=m.invBindMatrices[n];k.invBindMatrix=o;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,o);k.weights=[];for(o=0;o<m.weights.length;o++)for(var p=
0;p<m.weights[o].length;p++){var q=m.weights[o][p];q.joint==n&&k.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+k.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(m=0;m<h[j].weights.length;m++)k=h[j].weights[m],l=k.index,k=k.weight,n=a.vertices[l],l=i[l],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),l.position.x+=g.x*k,l.position.y+=g.y*k,l.position.z+=g.z*k;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function f(a){var b=
new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var j=va[a.controllers[g].url];switch(j.type){case "skin":if(pa[j.skin.source]){var i=new m;i.url=j.skin.source;i.instance_material=a.controllers[g].instance_material;a.geometries.push(i);c=a.controllers[g]}else if(va[j.skin.source]&&(d=j=va[j.skin.source],j.morph&&pa[j.morph.source]))i=new m,i.url=j.morph.source,i.instance_material=a.controllers[g].instance_material,a.geometries.push(i);break;case "morph":if(pa[j.morph.source])i=new m,
i.url=j.morph.source,i.instance_material=a.controllers[g].instance_material,a.geometries.push(i),d=a.controllers[g];console.log("ColladaLoader: Morph-controller partially supported.")}}for(g=0;g<a.geometries.length;g++){var j=a.geometries[g],i=j.instance_material,j=pa[j.url],k={},l=[],n=0,p;if(j&&j.mesh&&j.mesh.primitives){if(0==b.name.length)b.name=j.id;if(i)for(h=0;h<i.length;h++){p=i[h];var q=Ya[p.target],r=jb[q.instance_effect.url].shader;r.material.opacity=!r.material.opacity?1:r.material.opacity;
k[p.symbol]=n;l.push(r.material);p=r.material;p.name=null==q.name||""===q.name?q.id:q.name;n++}i=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});j=j.mesh.geometry3js;if(1<n){i=new THREE.MeshFaceMaterial;j.materials=l;for(h=0;h<j.faces.length;h++)l=j.faces[h],l.materialIndex=k[l.daeMaterial]}if(void 0!==c)e(j,c),i.morphTargets=!0,i=new THREE.SkinnedMesh(j,i),i.skeleton=c.skeleton,i.skinController=va[c.url],i.skinInstanceController=c,i.name="skin_"+wa.length,wa.push(i);
else if(void 0!==d){h=j;k=d instanceof o?va[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(n=pa[k.targets[l]],n.mesh&&n.mesh.primitives&&n.mesh.primitives.length)n=n.mesh.primitives[0].geometry,n.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:n.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}i.morphTargets=!0;i=new THREE.Mesh(j,i);i.name="morph_"+Va.length;Va.push(i)}else i=
new THREE.Mesh(j,i);1<a.geometries.length?b.add(i):b=i}}for(g=0;g<a.cameras.length;g++)b=fb[a.cameras[g].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;g=a.matrix.decompose();b.position=g[0];b.quaternion=g[1];b.useQuaternion=!0;b.scale=g[2];Ia.centerGeometry&&b.geometry&&(g=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(g.multiplySelf(b.scale)),b.position.subSelf(g));for(g=0;g<a.nodes.length;g++)b.add(f(a.nodes[g],a));
return b}function g(){this.init_from=this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=null}function k(){this.weights=this.targets=this.source=this.method=null}function i(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function l(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function p(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=
[];this.matrix=new THREE.Matrix4}function n(){this.type=this.sid="";this.data=[];this.obj=null}function o(){this.url="";this.skeleton=[];this.instance_material=[]}function q(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function r(){this.id="";this.mesh=null}function s(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function v(){}function u(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}
function t(){this.source="";this.stride=this.count=0;this.params=[]}function w(){this.input={}}function y(){this.semantic="";this.offset=0;this.source="";this.set=0}function H(a){this.id=a;this.type=null}function F(){this.name=this.id="";this.instance_effect=null}function C(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}function J(a,b){this.type=a;this.effect=b;this.material=null}function O(a){this.effect=
a;this.format=this.init_from=null}function Q(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function S(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function M(){this.url=""}function A(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function L(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function B(a){this.id="";this.animation=
a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.strideOut=this.output=this.input=null;this.duration=0}function j(a){this.targets=[];this.time=a}function T(){this.name=this.id=""}function G(){this.url=""}function D(a){return"dae"==a?"http://www.collada.org/2005/11/COLLADASchema":null}function V(a){for(var a=ga(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseFloat(a[c]));return b}function E(a){for(var a=ga(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseInt(a[c],10));return b}function ga(a){return 0<
a.length?a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/):[]}function da(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function ea(a,b){if(Ia.convertUpAxis&&la!==Ia.upAxis)switch(Ka){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;break;case "XtoZ":c=a[2];a[2]=a[1];a[1]=a[0];a[0]=c;break;case "YtoX":c=a[0];a[0]=a[1];a[1]=b*c;break;case "YtoZ":c=a[1];a[1]=b*a[2];a[2]=c;break;case "ZtoX":c=a[0];a[0]=a[1];a[1]=a[2];a[2]=c;break;case "ZtoY":c=a[1],a[1]=a[2],a[2]=b*c}}function R(a,b){var c=
[a[b],a[b+1],a[b+2]];ea(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function $(a){if(Ia.convertUpAxis){var b=[a[0],a[4],a[8]];ea(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];ea(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];ea(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];ea(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];ea(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];ea(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];ea(b,-1);a[3]=b[0];
a[7]=b[1];a[11]=b[2]}return new THREE.Matrix4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}var W=null,ba=null,ia,sa=null,Ha={},Ra={},Na={},va={},pa={},Ya={},jb={},fb={},bb,gb,ob,Va,wa,ta=THREE.SmoothShading,Ia={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},la="Y",Ka=null,Da=Math.PI/180;g.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("init_from"==c.nodeName)this.init_from=
c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new i).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new k).parse(c),this.type=c.nodeName}}return this};k.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(d=
0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(1==e.nodeType)switch(e.nodeName){case "source":e=(new H).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};k.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "input":b.push((new y).parse(d))}}return b};
i.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(1==f.nodeType)switch(f.nodeName){case "bind_shape_matrix":f=V(f.textContent);this.bindShapeMatrix=$(f);break;case "source":f=(new H).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,
b);return this};i.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "input":var d=(new y).parse(d),e=b[d.source];if("JOINT"==d.semantic)this.joints=e.read();else if("INV_BIND_MATRIX"==d.semantic)this.invBindMatrices=e.read()}}};i.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=a.childNodes[f];if(1==g.nodeType)switch(g.nodeName){case "input":e.push((new y).parse(g));break;
case "v":c=E(g.textContent);break;case "vcount":d=E(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var m={},k=0;k<e.length;k++){var l=e[k],n=c[g+l.offset];switch(l.semantic){case "JOINT":m.joint=n;break;case "WEIGHT":m.weight=b[l.source].data[n]}}i.push(m);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};l.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};
l.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};l.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "node":this.nodes.push((new p).parse(c))}}return this};p.prototype.getChannelForTransform=function(a){for(var b=0;b<this.channels.length;b++){var c=this.channels[b],
A
alteredq 已提交
673 674
d=c.target.split("/");d.shift();var e=d.shift(),f=0<=e.indexOf("."),g=0<=e.indexOf("("),h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;d<h.length;d++)h[d]=parseInt(h[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:g,arrIndices:h},c}return null};p.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};p.prototype.getChildBySid=
function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};p.prototype.getTransformBySid=function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};p.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");this.type="JOINT"==this.type?this.type:
675 676 677 678 679 680 681
"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.cameras=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],1==b.nodeType)switch(b.nodeName){case "node":this.nodes.push((new p).parse(b));break;case "instance_camera":this.cameras.push((new G).parse(b));break;case "instance_controller":this.controllers.push((new o).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;
case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=W.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",W,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new p).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new n).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in Na)for(var e=Na[d],f=0;f<e.channel.length;f++){var g=e.channel[f],
h=e.sampler[f];d=g.target.split("/")[0];if(d==this.id)h.create(),g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=[];a=[];c=0;for(e=this.channels.length;c<e;c++){b=this.channels[c];f=b.fullSid;g=b.member;if(Ia.convertUpAxis)switch(g){case "X":switch(Ka){case "XtoY":case "XtoZ":case "YtoX":g="Y";break;case "ZtoX":g="Z"}break;case "Y":switch(Ka){case "XtoY":case "YtoX":case "ZtoX":g="X";
break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(Ka){case "XtoZ":g="X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,k=this.getTransformBySid(b.sid);if(k){-1===a.indexOf(f)&&a.push(f);b=0;for(var l=i.length;b<l;b++){var q=i[b],r=h.getData(k.type,b),s;s=null;for(var t=0,u=d.length;t<u&&null==s;t++){var v=d[t];if(v.time===q)s=v;else if(v.time>q)break}if(!s){s=new j(q);t=-1;u=0;for(v=d.length;u<v&&-1==t;u++)d[u].time>=q&&(t=u);q=t;d.splice(-1==q?d.length:
q,0,s)}s.addTarget(f,k,g,r)}}else console.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(s=d[b],!s.hasTarget(e)){h=d;f=s;k=b;g=e;i=void 0;a:{i=k?k-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(l=h[i],l.hasTarget(g)){i=l;break a}i=null}l=void 0;a:{for(k+=1;k<h.length;k++)if(l=h[k],l.hasTarget(g))break a;l=null}if(i&&l){h=(f.time-i.time)/(l.time-i.time);i=i.getTarget(g);k=l.getTarget(g).data;l=i.data;r=void 0;if(l.length){r=[];for(q=0;q<
l.length;++q)r[q]=l[q]+(k[q]-l[q])*h}else r=l+(k-l)*h;f.addTarget(g,i.transform,i.member,r)}}}this.keys=d;this.sids=a}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};n.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=V(a.textContent);this.convert();return this};n.prototype.convert=function(){switch(this.type){case "matrix":this.obj=$(this.data);
break;case "rotate":this.angle=this.data[3]*Da;case "translate":ea(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":ea(this.data,1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};n.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,
682
this.angle);break;case "scale":a.scale(this.obj)}};n.prototype.update=function(a,b){switch(this.type){case "matrix":console.log("Currently not handling matrix transform updates");break;case "translate":case "scale":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case "rotate":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=
683 684 685 686 687 688 689 690 691 692 693 694 695 696
a*Da;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*Da}}};o.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=W.evaluate(".//dae:instance_material",c,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=
c.iterateNext();d;)this.instance_material.push((new q).parse(d)),d=c.iterateNext()}}return this};q.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,"");return this};m.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType&&"bind_material"==c.nodeName){if(a=W.evaluate(".//dae:instance_material",c,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null))for(b=a.iterateNext();b;)this.instance_material.push((new q).parse(b)),b=a.iterateNext();break}}return this};r.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new s(this)).parse(c)}}return this};s.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "source":var d=c.getAttribute("id");void 0==Ha[d]&&(Ha[d]=
(new H(d)).parse(c));break;case "vertices":this.vertices=(new w).parse(c);break;case "triangles":this.primitives.push((new u).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new v).parse(c))}}this.geometry3js=new THREE.Geometry;a=Ha[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(R(a,b)));for(b=0;b<this.primitives.length;b++)a=this.primitives[b],a.setVertices(this.vertices),
this.handlePrimitive(a,this.geometry3js);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.calcNormals&&(this.geometry3js.computeVertexNormals(),delete this.geometry3js.calcNormals);this.geometry3js.computeBoundingBox();return this};s.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,m=0,l=3,n=0,o=[];for(d=0;d<g.length;d++){h=g[d];var p=h.offset+1,n=n<p?p:n;switch(h.semantic){case "TEXCOORD":o.push(h.set)}}for(;c<f.length;){var q=
[],r=[],p={},s=[];a.vcount&&(l=a.vcount[m++]);for(d=0;d<l;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=Ha[h.source],i=f[c+d*n+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":q.push(i);break;case "NORMAL":r.push(R(k.data,j));break;case "TEXCOORD":void 0===p[h.set]&&(p[h.set]=[]);p[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":s.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(0==r.length)if(h=this.vertices.input.NORMAL){k=Ha[h.source];
j=k.accessor.params.length;h=0;for(i=q.length;h<i;h++)r.push(R(k.data,q[h]*j))}else b.calcNormals=!0;if(3===l)d.push(new THREE.Face3(q[0],q[1],q[2],r,s.length?s:new THREE.Color));else if(4===l)d.push(new THREE.Face4(q[0],q[1],q[2],q[3],r,s.length?s:new THREE.Color));else if(4<l&&Ia.subdivideFaces){s=s.length?s:new THREE.Color;for(e=1;e<l-1;)d.push(new THREE.Face3(q[0],q[e],q[e+1],[r[0],r[e++],r[e]],s))}if(d.length){h=0;for(i=d.length;h<i;h++){e=d[h];e.daeMaterial=a.material;b.faces.push(e);for(e=
0;e<o.length;e++)q=p[o[e]],q=4<l?[q[0],q[h+1],q[h+2]]:4===l?[q[0],q[1],q[2],q[3]]:[q[0],q[1],q[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(q)}}else console.log("dropped face with vcount "+l+" for geometry with id: "+b.id);c+=n*l}};v.prototype=new u;v.prototype.constructor=v;u.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=a.input.POSITION.source};u.prototype.parse=function(a){this.inputs=[];this.material=
a.getAttribute("material");this.count=da(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new y).parse(a.childNodes[b]));break;case "vcount":this.vcount=E(c.textContent);break;case "p":this.p=E(c.textContent)}}return this};t.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=da(a,"count",0);this.stride=da(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("param"==
c.nodeName){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};w.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if("input"==a.childNodes[b].nodeName){var c=(new y).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};y.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=da(a,"set",-1);this.offset=da(a,"offset",0);
if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};H.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=ga(c.textContent),e=[],f=0,g=d.length;f<g;f++)e.push("true"==d[f]||"1"==d[f]?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=V(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=E(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=
ga(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if("accessor"==c.childNodes[d].nodeName){this.accessor=(new t).parse(c.childNodes[d]);break}}}return this};H.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=this.data.slice(b,b+16),c=$(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+
b.type+".")}return a};F.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if("instance_effect"==a.childNodes[b].nodeName){this.instance_effect=(new M).parse(a.childNodes[b]);break}return this};C.prototype.isColor=function(){return null==this.texture};C.prototype.isTexture=function(){return null!=this.texture};C.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "color":c=
V(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord"),this.texOpts={offsetU:0,offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(c)}}return this};C.prototype.parseTexture=function(a){if(!a.childNodes)return this;a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&
M
Mr.doob 已提交
697
(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};J.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=
698 699 700 701 702 703 704 705 706
(new C).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=W.evaluate(".//dae:float",c,D,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;0<d.length&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};J.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];
if(d instanceof C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=Ra[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(ob+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else"diffuse"==
c?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=ta;return this.material=new THREE.MeshLambertMaterial(a)};O.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+
c.nodeName)}}return this};Q.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};
S.prototype.create=function(){if(null==this.shader)return null};S.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};S.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "surface":this.surface=
(new O(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new Q(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};S.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};
S.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new J(c.nodeName,this)).parse(c)}}};M.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};A.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
if(1==c.nodeType)switch(c.nodeName){case "source":c=(new H).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new B(this)).parse(c));break;case "channel":this.channel.push((new L(this)).parse(c))}}return this};L.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");b.shift();var a=b.shift(),c=0<=a.indexOf("."),d=0<=a.indexOf("(");if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();
else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e<b.length;e++)b[e]=parseInt(b[e].replace(/\)/,""));this.arrIndices=b}else this.sid=a;this.fullSid=a;this.dotSyntax=c;this.arrSyntax=d;return this};B.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "input":this.inputs.push((new y).parse(c))}}return this};B.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=
M
r48  
Mr.doob 已提交
707
this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();this.strideOut=c.accessor.stride;break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),
708
this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};B.prototype.getData=function(a,b){var c;if(1<this.strideOut){c=[];for(var b=b*this.strideOut,d=0;d<this.strideOut;++d)c[d]=this.output[b+d];if(3===this.strideOut)switch(a){case "rotate":case "translate":ea(c,-1);break;case "scale":ea(c,1)}}else c=this.output[b];return c};j.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,member:c,transform:b,data:d})};j.prototype.apply=function(a){for(var b=
709
0;b<this.targets.length;++b){var c=this.targets[b];(!a||c.sid===a)&&c.transform.update(c.data,c.member)}};j.prototype.getTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return this.targets[b];return null};j.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};j.prototype.interpolate=function(a,b){for(var c=0;c<this.targets.length;++c){var d=this.targets[c],e=a.getTarget(d.sid);if(e){var f=(b-this.time)/
M
Mr.doob 已提交
710
(a.time-this.time),g=e.data,h=d.data;if(0>f||1<f)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=0>f?0:1;if(h.length)for(var e=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;else e=h+(g-h)*f}else e=d.data;d.transform.update(e,d.member)}};T.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "optics":this.parseOptics(c)}}return this};T.prototype.parseOptics=
711 712 713
function(a){for(var b=0;b<a.childNodes.length;b++)if("technique_common"==a.childNodes[b].nodeName)for(var c=a.childNodes[b],d=0;d<c.childNodes.length;d++)if("perspective"==c.childNodes[d].nodeName)for(var e=c.childNodes[d],f=0;f<e.childNodes.length;f++){var g=e.childNodes[f];switch(g.nodeName){case "xfov":this.fov=g.textContent;break;case "znear":this.znear=0.4;break;case "zfar":this.zfar=1E15;break;case "aspect_ratio":this.aspect_ratio=g.textContent}}return this};G.prototype.parse=function(a){this.url=
a.getAttribute("url").replace(/^#/,"");return this};return{load:function(b,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=function(){if(4==f.readyState){if(0==f.status||200==f.status)f.responseXML?(sa=c,a(f.responseXML,void 0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else 3==f.readyState&&d&&(0==e&&(e=f.getResponseHeader("Content-Length")),
d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){ta=a},applySkin:e,geometries:pa,options:Ia}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
M
Mr.doob 已提交
714
THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
715 716
THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var h=JSON.parse(f.responseText);a.createModel(h,c,d)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+f.status+"]");else f.readyState===f.LOADING?e&&(0===g&&(g=f.getResponseHeader("Content-Length")),
e({total:g,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.overrideMimeType&&f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
717 718 719 720 721
THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){var c,e,k,i,l,p,n,o,q,m,r,s,v,u,t=a.faces;p=a.vertices;var w=a.normals,y=a.colors,H=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&H++;for(c=0;c<H;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];i=0;for(l=p.length;i<l;)n=new THREE.Vertex,n.position.x=p[i++]*b,n.position.y=p[i++]*b,n.position.z=p[i++]*b,d.vertices.push(n);i=0;for(l=t.length;i<l;){b=
t[i++];p=b&1;k=b&2;c=b&4;e=b&8;o=b&16;n=b&32;m=b&64;b&=128;p?(r=new THREE.Face4,r.a=t[i++],r.b=t[i++],r.c=t[i++],r.d=t[i++],p=4):(r=new THREE.Face3,r.a=t[i++],r.b=t[i++],r.c=t[i++],p=3);if(k)k=t[i++],r.materialIndex=k;k=d.faces.length;if(c)for(c=0;c<H;c++)s=a.uvs[c],q=t[i++],u=s[2*q],q=s[2*q+1],d.faceUvs[c][k]=new THREE.UV(u,q);if(e)for(c=0;c<H;c++){s=a.uvs[c];v=[];for(e=0;e<p;e++)q=t[i++],u=s[2*q],q=s[2*q+1],v[e]=new THREE.UV(u,q);d.faceVertexUvs[c][k]=v}if(o)o=3*t[i++],e=new THREE.Vector3,e.x=w[o++],
e.y=w[o++],e.z=w[o],r.normal=e;if(n)for(c=0;c<p;c++)o=3*t[i++],e=new THREE.Vector3,e.x=w[o++],e.y=w[o++],e.z=w[o],r.vertexNormals.push(e);if(m)n=t[i++],n=new THREE.Color(y[n]),r.color=n;if(b)for(c=0;c<p;c++)n=t[i++],n=new THREE.Color(y[n]),r.vertexColors.push(n);d.faces.push(r)}})(e);(function(){var b,c,e,k;if(a.skinWeights)for(b=0,c=a.skinWeights.length;b<c;b+=2)e=a.skinWeights[b],k=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(e,k,0,0));if(a.skinIndices)for(b=0,c=a.skinIndices.length;b<
c;b+=2)e=a.skinIndices[b],k=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(e,k,0,0));d.bones=a.bones;d.animation=a.animation})();(function(b){if(void 0!==a.morphTargets){var c,e,k,i,l,p,n,o,q;for(c=0,e=a.morphTargets.length;c<e;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];o=d.morphTargets[c].vertices;q=a.morphTargets[c].vertices;for(k=0,i=q.length;k<i;k+=3)l=q[k]*b,p=q[k+1]*b,n=q[k+2]*b,o.push(new THREE.Vertex(new THREE.Vector3(l,p,
n)))}}if(void 0!==a.morphColors)for(c=0,e=a.morphColors.length;c<e;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];i=d.morphColors[c].colors;l=a.morphColors[c].colors;for(b=0,k=l.length;b<k;b+=3)p=new THREE.Color(16755200),p.setRGB(l[b],l[b+1],l[b+2]),i.push(p)}})(e);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};
M
Mr.doob 已提交
722
THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
Z
zz85 已提交
723
THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(4==d.readyState)if(200==d.status||0==d.status){var e=JSON.parse(d.responseText);c.createScene(e,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,!0);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
724 725 726 727 728 729 730 731 732 733 734 735 736 737
THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:i+"/"+a}function e(){var a;for(n in M.objects)if(!G.objects[n])if(s=M.objects[n],void 0!==s.geometry){if(J=G.geometries[s.geometry])a=!1,O=G.materials[s.materials[0]],(a=O instanceof THREE.ShaderMaterial)&&J.computeTangents(),t=s.position,w=s.rotation,y=s.quaternion,H=s.scale,y=0,0==s.materials.length&&(O=new THREE.MeshFaceMaterial),1<s.materials.length&&(O=new THREE.MeshFaceMaterial),a=new THREE.Mesh(J,
O),a.name=n,a.position.set(t[0],t[1],t[2]),y?(a.quaternion.set(y[0],y[1],y[2],y[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]),a.scale.set(H[0],H[1],H[2]),a.visible=s.visible,a.doubleSided=s.doubleSided,a.castShadow=s.castShadow,a.receiveShadow=s.receiveShadow,G.scene.add(a),G.objects[n]=a}else t=s.position,w=s.rotation,y=s.quaternion,H=s.scale,y=0,a=new THREE.Object3D,a.name=n,a.position.set(t[0],t[1],t[2]),y?(a.quaternion.set(y[0],y[1],y[2],y[3]),a.useQuaternion=!0):a.rotation.set(w[0],
w[1],w[2]),a.scale.set(H[0],H[1],H[2]),a.visible=void 0!==s.visible?s.visible:!1,G.scene.add(a),G.objects[n]=a,G.empties[n]=a}function f(a){return function(b){G.geometries[a]=b;e();L-=1;k.onLoadComplete();h()}}function g(a){return function(b){G.geometries[a]=b}}function h(){k.callbackProgress({totalModels:j,totalTextures:T,loadedModels:j-L,loadedTextures:T-B},G);k.onLoadProgress();0==L&&0==B&&b(G)}var k=this,i=THREE.Loader.prototype.extractUrlBase(c),l,p,n,o,q,m,r,s,v,u,t,w,y,H,F,C,J,O,Q,S,M,A,L,
B,j,T,G;M=a;c=new THREE.BinaryLoader;A=new THREE.JSONLoader;B=L=0;G={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(M.transform&&(a=M.transform.position,v=M.transform.rotation,F=M.transform.scale,a&&G.scene.position.set(a[0],a[1],a[2]),v&&G.scene.rotation.set(v[0],v[1],v[2]),F&&G.scene.scale.set(F[0],F[1],F[2]),a||v||F))G.scene.updateMatrix(),G.scene.updateMatrixWorld();a=function(){B-=1;h();k.onLoadComplete()};for(q in M.cameras)F=
M.cameras[q],"perspective"==F.type?Q=new THREE.PerspectiveCamera(F.fov,F.aspect,F.near,F.far):"ortho"==F.type&&(Q=new THREE.OrthographicCamera(F.left,F.right,F.top,F.bottom,F.near,F.far)),t=F.position,v=F.target,F=F.up,Q.position.set(t[0],t[1],t[2]),Q.target=new THREE.Vector3(v[0],v[1],v[2]),F&&Q.up.set(F[0],F[1],F[2]),G.cameras[q]=Q;for(o in M.lights)v=M.lights[o],q=void 0!==v.color?v.color:16777215,Q=void 0!==v.intensity?v.intensity:1,"directional"==v.type?(t=v.direction,u=new THREE.DirectionalLight(q,
Q),u.position.set(t[0],t[1],t[2]),u.position.normalize()):"point"==v.type?(t=v.position,u=v.distance,u=new THREE.PointLight(q,Q,u),u.position.set(t[0],t[1],t[2])):"ambient"==v.type&&(u=new THREE.AmbientLight(q)),G.scene.add(u),G.lights[o]=u;for(m in M.fogs)o=M.fogs[m],"linear"==o.type?S=new THREE.Fog(0,o.near,o.far):"exp2"==o.type&&(S=new THREE.FogExp2(0,o.density)),F=o.color,S.color.setRGB(F[0],F[1],F[2]),G.fogs[m]=S;if(G.cameras&&M.defaults.camera)G.currentCamera=G.cameras[M.defaults.camera];if(G.fogs&&
M.defaults.fog)G.scene.fog=G.fogs[M.defaults.fog];F=M.defaults.bgcolor;G.bgColor=new THREE.Color;G.bgColor.setRGB(F[0],F[1],F[2]);G.bgColorAlpha=M.defaults.bgalpha;for(l in M.geometries)if(m=M.geometries[l],"bin_mesh"==m.type||"ascii_mesh"==m.type)L+=1,k.onLoadStart();j=L;for(l in M.geometries)if(m=M.geometries[l],"cube"==m.type)J=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),G.geometries[l]=J;else if("plane"==m.type)J=new THREE.PlaneGeometry(m.width,
m.height,m.segmentsWidth,m.segmentsHeight),G.geometries[l]=J;else if("sphere"==m.type)J=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),G.geometries[l]=J;else if("cylinder"==m.type)J=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),G.geometries[l]=J;else if("torus"==m.type)J=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),G.geometries[l]=J;else if("icosahedron"==m.type)J=new THREE.IcosahedronGeometry(m.radius,m.subdivisions),G.geometries[l]=
J;else if("bin_mesh"==m.type)c.load(d(m.url,M.urlBaseType),f(l));else if("ascii_mesh"==m.type)A.load(d(m.url,M.urlBaseType),f(l));else if("embedded_mesh"==m.type)m=M.embeds[m.id],m.metadata=M.metadata,m&&A.createModel(m,g(l),"");for(r in M.textures)if(l=M.textures[r],l.url instanceof Array){B+=l.url.length;for(m=0;m<l.url.length;m++)k.onLoadStart()}else B+=1,k.onLoadStart();T=B;for(r in M.textures){l=M.textures[r];if(void 0!=l.mapping&&void 0!=THREE[l.mapping])l.mapping=new THREE[l.mapping];if(l.url instanceof
Array){m=[];for(S=0;S<l.url.length;S++)m[S]=d(l.url[S],M.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,l.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(l.url,M.urlBaseType),l.mapping,a);if(void 0!=THREE[l.minFilter])m.minFilter=THREE[l.minFilter];if(void 0!=THREE[l.magFilter])m.magFilter=THREE[l.magFilter];if(l.repeat){m.repeat.set(l.repeat[0],l.repeat[1]);if(1!=l.repeat[0])m.wrapS=THREE.RepeatWrapping;if(1!=l.repeat[1])m.wrapT=THREE.RepeatWrapping}l.offset&&m.offset.set(l.offset[0],l.offset[1]);
if(l.wrap){S={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==S[l.wrap[0]])m.wrapS=S[l.wrap[0]];if(void 0!==S[l.wrap[1]])m.wrapT=S[l.wrap[1]]}}G.textures[r]=m}for(p in M.materials){r=M.materials[p];for(C in r.parameters)if("envMap"==C||"map"==C||"lightMap"==C)r.parameters[C]=G.textures[r.parameters[C]];else if("shading"==C)r.parameters[C]="flat"==r.parameters[C]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==C)r.parameters[C]=THREE[r.parameters[C]]?THREE[r.parameters[C]]:
THREE.NormalBlending;else if("combine"==C)r.parameters[C]="MixOperation"==r.parameters[C]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==C)if("face"==r.parameters[C])r.parameters[C]=THREE.FaceColors;else if(r.parameters[C])r.parameters[C]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){a=THREE.ShaderUtils.lib.normal;l=THREE.UniformsUtils.clone(a.uniforms);m=r.parameters.color;S=r.parameters.specular;
c=r.parameters.ambient;A=r.parameters.shininess;l.tNormal.texture=G.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)l.uNormalScale.value=r.parameters.normalMapFactor;if(r.parameters.map)l.tDiffuse.texture=r.parameters.map,l.enableDiffuse.value=!0;if(r.parameters.lightMap)l.tAO.texture=r.parameters.lightMap,l.enableAO.value=!0;if(r.parameters.specularMap)l.tSpecular.texture=G.textures[r.parameters.specularMap],l.enableSpecular.value=!0;l.uDiffuseColor.value.setHex(m);l.uSpecularColor.value.setHex(S);
l.uAmbientColor.value.setHex(c);l.uShininess.value=A;if(r.parameters.opacity)l.uOpacity.value=r.parameters.opacity;O=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:l,lights:!0,fog:!0})}else O=new THREE[r.type](r.parameters);G.materials[p]=O}e();k.callbackSync(G);h()};THREE.UTF8Loader=function(){};
738 739
THREE.UTF8Loader.prototype.load=function(a,b,c){var d=new XMLHttpRequest,e=void 0!==c.scale?c.scale:1,f=void 0!==c.offsetX?c.offsetX:0,g=void 0!==c.offsetY?c.offsetY:0,h=void 0!==c.offsetZ?c.offsetZ:0;d.onreadystatechange=function(){4==d.readyState?200==d.status||0==d.status?THREE.UTF8Loader.prototype.createModel(d.responseText,b,e,f,g,h):console.error("THREE.UTF8Loader: Couldn't load ["+a+"] ["+d.status+"]"):3!=d.readyState&&2==d.readyState&&d.getResponseHeader("Content-Length")};d.open("GET",a,
!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);57344<=b&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;8>e;e++){for(var f=0,g=0;g<b;++g){var h=a.charCodeAt(g+d),f=f+(h>>1^-(h&1));c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=0;e<b;e++)h=a.charCodeAt(e+d),f[e]=g-h,0==h&&g++;return[c,f]};
740 741 742
THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,f){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),i=[],l=[];(function(a,g,i){for(var k,m,l,s=a.length;i<s;i+=g)k=a[i],m=a[i+1],l=a[i+2],k=k/16383*c,m=m/16383*c,l=l/16383*c,k+=d,m+=e,l+=f,b.vertices.push(new THREE.Vertex(new THREE.Vector3(k,m,l)))})(g[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,l.push(d,1-e)})(g[0],8,3);(function(a,
b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,i.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,k,v,u,t,w=a.length;for(c=0;c<w;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;u=d;t=e;k=f;var y=i[3*e],H=i[3*e+1],F=i[3*e+2],C=i[3*f],J=i[3*f+1],O=i[3*f+2];v=new THREE.Vector3(i[3*d],i[3*d+1],i[3*d+2]);y=new THREE.Vector3(y,H,F);C=new THREE.Vector3(C,J,O);g.faces.push(new THREE.Face3(u,t,k,[v,y,C],null,0));g=l[2*d];d=l[2*d+1];k=l[2*e];v=l[2*e+1];u=l[2*
f];t=l[2*f+1];f=b.faceVertexUvs[0];e=k;k=v;v=[];v.push(new THREE.UV(g,d));v.push(new THREE.UV(e,k));v.push(new THREE.UV(u,t));f.push(v)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=new THREE.Object3D;THREE.ImmediateRenderObject.prototype.constructor=THREE.ImmediateRenderObject;
743 744
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,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=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:f,color:e,blending:d})};
Z
zz85 已提交
745
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)};
746 747
THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)};THREE.MorphBlendMesh.prototype=new THREE.Mesh;THREE.MorphBlendMesh.prototype.constructor=THREE.MorphBlendMesh;
THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={startFrame:b,endFrame:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[a]=b;this.animationsList.push(b)};
748
THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)(\d+)/,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);if(h&&1<h.length){var k=h[1];d[k]||(d[k]={start:Infinity,end:-Infinity});h=d[k];if(f<h.start)h.start=f;if(f>h.end)h.end=f;c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};
749 750 751
THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];if(c)c.fps=b,c.duration=(c.end-c.start)/c.fps};
THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];if(c)c.duration=b,c.fps=(c.end-c.start)/c.duration};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];if(c)c.weight=b};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];if(c)c.time=b};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};
752 753
THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||0>d.time){d.direction*=-1;if(d.time>d.duration)d.time=d.duration,d.directionBackwards=!0;if(0>d.time)d.time=0,d.directionBackwards=!1}}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;
if(f!==d.currentFrame)this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f;e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};
754 755 756 757 758 759 760 761 762
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,f,g,h,k,i,l,p,n,o;this.init=function(q){b=q.context;c=q;d=new Float32Array(16);e=new Uint16Array(6);q=0;d[q++]=-1;d[q++]=-1;d[q++]=0;d[q++]=0;d[q++]=1;d[q++]=-1;d[q++]=1;d[q++]=
0;d[q++]=1;d[q++]=1;d[q++]=1;d[q++]=1;d[q++]=-1;d[q++]=1;d[q++]=0;d[q++]=1;q=0;e[q++]=0;e[q++]=1;e[q++]=2;e[q++]=0;e[q++]=2;e[q++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
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);
b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(i=!1,l=a(THREE.ShaderFlares.lensFlare)):(i=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};n={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");n.renderType=b.getUniformLocation(l,"renderType");n.map=b.getUniformLocation(l,"map");n.occlusionMap=b.getUniformLocation(l,"occlusionMap");n.opacity=b.getUniformLocation(l,"opacity");n.color=b.getUniformLocation(l,
"color");n.scale=b.getUniformLocation(l,"scale");n.rotation=b.getUniformLocation(l,"rotation");n.screenPosition=b.getUniformLocation(l,"screenPosition");o=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,v=a.length;if(v){var u=new THREE.Vector3,t=s/e,w=0.5*e,y=0.5*s,H=16/s,F=new THREE.Vector2(H*t,H),C=new THREE.Vector3(1,1,0),J=new THREE.Vector2(1,1),O=n,H=p;b.useProgram(l);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(O.occlusionMap,0);b.uniform1i(O.map,
1);b.bindBuffer(b.ARRAY_BUFFER,f);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,g);b.disable(b.CULL_FACE);b.depthMask(!1);var Q,S,M,A,L;for(Q=0;Q<v;Q++)if(H=16/s,F.set(H*t,H),A=a[Q],u.set(A.matrixWorld.n14,A.matrixWorld.n24,A.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(u),d.projectionMatrix.multiplyVector3(u),C.copy(u),J.x=C.x*w+w,J.y=C.y*y+y,i||0<J.x&&J.x<e&&0<J.y&&J.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,J.x-8,J.y-8,16,16,0);b.uniform1i(O.renderType,0);b.uniform2f(O.scale,F.x,F.y);b.uniform3f(O.screenPosition,C.x,C.y,C.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,J.x-8,J.y-8,16,16,0);b.uniform1i(O.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,
6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(C);A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares();b.uniform1i(O.renderType,2);b.enable(b.BLEND);for(S=0,M=A.lensFlares.length;S<M;S++)if(L=A.lensFlares[S],0.0010<L.opacity&&0.0010<L.scale)C.x=L.x,C.y=L.y,C.z=L.z,H=L.size*L.scale/s,F.x=H*t,F.y=H,b.uniform3f(O.screenPosition,C.x,C.y,C.z),b.uniform2f(O.scale,F.x,F.y),b.uniform1f(O.rotation,L.rotation),b.uniform1f(O.opacity,L.opacity),b.uniform3f(O.color,L.color.r,L.color.g,L.color.b),
c.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst),c.setTexture(L.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
763
THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
764 765 766 767
c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,i){var l,p,n,o,q,m,r,s,v,u=[];o=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(l=0,p=k.__lights.length;l<p;l++)if(n=k.__lights[l],n.castShadow)if(n instanceof THREE.DirectionalLight&&n.shadowCascade)for(q=0;q<n.shadowCascadeCount;q++){var t;if(n.shadowCascadeArray[q])t=n.shadowCascadeArray[q];else{v=n;r=q;t=new THREE.DirectionalLight;t.isVirtual=
!0;t.onlyShadow=!0;t.castShadow=!0;t.shadowCameraNear=v.shadowCameraNear;t.shadowCameraFar=v.shadowCameraFar;t.shadowCameraLeft=v.shadowCameraLeft;t.shadowCameraRight=v.shadowCameraRight;t.shadowCameraBottom=v.shadowCameraBottom;t.shadowCameraTop=v.shadowCameraTop;t.shadowCameraVisible=v.shadowCameraVisible;t.shadowDarkness=v.shadowDarkness;t.shadowBias=v.shadowCascadeBias[r];t.shadowMapWidth=v.shadowCascadeWidth[r];t.shadowMapHeight=v.shadowCascadeHeight[r];t.pointsWorld=[];t.pointsFrustum=[];s=
t.pointsWorld;m=t.pointsFrustum;for(var w=0;8>w;w++)s[w]=new THREE.Vector3,m[w]=new THREE.Vector3;s=v.shadowCascadeNearZ[r];v=v.shadowCascadeFarZ[r];m[0].set(-1,-1,s);m[1].set(1,-1,s);m[2].set(-1,1,s);m[3].set(1,1,s);m[4].set(-1,-1,v);m[5].set(1,-1,v);m[6].set(-1,1,v);m[7].set(1,1,v);t.originalCamera=i;m=new THREE.Gyroscope;m.position=n.shadowCascadeOffset;m.add(t);m.add(t.target);i.add(m);n.shadowCascadeArray[q]=t;console.log("Created virtualLight",t)}r=n;s=q;v=r.shadowCascadeArray[s];v.position.copy(r.position);
v.target.position.copy(r.target.position);v.lookAt(v.target);v.shadowCameraVisible=r.shadowCameraVisible;v.shadowDarkness=r.shadowDarkness;v.shadowBias=r.shadowCascadeBias[s];m=r.shadowCascadeNearZ[s];r=r.shadowCascadeFarZ[s];v=v.pointsFrustum;v[0].z=m;v[1].z=m;v[2].z=m;v[3].z=m;v[4].z=r;v[5].z=r;v[6].z=r;v[7].z=r;u[o]=t;o++}else u[o]=n,o++;for(l=0,p=u.length;l<p;l++){n=u[l];if(!n.shadowMap)n.shadowMap=new THREE.WebGLRenderTarget(n.shadowMapWidth,n.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
768
format:THREE.RGBAFormat}),n.shadowMapSize=new THREE.Vector2(n.shadowMapWidth,n.shadowMapHeight),n.shadowMatrix=new THREE.Matrix4;if(!n.shadowCamera){if(n instanceof THREE.SpotLight)n.shadowCamera=new THREE.PerspectiveCamera(n.shadowCameraFov,n.shadowMapWidth/n.shadowMapHeight,n.shadowCameraNear,n.shadowCameraFar);else if(n instanceof THREE.DirectionalLight)n.shadowCamera=new THREE.OrthographicCamera(n.shadowCameraLeft,n.shadowCameraRight,n.shadowCameraTop,n.shadowCameraBottom,n.shadowCameraNear,n.shadowCameraFar);
769 770 771 772 773
else{console.error("Unsupported light type for shadow");continue}k.add(n.shadowCamera);b.autoUpdateScene&&k.updateMatrixWorld()}if(n.shadowCameraVisible&&!n.cameraHelper)n.cameraHelper=new THREE.CameraHelper(n.shadowCamera),n.shadowCamera.add(n.cameraHelper);if(n.isVirtual&&t.originalCamera==i){q=i;o=n.shadowCamera;m=n.pointsFrustum;v=n.pointsWorld;g.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(r=0;8>r;r++){s=v[r];s.copy(m[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(s,
q);o.matrixWorldInverse.multiplyVector3(s);if(s.x<g.x)g.x=s.x;if(s.x>h.x)h.x=s.x;if(s.y<g.y)g.y=s.y;if(s.y>h.y)h.y=s.y;if(s.z<g.z)g.z=s.z;if(s.z>h.z)h.z=s.z}o.left=g.x;o.right=h.x;o.top=h.y;o.bottom=g.y;o.updateProjectionMatrix()}o=n.shadowMap;m=n.shadowMatrix;q=n.shadowCamera;q.position.copy(n.matrixWorld.getPosition());q.lookAt(n.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(n.cameraHelper)n.cameraHelper.lines.visible=n.shadowCameraVisible;
n.shadowCameraVisible&&n.cameraHelper.update();m.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);m.multiplySelf(q.projectionMatrix);m.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);f.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(o);
b.clear();v=k.__webglObjects;for(n=0,o=v.length;n<o;n++)if(r=v[n],m=r.object,r.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||e.contains(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),r.render=!0;for(n=0,o=v.length;n<o;n++)if(r=v[n],r.render)m=r.object,r=r.buffer,b.setObjectFaces(m),s=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?d:
c,r instanceof THREE.BufferGeometry?b.renderBufferDirect(q,k.__lights,null,s,r,m):b.renderBuffer(q,k.__lights,null,s,r,m);v=k.__webglObjectsImmediate;for(n=0,o=v.length;n<o;n++)r=v[n],m=r.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),b.renderImmediateObject(q,k.__lights,null,c,m))}l=b.getClearColor();p=b.getClearAlpha();a.clearColor(l.r,l.g,l.b,p);
A
alteredq 已提交
774
a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
775 776 777 778 779 780 781
THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,f,g,h,k,i,l;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;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,n=b.createProgram(),o=b.createShader(b.FRAGMENT_SHADER),q=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,a.fragmentShader);b.shaderSource(q,a.vertexShader);b.compileShader(o);b.compileShader(q);b.attachShader(n,o);b.attachShader(n,q);b.linkProgram(n);h=n;k={};i={};k.position=b.getAttribLocation(h,"position");k.uv=b.getAttribLocation(h,"uv");i.uvOffset=b.getUniformLocation(h,"uvOffset");i.uvScale=b.getUniformLocation(h,
"uvScale");i.rotation=b.getUniformLocation(h,"rotation");i.scale=b.getUniformLocation(h,"scale");i.alignment=b.getUniformLocation(h,"alignment");i.color=b.getUniformLocation(h,"color");i.map=b.getUniformLocation(h,"map");i.opacity=b.getUniformLocation(h,"opacity");i.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");i.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");i.screenPosition=b.getUniformLocation(h,"screenPosition");i.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
i.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");l=!1};this.render=function(d,e,o,q){var d=d.__webglSprites,m=d.length;if(m){var r=k,s=i,v=q/o,o=0.5*o,u=0.5*q,t=!0;b.useProgram(h);l||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),l=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(r.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.uniformMatrix4fv(s.projectionMatrix,
!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(s.map,0);for(var w,y=[],r=0;r<m;r++)if(w=d[r],w.visible&&0!==w.opacity)w.useScreenCoordinates?w.z=-w.position.z:(w._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,w.matrixWorld,w._modelViewMatrixArray),w.z=-w._modelViewMatrix.n34);d.sort(a);for(r=0;r<m;r++)w=d[r],w.visible&&0!==w.opacity&&w.map&&w.map.image&&w.map.image.width&&(w.useScreenCoordinates?(b.uniform1i(s.useScreenCoordinates,1),b.uniform3f(s.screenPosition,(w.position.x-
o)/o,(u-w.position.y)/u,Math.max(0,Math.min(1,w.position.z)))):(b.uniform1i(s.useScreenCoordinates,0),b.uniform1i(s.affectedByDistance,w.affectedByDistance?1:0),b.uniformMatrix4fv(s.modelViewMatrix,!1,w._modelViewMatrixArray)),e=w.map.image.width/(w.scaleByViewport?q:1),y[0]=e*v*w.scale.x,y[1]=e*w.scale.y,b.uniform2f(s.uvScale,w.uvScale.x,w.uvScale.y),b.uniform2f(s.uvOffset,w.uvOffset.x,w.uvOffset.y),b.uniform2f(s.alignment,w.alignment.x,w.alignment.y),b.uniform1f(s.opacity,w.opacity),b.uniform3f(s.color,
w.color.r,w.color.g,w.color.b),b.uniform1f(s.rotation,w.rotation),b.uniform2fv(s.scale,y),w.mergeWith3D&&!t?(b.enable(b.DEPTH_TEST),t=!0):!w.mergeWith3D&&t&&(b.disable(b.DEPTH_TEST),t=!1),c.setBlending(w.blending,w.blendEquation,w.blendSrc,w.blendDst),c.setTexture(w.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
782
THREE.DepthPassPlugin=function(){this.enabled=!1;this.renderTarget=null;var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
783 784 785 786 787
b){this.enabled&&this.update(a,b)};this.update=function(g,h){var k,i,l,p,n,o;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.setDepthTest(!0);b.autoUpdateScene&&g.updateMatrixWorld();if(!h._viewMatrixArray)h._viewMatrixArray=new Float32Array(16);if(!h._projectionMatrixArray)h._projectionMatrixArray=new Float32Array(16);h.matrixWorldInverse.getInverse(h.matrixWorld);h.matrixWorldInverse.flattenToArray(h._viewMatrixArray);h.projectionMatrix.flattenToArray(h._projectionMatrixArray);f.multiply(h.projectionMatrix,
h.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(this.renderTarget);b.clear();o=g.__webglObjects;for(k=0,i=o.length;k<i;k++)if(l=o[k],n=l.object,l.render=!1,n.visible&&(!(n instanceof THREE.Mesh)||!n.frustumCulled||e.contains(n)))n.matrixWorld.flattenToArray(n._objectMatrixArray),n._modelViewMatrix.multiplyToArray(h.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray),l.render=!0;for(k=0,i=o.length;k<i;k++)if(l=o[k],l.render)n=l.object,l=l.buffer,b.setObjectFaces(n),p=n.customDepthMaterial?
n.customDepthMaterial:n.geometry.morphTargets.length?d:c,l instanceof THREE.BufferGeometry?b.renderBufferDirect(h,g.__lights,null,p,l,n):b.renderBuffer(h,g.__lights,null,p,l,n);o=g.__webglObjectsImmediate;for(k=0,i=o.length;k<i;k++)l=o[k],n=l.object,n.visible&&n.castShadow&&(n.matrixAutoUpdate&&n.matrixWorld.flattenToArray(n._objectMatrixArray),n._modelViewMatrix.multiplyToArray(h.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray),b.renderImmediateObject(h,g.__lights,null,c,n));k=b.getClearColor();
i=b.getClearAlpha();a.clearColor(k.r,k.g,k.b,i);a.enable(a.BLEND)}};
if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,g=new THREE.Matrix4,h=new THREE.Matrix4,k,i,l,p;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),q=new THREE.PerspectiveCamera(53,
788
1,1,1E4);q.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:n},mapRight:{type:"t",value:1,texture:o}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}),
789 790
m=new THREE.Scene,a=new THREE.Mesh(new THREE.PlaneGeometry(2,2),a);a.rotation.x=Math.PI/2;m.add(a);m.add(q);this.setSize=function(a,d){c.call(b,a,d);n.width=a;n.height=d;o.width=a;o.height=d};this.render=function(a,c){a.updateMatrixWorld();if(k!==c.aspect||i!==c.near||l!==c.far||p!==c.fov){k=c.aspect;i=c.near;l=c.far;p=c.fov;var v=c.projectionMatrix.clone(),u=0.5*(125/30),t=u*i/125,w=i*Math.tan(p*Math.PI/360),y;g.n14=u;h.n14=-u;u=-w*k+t;y=w*k+t;v.n11=2*i/(y-u);v.n13=(y+u)/(y-u);e.projectionMatrix.copy(v);
u=-w*k-t;y=w*k-t;v.n11=2*i/(y-u);v.n13=(y+u)/(y-u);f.projectionMatrix.copy(v)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,n,!0);f.matrixWorld.copy(c.matrixWorld).multiplySelf(g);f.position.copy(c.position);f.near=c.near;f.far=c.far;d.call(b,a,f,o,!0);m.updateMatrixWorld();d.call(b,m,q)}};
791 792
if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,d=this.render,e,f,g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&void 0!==a.separation)b.separation=a.separation;this.setSize=function(a,d){c.call(b,a,d);e=a/2;f=d};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=
c.far;g.updateProjectionMatrix();g.position.copy(c.position);g.target.copy(c.target);g.translateX(b.separation);g.lookAt(g.target);h.projectionMatrix=g.projectionMatrix;h.position.copy(c.position);h.target.copy(c.target);h.translateX(-b.separation);h.lookAt(h.target);this.setViewport(0,0,e,f);d.call(b,a,g);this.setViewport(e,0,e,f);d.call(b,a,h,!1)}};
A
alteredq 已提交
793 794
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 已提交
795
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 已提交
796
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}"}};