|
@@ -11,7 +11,7 @@ distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return
|
|
|
THREE.Vector4.prototype={set:function(a,b,f,c){this.x=a;this.y=b;this.z=f;this.w=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.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){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},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},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,f,c=a.objects,d=[];a=0;for(b=c.length;a<b;a++){f=c[a];if(f instanceof THREE.Mesh)d=d.concat(this.intersectObject(f))}d.sort(function(j,n){return j.distance-n.distance});return d},intersectObject:function(a){function b(x,h,A,q){q=q.clone().subSelf(h);A=A.clone().subSelf(h);var C=x.clone().subSelf(h);x=q.dot(q);h=q.dot(A);q=q.dot(C);var u=A.dot(A);A=A.dot(C);C=1/(x*u-h*h);u=(u*q-h*A)*C;x=(x*A-h*q)*C;return u>0&&x>0&&u+x<1}var f,c,d,j,n,t,e,g,l,i,
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var b,f,c=a.objects,d=[];a=0;for(b=c.length;a<b;a++){f=c[a];if(f instanceof THREE.Mesh)d=d.concat(this.intersectObject(f))}d.sort(function(j,n){return j.distance-n.distance});return d},intersectObject:function(a){function b(x,h,B,q){q=q.clone().subSelf(h);B=B.clone().subSelf(h);var D=x.clone().subSelf(h);x=q.dot(q);h=q.dot(B);q=q.dot(D);var u=B.dot(B);B=B.dot(D);D=1/(x*u-h*h);u=(u*q-h*B)*D;x=(x*B-h*q)*D;return u>0&&x>0&&u+x<1}var f,c,d,j,n,t,e,g,l,i,
|
|
|
m,r=a.geometry,o=r.vertices,p=[];f=0;for(c=r.faces.length;f<c;f++){d=r.faces[f];i=this.origin.clone();m=this.direction.clone();j=a.matrix.transform(o[d.a].position.clone());n=a.matrix.transform(o[d.b].position.clone());t=a.matrix.transform(o[d.c].position.clone());e=d instanceof THREE.Face4?a.matrix.transform(o[d.d].position.clone()):null;g=a.matrixRotation.transform(d.normal.clone());l=m.dot(g);if(l<0){g=g.dot((new THREE.Vector3).sub(j,i))/l;i=i.addSelf(m.multiplyScalar(g));if(d instanceof THREE.Face3){if(b(i,
|
|
|
j,n,t)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}else if(d instanceof THREE.Face4)if(b(i,j,n,e)||b(i,n,t,e)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}}return p}};
|
|
|
THREE.Rectangle=function(){function a(){j=c-b;n=d-f}var b,f,c,d,j,n,t=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return n};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return c};this.getBottom=function(){return d};this.set=function(e,g,l,i){t=false;b=e;f=g;c=l;d=i;a()};this.addPoint=function(e,g){if(t){t=false;b=e;f=g;c=e;d=g}else{b=Math.min(b,e);f=Math.min(f,g);c=Math.max(c,
|
|
@@ -71,49 +71,49 @@ THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);thi
|
|
|
this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b){this.image=a;this.mapping=b?b:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;
|
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
-THREE.Projector=function(){function a(h,A){var q;q=0;var C=1,u=h.z+h.w,K=A.z+A.w,v=-h.z+h.w,s=-A.z+A.w;if(u>=0&&K>=0&&v>=0&&s>=0)q=true;else if(u<0&&K<0||v<0&&s<0)q=false;else{if(u<0)q=Math.max(q,u/(u-K));else if(K<0)C=Math.min(C,u/(u-K));if(v<0)q=Math.max(q,v/(v-s));else if(s<0)C=Math.min(C,v/(v-s));if(C<q)q=false;else{h.lerpSelf(A,q);A.lerpSelf(h,1-C);q=true}}return q}var b=null,f,c,d=[],j,n,t=[],e,g,l=[],i,m,r=[],o=new THREE.Vector4,p=new THREE.Matrix4,x=new THREE.Matrix4;this.projectScene=function(h,
|
|
|
-A){var q,C,u,K,v,s,y,L,X,F,R,V,S,B;b=[];m=g=n=c=0;A.autoUpdateMatrix&&A.updateMatrix();p.multiply(A.projectionMatrix,A.matrix);v=h.objects;q=0;for(C=v.length;q<C;q++){s=v[q];y=s.matrix;s.autoUpdateMatrix&&s.updateMatrix();if(s instanceof THREE.Mesh){x.multiply(p,y);L=s.geometry.vertices;u=0;for(K=L.length;u<K;u++){X=L[u];F=X.positionScreen;F.copy(X.position);x.transform(F);F.multiplyScalar(1/F.w);X.__visible=F.z>0&&F.z<1}X=s.geometry.faces;u=0;for(K=X.length;u<K;u++){F=X[u];if(F instanceof THREE.Face3){R=
|
|
|
-L[F.a];V=L[F.b];S=L[F.c];if(R.__visible&&V.__visible&&S.__visible)if(s.doubleSided||s.flipSided!=(S.positionScreen.x-R.positionScreen.x)*(V.positionScreen.y-R.positionScreen.y)-(S.positionScreen.y-R.positionScreen.y)*(V.positionScreen.x-R.positionScreen.x)<0){f=d[c]=d[c]||new THREE.RenderableFace3;f.v1.positionScreen.copy(R.positionScreen);f.v2.positionScreen.copy(V.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(F.normal);s.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(F.centroid);
|
|
|
-y.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);p.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=s.material;f.faceMaterial=F.material;f.overdraw=s.overdraw;f.uvs=s.geometry.uvs[u];f.color=F.color;b.push(f);c++}}else if(F instanceof THREE.Face4){R=L[F.a];V=L[F.b];S=L[F.c];B=L[F.d];if(R.__visible&&V.__visible&&S.__visible&&B.__visible)if(s.doubleSided||s.flipSided!=((B.positionScreen.x-R.positionScreen.x)*(V.positionScreen.y-R.positionScreen.y)-(B.positionScreen.y-
|
|
|
-R.positionScreen.y)*(V.positionScreen.x-R.positionScreen.x)<0||(V.positionScreen.x-S.positionScreen.x)*(B.positionScreen.y-S.positionScreen.y)-(V.positionScreen.y-S.positionScreen.y)*(B.positionScreen.x-S.positionScreen.x)<0)){j=t[n]=t[n]||new THREE.RenderableFace4;j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(V.positionScreen);j.v3.positionScreen.copy(S.positionScreen);j.v4.positionScreen.copy(B.positionScreen);j.normalWorld.copy(F.normal);s.matrixRotation.transform(j.normalWorld);
|
|
|
-j.centroidWorld.copy(F.centroid);y.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=s.material;j.faceMaterial=F.material;j.overdraw=s.overdraw;j.uvs=s.geometry.uvs[u];j.color=F.color;b.push(j);n++}}}}else if(s instanceof THREE.Line){x.multiply(p,y);L=s.geometry.vertices;u=0;for(K=L.length;u<K;u++){X=L[u];X.positionScreen.copy(X.position);x.transform(X.positionScreen)}u=1;for(K=L.length;u<K;u++){y=L[u];X=L[u-1];if(a(y.positionScreen,
|
|
|
-X.positionScreen)){y.positionScreen.multiplyScalar(1/y.positionScreen.w);X.positionScreen.multiplyScalar(1/X.positionScreen.w);e=l[g]=l[g]||new THREE.RenderableLine;e.v1.positionScreen.copy(y.positionScreen);e.v2.positionScreen.copy(X.positionScreen);e.z=Math.max(y.positionScreen.z,X.positionScreen.z);e.material=s.material;b.push(e);g++}}}else if(s instanceof THREE.Particle){o.set(s.position.x,s.position.y,s.position.z,1);p.transform(o);o.z/=o.w;if(o.z>0&&o.z<1){i=r[m]=r[m]||new THREE.RenderableParticle;
|
|
|
-i.x=o.x/o.w;i.y=o.y/o.w;i.z=o.z;i.rotation=s.rotation.z;i.scale.x=s.scale.x*Math.abs(i.x-(o.x+A.projectionMatrix.n11)/(o.w+A.projectionMatrix.n14));i.scale.y=s.scale.y*Math.abs(i.y-(o.y+A.projectionMatrix.n22)/(o.w+A.projectionMatrix.n24));i.material=s.material;b.push(i);m++}}}b.sort(function(W,N){return N.z-W.z});return b};this.unprojectVector=function(h,A){var q=new THREE.Matrix4;q.multiply(THREE.Matrix4.makeInvert(A.matrix),THREE.Matrix4.makeInvert(A.projectionMatrix));q.transform(h);return h}};
|
|
|
+THREE.Projector=function(){function a(h,B){var q;q=0;var D=1,u=h.z+h.w,L=B.z+B.w,v=-h.z+h.w,s=-B.z+B.w;if(u>=0&&L>=0&&v>=0&&s>=0)q=true;else if(u<0&&L<0||v<0&&s<0)q=false;else{if(u<0)q=Math.max(q,u/(u-L));else if(L<0)D=Math.min(D,u/(u-L));if(v<0)q=Math.max(q,v/(v-s));else if(s<0)D=Math.min(D,v/(v-s));if(D<q)q=false;else{h.lerpSelf(B,q);B.lerpSelf(h,1-D);q=true}}return q}var b=null,f,c,d=[],j,n,t=[],e,g,l=[],i,m,r=[],o=new THREE.Vector4,p=new THREE.Matrix4,x=new THREE.Matrix4;this.projectScene=function(h,
|
|
|
+B){var q,D,u,L,v,s,y,M,X,F,Y=new THREE.Vector4,Z=new THREE.Vector4,Q,z,N,K;b=[];m=g=n=c=0;B.autoUpdateMatrix&&B.updateMatrix();p.multiply(B.projectionMatrix,B.matrix);v=h.objects;q=0;for(D=v.length;q<D;q++){s=v[q];y=s.matrix;s.autoUpdateMatrix&&s.updateMatrix();if(s instanceof THREE.Mesh){x.multiply(p,y);M=s.geometry.vertices;u=0;for(L=M.length;u<L;u++){X=M[u];F=X.positionScreen;F.copy(X.position);x.transform(F);F.multiplyScalar(1/F.w);X.__visible=F.z>0&&F.z<1}X=s.geometry.faces;u=0;for(L=X.length;u<
|
|
|
+L;u++){F=X[u];if(F instanceof THREE.Face3){Q=M[F.a];z=M[F.b];N=M[F.c];if(Q.__visible&&z.__visible&&N.__visible)if(s.doubleSided||s.flipSided!=(N.positionScreen.x-Q.positionScreen.x)*(z.positionScreen.y-Q.positionScreen.y)-(N.positionScreen.y-Q.positionScreen.y)*(z.positionScreen.x-Q.positionScreen.x)<0){f=d[c]=d[c]||new THREE.RenderableFace3;f.v1.positionScreen.copy(Q.positionScreen);f.v2.positionScreen.copy(z.positionScreen);f.v3.positionScreen.copy(N.positionScreen);f.normalWorld.copy(F.normal);
|
|
|
+s.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(F.centroid);y.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);p.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=s.material;f.faceMaterial=F.material;f.overdraw=s.overdraw;f.uvs=s.geometry.uvs[u];f.color=F.color;b.push(f);c++}}else if(F instanceof THREE.Face4){Q=M[F.a];z=M[F.b];N=M[F.c];K=M[F.d];if(Q.__visible&&z.__visible&&N.__visible&&K.__visible)if(s.doubleSided||s.flipSided!=((K.positionScreen.x-
|
|
|
+Q.positionScreen.x)*(z.positionScreen.y-Q.positionScreen.y)-(K.positionScreen.y-Q.positionScreen.y)*(z.positionScreen.x-Q.positionScreen.x)<0||(z.positionScreen.x-N.positionScreen.x)*(K.positionScreen.y-N.positionScreen.y)-(z.positionScreen.y-N.positionScreen.y)*(K.positionScreen.x-N.positionScreen.x)<0)){j=t[n]=t[n]||new THREE.RenderableFace4;j.v1.positionScreen.copy(Q.positionScreen);j.v2.positionScreen.copy(z.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.v4.positionScreen.copy(K.positionScreen);
|
|
|
+j.normalWorld.copy(F.normal);s.matrixRotation.transform(j.normalWorld);j.centroidWorld.copy(F.centroid);y.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=s.material;j.faceMaterial=F.material;j.overdraw=s.overdraw;j.uvs=s.geometry.uvs[u];j.color=F.color;b.push(j);n++}}}}else if(s instanceof THREE.Line){x.multiply(p,y);M=s.geometry.vertices;u=0;for(L=M.length;u<L;u++){X=M[u];X.positionScreen.copy(X.position);x.transform(X.positionScreen)}u=
|
|
|
+1;for(L=M.length;u<L;u++){y=M[u];X=M[u-1];Y.copy(y.positionScreen);Z.copy(X.positionScreen);if(a(Y,Z)){Y.multiplyScalar(1/Y.w);Z.multiplyScalar(1/Z.w);e=l[g]=l[g]||new THREE.RenderableLine;e.v1.positionScreen.copy(Y);e.v2.positionScreen.copy(Z);e.z=Math.max(Y.z,Z.z);e.material=s.material;b.push(e);g++}}}else if(s instanceof THREE.Particle){o.set(s.position.x,s.position.y,s.position.z,1);p.transform(o);o.z/=o.w;if(o.z>0&&o.z<1){i=r[m]=r[m]||new THREE.RenderableParticle;i.x=o.x/o.w;i.y=o.y/o.w;i.z=
|
|
|
+o.z;i.rotation=s.rotation.z;i.scale.x=s.scale.x*Math.abs(i.x-(o.x+B.projectionMatrix.n11)/(o.w+B.projectionMatrix.n14));i.scale.y=s.scale.y*Math.abs(i.y-(o.y+B.projectionMatrix.n22)/(o.w+B.projectionMatrix.n24));i.material=s.material;b.push(i);m++}}}b.sort(function(V,C){return C.z-V.z});return b};this.unprojectVector=function(h,B){var q=new THREE.Matrix4;q.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));q.transform(h);return h}};
|
|
|
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,c,d,j;this.domElement=document.createElement("div");this.setSize=function(n,t){f=n;c=t;d=f/2;j=c/2};this.render=function(n,t){var e,g,l,i,m,r,o,p;a=b.projectScene(n,t);e=0;for(g=a.length;e<g;e++){m=a[e];if(m instanceof THREE.RenderableParticle){o=m.x*d+d;p=m.y*j+j;l=0;for(i=m.material.length;l<i;l++){r=m.material[l];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=o+"px";r.style.top=p+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(G,M,I){var J,k,H;lights=G.lights;G=0;for(J=lights.length;G<J;G++){k=lights[G];H=k.color;if(k instanceof THREE.DirectionalLight){k=M.normalWorld.dot(k.position)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}else if(k instanceof THREE.PointLight){Ha.sub(k.position,M.centroidWorld);Ha.normalize();k=M.normalWorld.dot(Ha)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}}}function b(G,M,I,J,k,H){R=G.positionScreen.x;V=G.positionScreen.y;S=M.positionScreen.x;
|
|
|
-B=M.positionScreen.y;W=I.positionScreen.x;N=I.positionScreen.y;if(k.opacity!=A)h.globalAlpha=A=k.opacity;k.blending!=q&&n(k.blending);if(k.map){fa=k.map.image;qa=fa.width-1;ra=fa.height-1;da.u=J.uvs[0].u*qa;da.v=J.uvs[0].v*ra;$.u=J.uvs[1].u*qa;$.v=J.uvs[1].v*ra;ea.u=J.uvs[2].u*qa;ea.v=J.uvs[2].v*ra;j(fa,R,V,S,B,W,N,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshBasicMaterial)c(R,V,S,B,W,N,k.color,k.wireframe,k.wireframe_linewidth);else if(k instanceof THREE.MeshLambertMaterial){if(Da){ba.r=
|
|
|
-ga.r;ba.g=ga.g;ba.b=ga.b;a(H,J,ba);P.r=k.color.r*ba.r;P.g=k.color.g*ba.g;P.b=k.color.b*ba.b;P.updateStyleString()}else P.__styleString=k.color.__styleString;c(R,V,S,B,W,N,P,k.wireframe,k.wireframe_linewidth)}else if(k instanceof THREE.MeshDepthMaterial){sa=k.__2near;ta=k.__farPlusNear;ua=k.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-M.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[na,na,na],[na,na,na]);da.u=0;da.v=0;
|
|
|
-$.u=la;$.v=0;ea.u=0;ea.v=la;j(fa,R,V,S,B,W,N,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshNormalMaterial){P.r=e(J.normalWorld.x);P.g=e(J.normalWorld.y);P.b=e(J.normalWorld.z);P.updateStyleString();c(R,V,S,B,W,N,P,k.wireframe,k.wireframe_linewidth)}}function f(G,M,I,J,k,H,Q,w,T){R=G.positionScreen.x;V=G.positionScreen.y;S=M.positionScreen.x;B=M.positionScreen.y;W=I.positionScreen.x;N=I.positionScreen.y;Z=J.positionScreen.x;E=J.positionScreen.y;z=k.positionScreen.x;Y=k.positionScreen.y;
|
|
|
-pa=H.positionScreen.x;O=H.positionScreen.y;if(w.opacity!=A)h.globalAlpha=A=w.opacity;w.blending!=q&&n(w.blending);if(w.map){fa=w.map.image;qa=fa.width-1;ra=fa.height-1;da.copy(Q.uvs[0]);$.copy(Q.uvs[1]);ea.copy(Q.uvs[2]);ia.copy(Q.uvs[3]);da.u*=qa;da.v*=ra;$.u*=qa;$.v*=ra;ea.u*=qa;ea.v*=ra;ia.u*=qa;ia.v*=ra;j(fa,R,V,S,B,Z,E,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,z,Y,W,N,pa,O,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshBasicMaterial)d(R,V,S,B,W,N,Z,E,w.color,w.wireframe,w.wireframe_linewidth);
|
|
|
-else if(w instanceof THREE.MeshLambertMaterial){if(Da){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(T,Q,ba);P.r=w.color.r*ba.r;P.g=w.color.g*ba.g;P.b=w.color.b*ba.b;P.updateStyleString()}else P.__styleString=w.color.__styleString;d(R,V,S,B,W,N,Z,E,P,w.wireframe,w.wireframe_linewidth)}else if(w instanceof THREE.MeshDepthMaterial){sa=w.__2near;ta=w.__farPlusNear;ua=w.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-M.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255);
|
|
|
-Ea=~~((1-sa/(ta-J.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[Ea,Ea,Ea],[na,na,na]);da.u=0;da.v=0;$.u=la;$.v=0;ea.u=la;ea.v=la;ia.u=0;ia.v=la;j(fa,R,V,S,B,Z,E,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,z,Y,W,N,pa,O,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshNormalMaterial){P.r=e(Q.normalWorld.x);P.g=e(Q.normalWorld.y);P.b=e(Q.normalWorld.z);P.updateStyleString();d(R,V,S,B,W,N,Z,E,P,w.wireframe,w.wireframe_linewidth)}}function c(G,M,I,J,k,H,Q,w,T){h.beginPath();h.moveTo(G,M);h.lineTo(I,
|
|
|
-J);h.lineTo(k,H);h.lineTo(G,M);h.closePath();if(w){if(K!=T)h.lineWidth=K=T;if(C!=Q.__styleString)h.strokeStyle=C=Q.__styleString;h.stroke();aa.inflate(T*2)}else{if(u!=Q.__styleString)h.fillStyle=u=Q.__styleString;h.fill()}}function d(G,M,I,J,k,H,Q,w,T,D,ca){h.beginPath();h.moveTo(G,M);h.lineTo(I,J);h.lineTo(k,H);h.lineTo(Q,w);h.lineTo(G,M);h.closePath();if(D){if(K!=ca)h.lineWidth=K=ca;if(C!=T.__styleString)h.strokeStyle=C=T.__styleString;h.stroke();aa.inflate(ca*2)}else{if(u!=T.__styleString)h.fillStyle=
|
|
|
-u=T.__styleString;h.fill()}}function j(G,M,I,J,k,H,Q,w,T,D,ca,ma,va){h.beginPath();h.moveTo(M,I);h.lineTo(J,k);h.lineTo(H,Q);h.closePath();J-=M;k-=I;H-=M;Q-=I;D-=w;ca-=T;ma-=w;va-=T;var wa=1/(D*va-ma*ca),za=(va*J-ca*H)*wa;ca=(va*k-ca*Q)*wa;J=(D*H-ma*J)*wa;k=(D*Q-ma*k)*wa;M=M-za*w-J*T;I=I-ca*w-k*T;h.save();h.transform(za,ca,J,k,M,I);h.clip();h.drawImage(G,0,0);h.restore()}function n(G){switch(G){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation=
|
|
|
-"lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}q=G}function t(G,M,I,J){ja[0]=G[0];ja[1]=G[1];ja[2]=G[2];ja[4]=M[0];ja[5]=M[1];ja[6]=M[2];ja[8]=I[0];ja[9]=I[1];ja[10]=I[2];ja[12]=J[0];ja[13]=J[1];ja[14]=J[2];Aa.putImageData(Ia,0,0);Fa.drawImage(Ba,0,0);return Ca}function e(G){return G<0?Math.min((1+G)*0.5,0.5):0.5+Math.min(G*0.5,0.5)}function g(G,M){var I=M.x-G.x,J=M.y-G.y,k=1/Math.sqrt(I*I+J*J);I*=k;J*=k;M.x+=I;M.y+=J;G.x-=I;G.y-=J}var l=null,i=new THREE.Projector,
|
|
|
-m=document.createElement("canvas"),r,o,p,x,h=m.getContext("2d"),A=1,q=0,C=null,u=null,K=1,v,s,y,L,X=new THREE.Vertex,F=new THREE.Vertex,R,V,S,B,W,N,Z,E,z,Y,pa,O,U,ha,na,Ea,sa,ta,ua,fa,qa,ra,oa=new THREE.Rectangle,ka=new THREE.Rectangle,aa=new THREE.Rectangle,Da=false,P=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),xa=new THREE.Color(4278190080),ya=new THREE.Color(4278190080),Ma=Math.PI*2,Ha=new THREE.Vector3,da=new THREE.UV,$=new THREE.UV,ea=new THREE.UV,
|
|
|
-ia=new THREE.UV,Ba,Aa,Ia,ja,Ca,Fa,la=16;Ba=document.createElement("canvas");Ba.width=Ba.height=2;Aa=Ba.getContext("2d");Aa.fillStyle="rgba(0,0,0,1)";Aa.fillRect(0,0,2,2);Ia=Aa.getImageData(0,0,2,2);ja=Ia.data;Ca=document.createElement("canvas");Ca.width=Ca.height=la;Fa=Ca.getContext("2d");Fa.translate(-la/2,-la/2);Fa.scale(la,la);la--;this.domElement=m;this.autoClear=true;this.setSize=function(G,M){r=G;o=M;p=r/2;x=o/2;m.width=r;m.height=o;h.lineJoin="round";h.lineCap="round";oa.set(-p,-x,p,x)};this.clear=
|
|
|
-function(){if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(oa);h.setTransform(1,0,0,-1,p,x);h.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());ka.empty()}};this.render=function(G,M){var I,J,k,H,Q,w,T,D;this.autoClear&&this.clear();l=i.projectScene(G,M);h.setTransform(1,0,0,-1,p,x);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(oa.getX(),oa.getY(),oa.getWidth(),oa.getHeight());if(Da=G.lights.length>0){Q=G.lights;ga.setRGB(0,0,0);xa.setRGB(0,0,0);ya.setRGB(0,0,0);I=0;for(J=Q.length;I<J;I++){k=
|
|
|
-Q[I];H=k.color;if(k instanceof THREE.AmbientLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(k instanceof THREE.DirectionalLight){xa.r+=H.r;xa.g+=H.g;xa.b+=H.b}else if(k instanceof THREE.PointLight){ya.r+=H.r;ya.g+=H.g;ya.b+=H.b}}}I=0;for(J=l.length;I<J;I++){k=l[I];aa.empty();if(k instanceof THREE.RenderableParticle){v=k;v.x*=p;v.y*=x;H=0;for(Q=k.material.length;H<Q;H++)if(D=k.material[H]){w=v;T=k;D=D;var ca=void 0,ma=void 0,va=void 0,wa=void 0,za=void 0,Ja=void 0,Ga=void 0,Ka=void 0,La=void 0;if(D.opacity!=
|
|
|
-A)h.globalAlpha=A=D.opacity;D.blending!=q&&n(D.blending);if(D instanceof THREE.ParticleBasicMaterial){Ga=D.bitmap;Ka=Ga.width/2;La=Ga.height/2;va=T.scale.x*p;wa=T.scale.y*x;ca=va*Ka;ma=wa*La;za=D.offset.x*va;Ja=D.offset.y*wa;aa.set(w.x+za-ca,w.y+Ja-ma,w.x+za+ca,w.y+Ja+ma);if(oa.instersects(aa)){h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);h.scale(va,-wa);h.translate(-Ka+D.offset.x,-La-D.offset.y);h.drawImage(Ga,0,0);h.restore();h.beginPath();h.moveTo(w.x-10,w.y);h.lineTo(w.x+10,w.y);h.moveTo(w.x,
|
|
|
-w.y-10);h.lineTo(w.x,w.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}}else if(D instanceof THREE.ParticleCircleMaterial){if(Da){ba.r=ga.r+xa.r+ya.r;ba.g=ga.g+xa.g+ya.g;ba.b=ga.b+xa.b+ya.b;P.r=D.color.r*ba.r;P.g=D.color.g*ba.g;P.b=D.color.b*ba.b;P.updateStyleString()}else P.__styleString=D.color.__styleString;ca=T.scale.x*p;ma=T.scale.y*x;aa.set(w.x-ca,w.y-ma,w.x+ca,w.y+ma);if(oa.instersects(aa)){if(u!==P.__styleString)h.fillStyle=u=P.__styleString;h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);
|
|
|
-h.scale(ca,ma);h.beginPath();h.arc(0,0,1,0,Ma,true);h.closePath();h.fill();h.restore()}}}}else if(k instanceof THREE.RenderableLine){v=k.v1;s=k.v2;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(Q=k.material.length;H<Q;)if(D=k.material[H++]){w=v;T=s;D=D;if(D.opacity!=A)h.globalAlpha=A=D.opacity;D.blending!=q&&n(D.blending);
|
|
|
-h.beginPath();h.moveTo(w.positionScreen.x,w.positionScreen.y);h.lineTo(T.positionScreen.x,T.positionScreen.y);h.closePath();if(D instanceof THREE.LineBasicMaterial){P.__styleString=D.color.__styleString;if(K!=D.linewidth)h.lineWidth=K=D.linewidth;if(C!=P.__styleString)h.strokeStyle=C=P.__styleString;h.stroke();aa.inflate(D.linewidth*2)}}}else if(k instanceof THREE.RenderableFace3){v=k.v1;s=k.v2;y=k.v3;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=
|
|
|
-p;y.positionScreen.y*=x;if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,y.positionScreen);g(y.positionScreen,v.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(Q=k.meshMaterial.length;H<Q;){D=k.meshMaterial[H++];if(D instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(D=k.faceMaterial[w++])&&b(v,
|
|
|
-s,y,k,D,G)}else D&&b(v,s,y,k,D,G)}}else if(k instanceof THREE.RenderableFace4){v=k.v1;s=k.v2;y=k.v3;L=k.v4;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=p;y.positionScreen.y*=x;L.positionScreen.x*=p;L.positionScreen.y*=x;X.positionScreen.copy(s.positionScreen);F.positionScreen.copy(L.positionScreen);if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,L.positionScreen);g(L.positionScreen,v.positionScreen)}if(k.overdraw){g(y.positionScreen,
|
|
|
-X.positionScreen);g(y.positionScreen,F.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);aa.addPoint(L.positionScreen.x,L.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(Q=k.meshMaterial.length;H<Q;){D=k.meshMaterial[H++];if(D instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(D=k.faceMaterial[w++])&&f(v,s,y,L,X,F,k,D,G)}else D&&f(v,s,y,L,X,F,k,D,G)}}ka.addRectangle(aa)}h.lineWidth=
|
|
|
+THREE.CanvasRenderer=function(){function a(G,O,I){var J,k,H;lights=G.lights;G=0;for(J=lights.length;G<J;G++){k=lights[G];H=k.color;if(k instanceof THREE.DirectionalLight){k=O.normalWorld.dot(k.position)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}else if(k instanceof THREE.PointLight){Ha.sub(k.position,O.centroidWorld);Ha.normalize();k=O.normalWorld.dot(Ha)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}}}function b(G,O,I,J,k,H){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x;
|
|
|
+z=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;if(k.opacity!=B)h.globalAlpha=B=k.opacity;k.blending!=q&&n(k.blending);if(k.map){fa=k.map.image;qa=fa.width-1;ra=fa.height-1;da.u=J.uvs[0].u*qa;da.v=J.uvs[0].v*ra;$.u=J.uvs[1].u*qa;$.v=J.uvs[1].v*ra;ea.u=J.uvs[2].u*qa;ea.v=J.uvs[2].v*ra;j(fa,Y,Z,Q,z,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshBasicMaterial)c(Y,Z,Q,z,N,K,k.color,k.wireframe,k.wireframe_linewidth);else if(k instanceof THREE.MeshLambertMaterial){if(Da){ba.r=
|
|
|
+ga.r;ba.g=ga.g;ba.b=ga.b;a(H,J,ba);R.r=k.color.r*ba.r;R.g=k.color.g*ba.g;R.b=k.color.b*ba.b;R.updateStyleString()}else R.__styleString=k.color.__styleString;c(Y,Z,Q,z,N,K,R,k.wireframe,k.wireframe_linewidth)}else if(k instanceof THREE.MeshDepthMaterial){sa=k.__2near;ta=k.__farPlusNear;ua=k.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-O.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[na,na,na],[na,na,na]);da.u=0;da.v=0;
|
|
|
+$.u=la;$.v=0;ea.u=0;ea.v=la;j(fa,Y,Z,Q,z,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshNormalMaterial){R.r=e(J.normalWorld.x);R.g=e(J.normalWorld.y);R.b=e(J.normalWorld.z);R.updateStyleString();c(Y,Z,Q,z,N,K,R,k.wireframe,k.wireframe_linewidth)}}function f(G,O,I,J,k,H,S,w,T){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x;z=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;V=J.positionScreen.x;C=J.positionScreen.y;A=k.positionScreen.x;W=k.positionScreen.y;
|
|
|
+pa=H.positionScreen.x;P=H.positionScreen.y;if(w.opacity!=B)h.globalAlpha=B=w.opacity;w.blending!=q&&n(w.blending);if(w.map){fa=w.map.image;qa=fa.width-1;ra=fa.height-1;da.copy(S.uvs[0]);$.copy(S.uvs[1]);ea.copy(S.uvs[2]);ia.copy(S.uvs[3]);da.u*=qa;da.v*=ra;$.u*=qa;$.v*=ra;ea.u*=qa;ea.v*=ra;ia.u*=qa;ia.v*=ra;j(fa,Y,Z,Q,z,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,pa,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshBasicMaterial)d(Y,Z,Q,z,N,K,V,C,w.color,w.wireframe,w.wireframe_linewidth);
|
|
|
+else if(w instanceof THREE.MeshLambertMaterial){if(Da){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(T,S,ba);R.r=w.color.r*ba.r;R.g=w.color.g*ba.g;R.b=w.color.b*ba.b;R.updateStyleString()}else R.__styleString=w.color.__styleString;d(Y,Z,Q,z,N,K,V,C,R,w.wireframe,w.wireframe_linewidth)}else if(w instanceof THREE.MeshDepthMaterial){sa=w.__2near;ta=w.__farPlusNear;ua=w.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-O.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255);
|
|
|
+Ea=~~((1-sa/(ta-J.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[Ea,Ea,Ea],[na,na,na]);da.u=0;da.v=0;$.u=la;$.v=0;ea.u=la;ea.v=la;ia.u=0;ia.v=la;j(fa,Y,Z,Q,z,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,pa,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshNormalMaterial){R.r=e(S.normalWorld.x);R.g=e(S.normalWorld.y);R.b=e(S.normalWorld.z);R.updateStyleString();d(Y,Z,Q,z,N,K,V,C,R,w.wireframe,w.wireframe_linewidth)}}function c(G,O,I,J,k,H,S,w,T){h.beginPath();h.moveTo(G,O);h.lineTo(I,
|
|
|
+J);h.lineTo(k,H);h.lineTo(G,O);h.closePath();if(w){if(L!=T)h.lineWidth=L=T;if(D!=S.__styleString)h.strokeStyle=D=S.__styleString;h.stroke();aa.inflate(T*2)}else{if(u!=S.__styleString)h.fillStyle=u=S.__styleString;h.fill()}}function d(G,O,I,J,k,H,S,w,T,E,ca){h.beginPath();h.moveTo(G,O);h.lineTo(I,J);h.lineTo(k,H);h.lineTo(S,w);h.lineTo(G,O);h.closePath();if(E){if(L!=ca)h.lineWidth=L=ca;if(D!=T.__styleString)h.strokeStyle=D=T.__styleString;h.stroke();aa.inflate(ca*2)}else{if(u!=T.__styleString)h.fillStyle=
|
|
|
+u=T.__styleString;h.fill()}}function j(G,O,I,J,k,H,S,w,T,E,ca,ma,va){h.beginPath();h.moveTo(O,I);h.lineTo(J,k);h.lineTo(H,S);h.closePath();J-=O;k-=I;H-=O;S-=I;E-=w;ca-=T;ma-=w;va-=T;var wa=1/(E*va-ma*ca),za=(va*J-ca*H)*wa;ca=(va*k-ca*S)*wa;J=(E*H-ma*J)*wa;k=(E*S-ma*k)*wa;O=O-za*w-J*T;I=I-ca*w-k*T;h.save();h.transform(za,ca,J,k,O,I);h.clip();h.drawImage(G,0,0);h.restore()}function n(G){switch(G){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation=
|
|
|
+"lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}q=G}function t(G,O,I,J){ja[0]=G[0];ja[1]=G[1];ja[2]=G[2];ja[4]=O[0];ja[5]=O[1];ja[6]=O[2];ja[8]=I[0];ja[9]=I[1];ja[10]=I[2];ja[12]=J[0];ja[13]=J[1];ja[14]=J[2];Aa.putImageData(Ia,0,0);Fa.drawImage(Ba,0,0);return Ca}function e(G){return G<0?Math.min((1+G)*0.5,0.5):0.5+Math.min(G*0.5,0.5)}function g(G,O){var I=O.x-G.x,J=O.y-G.y,k=1/Math.sqrt(I*I+J*J);I*=k;J*=k;O.x+=I;O.y+=J;G.x-=I;G.y-=J}var l=null,i=new THREE.Projector,
|
|
|
+m=document.createElement("canvas"),r,o,p,x,h=m.getContext("2d"),B=1,q=0,D=null,u=null,L=1,v,s,y,M,X=new THREE.Vertex,F=new THREE.Vertex,Y,Z,Q,z,N,K,V,C,A,W,pa,P,U,ha,na,Ea,sa,ta,ua,fa,qa,ra,oa=new THREE.Rectangle,ka=new THREE.Rectangle,aa=new THREE.Rectangle,Da=false,R=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),xa=new THREE.Color(4278190080),ya=new THREE.Color(4278190080),Ma=Math.PI*2,Ha=new THREE.Vector3,da=new THREE.UV,$=new THREE.UV,ea=new THREE.UV,
|
|
|
+ia=new THREE.UV,Ba,Aa,Ia,ja,Ca,Fa,la=16;Ba=document.createElement("canvas");Ba.width=Ba.height=2;Aa=Ba.getContext("2d");Aa.fillStyle="rgba(0,0,0,1)";Aa.fillRect(0,0,2,2);Ia=Aa.getImageData(0,0,2,2);ja=Ia.data;Ca=document.createElement("canvas");Ca.width=Ca.height=la;Fa=Ca.getContext("2d");Fa.translate(-la/2,-la/2);Fa.scale(la,la);la--;this.domElement=m;this.autoClear=true;this.setSize=function(G,O){r=G;o=O;p=r/2;x=o/2;m.width=r;m.height=o;h.lineJoin="round";h.lineCap="round";oa.set(-p,-x,p,x)};this.clear=
|
|
|
+function(){if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(oa);h.setTransform(1,0,0,-1,p,x);h.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());ka.empty()}};this.render=function(G,O){var I,J,k,H,S,w,T,E;this.autoClear&&this.clear();l=i.projectScene(G,O);h.setTransform(1,0,0,-1,p,x);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(oa.getX(),oa.getY(),oa.getWidth(),oa.getHeight());if(Da=G.lights.length>0){S=G.lights;ga.setRGB(0,0,0);xa.setRGB(0,0,0);ya.setRGB(0,0,0);I=0;for(J=S.length;I<J;I++){k=
|
|
|
+S[I];H=k.color;if(k instanceof THREE.AmbientLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(k instanceof THREE.DirectionalLight){xa.r+=H.r;xa.g+=H.g;xa.b+=H.b}else if(k instanceof THREE.PointLight){ya.r+=H.r;ya.g+=H.g;ya.b+=H.b}}}I=0;for(J=l.length;I<J;I++){k=l[I];aa.empty();if(k instanceof THREE.RenderableParticle){v=k;v.x*=p;v.y*=x;H=0;for(S=k.material.length;H<S;H++)if(E=k.material[H]){w=v;T=k;E=E;var ca=void 0,ma=void 0,va=void 0,wa=void 0,za=void 0,Ja=void 0,Ga=void 0,Ka=void 0,La=void 0;if(E.opacity!=
|
|
|
+B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);if(E instanceof THREE.ParticleBasicMaterial){Ga=E.bitmap;Ka=Ga.width/2;La=Ga.height/2;va=T.scale.x*p;wa=T.scale.y*x;ca=va*Ka;ma=wa*La;za=E.offset.x*va;Ja=E.offset.y*wa;aa.set(w.x+za-ca,w.y+Ja-ma,w.x+za+ca,w.y+Ja+ma);if(oa.instersects(aa)){h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);h.scale(va,-wa);h.translate(-Ka+E.offset.x,-La-E.offset.y);h.drawImage(Ga,0,0);h.restore();h.beginPath();h.moveTo(w.x-10,w.y);h.lineTo(w.x+10,w.y);h.moveTo(w.x,
|
|
|
+w.y-10);h.lineTo(w.x,w.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}}else if(E instanceof THREE.ParticleCircleMaterial){if(Da){ba.r=ga.r+xa.r+ya.r;ba.g=ga.g+xa.g+ya.g;ba.b=ga.b+xa.b+ya.b;R.r=E.color.r*ba.r;R.g=E.color.g*ba.g;R.b=E.color.b*ba.b;R.updateStyleString()}else R.__styleString=E.color.__styleString;ca=T.scale.x*p;ma=T.scale.y*x;aa.set(w.x-ca,w.y-ma,w.x+ca,w.y+ma);if(oa.instersects(aa)){if(u!==R.__styleString)h.fillStyle=u=R.__styleString;h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);
|
|
|
+h.scale(ca,ma);h.beginPath();h.arc(0,0,1,0,Ma,true);h.closePath();h.fill();h.restore()}}}}else if(k instanceof THREE.RenderableLine){v=k.v1;s=k.v2;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.material.length;H<S;)if(E=k.material[H++]){w=v;T=s;E=E;if(E.opacity!=B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);
|
|
|
+h.beginPath();h.moveTo(w.positionScreen.x,w.positionScreen.y);h.lineTo(T.positionScreen.x,T.positionScreen.y);h.closePath();if(E instanceof THREE.LineBasicMaterial){R.__styleString=E.color.__styleString;if(L!=E.linewidth)h.lineWidth=L=E.linewidth;if(D!=R.__styleString)h.strokeStyle=D=R.__styleString;h.stroke();aa.inflate(E.linewidth*2)}}}else if(k instanceof THREE.RenderableFace3){v=k.v1;s=k.v2;y=k.v3;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=
|
|
|
+p;y.positionScreen.y*=x;if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,y.positionScreen);g(y.positionScreen,v.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&b(v,
|
|
|
+s,y,k,E,G)}else E&&b(v,s,y,k,E,G)}}else if(k instanceof THREE.RenderableFace4){v=k.v1;s=k.v2;y=k.v3;M=k.v4;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=p;y.positionScreen.y*=x;M.positionScreen.x*=p;M.positionScreen.y*=x;X.positionScreen.copy(s.positionScreen);F.positionScreen.copy(M.positionScreen);if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,M.positionScreen);g(M.positionScreen,v.positionScreen)}if(k.overdraw){g(y.positionScreen,
|
|
|
+X.positionScreen);g(y.positionScreen,F.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);aa.addPoint(M.positionScreen.x,M.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&f(v,s,y,M,X,F,k,E,G)}else E&&f(v,s,y,M,X,F,k,E,G)}}ka.addRectangle(aa)}h.lineWidth=
|
|
|
1;h.strokeStyle="rgba( 255, 0, 0, 0.5 )";h.strokeRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());h.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(B,W,N){var Z,E,z,Y;Z=0;for(E=B.lights.length;Z<E;Z++){z=B.lights[Z];if(z instanceof THREE.DirectionalLight){Y=W.normalWorld.dot(z.position)*z.intensity;if(Y>0){N.r+=z.color.r*Y;N.g+=z.color.g*Y;N.b+=z.color.b*Y}}else if(z instanceof THREE.PointLight){y.sub(z.position,W.centroidWorld);y.normalize();Y=W.normalWorld.dot(y)*z.intensity;if(Y>0){N.r+=z.color.r*Y;N.g+=z.color.g*Y;N.b+=z.color.b*Y}}}}function b(B,W,N,Z,E,z){F=c(R++);F.setAttribute("d","M "+B.positionScreen.x+
|
|
|
-" "+B.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(A){C.r=u.r;C.g=u.g;C.b=u.b;a(z,Z,C);q.r=E.color.r*C.r;q.g=E.color.g*C.g;q.b=E.color.b*C.b;q.updateStyleString()}else q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){s=1-E.__2near/(E.__farPlusNear-Z.z*E.__farMinusNear);
|
|
|
-q.setRGB(s,s,s)}else E instanceof THREE.MeshNormalMaterial&&q.setRGB(d(Z.normalWorld.x),d(Z.normalWorld.y),d(Z.normalWorld.z));E.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+E.opacity);t.appendChild(F)}function f(B,W,N,Z,E,z,Y){F=c(R++);F.setAttribute("d","M "+B.positionScreen.x+" "+
|
|
|
-B.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)q.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(A){C.r=u.r;C.g=u.g;C.b=u.b;a(Y,E,C);q.r=z.color.r*C.r;q.g=z.color.g*C.g;q.b=z.color.b*C.b;q.updateStyleString()}else q.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){s=1-
|
|
|
-z.__2near/(z.__farPlusNear-E.z*z.__farMinusNear);q.setRGB(s,s,s)}else z instanceof THREE.MeshNormalMaterial&&q.setRGB(d(E.normalWorld.x),d(E.normalWorld.y),d(E.normalWorld.z));z.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+z.opacity);t.appendChild(F)}function c(B){if(L[B]==null){L[B]=
|
|
|
-document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&L[B].setAttribute("shape-rendering","crispEdges");return L[B]}return L[B]}function d(B){return B<0?Math.min((1+B)*0.5,0.5):0.5+Math.min(B*0.5,0.5)}var j=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,l,i,m,r,o,p,x=new THREE.Rectangle,h=new THREE.Rectangle,A=false,q=new THREE.Color(4294967295),C=new THREE.Color(4294967295),u=new THREE.Color(4278190080),K=new THREE.Color(4278190080),v=
|
|
|
-new THREE.Color(4278190080),s,y=new THREE.Vector3,L=[],X=[],F,R,V,S=1;this.domElement=t;this.autoClear=true;this.setQuality=function(B){switch(B){case "high":S=1;break;case "low":S=0}};this.setSize=function(B,W){e=B;g=W;l=e/2;i=g/2;t.setAttribute("viewBox",-l+" "+-i+" "+e+" "+g);t.setAttribute("width",e);t.setAttribute("height",g);x.set(-l,-i,l,i)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])};this.render=function(B,W){var N,Z,E,z,Y,pa,O,U;this.autoClear&&this.clear();
|
|
|
-j=n.projectScene(B,W);V=R=0;if(A=B.lights.length>0){O=B.lights;u.setRGB(0,0,0);K.setRGB(0,0,0);v.setRGB(0,0,0);N=0;for(Z=O.length;N<Z;N++){E=O[N];z=E.color;if(E instanceof THREE.AmbientLight){u.r+=z.r;u.g+=z.g;u.b+=z.b}else if(E instanceof THREE.DirectionalLight){K.r+=z.r;K.g+=z.g;K.b+=z.b}else if(E instanceof THREE.PointLight){v.r+=z.r;v.g+=z.g;v.b+=z.b}}}N=0;for(Z=j.length;N<Z;N++){O=j[N];h.empty();if(O instanceof THREE.RenderableParticle){m=O;m.x*=l;m.y*=-i;E=0;for(z=O.material.length;E<z;E++)if(U=
|
|
|
-O.material[E]){Y=m;pa=O;U=U;var ha=V++;if(X[ha]==null){X[ha]=document.createElementNS("http://www.w3.org/2000/svg","circle");S==0&&X[ha].setAttribute("shape-rendering","crispEdges")}F=X[ha];F.setAttribute("cx",Y.x);F.setAttribute("cy",Y.y);F.setAttribute("r",pa.scale.x*l);if(U instanceof THREE.ParticleCircleMaterial){if(A){C.r=u.r+K.r+v.r;C.g=u.g+K.g+v.g;C.b=u.b+K.b+v.b;q.r=U.color.r*C.r;q.g=U.color.g*C.g;q.b=U.color.b*C.b;q.updateStyleString()}else q=U.color;F.setAttribute("style","fill: "+q.__styleString)}t.appendChild(F)}}else if(O instanceof
|
|
|
-THREE.RenderableFace3){m=O.v1;r=O.v2;o=O.v3;m.positionScreen.x*=l;m.positionScreen.y*=-i;r.positionScreen.x*=l;r.positionScreen.y*=-i;o.positionScreen.x*=l;o.positionScreen.y*=-i;h.addPoint(m.positionScreen.x,m.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);if(x.instersects(h)){E=0;for(z=O.meshMaterial.length;E<z;){U=O.meshMaterial[E++];if(U instanceof THREE.MeshFaceMaterial){Y=0;for(pa=O.faceMaterial.length;Y<pa;)(U=O.faceMaterial[Y++])&&
|
|
|
-b(m,r,o,O,U,B)}else U&&b(m,r,o,O,U,B)}}}else if(O instanceof THREE.RenderableFace4){m=O.v1;r=O.v2;o=O.v3;p=O.v4;m.positionScreen.x*=l;m.positionScreen.y*=-i;r.positionScreen.x*=l;r.positionScreen.y*=-i;o.positionScreen.x*=l;o.positionScreen.y*=-i;p.positionScreen.x*=l;p.positionScreen.y*=-i;h.addPoint(m.positionScreen.x,m.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);h.addPoint(p.positionScreen.x,p.positionScreen.y);if(x.instersects(h)){E=
|
|
|
-0;for(z=O.meshMaterial.length;E<z;){U=O.meshMaterial[E++];if(U instanceof THREE.MeshFaceMaterial){Y=0;for(pa=O.faceMaterial.length;Y<pa;)(U=O.faceMaterial[Y++])&&f(m,r,o,p,O,U,B)}else U&&f(m,r,o,p,O,U,B)}}}}}};
|
|
|
+THREE.SVGRenderer=function(){function a(z,N,K){var V,C,A,W;V=0;for(C=z.lights.length;V<C;V++){A=z.lights[V];if(A instanceof THREE.DirectionalLight){W=N.normalWorld.dot(A.position)*A.intensity;if(W>0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}else if(A instanceof THREE.PointLight){y.sub(A.position,N.centroidWorld);y.normalize();W=N.normalWorld.dot(y)*A.intensity;if(W>0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}}}function b(z,N,K,V,C,A){F=c(Y++);F.setAttribute("d","M "+z.positionScreen.x+
|
|
|
+" "+z.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(A,V,D);q.r=C.color.r*D.r;q.g=C.color.g*D.g;q.b=C.color.b*D.b;q.updateStyleString()}else q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){s=1-C.__2near/(C.__farPlusNear-V.z*C.__farMinusNear);
|
|
|
+q.setRGB(s,s,s)}else C instanceof THREE.MeshNormalMaterial&&q.setRGB(d(V.normalWorld.x),d(V.normalWorld.y),d(V.normalWorld.z));C.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+C.opacity);t.appendChild(F)}function f(z,N,K,V,C,A,W){F=c(Y++);F.setAttribute("d","M "+z.positionScreen.x+" "+
|
|
|
+z.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(W,C,D);q.r=A.color.r*D.r;q.g=A.color.g*D.g;q.b=A.color.b*D.b;q.updateStyleString()}else q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){s=1-
|
|
|
+A.__2near/(A.__farPlusNear-C.z*A.__farMinusNear);q.setRGB(s,s,s)}else A instanceof THREE.MeshNormalMaterial&&q.setRGB(d(C.normalWorld.x),d(C.normalWorld.y),d(C.normalWorld.z));A.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+A.opacity);t.appendChild(F)}function c(z){if(M[z]==null){M[z]=
|
|
|
+document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function d(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var j=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,l,i,m,r,o,p,x=new THREE.Rectangle,h=new THREE.Rectangle,B=false,q=new THREE.Color(4294967295),D=new THREE.Color(4294967295),u=new THREE.Color(4278190080),L=new THREE.Color(4278190080),v=
|
|
|
+new THREE.Color(4278190080),s,y=new THREE.Vector3,M=[],X=[],F,Y,Z,Q=1;this.domElement=t;this.autoClear=true;this.setQuality=function(z){switch(z){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(z,N){e=z;g=N;l=e/2;i=g/2;t.setAttribute("viewBox",-l+" "+-i+" "+e+" "+g);t.setAttribute("width",e);t.setAttribute("height",g);x.set(-l,-i,l,i)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])};this.render=function(z,N){var K,V,C,A,W,pa,P,U;this.autoClear&&this.clear();
|
|
|
+j=n.projectScene(z,N);Z=Y=0;if(B=z.lights.length>0){P=z.lights;u.setRGB(0,0,0);L.setRGB(0,0,0);v.setRGB(0,0,0);K=0;for(V=P.length;K<V;K++){C=P[K];A=C.color;if(C instanceof THREE.AmbientLight){u.r+=A.r;u.g+=A.g;u.b+=A.b}else if(C instanceof THREE.DirectionalLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}else if(C instanceof THREE.PointLight){v.r+=A.r;v.g+=A.g;v.b+=A.b}}}K=0;for(V=j.length;K<V;K++){P=j[K];h.empty();if(P instanceof THREE.RenderableParticle){m=P;m.x*=l;m.y*=-i;C=0;for(A=P.material.length;C<A;C++)if(U=
|
|
|
+P.material[C]){W=m;pa=P;U=U;var ha=Z++;if(X[ha]==null){X[ha]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&X[ha].setAttribute("shape-rendering","crispEdges")}F=X[ha];F.setAttribute("cx",W.x);F.setAttribute("cy",W.y);F.setAttribute("r",pa.scale.x*l);if(U instanceof THREE.ParticleCircleMaterial){if(B){D.r=u.r+L.r+v.r;D.g=u.g+L.g+v.g;D.b=u.b+L.b+v.b;q.r=U.color.r*D.r;q.g=U.color.g*D.g;q.b=U.color.b*D.b;q.updateStyleString()}else q=U.color;F.setAttribute("style","fill: "+q.__styleString)}t.appendChild(F)}}else if(P instanceof
|
|
|
+THREE.RenderableFace3){m=P.v1;r=P.v2;o=P.v3;m.positionScreen.x*=l;m.positionScreen.y*=-i;r.positionScreen.x*=l;r.positionScreen.y*=-i;o.positionScreen.x*=l;o.positionScreen.y*=-i;h.addPoint(m.positionScreen.x,m.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);if(x.instersects(h)){C=0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&
|
|
|
+b(m,r,o,P,U,z)}else U&&b(m,r,o,P,U,z)}}}else if(P instanceof THREE.RenderableFace4){m=P.v1;r=P.v2;o=P.v3;p=P.v4;m.positionScreen.x*=l;m.positionScreen.y*=-i;r.positionScreen.x*=l;r.positionScreen.y*=-i;o.positionScreen.x*=l;o.positionScreen.y*=-i;p.positionScreen.x*=l;p.positionScreen.y*=-i;h.addPoint(m.positionScreen.x,m.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);h.addPoint(p.positionScreen.x,p.positionScreen.y);if(x.instersects(h)){C=
|
|
|
+0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&f(m,r,o,p,P,U,z)}else U&&f(m,r,o,p,P,U,z)}}}}}};
|
|
|
THREE.WebGLRenderer=function(a){function b(e,g){var l;if(e=="fragment")l=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")l=c.createShader(c.VERTEX_SHADER);c.shaderSource(l,g);c.compileShader(l);if(!c.getShaderParameter(l,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(l));return null}return l}var f=document.createElement("canvas"),c,d,j=new THREE.Matrix4,n;a=function(e,g){if(e){var l,i,m,r=pointLights=maxDirLights=maxPointLights=0;l=0;for(i=e.lights.length;l<i;l++){m=e.lights[l];m instanceof THREE.DirectionalLight&&
|
|
|
r++;m instanceof THREE.PointLight&&pointLights++}if(pointLights+r<=g){maxDirLights=r;maxPointLights=pointLights}else{maxDirLights=Math.ceil(g*r/(pointLights+r));maxPointLights=g-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:g-1}}(a,5);this.domElement=f;this.autoClear=true;try{c=f.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
|
|
|
c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);(function(e,g){d=c.createProgram();c.attachShader(d,b("fragment",["#ifdef GL_ES\nprecision highp float;\n#endif",e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform int material;\nuniform bool enableMap;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
@@ -131,12 +131,12 @@ c.getUniformLocation(d,"pointLightNumber");d.pointLightColor=c.getUniformLocatio
|
|
|
0);d.tMap=c.getUniformLocation(d,"tMap");c.uniform1i(d.tMap,0);d.m2Near=c.getUniformLocation(d,"m2Near");d.mFarPlusNear=c.getUniformLocation(d,"mFarPlusNear");d.mFarMinusNear=c.getUniformLocation(d,"mFarMinusNear");d.position=c.getAttribLocation(d,"position");c.enableVertexAttribArray(d.position);d.normal=c.getAttribLocation(d,"normal");c.enableVertexAttribArray(d.normal);d.uv=c.getAttribLocation(d,"uv");c.enableVertexAttribArray(d.uv);d.viewMatrixArray=new Float32Array(16);d.modelViewMatrixArray=
|
|
|
new Float32Array(16);d.projectionMatrixArray=new Float32Array(16)})(a.directional,a.point);this.setSize=function(e,g){f.width=e;f.height=g;c.viewport(0,0,f.width,f.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e){var g,l,i,m,r=[],o=[],p=[];m=[];var x=[];c.uniform1i(d.enableLighting,e.lights.length);g=0;for(l=e.lights.length;g<l;g++){i=e.lights[g];if(i instanceof THREE.AmbientLight)r.push(i);else if(i instanceof THREE.DirectionalLight)p.push(i);
|
|
|
else i instanceof THREE.PointLight&&o.push(i)}g=e=i=m=0;for(l=r.length;g<l;g++){e+=r[g].color.r;i+=r[g].color.g;m+=r[g].color.b}c.uniform3f(d.ambientLightColor,e,i,m);m=[];x=[];g=0;for(l=p.length;g<l;g++){i=p[g];m.push(i.color.r*i.intensity);m.push(i.color.g*i.intensity);m.push(i.color.b*i.intensity);x.push(i.position.x);x.push(i.position.y);x.push(i.position.z)}if(p.length){c.uniform1i(d.directionalLightNumber,p.length);c.uniform3fv(d.directionalLightDirection,x);c.uniform3fv(d.directionalLightColor,
|
|
|
-m)}m=[];x=[];g=0;for(l=o.length;g<l;g++){i=o[g];m.push(i.color.r*i.intensity);m.push(i.color.g*i.intensity);m.push(i.color.b*i.intensity);x.push(i.position.x);x.push(i.position.y);x.push(i.position.z)}if(o.length){c.uniform1i(d.pointLightNumber,o.length);c.uniform3fv(d.pointLightPosition,x);c.uniform3fv(d.pointLightColor,m)}};this.createBuffers=function(e,g){var l,i,m,r,o,p,x,h,A,q=e.materialFaceGroup[g],C=[],u=[],K=[],v=[],s=[],y=0,L=false;l=0;for(i=e.material.length;l<i;l++){meshMaterial=e.material[l];
|
|
|
-if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(p=q.material.length;o<p;o++)if(q.material[o].shading!=undefined&&q.material[o].shading==THREE.SmoothShading){L=true;break}}else if(meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){L=true;break}if(L)break}l=0;for(i=q.faces.length;l<i;l++){m=q.faces[l];r=e.geometry.faces[m];o=r.vertexNormals;p=r.normal;m=e.geometry.uvs[m];if(r instanceof THREE.Face3){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;
|
|
|
-A=e.geometry.vertices[r.c].position;K.push(x.x,x.y,x.z);K.push(h.x,h.y,h.z);K.push(A.x,A.y,A.z);if(o.length==3&&L){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(m){s.push(m[0].u,m[0].v);s.push(m[1].u,m[1].v);s.push(m[2].u,m[2].v)}C.push(y,y+1,y+2);u.push(y,y+1);u.push(y,y+2);u.push(y+1,y+2);y+=3}else if(r instanceof THREE.Face4){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;
|
|
|
-A=e.geometry.vertices[r.c].position;r=e.geometry.vertices[r.d].position;K.push(x.x,x.y,x.z);K.push(h.x,h.y,h.z);K.push(A.x,A.y,A.z);K.push(r.x,r.y,r.z);if(o.length==4&&L){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z);v.push(o[3].x,o[3].y,o[3].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(m){s.push(m[0].u,m[0].v);s.push(m[1].u,m[1].v);s.push(m[2].u,m[2].v);s.push(m[3].u,m[3].v)}C.push(y,y+1,y+2);C.push(y,y+2,y+3);
|
|
|
-u.push(y,y+1);u.push(y,y+2);u.push(y,y+3);u.push(y+1,y+2);u.push(y+2,y+3);y+=4}}if(K.length){q.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW);q.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(v),c.STATIC_DRAW);q.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,
|
|
|
-new Float32Array(s),c.STATIC_DRAW);q.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);q.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(u),c.STATIC_DRAW);q.__webGLFaceCount=C.length;q.__webGLLineCount=u.length}};this.renderBuffer=function(e,g){var l,i,m,r,o,p,x;if(e instanceof THREE.MeshPhongMaterial||
|
|
|
+m)}m=[];x=[];g=0;for(l=o.length;g<l;g++){i=o[g];m.push(i.color.r*i.intensity);m.push(i.color.g*i.intensity);m.push(i.color.b*i.intensity);x.push(i.position.x);x.push(i.position.y);x.push(i.position.z)}if(o.length){c.uniform1i(d.pointLightNumber,o.length);c.uniform3fv(d.pointLightPosition,x);c.uniform3fv(d.pointLightColor,m)}};this.createBuffers=function(e,g){var l,i,m,r,o,p,x,h,B,q=e.materialFaceGroup[g],D=[],u=[],L=[],v=[],s=[],y=0,M=false;l=0;for(i=e.material.length;l<i;l++){meshMaterial=e.material[l];
|
|
|
+if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(p=q.material.length;o<p;o++)if(q.material[o].shading!=undefined&&q.material[o].shading==THREE.SmoothShading){M=true;break}}else if(meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){M=true;break}if(M)break}l=0;for(i=q.faces.length;l<i;l++){m=q.faces[l];r=e.geometry.faces[m];o=r.vertexNormals;p=r.normal;m=e.geometry.uvs[m];if(r instanceof THREE.Face3){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;
|
|
|
+B=e.geometry.vertices[r.c].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,B.y,B.z);if(o.length==3&&M){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(m){s.push(m[0].u,m[0].v);s.push(m[1].u,m[1].v);s.push(m[2].u,m[2].v)}D.push(y,y+1,y+2);u.push(y,y+1);u.push(y,y+2);u.push(y+1,y+2);y+=3}else if(r instanceof THREE.Face4){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;
|
|
|
+B=e.geometry.vertices[r.c].position;r=e.geometry.vertices[r.d].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,B.y,B.z);L.push(r.x,r.y,r.z);if(o.length==4&&M){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z);v.push(o[3].x,o[3].y,o[3].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(m){s.push(m[0].u,m[0].v);s.push(m[1].u,m[1].v);s.push(m[2].u,m[2].v);s.push(m[3].u,m[3].v)}D.push(y,y+1,y+2);D.push(y,y+2,y+3);
|
|
|
+u.push(y,y+1);u.push(y,y+2);u.push(y,y+3);u.push(y+1,y+2);u.push(y+2,y+3);y+=4}}if(L.length){q.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(L),c.STATIC_DRAW);q.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(v),c.STATIC_DRAW);q.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,
|
|
|
+new Float32Array(s),c.STATIC_DRAW);q.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),c.STATIC_DRAW);q.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(u),c.STATIC_DRAW);q.__webGLFaceCount=D.length;q.__webGLLineCount=u.length}};this.renderBuffer=function(e,g){var l,i,m,r,o,p,x;if(e instanceof THREE.MeshPhongMaterial||
|
|
|
e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){l=e.color;i=e.opacity;m=e.wireframe;r=e.wireframe_linewidth;x=e.map;c.uniform4f(d.mColor,l.r*i,l.g*i,l.b*i,i)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;c.uniform1f(d.mOpacity,i);c.uniform1i(d.material,4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;m=e.wireframe;r=e.wireframe_linewidth;c.uniform1f(d.mOpacity,i);c.uniform1f(d.m2Near,e.__2near);c.uniform1f(d.mFarPlusNear,e.__farPlusNear);c.uniform1f(d.mFarMinusNear,
|
|
|
e.__farMinusNear);c.uniform1i(d.material,3)}else if(e instanceof THREE.MeshPhongMaterial){l=e.ambient;o=e.specular;p=e.shininess;c.uniform4f(d.mAmbient,l.r,l.g,l.b,i);c.uniform4f(d.mSpecular,o.r,o.g,o.b,i);c.uniform1f(d.mShininess,p);c.uniform1i(d.material,2)}else if(e instanceof THREE.MeshLambertMaterial)c.uniform1i(d.material,1);else e instanceof THREE.MeshBasicMaterial&&c.uniform1i(d.material,0);if(x){if(!e.__webGLTexture&&e.map.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
|
|
|
e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.map.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.uniform1i(d.tMap,0);c.uniform1i(d.enableMap,1)}else c.uniform1i(d.enableMap,0);c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.vertexAttribPointer(d.position,
|