|
@@ -101,37 +101,37 @@ q.positionScreen.copy(q.position);O.multiplyVector4(q.positionScreen);C=w[y-1];E
|
|
|
x.x=J.x/J.w;x.y=J.y/J.w;x.z=J.z;x.rotation=t.rotation.z;x.scale.x=t.scale.x*Math.abs(x.x-(J.x+p.projectionMatrix.n11)/(J.w+p.projectionMatrix.n14));x.scale.y=t.scale.y*Math.abs(x.y-(J.y+p.projectionMatrix.n22)/(J.w+p.projectionMatrix.n24));x.material=t.material;h.push(x);v++}}}}l&&h.sort(b);return h};this.unprojectVector=function(e,p){var l=new THREE.Matrix4;l.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));l.multiplyVector3(e);return e}};
|
|
|
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,k;this.domElement=document.createElement("div");this.setSize=function(o,j){g=o;d=j;i=g/2;k=d/2};this.render=function(o,j){var n,c,B,A,x,v,H,L;a=b.projectScene(o,j);n=0;for(c=a.length;n<c;n++){x=a[n];if(x instanceof THREE.RenderableParticle){H=x.x*i+i;L=x.y*k+k;B=0;for(A=x.material.length;B<A;B++){v=x.material[B];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=H+"px";v.style.top=L+"px"}}}}}};
|
|
|
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,g=document.createElement("canvas"),d,i,k,o,j=g.getContext("2d"),n=1,c=0,B=null,A=null,x=1,v,H,L,J,I,O,E,f,m,e=new THREE.Color,p=new THREE.Color,l=new THREE.Color,h=new THREE.Color,u=new THREE.Color,y,D,q,C,Q,t,U,P,X,V,F=new THREE.Rectangle,w=new THREE.Rectangle,r=new THREE.Rectangle,N=false,S=new THREE.Color,M=new THREE.Color,T=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,Y=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
|
|
|
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=g;this.autoClear=true;this.setSize=function(ga,ua){d=ga;i=ua;k=d/2;o=i/2;g.width=d;g.height=i;F.set(-k,-o,k,o)};this.clear=function(){if(!w.isEmpty()){w.inflate(1);w.minSelf(F);j.clearRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());
|
|
|
-w.empty()}};this.render=function(ga,ua){function Ka(s){var R,K,z,G=s.lights;M.setRGB(0,0,0);T.setRGB(0,0,0);aa.setRGB(0,0,0);s=0;for(R=G.length;s<R;s++){K=G[s];z=K.color;if(K instanceof THREE.AmbientLight){M.r+=z.r;M.g+=z.g;M.b+=z.b}else if(K instanceof THREE.DirectionalLight){T.r+=z.r;T.g+=z.g;T.b+=z.b}else if(K instanceof THREE.PointLight){aa.r+=z.r;aa.g+=z.g;aa.b+=z.b}}}function va(s,R,K,z){var G,W,$,ba,ca=s.lights;s=0;for(G=ca.length;s<G;s++){W=ca[s];$=W.color;ba=W.intensity;if(W instanceof THREE.DirectionalLight){W=
|
|
|
-K.dot(W.position)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,R);Y.normalize();W=K.dot(Y)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}}}function La(s,R,K){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);var z,G,W,$,ba,ca;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){$=K.map;ba=$.width>>1;ca=$.height>>1;G=R.scale.x*k;W=R.scale.y*o;K=G*ba;z=W*ca;r.set(s.x-K,s.y-z,s.x+K,s.y+z);if(!F.instersects(r))return;j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);
|
|
|
-j.scale(G,-W);j.translate(-ba,-ca);j.drawImage($,0,0);j.restore()}j.beginPath();j.moveTo(s.x-10,s.y);j.lineTo(s.x+10,s.y);j.moveTo(s.x,s.y-10);j.lineTo(s.x,s.y+10);j.closePath();j.strokeStyle="rgb(255,255,0)";j.stroke()}else if(K instanceof THREE.ParticleCircleMaterial){if(N){S.r=M.r+T.r+aa.r;S.g=M.g+T.g+aa.g;S.b=M.b+T.b+aa.b;e.r=K.color.r*S.r;e.g=K.color.g*S.g;e.b=K.color.b*S.b;e.updateStyleString()}else e.__styleString=K.color.__styleString;K=R.scale.x*k;z=R.scale.y*o;r.set(s.x-K,s.y-z,s.x+K,s.y+
|
|
|
-z);if(F.instersects(r)){G=e.__styleString;if(A!=G)j.fillStyle=A=G;j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);j.scale(K,z);j.beginPath();j.arc(0,0,1,0,Ja,true);j.closePath();j.fill();j.restore()}}}}function Ma(s,R,K,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);j.beginPath();j.moveTo(s.positionScreen.x,s.positionScreen.y);j.lineTo(R.positionScreen.x,R.positionScreen.y);j.closePath();if(z instanceof THREE.LineBasicMaterial){e.__styleString=z.color.__styleString;s=z.linewidth;if(x!=s)j.lineWidth=
|
|
|
-x=s;s=e.__styleString;if(B!=s)j.strokeStyle=B=s;j.stroke();r.inflate(z.linewidth*2)}}}function Fa(s,R,K,z,G,W){if(G.opacity!=0){Ba(G.opacity);wa(G.blending);J=s.positionScreen.x;I=s.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;f=K.positionScreen.x;m=K.positionScreen.y;j.beginPath();j.moveTo(J,I);j.lineTo(O,E);j.lineTo(f,m);j.lineTo(J,I);j.closePath();if(G instanceof THREE.MeshBasicMaterial)if(G.map)G.map.image.loaded&&G.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,
|
|
|
-z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(G.env_map){if(G.env_map.image.loaded)if(G.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ua.matrix;Y.copy(z.vertexNormalsWorld[0]);Q=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;t=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[1]);U=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;P=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[2]);X=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;V=-(Y.x*
|
|
|
-s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;qa(J,I,O,E,f,m,G.env_map.image,Q,t,U,P,X,V)}}else G.wireframe?xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString);else if(G instanceof THREE.MeshLambertMaterial){if(G.map&&!G.wireframe){G.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!G.wireframe&&G.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){p.r=l.r=
|
|
|
-h.r=M.r;p.g=l.g=h.g=M.g;p.b=l.b=h.b=M.b;va(W,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(W,z.v2.positionWorld,z.vertexNormalsWorld[1],l);va(W,z.v3.positionWorld,z.vertexNormalsWorld[2],h);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else{S.r=M.r;S.g=M.g;S.b=M.b;va(W,z.centroidWorld,z.normalWorld,S);e.r=G.color.r*S.r;e.g=G.color.g*S.g;e.b=G.color.b*S.b;e.updateStyleString();G.wireframe?xa(e.__styleString,G.wireframe_linewidth):ya(e.__styleString)}else G.wireframe?
|
|
|
-xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString)}else if(G instanceof THREE.MeshDepthMaterial){y=G.__2near;D=G.__farPlusNear;q=G.__farMinusNear;p.r=p.g=p.b=1-y/(D-s.positionScreen.z*q);l.r=l.g=l.b=1-y/(D-R.positionScreen.z*q);h.r=h.g=h.b=1-y/(D-K.positionScreen.z*q);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else if(G instanceof THREE.MeshNormalMaterial){e.r=Ca(z.normalWorld.x);e.g=Ca(z.normalWorld.y);e.b=Ca(z.normalWorld.z);
|
|
|
-e.updateStyleString();G.wireframe?xa(e.__styleString,G.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,R){if(B!=s)j.strokeStyle=B=s;if(x!=R)j.lineWidth=x=R;j.stroke();r.inflate(R*2)}function ya(s){if(A!=s)j.fillStyle=A=s;j.fill()}function qa(s,R,K,z,G,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;K-=s;z-=R;G-=s;W-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*K-ea*G)*ja;ea=(ra*z-ea*W)*ja;K=(ha*G-ia*K)*ja;z=(ha*W-ia*z)*ja;s=
|
|
|
-s-ka*ba-K*ca;R=R-ea*ba-z*ca;j.save();j.transform(ka,ea,K,z,s,R);j.clip();j.drawImage($,0,0);j.restore()}function Ba(s){if(n!=s)j.globalAlpha=n=s}function wa(s){if(c!=s){switch(s){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}c=s}}function Ga(s,R,K,z){var G=~~(s.r*255),W=~~(s.g*255);s=~~(s.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*
|
|
|
-255);var ca=~~(K.r*255),ha=~~(K.g*255);K=~~(K.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=G<0?0:G>255?255:G;da[1]=W<0?0:W>255?255:W;da[2]=s<0?0:s>255?255:s;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=K<0?0:K>255?255:K;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(s){s=(s+1)*0.5;return s<0?
|
|
|
-0:s>1?1:s}function Da(s,R){var K=R.x-s.x,z=R.y-s.y,G=1/Math.sqrt(K*K+z*z);K*=G;z*=G;R.x+=K;R.y+=z;s.x-=K;s.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;j.setTransform(1,0,0,-1,k,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,true);j.fillStyle="rgba(0, 255, 255, 0.5)";j.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];r.empty();if(Z instanceof THREE.RenderableParticle){v=Z;v.x*=k;v.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(v,
|
|
|
-Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){v=Z.v1;H=Z.v2;v.positionScreen.x*=k;v.positionScreen.y*=o;H.positionScreen.x*=k;H.positionScreen.y*=o;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(F.instersects(r)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(v,H,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){v=Z.v1;H=Z.v2;L=Z.v3;v.positionScreen.x*=k;v.positionScreen.y*=o;H.positionScreen.x*=k;H.positionScreen.y*=
|
|
|
-o;L.positionScreen.x*=k;L.positionScreen.y*=o;if(Z.overdraw){Da(v.positionScreen,H.positionScreen);Da(H.positionScreen,L.positionScreen);Da(L.positionScreen,v.positionScreen)}r.add3Points(v.positionScreen.x,v.positionScreen.y,H.positionScreen.x,H.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(F.instersects(r)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(v,
|
|
|
-H,L,Z,sa,ga)}else Fa(v,H,L,Z,sa,ga)}}}w.addRectangle(r)}j.lineWidth=1;j.strokeStyle="rgba( 255, 0, 0, 0.5 )";j.strokeRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());j.setTransform(1,0,0,1,0,0)}};
|
|
|
+na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ua){d=ga;i=ua;k=d/2;o=i/2;g.width=d;g.height=i;F.set(-k,-o,k,o)};this.clear=function(){if(!w.isEmpty()){w.inflate(1);w.minSelf(F);j.clearRect(w.getX(),
|
|
|
+w.getY(),w.getWidth(),w.getHeight());w.empty()}};this.render=function(ga,ua){function Ka(s){var R,K,z,G=s.lights;M.setRGB(0,0,0);T.setRGB(0,0,0);aa.setRGB(0,0,0);s=0;for(R=G.length;s<R;s++){K=G[s];z=K.color;if(K instanceof THREE.AmbientLight){M.r+=z.r;M.g+=z.g;M.b+=z.b}else if(K instanceof THREE.DirectionalLight){T.r+=z.r;T.g+=z.g;T.b+=z.b}else if(K instanceof THREE.PointLight){aa.r+=z.r;aa.g+=z.g;aa.b+=z.b}}}function va(s,R,K,z){var G,W,$,ba,ca=s.lights;s=0;for(G=ca.length;s<G;s++){W=ca[s];$=W.color;
|
|
|
+ba=W.intensity;if(W instanceof THREE.DirectionalLight){W=K.dot(W.position)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,R);Y.normalize();W=K.dot(Y)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}}}function La(s,R,K){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);var z,G,W,$,ba,ca;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){$=K.map;ba=$.width>>1;ca=$.height>>1;G=R.scale.x*k;W=R.scale.y*o;K=G*ba;z=W*ca;r.set(s.x-K,s.y-z,s.x+K,s.y+z);if(!F.instersects(r))return;
|
|
|
+j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);j.scale(G,-W);j.translate(-ba,-ca);j.drawImage($,0,0);j.restore()}j.beginPath();j.moveTo(s.x-10,s.y);j.lineTo(s.x+10,s.y);j.moveTo(s.x,s.y-10);j.lineTo(s.x,s.y+10);j.closePath();j.strokeStyle="rgb(255,255,0)";j.stroke()}else if(K instanceof THREE.ParticleCircleMaterial){if(N){S.r=M.r+T.r+aa.r;S.g=M.g+T.g+aa.g;S.b=M.b+T.b+aa.b;e.r=K.color.r*S.r;e.g=K.color.g*S.g;e.b=K.color.b*S.b;e.updateStyleString()}else e.__styleString=K.color.__styleString;K=
|
|
|
+R.scale.x*k;z=R.scale.y*o;r.set(s.x-K,s.y-z,s.x+K,s.y+z);if(F.instersects(r)){G=e.__styleString;if(A!=G)j.fillStyle=A=G;j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);j.scale(K,z);j.beginPath();j.arc(0,0,1,0,Ja,true);j.closePath();j.fill();j.restore()}}}}function Ma(s,R,K,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);j.beginPath();j.moveTo(s.positionScreen.x,s.positionScreen.y);j.lineTo(R.positionScreen.x,R.positionScreen.y);j.closePath();if(z instanceof THREE.LineBasicMaterial){e.__styleString=
|
|
|
+z.color.__styleString;s=z.linewidth;if(x!=s)j.lineWidth=x=s;s=e.__styleString;if(B!=s)j.strokeStyle=B=s;j.stroke();r.inflate(z.linewidth*2)}}}function Fa(s,R,K,z,G,W){if(G.opacity!=0){Ba(G.opacity);wa(G.blending);J=s.positionScreen.x;I=s.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;f=K.positionScreen.x;m=K.positionScreen.y;j.beginPath();j.moveTo(J,I);j.lineTo(O,E);j.lineTo(f,m);j.lineTo(J,I);j.closePath();if(G instanceof THREE.MeshBasicMaterial)if(G.map)G.map.image.loaded&&G.map.mapping instanceof
|
|
|
+THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(G.env_map){if(G.env_map.image.loaded)if(G.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ua.matrix;Y.copy(z.vertexNormalsWorld[0]);Q=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;t=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[1]);U=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;P=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[2]);X=
|
|
|
+(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;V=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;qa(J,I,O,E,f,m,G.env_map.image,Q,t,U,P,X,V)}}else G.wireframe?xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString);else if(G instanceof THREE.MeshLambertMaterial){if(G.map&&!G.wireframe){G.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!G.wireframe&&G.shading==THREE.SmoothShading&&
|
|
|
+z.vertexNormalsWorld.length==3){p.r=l.r=h.r=M.r;p.g=l.g=h.g=M.g;p.b=l.b=h.b=M.b;va(W,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(W,z.v2.positionWorld,z.vertexNormalsWorld[1],l);va(W,z.v3.positionWorld,z.vertexNormalsWorld[2],h);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else{S.r=M.r;S.g=M.g;S.b=M.b;va(W,z.centroidWorld,z.normalWorld,S);e.r=G.color.r*S.r;e.g=G.color.g*S.g;e.b=G.color.b*S.b;e.updateStyleString();G.wireframe?xa(e.__styleString,
|
|
|
+G.wireframe_linewidth):ya(e.__styleString)}else G.wireframe?xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString)}else if(G instanceof THREE.MeshDepthMaterial){y=G.__2near;D=G.__farPlusNear;q=G.__farMinusNear;p.r=p.g=p.b=1-y/(D-s.positionScreen.z*q);l.r=l.g=l.b=1-y/(D-R.positionScreen.z*q);h.r=h.g=h.b=1-y/(D-K.positionScreen.z*q);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else if(G instanceof THREE.MeshNormalMaterial){e.r=
|
|
|
+Ca(z.normalWorld.x);e.g=Ca(z.normalWorld.y);e.b=Ca(z.normalWorld.z);e.updateStyleString();G.wireframe?xa(e.__styleString,G.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,R){if(B!=s)j.strokeStyle=B=s;if(x!=R)j.lineWidth=x=R;j.stroke();r.inflate(R*2)}function ya(s){if(A!=s)j.fillStyle=A=s;j.fill()}function qa(s,R,K,z,G,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;K-=s;z-=R;G-=s;W-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=
|
|
|
+(ra*K-ea*G)*ja;ea=(ra*z-ea*W)*ja;K=(ha*G-ia*K)*ja;z=(ha*W-ia*z)*ja;s=s-ka*ba-K*ca;R=R-ea*ba-z*ca;j.save();j.transform(ka,ea,K,z,s,R);j.clip();j.drawImage($,0,0);j.restore()}function Ba(s){if(n!=s)j.globalAlpha=n=s}function wa(s){if(c!=s){switch(s){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}c=s}}function Ga(s,R,K,z){var G=~~(s.r*255),
|
|
|
+W=~~(s.g*255);s=~~(s.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*255);var ca=~~(K.r*255),ha=~~(K.g*255);K=~~(K.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=G<0?0:G>255?255:G;da[1]=W<0?0:W>255?255:W;da[2]=s<0?0:s>255?255:s;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=K<0?0:K>255?255:K;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);
|
|
|
+ta.drawImage(na,0,0);return pa}function Ca(s){s=(s+1)*0.5;return s<0?0:s>1?1:s}function Da(s,R){var K=R.x-s.x,z=R.y-s.y,G=1/Math.sqrt(K*K+z*z);K*=G;z*=G;R.x+=K;R.y+=z;s.x-=K;s.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;j.setTransform(1,0,0,-1,k,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);j.fillStyle="rgba(0, 255, 255, 0.5)";j.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];r.empty();if(Z instanceof THREE.RenderableParticle){v=
|
|
|
+Z;v.x*=k;v.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(v,Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){v=Z.v1;H=Z.v2;v.positionScreen.x*=k;v.positionScreen.y*=o;H.positionScreen.x*=k;H.positionScreen.y*=o;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(F.instersects(r)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(v,H,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){v=Z.v1;H=Z.v2;L=Z.v3;v.positionScreen.x*=
|
|
|
+k;v.positionScreen.y*=o;H.positionScreen.x*=k;H.positionScreen.y*=o;L.positionScreen.x*=k;L.positionScreen.y*=o;if(Z.overdraw){Da(v.positionScreen,H.positionScreen);Da(H.positionScreen,L.positionScreen);Da(L.positionScreen,v.positionScreen)}r.add3Points(v.positionScreen.x,v.positionScreen.y,H.positionScreen.x,H.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(F.instersects(r)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;
|
|
|
+for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(v,H,L,Z,sa,ga)}else Fa(v,H,L,Z,sa,ga)}}}w.addRectangle(r)}j.lineWidth=1;j.strokeStyle="rgba( 255, 0, 0, 0.5 )";j.strokeRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());j.setTransform(1,0,0,1,0,0)}};
|
|
|
THREE.SVGRenderer=function(){function a(P,X,V){var F,w,r,N;F=0;for(w=P.lights.length;F<w;F++){r=P.lights[F];if(r instanceof THREE.DirectionalLight){N=X.normalWorld.dot(r.position)*r.intensity;if(N>0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}else if(r instanceof THREE.PointLight){h.sub(r.position,X.centroidWorld);h.normalize();N=X.normalWorld.dot(h)*r.intensity;if(N>0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}}}function b(P,X,V,F,w,r){q=d(C++);q.setAttribute("d","M "+P.positionScreen.x+
|
|
|
" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(r,F,f);E.r=w.color.r*f.r;E.g=w.color.g*f.g;E.b=w.color.b*f.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){l=1-w.__2near/(w.__farPlusNear-F.z*w.__farMinusNear);
|
|
|
E.setRGB(l,l,l)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));w.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);j.appendChild(q)}function g(P,X,V,F,w,r,N){q=d(C++);q.setAttribute("d",
|
|
|
"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(N,w,f);E.r=r.color.r*f.r;E.g=r.color.g*f.g;E.b=r.color.b*f.b;E.updateStyleString()}else E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){l=
|
|
|
1-r.__2near/(r.__farPlusNear-w.z*r.__farMinusNear);E.setRGB(l,l,l)}else r instanceof THREE.MeshNormalMaterial&&E.setRGB(i(w.normalWorld.x),i(w.normalWorld.y),i(w.normalWorld.z));r.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+r.opacity);j.appendChild(q)}
|
|
|
function d(P){if(u[P]==null){u[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&u[P].setAttribute("shape-rendering","crispEdges");return u[P]}return u[P]}function i(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var k=null,o=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,B,A,x,v,H,L,J=new THREE.Rectangle,I=new THREE.Rectangle,O=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),m=new THREE.Color(0),e=new THREE.Color(0),
|
|
|
-p=new THREE.Color(0),l,h=new THREE.Vector3,u=[],y=[],D=[],q,C,Q,t,U=1;this.domElement=j;this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,X){n=P;c=X;B=n/2;A=c/2;j.setAttribute("viewBox",-B+" "+-A+" "+n+" "+c);j.setAttribute("width",n);j.setAttribute("height",c);J.set(-B,-A,B,A)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(P,X){var V,F,w,r,N,S,M,T;this.autoClear&&this.clear();
|
|
|
-k=o.projectScene(P,X,true);t=Q=C=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(F=M.length;V<F;V++){w=M[V];r=w.color;if(w instanceof THREE.AmbientLight){m.r+=r.r;m.g+=r.g;m.b+=r.b}else if(w instanceof THREE.DirectionalLight){e.r+=r.r;e.g+=r.g;e.b+=r.b}else if(w instanceof THREE.PointLight){p.r+=r.r;p.g+=r.g;p.b+=r.b}}}V=0;for(F=k.length;V<F;V++){M=k[V];I.empty();if(M instanceof THREE.RenderableParticle){x=M;x.x*=B;x.y*=-A;w=0;for(r=M.material.length;w<
|
|
|
-r;w++)if(T=M.material[w]){N=x;S=M;T=T;var aa=Q++;if(y[aa]==null){y[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&y[aa].setAttribute("shape-rendering","crispEdges")}q=y[aa];q.setAttribute("cx",N.x);q.setAttribute("cy",N.y);q.setAttribute("r",S.scale.x*B);if(T instanceof THREE.ParticleCircleMaterial){if(O){f.r=m.r+e.r+p.r;f.g=m.g+e.g+p.g;f.b=m.b+e.b+p.b;E.r=T.color.r*f.r;E.g=T.color.g*f.g;E.b=T.color.b*f.b;E.updateStyleString()}else E=T.color;q.setAttribute("style","fill: "+
|
|
|
-E.__styleString)}j.appendChild(q)}}else if(M instanceof THREE.RenderableLine){x=M.v1;v=M.v2;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);if(J.instersects(I)){w=0;for(r=M.material.length;w<r;)if(T=M.material[w++]){N=x;S=v;T=T;aa=t++;if(D[aa]==null){D[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");U==0&&D[aa].setAttribute("shape-rendering",
|
|
|
-"crispEdges")}q=D[aa];q.setAttribute("x1",N.positionScreen.x);q.setAttribute("y1",N.positionScreen.y);q.setAttribute("x2",S.positionScreen.x);q.setAttribute("y2",S.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){E.__styleString=T.color.__styleString;q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin);j.appendChild(q)}}}}else if(M instanceof THREE.RenderableFace3){x=
|
|
|
-M.v1;v=M.v2;H=M.v3;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;H.positionScreen.x*=B;H.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(H.positionScreen.x,H.positionScreen.y);if(J.instersects(I)){w=0;for(r=M.meshMaterial.length;w<r;){T=M.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=M.faceMaterial.length;N<S;)(T=M.faceMaterial[N++])&&b(x,v,H,M,T,P)}else T&&
|
|
|
-b(x,v,H,M,T,P)}}}else if(M instanceof THREE.RenderableFace4){x=M.v1;v=M.v2;H=M.v3;L=M.v4;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;H.positionScreen.x*=B;H.positionScreen.y*=-A;L.positionScreen.x*=B;L.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(H.positionScreen.x,H.positionScreen.y);I.addPoint(L.positionScreen.x,L.positionScreen.y);if(J.instersects(I)){w=0;for(r=M.meshMaterial.length;w<
|
|
|
-r;){T=M.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=M.faceMaterial.length;N<S;)(T=M.faceMaterial[N++])&&g(x,v,H,L,M,T,P)}else T&&g(x,v,H,L,M,T,P)}}}}}};
|
|
|
+p=new THREE.Color(0),l,h=new THREE.Vector3,u=[],y=[],D=[],q,C,Q,t,U=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,X){n=P;c=X;B=n/2;A=c/2;j.setAttribute("viewBox",-B+" "+-A+" "+n+" "+c);j.setAttribute("width",n);j.setAttribute("height",c);J.set(-B,-A,B,A)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(P,X){var V,F,
|
|
|
+w,r,N,S,M,T;this.autoClear&&this.clear();k=o.projectScene(P,X,this.sortElements);t=Q=C=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(F=M.length;V<F;V++){w=M[V];r=w.color;if(w instanceof THREE.AmbientLight){m.r+=r.r;m.g+=r.g;m.b+=r.b}else if(w instanceof THREE.DirectionalLight){e.r+=r.r;e.g+=r.g;e.b+=r.b}else if(w instanceof THREE.PointLight){p.r+=r.r;p.g+=r.g;p.b+=r.b}}}V=0;for(F=k.length;V<F;V++){M=k[V];I.empty();if(M instanceof THREE.RenderableParticle){x=
|
|
|
+M;x.x*=B;x.y*=-A;w=0;for(r=M.material.length;w<r;w++)if(T=M.material[w]){N=x;S=M;T=T;var aa=Q++;if(y[aa]==null){y[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&y[aa].setAttribute("shape-rendering","crispEdges")}q=y[aa];q.setAttribute("cx",N.x);q.setAttribute("cy",N.y);q.setAttribute("r",S.scale.x*B);if(T instanceof THREE.ParticleCircleMaterial){if(O){f.r=m.r+e.r+p.r;f.g=m.g+e.g+p.g;f.b=m.b+e.b+p.b;E.r=T.color.r*f.r;E.g=T.color.g*f.g;E.b=T.color.b*f.b;E.updateStyleString()}else E=
|
|
|
+T.color;q.setAttribute("style","fill: "+E.__styleString)}j.appendChild(q)}}else if(M instanceof THREE.RenderableLine){x=M.v1;v=M.v2;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);if(J.instersects(I)){w=0;for(r=M.material.length;w<r;)if(T=M.material[w++]){N=x;S=v;T=T;aa=t++;if(D[aa]==null){D[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");
|
|
|
+U==0&&D[aa].setAttribute("shape-rendering","crispEdges")}q=D[aa];q.setAttribute("x1",N.positionScreen.x);q.setAttribute("y1",N.positionScreen.y);q.setAttribute("x2",S.positionScreen.x);q.setAttribute("y2",S.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){E.__styleString=T.color.__styleString;q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin);j.appendChild(q)}}}}else if(M instanceof
|
|
|
+THREE.RenderableFace3){x=M.v1;v=M.v2;H=M.v3;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;H.positionScreen.x*=B;H.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(H.positionScreen.x,H.positionScreen.y);if(J.instersects(I)){w=0;for(r=M.meshMaterial.length;w<r;){T=M.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=M.faceMaterial.length;N<S;)(T=M.faceMaterial[N++])&&
|
|
|
+b(x,v,H,M,T,P)}else T&&b(x,v,H,M,T,P)}}}else if(M instanceof THREE.RenderableFace4){x=M.v1;v=M.v2;H=M.v3;L=M.v4;x.positionScreen.x*=B;x.positionScreen.y*=-A;v.positionScreen.x*=B;v.positionScreen.y*=-A;H.positionScreen.x*=B;H.positionScreen.y*=-A;L.positionScreen.x*=B;L.positionScreen.y*=-A;I.addPoint(x.positionScreen.x,x.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(H.positionScreen.x,H.positionScreen.y);I.addPoint(L.positionScreen.x,L.positionScreen.y);if(J.instersects(I)){w=
|
|
|
+0;for(r=M.meshMaterial.length;w<r;){T=M.meshMaterial[w++];if(T instanceof THREE.MeshFaceMaterial){N=0;for(S=M.faceMaterial.length;N<S;)(T=M.faceMaterial[N++])&&g(x,v,H,L,M,T,P)}else T&&g(x,v,H,L,M,T,P)}}}}}};
|
|
|
THREE.WebGLRenderer=function(a){function b(f,m){var e=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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;\n"].join("\n");c.attachShader(e,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+
|
|
|
f));c.attachShader(e,o("vertex",p+m));c.linkProgram(e);c.getProgramParameter(e,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(e,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");e.uniforms={};e.attributes={};return e}function g(f,m){if(f.image.length==6){if(!f.image.__webGLTextureCube&&!f.image.__cubeMapInitialized&&f.image.loadCount==6){f.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,f.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
|
|
|
c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var e=0;e<6;++e)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image[e]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);f.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP,
|