Browse Source

Merge branch 'master' into gui

zz85 14 years ago
parent
commit
13c08981db

+ 1 - 1
README.md

@@ -143,7 +143,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
 * Added `.depthWrite` and `.fog` to `Material`. ([alteredq](http://github.com/alteredq))
 * Added `.depthWrite` and `.fog` to `Material`. ([alteredq](http://github.com/alteredq))
 * Added `.applyMatrix` to `Geometry`. ([mrdoob](http://github.com/mrdoob))
 * Added `.applyMatrix` to `Geometry`. ([mrdoob](http://github.com/mrdoob))
 * Improved postprocessing stack in `/examples/js/postprocessing`. ([alteredq](http://github.com/alteredq))
 * Improved postprocessing stack in `/examples/js/postprocessing`. ([alteredq](http://github.com/alteredq))
-* Added a realistic sking shading example. ([alteredq](http://github.com/alteredq))
+* Added a realistic skin shading example. ([alteredq](http://github.com/alteredq))
 * Started of a GUI for composing scenes and autogenerate code. ([mrdoob](http://github.com/mrdoob))
 * Started of a GUI for composing scenes and autogenerate code. ([mrdoob](http://github.com/mrdoob))
 * Added `.center()` to `GeometryUtils`. ([alteredq](http://github.com/alteredq))
 * Added `.center()` to `GeometryUtils`. ([alteredq](http://github.com/alteredq))
 * Fixed buggy scenegraph manipulation (adding/removing objects). ([jsermeno](http://github.com/jsermeno), [alteredq](http://github.com/alteredq) and [skython](http://github.com/skython))
 * Fixed buggy scenegraph manipulation (adding/removing objects). ([jsermeno](http://github.com/jsermeno), [alteredq](http://github.com/alteredq) and [skython](http://github.com/skython))

File diff suppressed because it is too large
+ 18 - 20
build/Three.js


+ 15 - 17
build/custom/ThreeCanvas.js

@@ -54,17 +54,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){thi
 a)return f;if(b&&(f=f.getChildByName(a,b),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 a)return f;if(b&&(f=f.getChildByName(a,b),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(a)}};THREE.Object3DCount=0;
 this.remove(a)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function a(){var a=m[h]=m[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,j=-b.z+b.w;return e>=0&&f>=0&&g>=0&&j>=0?!0:e<0&&f<0||g<0&&j<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-j)):j<0&&(d=Math.min(d,g/(g-j))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,e=[],g,h,m=[],k,l,i=[],n,j=[],r,t,w=[],u,M,R=[],B=[],N=[],O=new THREE.Vector4,s=new THREE.Vector4,
-o=new THREE.Matrix4,C=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],T=new THREE.Vector4,U=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,g){var j,h;f=B.length=0;j=a.objects;a=0;for(c=j.length;a<c;a++){h=j[a];var i;if(!(i=!h.visible))if(i=h instanceof THREE.Mesh)if(i=h.frustumCulled){a:{i=void 0;for(var k=h.matrixWorld,m=-h.geometry.boundingSphere.radius*Math.max(h.scale.x,Math.max(h.scale.y,h.scale.z)),l=0;l<6;l++)if(i=D[l].x*k.n14+D[l].y*k.n24+D[l].z*k.n34+D[l].w,i<=m){i=!1;break a}i=!0}i=
-!i}if(!i)i=e[f]=e[f]||new THREE.RenderableObject,f++,d=i,O.copy(h.position),o.multiplyVector3(O),d.object=h,d.z=O.z,B.push(d)}g&&B.sort(b);return B};this.projectScene=function(d,e,f){var J=e.near,P=e.far,Q,V,E,B,y,L,H,z,x,q,v,G,O,ea,Z,ba,W;M=t=n=l=N.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);D[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);D[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);D[2].set(o.n41+
-o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);D[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);D[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);D[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(Q=0;Q<6;Q++)x=D[Q],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,e,!0);d=0;for(Q=x.length;d<Q;d++)if(q=x[d].object,q.visible)if(v=q.matrixWorld,G=q.matrixRotationWorld,O=q.materials,ea=q.overdraw,h=0,q instanceof THREE.Mesh){Z=q.geometry;B=Z.vertices;
-ba=Z.faces;Z=Z.faceVertexUvs;V=0;for(E=B.length;V<E;V++)g=a(),g.positionWorld.copy(B[V].position),v.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),o.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>J&&g.positionScreen.z<P;B=0;for(V=ba.length;B<V;B++){E=ba[B];if(E instanceof THREE.Face3)if(y=m[E.a],L=m[E.b],H=m[E.c],y.visible&&L.visible&&H.visible&&(q.doubleSided||q.flipSided!=(H.positionScreen.x-
-y.positionScreen.x)*(L.positionScreen.y-y.positionScreen.y)-(H.positionScreen.y-y.positionScreen.y)*(L.positionScreen.x-y.positionScreen.x)<0))z=i[l]=i[l]||new THREE.RenderableFace3,l++,k=z,k.v1.copy(y),k.v2.copy(L),k.v3.copy(H);else continue;else if(E instanceof THREE.Face4)if(y=m[E.a],L=m[E.b],H=m[E.c],z=m[E.d],y.visible&&L.visible&&H.visible&&z.visible&&(q.doubleSided||q.flipSided!=((z.positionScreen.x-y.positionScreen.x)*(L.positionScreen.y-y.positionScreen.y)-(z.positionScreen.y-y.positionScreen.y)*
-(L.positionScreen.x-y.positionScreen.x)<0||(L.positionScreen.x-H.positionScreen.x)*(z.positionScreen.y-H.positionScreen.y)-(L.positionScreen.y-H.positionScreen.y)*(z.positionScreen.x-H.positionScreen.x)<0)))W=j[n]=j[n]||new THREE.RenderableFace4,n++,k=W,k.v1.copy(y),k.v2.copy(L),k.v3.copy(H),k.v4.copy(z);else continue;k.normalWorld.copy(E.normal);G.multiplyVector3(k.normalWorld);k.centroidWorld.copy(E.centroid);v.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);o.multiplyVector3(k.centroidScreen);
-H=E.vertexNormals;y=0;for(L=H.length;y<L;y++)z=k.vertexNormalsWorld[y],z.copy(H[y]),G.multiplyVector3(z);y=0;for(L=Z.length;y<L;y++)if(W=Z[y][B]){H=0;for(z=W.length;H<z;H++)k.uvs[y][H]=W[H]}k.meshMaterials=O;k.faceMaterials=E.materials;k.overdraw=ea;k.z=k.centroidScreen.z;N.push(k)}}else if(q instanceof THREE.Line){C.multiply(o,v);B=q.geometry.vertices;y=a();y.positionScreen.copy(B[0].position);C.multiplyVector4(y.positionScreen);V=1;for(E=B.length;V<E;V++)if(y=a(),y.positionScreen.copy(B[V].position),
-C.multiplyVector4(y.positionScreen),L=m[h-2],T.copy(y.positionScreen),U.copy(L.positionScreen),c(T,U))T.multiplyScalar(1/T.w),U.multiplyScalar(1/U.w),v=w[t]=w[t]||new THREE.RenderableLine,t++,r=v,r.v1.positionScreen.copy(T),r.v2.positionScreen.copy(U),r.z=Math.max(T.z,U.z),r.materials=q.materials,N.push(r)}else if(q instanceof THREE.Particle&&(s.set(q.matrixWorld.n14,q.matrixWorld.n24,q.matrixWorld.n34,1),o.multiplyVector4(s),s.z/=s.w,s.z>0&&s.z<1))v=R[M]=R[M]||new THREE.RenderableParticle,M++,u=
-v,u.x=s.x/s.w,u.y=s.y/s.w,u.z=s.z,u.rotation=q.rotation.z,u.scale.x=q.scale.x*Math.abs(u.x-(s.x+e.projectionMatrix.n11)/(s.w+e.projectionMatrix.n14)),u.scale.y=q.scale.y*Math.abs(u.y-(s.y+e.projectionMatrix.n22)/(s.w+e.projectionMatrix.n24)),u.materials=q.materials,N.push(u);f&&N.sort(b);return N}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+THREE.Projector=function(){function a(){var a=m[h]=m[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,j=-b.z+b.w;return e>=0&&f>=0&&g>=0&&j>=0?!0:e<0&&f<0||g<0&&j<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-j)):j<0&&(d=Math.min(d,g/(g-j))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,e=[],g,h,m=[],k,l,i=[],n,j=[],r,t,w=[],u,M,R=[],B=[],N=[],O=new THREE.Vector3,s=new THREE.Vector4,
+o=new THREE.Matrix4,C=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],T=new THREE.Vector4,U=new THREE.Vector4;this.projectVector=function(a,b){THREE.Matrix4.makeInvert(b.matrixWorld,b.matrixWorldInverse);o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,g){var j,h;f=B.length=0;j=a.objects;a=0;for(c=j.length;a<c;a++){h=j[a];var i;if(!(i=!h.visible))if(i=h instanceof THREE.Mesh)if(i=h.frustumCulled){a:{i=void 0;for(var k=h.matrixWorld,m=-h.geometry.boundingSphere.radius*Math.max(h.scale.x,Math.max(h.scale.y,h.scale.z)),l=0;l<6;l++)if(i=D[l].x*
+k.n14+D[l].y*k.n24+D[l].z*k.n34+D[l].w,i<=m){i=!1;break a}i=!0}i=!i}if(!i)i=e[f]=e[f]||new THREE.RenderableObject,f++,d=i,O.copy(h.position),o.multiplyVector3(O),d.object=h,d.z=O.z,B.push(d)}g&&B.sort(b);return B};this.projectScene=function(d,e,f){var J=e.near,P=e.far,Q,V,E,B,y,L,H,z,x,q,v,G,O,ea,Z,ba,W;M=t=n=l=N.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);THREE.Matrix4.makeInvert(e.matrixWorld,e.matrixWorldInverse);o.multiply(e.projectionMatrix,e.matrixWorldInverse);D[0].set(o.n41-
+o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);D[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);D[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);D[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);D[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);D[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(Q=0;Q<6;Q++)x=D[Q],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,e,!0);d=0;for(Q=x.length;d<Q;d++)if(q=x[d].object,q.visible)if(v=q.matrixWorld,
+G=q.matrixRotationWorld,O=q.materials,ea=q.overdraw,h=0,q instanceof THREE.Mesh){Z=q.geometry;B=Z.vertices;ba=Z.faces;Z=Z.faceVertexUvs;V=0;for(E=B.length;V<E;V++)g=a(),g.positionWorld.copy(B[V].position),v.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),o.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>J&&g.positionScreen.z<P;B=0;for(V=ba.length;B<V;B++){E=ba[B];if(E instanceof THREE.Face3)if(y=
+m[E.a],L=m[E.b],H=m[E.c],y.visible&&L.visible&&H.visible&&(q.doubleSided||q.flipSided!=(H.positionScreen.x-y.positionScreen.x)*(L.positionScreen.y-y.positionScreen.y)-(H.positionScreen.y-y.positionScreen.y)*(L.positionScreen.x-y.positionScreen.x)<0))z=i[l]=i[l]||new THREE.RenderableFace3,l++,k=z,k.v1.copy(y),k.v2.copy(L),k.v3.copy(H);else continue;else if(E instanceof THREE.Face4)if(y=m[E.a],L=m[E.b],H=m[E.c],z=m[E.d],y.visible&&L.visible&&H.visible&&z.visible&&(q.doubleSided||q.flipSided!=((z.positionScreen.x-
+y.positionScreen.x)*(L.positionScreen.y-y.positionScreen.y)-(z.positionScreen.y-y.positionScreen.y)*(L.positionScreen.x-y.positionScreen.x)<0||(L.positionScreen.x-H.positionScreen.x)*(z.positionScreen.y-H.positionScreen.y)-(L.positionScreen.y-H.positionScreen.y)*(z.positionScreen.x-H.positionScreen.x)<0)))W=j[n]=j[n]||new THREE.RenderableFace4,n++,k=W,k.v1.copy(y),k.v2.copy(L),k.v3.copy(H),k.v4.copy(z);else continue;k.normalWorld.copy(E.normal);G.multiplyVector3(k.normalWorld);k.centroidWorld.copy(E.centroid);
+v.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);o.multiplyVector3(k.centroidScreen);H=E.vertexNormals;y=0;for(L=H.length;y<L;y++)z=k.vertexNormalsWorld[y],z.copy(H[y]),G.multiplyVector3(z);y=0;for(L=Z.length;y<L;y++)if(W=Z[y][B]){H=0;for(z=W.length;H<z;H++)k.uvs[y][H]=W[H]}k.meshMaterials=O;k.faceMaterials=E.materials;k.overdraw=ea;k.z=k.centroidScreen.z;N.push(k)}}else if(q instanceof THREE.Line){C.multiply(o,v);B=q.geometry.vertices;y=a();y.positionScreen.copy(B[0].position);
+C.multiplyVector4(y.positionScreen);V=1;for(E=B.length;V<E;V++)if(y=a(),y.positionScreen.copy(B[V].position),C.multiplyVector4(y.positionScreen),L=m[h-2],T.copy(y.positionScreen),U.copy(L.positionScreen),c(T,U))T.multiplyScalar(1/T.w),U.multiplyScalar(1/U.w),v=w[t]=w[t]||new THREE.RenderableLine,t++,r=v,r.v1.positionScreen.copy(T),r.v2.positionScreen.copy(U),r.z=Math.max(T.z,U.z),r.materials=q.materials,N.push(r)}else if(q instanceof THREE.Particle&&(s.set(q.matrixWorld.n14,q.matrixWorld.n24,q.matrixWorld.n34,
+1),o.multiplyVector4(s),s.z/=s.w,s.z>0&&s.z<1))v=R[M]=R[M]||new THREE.RenderableParticle,M++,u=v,u.x=s.x/s.w,u.y=s.y/s.w,u.z=s.z,u.rotation=q.rotation.z,u.scale.x=q.scale.x*Math.abs(u.x-(s.x+e.projectionMatrix.n11)/(s.w+e.projectionMatrix.n14)),u.scale.y=q.scale.y*Math.abs(u.y-(s.y+e.projectionMatrix.n22)/(s.w+e.projectionMatrix.n24)),u.materials=q.materials,N.push(u);f&&N.sort(b);return N}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -84,12 +84,10 @@ D[c].addSelf(U);D[d].addSelf(U)}var b,c,d,f,e,g,h,m,k,l,i,n,j,r,t,w,u,M,R,B,N,O,
 this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
 this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
 a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g;e=0;for(g=this.vertices.length;e<g;e++)d=this.vertices[e].position,d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_"),a[d]===void 0?(a[d]=e,b.push(this.vertices[e]),
 a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g;e=0;for(g=this.vertices.length;e<g;e++)d=this.vertices[e].position,d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_"),a[d]===void 0?(a[d]=e,b.push(this.vertices[e]),
 c[e]=b.length-1):c[e]=c[a[d]];e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];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;
 c[e]=b.length-1):c[e]=c[a[d]];e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d]}this.vertices=b}};THREE.GeometryCount=0;
-THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};
-THREE.Camera.prototype.update=function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
-THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e: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)};
-THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};
-THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
+THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.projectionMatrix=new THREE.Matrix4;this.matrixWorldInverse=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.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e: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)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
 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,
 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,
 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;
 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;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;

+ 15 - 17
build/custom/ThreeDOM.js

@@ -54,17 +54,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){thi
 a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(a)}};THREE.Object3DCount=0;
 this.remove(a)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function a(){var a=k[h]=k[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(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;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,k=[],i,j,l=[],n,m=[],p,q,s=[],r,J,M=[],C=[],D=[],H=new THREE.Vector4,v=new THREE.Vector4,
-o=new THREE.Matrix4,K=new THREE.Matrix4,z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,f){var h,i;e=C.length=0;h=a.objects;a=0;for(c=h.length;a<c;a++){i=h[a];var j;if(!(j=!i.visible))if(j=i instanceof THREE.Mesh)if(j=i.frustumCulled){a:{j=void 0;for(var k=i.matrixWorld,l=-i.geometry.boundingSphere.radius*Math.max(i.scale.x,Math.max(i.scale.y,i.scale.z)),m=0;m<6;m++)if(j=z[m].x*k.n14+z[m].y*k.n24+z[m].z*k.n34+z[m].w,j<=l){j=!1;break a}j=!0}j=
-!j}if(!j)j=g[e]=g[e]||new THREE.RenderableObject,e++,d=j,H.copy(i.position),o.multiplyVector3(H),d.object=i,d.z=H.z,C.push(d)}f&&C.sort(b);return C};this.projectScene=function(d,e,g){var C=e.near,H=e.far,O,I,x,B,t,y,w,A,G,u,L,V,X,Y,N,W,P;J=q=n=j=D.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);z[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);z[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);z[2].set(o.n41+
-o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);z[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);z[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);z[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(O=0;O<6;O++)G=z[O],G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z));G=this.projectObjects(d,e,!0);d=0;for(O=G.length;d<O;d++)if(u=G[d].object,u.visible)if(L=u.matrixWorld,V=u.matrixRotationWorld,X=u.materials,Y=u.overdraw,h=0,u instanceof THREE.Mesh){N=u.geometry;B=N.vertices;W=
-N.faces;N=N.faceVertexUvs;I=0;for(x=B.length;I<x;I++)f=a(),f.positionWorld.copy(B[I].position),L.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>C&&f.positionScreen.z<H;B=0;for(I=W.length;B<I;B++){x=W[B];if(x instanceof THREE.Face3)if(t=k[x.a],y=k[x.b],w=k[x.c],t.visible&&y.visible&&w.visible&&(u.doubleSided||u.flipSided!=(w.positionScreen.x-
-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(w.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0))A=l[j]=l[j]||new THREE.RenderableFace3,j++,i=A,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w);else continue;else if(x instanceof THREE.Face4)if(t=k[x.a],y=k[x.b],w=k[x.c],A=k[x.d],t.visible&&y.visible&&w.visible&&A.visible&&(u.doubleSided||u.flipSided!=((A.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*
-(y.positionScreen.x-t.positionScreen.x)<0||(y.positionScreen.x-w.positionScreen.x)*(A.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(A.positionScreen.x-w.positionScreen.x)<0)))P=m[n]=m[n]||new THREE.RenderableFace4,n++,i=P,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w),i.v4.copy(A);else continue;i.normalWorld.copy(x.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(x.centroid);L.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);
-w=x.vertexNormals;t=0;for(y=w.length;t<y;t++)A=i.vertexNormalsWorld[t],A.copy(w[t]),V.multiplyVector3(A);t=0;for(y=N.length;t<y;t++)if(P=N[t][B]){w=0;for(A=P.length;w<A;w++)i.uvs[t][w]=P[w]}i.meshMaterials=X;i.faceMaterials=x.materials;i.overdraw=Y;i.z=i.centroidScreen.z;D.push(i)}}else if(u instanceof THREE.Line){K.multiply(o,L);B=u.geometry.vertices;t=a();t.positionScreen.copy(B[0].position);K.multiplyVector4(t.positionScreen);I=1;for(x=B.length;I<x;I++)if(t=a(),t.positionScreen.copy(B[I].position),
-K.multiplyVector4(t.positionScreen),y=k[h-2],E.copy(t.positionScreen),F.copy(y.positionScreen),c(E,F))E.multiplyScalar(1/E.w),F.multiplyScalar(1/F.w),L=s[q]=s[q]||new THREE.RenderableLine,q++,p=L,p.v1.positionScreen.copy(E),p.v2.positionScreen.copy(F),p.z=Math.max(E.z,F.z),p.materials=u.materials,D.push(p)}else if(u instanceof THREE.Particle&&(v.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,1),o.multiplyVector4(v),v.z/=v.w,v.z>0&&v.z<1))L=M[J]=M[J]||new THREE.RenderableParticle,J++,r=
-L,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=u.rotation.z,r.scale.x=u.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=u.scale.y*Math.abs(r.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.materials=u.materials,D.push(r);g&&D.sort(b);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+THREE.Projector=function(){function a(){var a=k[h]=k[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(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;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,k=[],i,j,l=[],n,m=[],p,q,s=[],r,J,M=[],C=[],D=[],H=new THREE.Vector3,v=new THREE.Vector4,
+o=new THREE.Matrix4,K=new THREE.Matrix4,z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(a,b){THREE.Matrix4.makeInvert(b.matrixWorld,b.matrixWorldInverse);o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,f){var h,i;e=C.length=0;h=a.objects;a=0;for(c=h.length;a<c;a++){i=h[a];var j;if(!(j=!i.visible))if(j=i instanceof THREE.Mesh)if(j=i.frustumCulled){a:{j=void 0;for(var k=i.matrixWorld,l=-i.geometry.boundingSphere.radius*Math.max(i.scale.x,Math.max(i.scale.y,i.scale.z)),m=0;m<6;m++)if(j=z[m].x*
+k.n14+z[m].y*k.n24+z[m].z*k.n34+z[m].w,j<=l){j=!1;break a}j=!0}j=!j}if(!j)j=g[e]=g[e]||new THREE.RenderableObject,e++,d=j,H.copy(i.position),o.multiplyVector3(H),d.object=i,d.z=H.z,C.push(d)}f&&C.sort(b);return C};this.projectScene=function(d,e,g){var C=e.near,H=e.far,O,I,x,B,t,y,w,A,G,u,L,V,X,Y,N,W,P;J=q=n=j=D.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);THREE.Matrix4.makeInvert(e.matrixWorld,e.matrixWorldInverse);o.multiply(e.projectionMatrix,e.matrixWorldInverse);z[0].set(o.n41-
+o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);z[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);z[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);z[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);z[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);z[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(O=0;O<6;O++)G=z[O],G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z));G=this.projectObjects(d,e,!0);d=0;for(O=G.length;d<O;d++)if(u=G[d].object,u.visible)if(L=u.matrixWorld,
+V=u.matrixRotationWorld,X=u.materials,Y=u.overdraw,h=0,u instanceof THREE.Mesh){N=u.geometry;B=N.vertices;W=N.faces;N=N.faceVertexUvs;I=0;for(x=B.length;I<x;I++)f=a(),f.positionWorld.copy(B[I].position),L.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>C&&f.positionScreen.z<H;B=0;for(I=W.length;B<I;B++){x=W[B];if(x instanceof THREE.Face3)if(t=
+k[x.a],y=k[x.b],w=k[x.c],t.visible&&y.visible&&w.visible&&(u.doubleSided||u.flipSided!=(w.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(w.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0))A=l[j]=l[j]||new THREE.RenderableFace3,j++,i=A,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w);else continue;else if(x instanceof THREE.Face4)if(t=k[x.a],y=k[x.b],w=k[x.c],A=k[x.d],t.visible&&y.visible&&w.visible&&A.visible&&(u.doubleSided||u.flipSided!=((A.positionScreen.x-
+t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0||(y.positionScreen.x-w.positionScreen.x)*(A.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(A.positionScreen.x-w.positionScreen.x)<0)))P=m[n]=m[n]||new THREE.RenderableFace4,n++,i=P,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w),i.v4.copy(A);else continue;i.normalWorld.copy(x.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(x.centroid);
+L.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);w=x.vertexNormals;t=0;for(y=w.length;t<y;t++)A=i.vertexNormalsWorld[t],A.copy(w[t]),V.multiplyVector3(A);t=0;for(y=N.length;t<y;t++)if(P=N[t][B]){w=0;for(A=P.length;w<A;w++)i.uvs[t][w]=P[w]}i.meshMaterials=X;i.faceMaterials=x.materials;i.overdraw=Y;i.z=i.centroidScreen.z;D.push(i)}}else if(u instanceof THREE.Line){K.multiply(o,L);B=u.geometry.vertices;t=a();t.positionScreen.copy(B[0].position);
+K.multiplyVector4(t.positionScreen);I=1;for(x=B.length;I<x;I++)if(t=a(),t.positionScreen.copy(B[I].position),K.multiplyVector4(t.positionScreen),y=k[h-2],E.copy(t.positionScreen),F.copy(y.positionScreen),c(E,F))E.multiplyScalar(1/E.w),F.multiplyScalar(1/F.w),L=s[q]=s[q]||new THREE.RenderableLine,q++,p=L,p.v1.positionScreen.copy(E),p.v2.positionScreen.copy(F),p.z=Math.max(E.z,F.z),p.materials=u.materials,D.push(p)}else if(u instanceof THREE.Particle&&(v.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,
+1),o.multiplyVector4(v),v.z/=v.w,v.z>0&&v.z<1))L=M[J]=M[J]||new THREE.RenderableParticle,J++,r=L,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=u.rotation.z,r.scale.x=u.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=u.scale.y*Math.abs(r.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.materials=u.materials,D.push(r);g&&D.sort(b);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -73,12 +73,10 @@ c-f*d-h*e;b.x=i*k+c*-g+j*-h-l*-f;b.y=j*k+c*-f+l*-g-i*-h;b.z=l*k+c*-h+i*-f-j*-g;r
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};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},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
-THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};
-THREE.Camera.prototype.update=function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
-THREE.OrthographicCamera=function(a,b,c,d,e,g){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=g!==void 0?g:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};
-THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};
-THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
+THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.projectionMatrix=new THREE.Matrix4;this.matrixWorldInverse=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.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,g){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=g!==void 0?g:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
+THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 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,
 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,
 this.far)};THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;
 this.far)};THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;
 THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.supr=THREE.Object3D.prototype;

File diff suppressed because it is too large
+ 12 - 12
build/custom/ThreeExtras.js


+ 15 - 17
build/custom/ThreeSVG.js

@@ -54,17 +54,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){thi
 a)return f;if(b&&(f=f.getChildByName(a,b),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 a)return f;if(b&&(f=f.getChildByName(a,b),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)},addChild:function(a){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(a)},removeChild:function(a){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(a)}};THREE.Object3DCount=0;
 this.remove(a)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function a(){var a=k[i]=k[i]||new THREE.RenderableVertex;i++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,i=-b.z+b.w;return e>=0&&f>=0&&g>=0&&i>=0?!0:e<0&&f<0||g<0&&i<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-i)):i<0&&(d=Math.min(d,g/(g-i))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,e=[],g,i,k=[],h,j,m=[],n,l=[],p,q,v=[],u,C,K=[],t=[],w=[],z=new THREE.Vector4,y=new THREE.Vector4,
-o=new THREE.Matrix4,E=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,g){var i,k;f=t.length=0;i=a.objects;a=0;for(c=i.length;a<c;a++){k=i[a];var h;if(!(h=!k.visible))if(h=k instanceof THREE.Mesh)if(h=k.frustumCulled){a:{h=void 0;for(var j=k.matrixWorld,m=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),l=0;l<6;l++)if(h=D[l].x*j.n14+D[l].y*j.n24+D[l].z*j.n34+D[l].w,h<=m){h=!1;break a}h=!0}h=
-!h}if(!h)h=e[f]=e[f]||new THREE.RenderableObject,f++,d=h,z.copy(k.position),o.multiplyVector3(z),d.object=k,d.z=z.z,t.push(d)}g&&t.sort(b);return t};this.projectScene=function(d,e,f){var t=e.near,S=e.far,z,P,I,L,r,J,H,s,x,B,Q,U,W,X,R,V,T;C=q=n=j=w.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);D[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);D[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);D[2].set(o.n41+
-o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);D[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);D[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);D[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(z=0;z<6;z++)x=D[z],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,e,!0);d=0;for(z=x.length;d<z;d++)if(B=x[d].object,B.visible)if(Q=B.matrixWorld,U=B.matrixRotationWorld,W=B.materials,X=B.overdraw,i=0,B instanceof THREE.Mesh){R=B.geometry;L=R.vertices;V=
-R.faces;R=R.faceVertexUvs;P=0;for(I=L.length;P<I;P++)g=a(),g.positionWorld.copy(L[P].position),Q.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),o.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>t&&g.positionScreen.z<S;L=0;for(P=V.length;L<P;L++){I=V[L];if(I instanceof THREE.Face3)if(r=k[I.a],J=k[I.b],H=k[I.c],r.visible&&J.visible&&H.visible&&(B.doubleSided||B.flipSided!=(H.positionScreen.x-
-r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(H.positionScreen.y-r.positionScreen.y)*(J.positionScreen.x-r.positionScreen.x)<0))s=m[j]=m[j]||new THREE.RenderableFace3,j++,h=s,h.v1.copy(r),h.v2.copy(J),h.v3.copy(H);else continue;else if(I instanceof THREE.Face4)if(r=k[I.a],J=k[I.b],H=k[I.c],s=k[I.d],r.visible&&J.visible&&H.visible&&s.visible&&(B.doubleSided||B.flipSided!=((s.positionScreen.x-r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(s.positionScreen.y-r.positionScreen.y)*
-(J.positionScreen.x-r.positionScreen.x)<0||(J.positionScreen.x-H.positionScreen.x)*(s.positionScreen.y-H.positionScreen.y)-(J.positionScreen.y-H.positionScreen.y)*(s.positionScreen.x-H.positionScreen.x)<0)))T=l[n]=l[n]||new THREE.RenderableFace4,n++,h=T,h.v1.copy(r),h.v2.copy(J),h.v3.copy(H),h.v4.copy(s);else continue;h.normalWorld.copy(I.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(I.centroid);Q.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);o.multiplyVector3(h.centroidScreen);
-H=I.vertexNormals;r=0;for(J=H.length;r<J;r++)s=h.vertexNormalsWorld[r],s.copy(H[r]),U.multiplyVector3(s);r=0;for(J=R.length;r<J;r++)if(T=R[r][L]){H=0;for(s=T.length;H<s;H++)h.uvs[r][H]=T[H]}h.meshMaterials=W;h.faceMaterials=I.materials;h.overdraw=X;h.z=h.centroidScreen.z;w.push(h)}}else if(B instanceof THREE.Line){E.multiply(o,Q);L=B.geometry.vertices;r=a();r.positionScreen.copy(L[0].position);E.multiplyVector4(r.positionScreen);P=1;for(I=L.length;P<I;P++)if(r=a(),r.positionScreen.copy(L[P].position),
-E.multiplyVector4(r.positionScreen),J=k[i-2],F.copy(r.positionScreen),G.copy(J.positionScreen),c(F,G))F.multiplyScalar(1/F.w),G.multiplyScalar(1/G.w),Q=v[q]=v[q]||new THREE.RenderableLine,q++,p=Q,p.v1.positionScreen.copy(F),p.v2.positionScreen.copy(G),p.z=Math.max(F.z,G.z),p.materials=B.materials,w.push(p)}else if(B instanceof THREE.Particle&&(y.set(B.matrixWorld.n14,B.matrixWorld.n24,B.matrixWorld.n34,1),o.multiplyVector4(y),y.z/=y.w,y.z>0&&y.z<1))Q=K[C]=K[C]||new THREE.RenderableParticle,C++,u=
-Q,u.x=y.x/y.w,u.y=y.y/y.w,u.z=y.z,u.rotation=B.rotation.z,u.scale.x=B.scale.x*Math.abs(u.x-(y.x+e.projectionMatrix.n11)/(y.w+e.projectionMatrix.n14)),u.scale.y=B.scale.y*Math.abs(u.y-(y.y+e.projectionMatrix.n22)/(y.w+e.projectionMatrix.n24)),u.materials=B.materials,w.push(u);f&&w.sort(b);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+THREE.Projector=function(){function a(){var a=k[i]=k[i]||new THREE.RenderableVertex;i++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,i=-b.z+b.w;return e>=0&&f>=0&&g>=0&&i>=0?!0:e<0&&f<0||g<0&&i<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-i)):i<0&&(d=Math.min(d,g/(g-i))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,e=[],g,i,k=[],h,j,m=[],n,l=[],p,q,v=[],u,C,K=[],t=[],w=[],z=new THREE.Vector3,y=new THREE.Vector4,
+o=new THREE.Matrix4,E=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4;this.projectVector=function(a,b){THREE.Matrix4.makeInvert(b.matrixWorld,b.matrixWorldInverse);o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.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.projectObjects=function(a,c,g){var i,k;f=t.length=0;i=a.objects;a=0;for(c=i.length;a<c;a++){k=i[a];var h;if(!(h=!k.visible))if(h=k instanceof THREE.Mesh)if(h=k.frustumCulled){a:{h=void 0;for(var j=k.matrixWorld,m=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),l=0;l<6;l++)if(h=D[l].x*
+j.n14+D[l].y*j.n24+D[l].z*j.n34+D[l].w,h<=m){h=!1;break a}h=!0}h=!h}if(!h)h=e[f]=e[f]||new THREE.RenderableObject,f++,d=h,z.copy(k.position),o.multiplyVector3(z),d.object=k,d.z=z.z,t.push(d)}g&&t.sort(b);return t};this.projectScene=function(d,e,f){var t=e.near,S=e.far,z,P,I,L,r,J,H,s,x,B,Q,U,W,X,R,V,T;C=q=n=j=w.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);THREE.Matrix4.makeInvert(e.matrixWorld,e.matrixWorldInverse);o.multiply(e.projectionMatrix,e.matrixWorldInverse);D[0].set(o.n41-
+o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);D[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);D[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);D[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);D[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);D[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(z=0;z<6;z++)x=D[z],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,e,!0);d=0;for(z=x.length;d<z;d++)if(B=x[d].object,B.visible)if(Q=B.matrixWorld,
+U=B.matrixRotationWorld,W=B.materials,X=B.overdraw,i=0,B instanceof THREE.Mesh){R=B.geometry;L=R.vertices;V=R.faces;R=R.faceVertexUvs;P=0;for(I=L.length;P<I;P++)g=a(),g.positionWorld.copy(L[P].position),Q.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),o.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>t&&g.positionScreen.z<S;L=0;for(P=V.length;L<P;L++){I=V[L];if(I instanceof THREE.Face3)if(r=
+k[I.a],J=k[I.b],H=k[I.c],r.visible&&J.visible&&H.visible&&(B.doubleSided||B.flipSided!=(H.positionScreen.x-r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(H.positionScreen.y-r.positionScreen.y)*(J.positionScreen.x-r.positionScreen.x)<0))s=m[j]=m[j]||new THREE.RenderableFace3,j++,h=s,h.v1.copy(r),h.v2.copy(J),h.v3.copy(H);else continue;else if(I instanceof THREE.Face4)if(r=k[I.a],J=k[I.b],H=k[I.c],s=k[I.d],r.visible&&J.visible&&H.visible&&s.visible&&(B.doubleSided||B.flipSided!=((s.positionScreen.x-
+r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(s.positionScreen.y-r.positionScreen.y)*(J.positionScreen.x-r.positionScreen.x)<0||(J.positionScreen.x-H.positionScreen.x)*(s.positionScreen.y-H.positionScreen.y)-(J.positionScreen.y-H.positionScreen.y)*(s.positionScreen.x-H.positionScreen.x)<0)))T=l[n]=l[n]||new THREE.RenderableFace4,n++,h=T,h.v1.copy(r),h.v2.copy(J),h.v3.copy(H),h.v4.copy(s);else continue;h.normalWorld.copy(I.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(I.centroid);
+Q.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);o.multiplyVector3(h.centroidScreen);H=I.vertexNormals;r=0;for(J=H.length;r<J;r++)s=h.vertexNormalsWorld[r],s.copy(H[r]),U.multiplyVector3(s);r=0;for(J=R.length;r<J;r++)if(T=R[r][L]){H=0;for(s=T.length;H<s;H++)h.uvs[r][H]=T[H]}h.meshMaterials=W;h.faceMaterials=I.materials;h.overdraw=X;h.z=h.centroidScreen.z;w.push(h)}}else if(B instanceof THREE.Line){E.multiply(o,Q);L=B.geometry.vertices;r=a();r.positionScreen.copy(L[0].position);
+E.multiplyVector4(r.positionScreen);P=1;for(I=L.length;P<I;P++)if(r=a(),r.positionScreen.copy(L[P].position),E.multiplyVector4(r.positionScreen),J=k[i-2],F.copy(r.positionScreen),G.copy(J.positionScreen),c(F,G))F.multiplyScalar(1/F.w),G.multiplyScalar(1/G.w),Q=v[q]=v[q]||new THREE.RenderableLine,q++,p=Q,p.v1.positionScreen.copy(F),p.v2.positionScreen.copy(G),p.z=Math.max(F.z,G.z),p.materials=B.materials,w.push(p)}else if(B instanceof THREE.Particle&&(y.set(B.matrixWorld.n14,B.matrixWorld.n24,B.matrixWorld.n34,
+1),o.multiplyVector4(y),y.z/=y.w,y.z>0&&y.z<1))Q=K[C]=K[C]||new THREE.RenderableParticle,C++,u=Q,u.x=y.x/y.w,u.y=y.y/y.w,u.z=y.z,u.rotation=B.rotation.z,u.scale.x=B.scale.x*Math.abs(u.x-(y.x+e.projectionMatrix.n11)/(y.w+e.projectionMatrix.n14)),u.scale.y=B.scale.y*Math.abs(u.y-(y.y+e.projectionMatrix.n22)/(y.w+e.projectionMatrix.n24)),u.materials=B.materials,w.push(u);f&&w.sort(b);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,i=d*f;this.w=g*e-i*c;this.x=g*c+i*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,i=d*f;this.w=g*e-i*c;this.x=g*c+i*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -84,12 +84,10 @@ D[c].addSelf(G);D[d].addSelf(G)}var b,c,d,f,e,g,i,k,h,j,m,n,l,p,q,v,u,C,K,t,w,z,
 this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
 this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
 a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g;e=0;for(g=this.vertices.length;e<g;e++)d=this.vertices[e].position,d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_"),a[d]===void 0?(a[d]=e,b.push(this.vertices[e]),
 a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g;e=0;for(g=this.vertices.length;e<g;e++)d=this.vertices[e].position,d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_"),a[d]===void 0?(a[d]=e,b.push(this.vertices[e]),
 c[e]=b.length-1):c[e]=c[a[d]];e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];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;
 c[e]=b.length-1):c[e]=c[a[d]];e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d]}this.vertices=b}};THREE.GeometryCount=0;
-THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};
-THREE.Camera.prototype.update=function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
-THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e: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)};
-THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};
-THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
+THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.projectionMatrix=new THREE.Matrix4;this.matrixWorldInverse=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.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e: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)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
 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,
 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,
 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;
 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;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;

File diff suppressed because it is too large
+ 93 - 94
build/custom/ThreeWebGL.js


+ 16 - 16
examples/webgl_geometry_minecraft_ao.html

@@ -135,22 +135,22 @@
 					// map of UV indices for faces of partially defined cubes
 					// map of UV indices for faces of partially defined cubes
 
 
 					uv_index_map = {
 					uv_index_map = {
-					0:	{ px: N, nx: N, py: 0, ny: N, pz: N, nz: N },
-					1:	{ px: N, nx: N, py: 0, ny: N, pz: N, nz: 1 },
-					2:	{ px: N, nx: N, py: 0, ny: N, pz: 1, nz: N },
-					3:	{ px: N, nx: N, py: 0, ny: N, pz: 1, nz: 2 },
-					4:	{ px: N, nx: 0, py: 1, ny: N, pz: N, nz: N },
-					5:	{ px: N, nx: 0, py: 1, ny: N, pz: N, nz: 2 },
-					6:	{ px: N, nx: 0, py: 1, ny: N, pz: 2, nz: N },
-					7:	{ px: N, nx: 0, py: 1, ny: N, pz: 2, nz: 3 },
-					8:	{ px: 0, nx: N, py: 1, ny: N, pz: N, nz: N },
-					9:	{ px: 0, nx: N, py: 1, ny: N, pz: N, nz: 2 },
-					10:	{ px: 0, nx: N, py: 1, ny: N, pz: 2, nz: N },
-					11:	{ px: 0, nx: N, py: 1, ny: N, pz: 2, nz: 3 },
-					12:	{ px: 0, nx: 1, py: 2, ny: N, pz: N, nz: N },
-					13:	{ px: 0, nx: 1, py: 2, ny: N, pz: N, nz: 3 },
-					14:	{ px: 0, nx: 1, py: 2, ny: N, pz: 3, nz: N },
-					15:	{ px: 0, nx: 1, py: 2, ny: N, pz: 3, nz: 4 }
+					0:	{ nx: N, px: N, py: 0, ny: N, pz: N, nz: N },
+					1:	{ nx: N, px: N, py: 0, ny: N, pz: N, nz: 1 },
+					2:	{ nx: N, px: N, py: 0, ny: N, pz: 1, nz: N },
+					3:	{ nx: N, px: N, py: 0, ny: N, pz: 1, nz: 2 },
+					4:	{ nx: N, px: 0, py: 1, ny: N, pz: N, nz: N },
+					5:	{ nx: N, px: 0, py: 1, ny: N, pz: N, nz: 2 },
+					6:	{ nx: N, px: 0, py: 1, ny: N, pz: 2, nz: N },
+					7:	{ nx: N, px: 0, py: 1, ny: N, pz: 2, nz: 3 },
+					8:	{ nx: 0, px: N, py: 1, ny: N, pz: N, nz: N },
+					9:	{ nx: 0, px: N, py: 1, ny: N, pz: N, nz: 2 },
+					10:	{ nx: 0, px: N, py: 1, ny: N, pz: 2, nz: N },
+					11:	{ nx: 0, px: N, py: 1, ny: N, pz: 2, nz: 3 },
+					12:	{ nx: 0, px: 1, py: 2, ny: N, pz: N, nz: N },
+					13:	{ nx: 0, px: 1, py: 2, ny: N, pz: N, nz: 3 },
+					14:	{ nx: 0, px: 1, py: 2, ny: N, pz: 3, nz: N },
+					15:	{ nx: 0, px: 1, py: 2, ny: N, pz: 3, nz: 4 }
 					},
 					},
 
 
 					// all possible combinations of corners and sides
 					// all possible combinations of corners and sides

+ 10 - 20
examples/webgl_interactive_voxelpainter.html

@@ -22,7 +22,7 @@
 		<script src="js/Detector.js"></script>
 		<script src="js/Detector.js"></script>
 		<script src="js/RequestAnimationFrame.js"></script>
 		<script src="js/RequestAnimationFrame.js"></script>
 		<script src="js/Stats.js"></script>
 		<script src="js/Stats.js"></script>
-		
+
 		<link href="js/gui/gui.css" media="screen" rel="stylesheet" type="text/css" />
 		<link href="js/gui/gui.css" media="screen" rel="stylesheet" type="text/css" />
 		<script src="js/gui/gui.min.js"></script>
 		<script src="js/gui/gui.min.js"></script>
 
 
@@ -44,7 +44,7 @@
 			var gui, voxelConfig = {
 			var gui, voxelConfig = {
 				orthographicProjection: false
 				orthographicProjection: false
 			};
 			};
-			
+
 			init();
 			init();
 			animate();
 			animate();
 
 
@@ -58,12 +58,12 @@
 				info.style.top = '10px';
 				info.style.top = '10px';
 				info.style.width = '100%';
 				info.style.width = '100%';
 				info.style.textAlign = 'center';
 				info.style.textAlign = 'center';
-				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br /><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>';
+				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>';
 				container.appendChild( info );
 				container.appendChild( info );
 
 
 				camera = new THREE.CombinedCamera( window.innerWidth, window.innerHeight, 45, 1, 10000, -2000, 10000 );
 				camera = new THREE.CombinedCamera( window.innerWidth, window.innerHeight, 45, 1, 10000, -2000, 10000 );
 				camera.position.y = 800;
 				camera.position.y = 800;
-				
+
 				cameraTarget = new THREE.Vector3( 0, 0, 0 );
 				cameraTarget = new THREE.Vector3( 0, 0, 0 );
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
@@ -99,20 +99,10 @@
 				scene.add( ambientLight );
 				scene.add( ambientLight );
 
 
 				var directionalLight = new THREE.DirectionalLight( 0xffffff );
 				var directionalLight = new THREE.DirectionalLight( 0xffffff );
-				directionalLight.position.x = Math.random() - 0.5;
-				directionalLight.position.y = Math.random() - 0.5;
-				directionalLight.position.z = Math.random() - 0.5;
-				directionalLight.position.normalize();
-				scene.add( directionalLight );
-
-				var directionalLight = new THREE.DirectionalLight( 0x808080 );
-				directionalLight.position.x = Math.random() - 0.5;
-				directionalLight.position.y = Math.random() - 0.5;
-				directionalLight.position.z = Math.random() - 0.5;
-				directionalLight.position.normalize();
+				directionalLight.position.set( 1, 0.75, 0.5 ).normalize();
 				scene.add( directionalLight );
 				scene.add( directionalLight );
 
 
-				renderer = new THREE.WebGLRenderer( { antialias: true } );
+				renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer : true } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
@@ -126,11 +116,11 @@
 				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
 				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
 				document.addEventListener( 'keydown', onDocumentKeyDown, false );
 				document.addEventListener( 'keydown', onDocumentKeyDown, false );
 				document.addEventListener( 'keyup', onDocumentKeyUp, false );
 				document.addEventListener( 'keyup', onDocumentKeyUp, false );
-				
+
 				// add GUI
 				// add GUI
 				gui = new GUI();
 				gui = new GUI();
 				gui.add(voxelConfig, 'orthographicProjection').onChange(function(){
 				gui.add(voxelConfig, 'orthographicProjection').onChange(function(){
-					
+
 					if ( voxelConfig.orthographicProjection ) {
 					if ( voxelConfig.orthographicProjection ) {
 						camera.toOrthographic();
 						camera.toOrthographic();
 						camera.position.x = 1000;
 						camera.position.x = 1000;
@@ -141,9 +131,9 @@
 						camera.toPerspective();
 						camera.toPerspective();
 						camera.position.y = 800;
 						camera.position.y = 800;
 					}
 					}
-				
+
 				});
 				});
-				
+
 			}
 			}
 
 
 			function getRealIntersector( intersects ) {
 			function getRealIntersector( intersects ) {

+ 614 - 0
examples/webgl_materials_cars_parallaxbarrier.html

@@ -0,0 +1,614 @@
+<!doctype html>
+<html lang="en">
+	<head>
+		<title>three.js webgl - materials - cube reflection [cars]</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+		<style>
+			body {
+				background:#000;
+				color:#fff;
+				padding:0;
+				margin:0;
+				overflow:hidden;
+				font-family:georgia;
+				text-align:center;
+			}
+			h1 { }
+			a { color:skyblue; text-decoration:none }
+			canvas { pointer-events:none; z-index:10; position:relative; }
+
+			#d { position:absolute; width: 100%; text-align:center; margin:1em 0 -4.5em 0; z-index:1000; }
+
+			.bwrap { margin:0.5em 0 0 0 }
+			button { font-family:georgia; border:0; background:#000; color:#fff; padding:0.2em 0.5em; cursor:pointer; border-radius:3px; }
+			button:hover { background:#333 }
+			#buttons_cars button { color:#fa0 }
+
+			#car_info { text-align:center; }
+			#car_name { font-size:1em }
+			#car_author { font-size:1em }
+
+			#oldie { background:rgb(50,0,0) !important; color:#fff !important; margin-top:7em!important }
+		</style>
+	</head>
+
+	<body>
+		<div id="d">
+			<div id="info">
+				<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl demo :
+				texture by <a href="http://www.humus.name/index.php?page=Textures" target="_blank">Humus</a> :
+				<span id="car_info">
+					<span id="car_name">Bugatti Veyron model</span>
+					by <span id="car_author"><a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank">Troyano</a></span>
+				</span>
+
+			</div>
+
+			<div id="buttons_cars" class="bwrap">
+				<button id="veyron">Bugatti Veyron</button>
+				<button id="gallardo">Lamborghini Gallardo</button>
+				<button id="f50">Ferrari F50</button>
+				<button id="camaro">Chevrolet Camaro</button>
+			</div>
+
+			<div id="buttons_materials" class="bwrap"></div>
+		</div>
+
+		<script src="../build/Three.js"></script>
+		<script src="../src/extras/renderers/ParallaxBarrierWebGLRenderer.js"></script>
+
+		<script src="js/Detector.js"></script>
+		<script src="js/RequestAnimationFrame.js"></script>
+		<script src="js/Stats.js"></script>
+
+		<script>
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var STATS_ENABLED = false;
+
+			var CARS = {
+
+				"veyron": 	{
+
+					name:	"Bugatti Veyron",
+					url: 	"obj/veyron/VeyronNoUv_bin.js",
+					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank">Troyano</a>',
+					init_rotation: [ 0, 0, 0 ],
+					scale: 5.5,
+					init_material: 4,
+					body_materials: [ 2 ],
+
+					object: null,
+					buttons: null,
+					materials: null
+
+				},
+
+				"gallardo": {
+
+					name: 	"Lamborghini Gallardo",
+					url:	"obj/gallardo/GallardoNoUv_bin.js",
+					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1711" target="_blank">machman_3d</a>',
+					init_rotation: [ 0, 0, 0 ],
+					scale: 3.7,
+					init_material: 9,
+					body_materials: [ 3 ],
+
+					object:	null,
+					buttons: null,
+					materials: null
+
+				},
+
+				"f50": {
+
+					name: 	"Ferrari F50",
+					url:	"obj/f50/F50NoUv_bin.js",
+					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1687" target="_blank">daniel sathya</a>',
+					init_rotation: [ 0, 0, 0 ],
+					scale: 0.175,
+					init_material: 2,
+					body_materials: [ 3, 6, 7, 8, 9, 10, 23, 24 ],
+
+					object:	null,
+					buttons: null,
+					materials: null
+
+				},
+
+				"camaro": {
+
+					name: 	"Chevrolet Camaro",
+					url:	"obj/camaro/CamaroNoUv_bin.js",
+					author: '<a href="http://www.turbosquid.com/3d-models/blender-camaro/411348" target="_blank">dskfnwn</a>',
+					init_rotation: [ 0.0, 0.0, 0.0 ],
+					scale: 75,
+					init_material: 0,
+					body_materials: [ 0 ],
+
+					object:	null,
+					buttons: null,
+					materials: null
+
+				}
+
+			};
+
+
+			var container, stats;
+
+			var camera, scene, renderer;
+
+			var m, mi;
+
+			var directionalLight, pointLight;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			var loader = new THREE.BinaryLoader( true );
+			document.body.appendChild( loader.statusDomElement );
+
+			init();
+			animate();
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 100000 );
+
+				scene = new THREE.Scene();
+
+				// LIGHTS
+
+				var ambient = new THREE.AmbientLight( 0x555555 );
+				scene.add( ambient );
+
+				directionalLight = new THREE.DirectionalLight( 0xffffff, 2 );
+				directionalLight.position.set( 2, 1.2, 10 ).normalize();
+				scene.add( directionalLight );
+
+				directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
+				directionalLight.position.set( - 2, 1.2, -10 ).normalize();
+				scene.add( directionalLight );
+
+				pointLight = new THREE.PointLight( 0xffaa00, 2 );
+				pointLight.position.set( 2000, 1200, 10000 );
+				scene.add( pointLight );
+
+				// Skybox
+
+				var shader = THREE.ShaderUtils.lib[ "cube" ];
+				shader.uniforms[ "tCube" ].texture = textureCube;
+
+				var material = new THREE.ShaderMaterial( {
+
+					fragmentShader: shader.fragmentShader,
+					vertexShader: shader.vertexShader,
+					uniforms: shader.uniforms
+
+				} ),
+
+				mesh = new THREE.Mesh( new THREE.CubeGeometry( 100000, 100000, 100000 ), material );
+				mesh.flipSided = true;
+				scene.add( mesh );
+
+				//
+
+				renderer = new THREE.ParallaxBarrierWebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.setFaceCulling( 0 );
+
+				container.appendChild( renderer.domElement );
+
+				if ( STATS_ENABLED ) {
+
+					stats = new Stats();
+					stats.domElement.style.position = 'absolute';
+					stats.domElement.style.top = '0px';
+					stats.domElement.style.zIndex = 100;
+					container.appendChild( stats.domElement );
+
+				}
+
+				document.addEventListener('mousemove', onDocumentMouseMove, false);
+
+				var r = "textures/cube/Bridge2/";
+				var urls = [ r + "posx.jpg", r + "negx.jpg",
+							 r + "posy.jpg", r + "negy.jpg",
+							 r + "posz.jpg", r + "negz.jpg" ];
+
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls );
+
+				// common materials
+
+				var mlib = {
+
+				"Orange": 	new THREE.MeshLambertMaterial( { color: 0xff6600, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
+				"Blue": 	new THREE.MeshLambertMaterial( { color: 0x001133, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
+				"Red": 		new THREE.MeshLambertMaterial( { color: 0x660000, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
+				"Black": 	new THREE.MeshLambertMaterial( { color: 0x000000, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.15 } ),
+				"White":	new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
+
+				"Carmine": 	new THREE.MeshPhongMaterial( { color: 0x770000, specular:0xffaaaa, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+				"Gold": 	new THREE.MeshPhongMaterial( { color: 0xaa9944, specular:0xbbaa99, shininess:50, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+				"Bronze":	new THREE.MeshPhongMaterial( { color: 0x150505, specular:0xee6600, shininess:10, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
+				"Chrome": 	new THREE.MeshPhongMaterial( { color: 0xffffff, specular:0xffffff, envMap: textureCube, combine: THREE.Multiply } ),
+
+				"Orange metal": new THREE.MeshLambertMaterial( { color: 0xff6600, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+				"Blue metal": 	new THREE.MeshLambertMaterial( { color: 0x001133, envMap: textureCube, combine: THREE.MultiplyOperation  } ),
+				"Red metal": 	new THREE.MeshLambertMaterial( { color: 0x770000, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+				"Green metal": 	new THREE.MeshLambertMaterial( { color: 0x007711, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+				"Black metal":	new THREE.MeshLambertMaterial( { color: 0x222222, envMap: textureCube, combine: THREE.MultiplyOperation } ),
+
+				"Pure chrome": 	new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube } ),
+				"Dark chrome":	new THREE.MeshLambertMaterial( { color: 0x444444, envMap: textureCube } ),
+				"Darker chrome":new THREE.MeshLambertMaterial( { color: 0x222222, envMap: textureCube } ),
+
+				"Black glass": 	new THREE.MeshLambertMaterial( { color: 0x101016, envMap: textureCube, opacity: 0.975, transparent: true } ),
+				"Dark glass":	new THREE.MeshLambertMaterial( { color: 0x101046, envMap: textureCube, opacity: 0.25, transparent: true } ),
+				"Blue glass":	new THREE.MeshLambertMaterial( { color: 0x668899, envMap: textureCube, opacity: 0.75, transparent: true } ),
+				"Light glass":	new THREE.MeshBasicMaterial( { color: 0x223344, envMap: textureCube, opacity: 0.25, transparent: true, combine: THREE.MixOperation, reflectivity: 0.25 } ),
+
+				"Red glass":	new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.75, transparent: true } ),
+				"Yellow glass":	new THREE.MeshLambertMaterial( { color: 0xffffaa, opacity: 0.75, transparent: true } ),
+				"Orange glass":	new THREE.MeshLambertMaterial( { color: 0x995500, opacity: 0.75, transparent: true } ),
+
+				"Orange glass 50":	new THREE.MeshLambertMaterial( { color: 0xffbb00, opacity: 0.5, transparent: true } ),
+				"Red glass 50": 	new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.5, transparent: true } ),
+
+				"Fullblack rough":	new THREE.MeshLambertMaterial( { color: 0x000000 } ),
+				"Black rough":		new THREE.MeshLambertMaterial( { color: 0x050505 } ),
+				"Darkgray rough":	new THREE.MeshLambertMaterial( { color: 0x090909 } ),
+				"Red rough":		new THREE.MeshLambertMaterial( { color: 0x330500 } ),
+
+				"Darkgray shiny":	new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x050505 } ),
+				"Gray shiny":		new THREE.MeshPhongMaterial( { color: 0x050505, shininess: 20 } )
+
+				}
+
+				// Gallardo materials
+
+				CARS[ "gallardo" ].materials = {
+
+					body: [
+
+						[ "Orange", 	mlib[ "Orange" ] ],
+						[ "Blue", 		mlib[ "Blue" ] ],
+						[ "Red", 		mlib[ "Red" ] ],
+						[ "Black", 		mlib[ "Black" ] ],
+						[ "White", 		mlib[ "White" ] ],
+
+						[ "Orange metal", 	mlib[ "Orange metal" ] ],
+						[ "Blue metal", 	mlib[ "Blue metal" ] ],
+						[ "Green metal", 	mlib[ "Green metal" ] ],
+						[ "Black metal", 	mlib[ "Black metal" ] ],
+
+						[ "Carmine", 	mlib[ "Carmine" ] ],
+						[ "Gold", 		mlib[ "Gold" ] ],
+						[ "Bronze", 	mlib[ "Bronze" ] ],
+						[ "Chrome", 	mlib[ "Chrome" ] ]
+
+					]
+
+				}
+
+				m = CARS[ "gallardo" ].materials;
+				mi = CARS[ "gallardo" ].init_material;
+
+				CARS[ "gallardo" ].mmap = {
+
+					0: mlib[ "Pure chrome" ], 	// wheels chrome
+					1: mlib[ "Black rough" ],   // tire
+					2: mlib[ "Black glass" ], 	// windshield
+					3: m.body[ mi ][ 1 ], 		// body
+					4: mlib[ "Red glass" ],    	// back lights
+					5: mlib[ "Yellow glass" ],  // front lights
+					6: mlib[ "Dark chrome" ]	// windshield rim
+
+				}
+
+				// Veyron materials
+
+				CARS[ "veyron" ].materials = {
+
+					body: [
+
+						[ "Orange metal", 	mlib[ "Orange metal" ] ],
+						[ "Blue metal", 	mlib[ "Blue metal" ] ],
+						[ "Red metal", 		mlib[ "Red metal" ] ],
+						[ "Green metal",	mlib[ "Green metal" ] ],
+						[ "Black metal", 	mlib[ "Black metal" ] ],
+
+						[ "Gold", 		mlib[ "Gold" ] ],
+						[ "Bronze", 	mlib[ "Bronze" ] ],
+						[ "Chrome", 	mlib[ "Chrome" ] ]
+
+					],
+
+				}
+
+				m = CARS[ "veyron" ].materials;
+				mi = CARS[ "veyron" ].init_material;
+
+				CARS[ "veyron" ].mmap = {
+
+					0: mlib[ "Black rough" ],		// tires + inside
+					1: mlib[ "Pure chrome" ],		// wheels + extras chrome
+					2: m.body[ mi ][ 1 ], 			// back / top / front torso
+					3: mlib[ "Dark glass" ],		// glass
+					4: mlib[ "Pure chrome" ],		// sides torso
+					5: mlib[ "Pure chrome" ],		// engine
+					6: mlib[ "Red glass 50" ],		// backlights
+					7: mlib[ "Orange glass 50" ]	// backsignals
+
+				}
+
+				// F50 materials
+
+				CARS[ "f50" ].materials = {
+
+					body: [
+
+						[ "Orange", 	mlib[ "Orange" ] ],
+						[ "Blue", 		mlib[ "Blue" ] ],
+						[ "Red", 		mlib[ "Red" ] ],
+						[ "Black", 		mlib[ "Black" ] ],
+						[ "White", 		mlib[ "White" ] ],
+
+						[ "Orange metal", 	mlib[ "Orange metal" ] ],
+						[ "Blue metal", 	mlib[ "Blue metal" ] ],
+						[ "Black metal", 	mlib[ "Black metal" ] ],
+
+						[ "Carmine", 	mlib[ "Carmine" ] ],
+						[ "Gold", 		mlib[ "Gold" ] ],
+						[ "Bronze", 	mlib[ "Bronze" ] ],
+						[ "Chrome", 	mlib[ "Chrome" ] ]
+
+					],
+
+				}
+
+				m = CARS[ "f50" ].materials;
+				mi = CARS[ "f50" ].init_material;
+
+				CARS[ "f50" ].mmap = {
+
+					0:  mlib[ "Dark chrome" ], 		// interior + rim
+					1:  mlib[ "Pure chrome" ], 		// wheels + gears chrome
+					2:  mlib[ "Blue glass" ], 		// glass
+					3:  m.body[ mi ][ 1 ], 			// torso mid + front spoiler
+					4:  mlib[ "Darkgray shiny" ], 	// interior + behind seats
+					5:  mlib[ "Darkgray shiny" ], 	// tiny dots in interior
+					6:  m.body[ mi ][ 1 ], 			// back torso
+					7:  m.body[ mi ][ 1 ], 			// right mirror decal
+					8:  m.body[ mi ][ 1 ], 			// front decal
+					9:  m.body[ mi ][ 1 ], 			// front torso
+					10: m.body[ mi ][ 1 ], 			// left mirror decal
+					11: mlib[ "Pure chrome" ], 		// engine
+					12: mlib[ "Darkgray rough" ],	// tires side
+					13: mlib[ "Darkgray rough" ],	// tires bottom
+					14: mlib[ "Darkgray shiny" ], 	// bottom
+					15: mlib[ "Black rough" ],		// ???
+					16: mlib[ "Orange glass" ],		// front signals
+					17: mlib[ "Dark chrome" ], 		// wheels center
+					18: mlib[ "Red glass" ], 		// back lights
+					19: mlib[ "Black rough" ], 		// ???
+					20: mlib[ "Red rough" ], 		// seats
+					21: mlib[ "Black rough" ], 		// back plate
+					22: mlib[ "Black rough" ], 		// front light dots
+					23: m.body[ mi ][ 1 ], 			// back torso
+					24: m.body[ mi ][ 1 ] 			// back torso center
+
+				}
+
+
+				// Camero materials
+
+				CARS[ "camaro" ].materials = {
+
+					body: [
+
+						[ "Orange", 	mlib[ "Orange" ] ],
+						[ "Blue", 		mlib[ "Blue" ] ],
+						[ "Red", 		mlib[ "Red" ] ],
+						[ "Black", 		mlib[ "Black" ] ],
+						[ "White", 		mlib[ "White" ] ],
+
+						[ "Orange metal", 	mlib[ "Orange metal" ] ],
+						[ "Blue metal", 	mlib[ "Blue metal" ] ],
+						[ "Red metal", 		mlib[ "Red metal" ] ],
+						[ "Green metal", 	mlib[ "Green metal" ] ],
+						[ "Black metal", 	mlib[ "Black metal" ] ],
+
+						[ "Gold", 		mlib[ "Gold" ] ],
+						[ "Bronze", 	mlib[ "Bronze" ] ],
+						[ "Chrome", 	mlib[ "Chrome" ] ]
+
+					],
+
+				}
+
+				m = CARS[ "camaro" ].materials;
+				mi = CARS[ "camaro" ].init_material;
+
+				CARS[ "camaro" ].mmap = {
+
+					0: m.body[ mi ][ 1 ], 			// car body
+					1: mlib[ "Pure chrome" ], 		// wheels chrome
+					2: mlib[ "Pure chrome" ], 		// grille chrome
+					3: mlib[ "Dark chrome" ], 		// door lines
+					4: mlib[ "Light glass" ], 		// windshield
+					5: mlib[ "Gray shiny" ],        // interior
+					6: mlib[ "Black rough" ],       // tire
+					7: mlib[ "Fullblack rough" ],   // tireling
+					8: mlib[ "Fullblack rough" ]    // behind grille
+
+				}
+
+				loader.load( { model: CARS[ "veyron" ].url, callback: function( geometry ) { createScene( geometry, "veyron" ) } } );
+
+				for( var c in CARS ) initCarButton( c );
+
+			}
+
+			function initCarButton( car ) {
+
+				$( car ).addEventListener( 'click', function() {
+
+					if ( ! CARS[ car ].object ) {
+
+						loader.statusDomElement.style.display = "block";
+						loader.load( { model: CARS[ car ].url, callback: function( geometry ) { createScene( geometry, car ) } } );
+
+					} else {
+
+						switchCar( car );
+
+					}
+
+				}, false);
+
+			}
+
+			function $( id ) { return document.getElementById( id ) }
+			function button_name( car, index ) { return "m_" + car  + "_" + index }
+
+			function switchCar( car ) {
+
+				for ( var c in CARS ) {
+
+					if ( c != car && CARS[ c ].object ) {
+
+						CARS[ c ].object.visible = false;
+						CARS[ c ].buttons.style.display = "none";
+
+					}
+				}
+
+				CARS[ car ].object.visible = true;
+				CARS[ car ].buttons.style.display = "block";
+
+				$( "car_name" ).innerHTML = CARS[ car ].name + " model";
+				$( "car_author" ).innerHTML = CARS[ car ].author;
+
+			}
+
+			function createButtons( materials, car ) {
+
+				var buttons, i, src = "";
+
+				for( i = 0; i < materials.length; i++ ) {
+
+					src += '<button id="' + button_name( car, i ) + '">' + materials[ i ][ 0 ] + '</button> ';
+
+				}
+
+				buttons = document.createElement("div");
+				buttons.innerHTML = src;
+
+				$( "buttons_materials" ).appendChild( buttons );
+
+				return buttons;
+
+			}
+
+			function attachButtonMaterials( materials, geometry, material_indices, car ) {
+
+				for( var i = 0; i < materials.length; i++ ) {
+
+					$( button_name( car, i ) ).counter = i;
+					$( button_name( car, i ) ).addEventListener( 'click', function() {
+
+						for ( var j = 0; j < material_indices.length; j++ ) {
+
+							geometry.materials[ material_indices [ j ] ][ 0 ] = materials[ this.counter ][ 1 ];
+
+						}
+
+					}, false );
+
+				}
+
+			}
+
+			function createScene( geometry, car ) {
+
+				loader.statusDomElement.innerHTML = "Creating model ...";
+
+				var m = new THREE.MeshFaceMaterial(),
+					s = CARS[ car ].scale * 1,
+					r = CARS[ car ].init_rotation,
+					materials = CARS[ car ].materials,
+					mi = CARS[ car ].init_material,
+					bm = CARS[ car ].body_materials;
+
+				for( var i in CARS[ car ].mmap ) {
+
+					geometry.materials[ i ][ 0 ] = CARS[ car ].mmap[ i ];
+
+				}
+
+				var mesh = new THREE.Mesh( geometry, m );
+				mesh.rotation.x = r[ 0 ];
+				mesh.rotation.y = r[ 1 ];
+				mesh.rotation.z = r[ 2 ];
+				mesh.scale.x = mesh.scale.y = mesh.scale.z = s;
+				scene.add( mesh );
+
+				CARS[ car ].object = mesh;
+
+				CARS[ car ].buttons = createButtons( materials.body, car );
+				attachButtonMaterials( materials.body, geometry, bm, car );
+
+				switchCar( car );
+
+				loader.statusDomElement.style.display = "none";
+				loader.statusDomElement.innerHTML = "Loading model ...";
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseY = ( event.clientY - window.innerHeight );
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+
+			}
+
+			function render() {
+
+				var timer = - new Date().getTime() * 0.0002;
+
+				camera.position.y += ( - mouseY - camera.position.y ) * .05;
+
+				camera.position.x = 1000 * Math.cos( timer );
+				camera.position.z = 1000 * Math.sin( timer );
+
+				camera.lookAt( scene.position );
+
+				renderer.render( scene, camera );
+
+				if ( STATS_ENABLED ) stats.update();
+
+			}
+
+
+		</script>
+
+	</body>
+</html>

+ 1 - 4
examples/webgl_performance.html

@@ -71,18 +71,15 @@
 						mesh.matrixAutoUpdate = false;
 						mesh.matrixAutoUpdate = false;
 						mesh.updateMatrix();
 						mesh.updateMatrix();
 
 
-						//mesh.frustumCulled = false;
-
 						scene.add( mesh );
 						scene.add( mesh );
 
 
 					}
 					}
 
 
 				} } );
 				} } );
 
 
-				renderer = new THREE.WebGLRenderer( { preserveDrawingBuffer: true } );
+				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortObjects = false;
 				renderer.sortObjects = false;
-				renderer.autoClearColor = false;
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				stats = new Stats();
 				stats = new Stats();

+ 120 - 0
examples/webgl_trails.html

@@ -0,0 +1,120 @@
+<!doctype html>
+<html lang="en">
+	<head>
+		<title>three.js webgl - trails</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+		<style>
+			body {
+				background:#000;
+				padding:0;
+				margin:0;
+				font-weight: bold;
+				overflow:hidden;
+			}
+		</style>
+	</head>
+	<body>
+
+		<script src="../build/Three.js"></script>
+
+		<script src="js/RequestAnimationFrame.js"></script>
+		<script src="js/Stats.js"></script>
+
+		<script>
+
+			var container, stats;
+
+			var camera, scene, renderer;
+
+			var mesh, zmesh, lightMesh, geometry;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			init();
+			animate();
+
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera.position.x = 100000;
+				camera.position.z = 3200;
+
+				scene = new THREE.Scene();
+
+				var colors = [ 0x000000, 0xff0080, 0x8000ff, 0xffffff ];
+				var geometry = new THREE.Geometry();
+
+				for ( var i = 0; i < 2000; i ++ ) {
+
+					var vertex = new THREE.Vertex();
+					vertex.position.x = Math.random() * 4000 - 2000;
+					vertex.position.y = Math.random() * 4000 - 2000;
+					vertex.position.z = Math.random() * 4000 - 2000;
+					geometry.vertices.push( vertex );
+
+					geometry.colors.push( new THREE.Color( colors[ Math.floor( Math.random() * colors.length ) ] ) );
+
+				}
+
+				var material = new THREE.ParticleBasicMaterial( { size: 1, vertexColors: THREE. VertexColors, depthTest: false, opacity: 0.5, sizeAttenuation: false } );
+
+				var mesh = new THREE.ParticleSystem( geometry, material );
+				scene.add( mesh );
+
+				renderer = new THREE.WebGLRenderer( { preserveDrawingBuffer: true } );
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.sortObjects = false;
+				renderer.autoClearColor = false;
+				container.appendChild( renderer.domElement );
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.zIndex = 100;
+				container.appendChild( stats.domElement );
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX ) * 10;
+				mouseY = ( event.clientY - windowHalfY ) * 10;
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - mouseY - camera.position.y ) * .05;
+
+				camera.lookAt( scene.position );
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 46 - 15
gui/index.html

@@ -45,6 +45,9 @@
 
 
 		<script>
 		<script>
 
 
+			window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
+			window.URL = window.URL || window.webkitURL || window.mozURL;
+
 			var Signal = signals.Signal;
 			var Signal = signals.Signal;
 
 
 			var signals = {
 			var signals = {
@@ -121,33 +124,61 @@
 				event.preventDefault();
 				event.preventDefault();
 
 
 				var file = event.dataTransfer.files[ 0 ];
 				var file = event.dataTransfer.files[ 0 ];
+				var extension = file.name.split( '.' )[1].toLowerCase();
 				var reader = new FileReader();
 				var reader = new FileReader();
 
 
 				reader.onload = function ( event ) {
 				reader.onload = function ( event ) {
 
 
-					var parser = new DOMParser();
-					var xml = parser.parseFromString( event.target.result, 'text/xml' );
+					var contents = event.target.result;
+
+					switch ( extension ) {
+
+						case 'dae':
+
+							var parser = new DOMParser();
+							var xml = parser.parseFromString( contents, 'text/xml' );
+
+							var loader = new THREE.ColladaLoader();
+							loader.parse( xml, function ( collada ) {
+
+								// console.log( collada );
+
+								signals.added.dispatch( collada.scene );
+
+							} );
+
+							break;
+
+						case 'js':
+
+							var blob = new BlobBuilder();
+							blob.append( contents );
+
+							var url = URL.createObjectURL( blob.getBlob() );
+
+							var loader = new THREE.JSONLoader();
+							loader.load( { model: url, callback: function ( geometry ) {
 
 
-					var loader = new THREE.ColladaLoader();
-					loader.parse( xml, function ( collada ) {
+								geometry.gui = {
+									paremeters: {
+									},
+									getCode: function () {
 
 
-						console.log( collada );
+										return 'new THREE.JSONLoader( TODO )';
 
 
-						signals.added.dispatch( collada.scene );
+									}
+								};
 
 
-					} );
+								var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
+								var mesh = new THREE.Mesh( geometry, material );
 
 
-					/*
-					var loader = new THREE.JSONLoader();
-					loader.createModel( event.target.result, function ( geometry ) {
+								signals.added.dispatch( mesh );
 
 
-						var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
-						var mesh = new THREE.Mesh( geometry, material );
+							} } );
 
 
-						signals.added.dispatch( mesh );
+							break;
 
 
-					} );
-					*/
+					}
 
 
 				};
 				};
 
 

+ 17 - 12
gui/js/Code.js

@@ -14,16 +14,15 @@ var Code = function () {
 	_checkbox.style.margin = '20px 6px 0px 20px';
 	_checkbox.style.margin = '20px 6px 0px 20px';
 	_checkbox.addEventListener( 'click', function () { _html = !_html; _update(); }, false );
 	_checkbox.addEventListener( 'click', function () { _html = !_html; _update(); }, false );
 	_domElement.appendChild( _checkbox );
 	_domElement.appendChild( _checkbox );
-	
+
 	var _preview = document.createElement( 'a' );
 	var _preview = document.createElement( 'a' );
 	_preview.href = '#';
 	_preview.href = '#';
 	_preview.innerHTML = 'preview';
 	_preview.innerHTML = 'preview';
 	_preview.style.margin = '20px 6px 0px 20px';
 	_preview.style.margin = '20px 6px 0px 20px';
-	_preview.addEventListener( 'click', 
-		function () { 
-			
-			
+	_preview.addEventListener( 'click', function () { 
+
 			// Get unescaped code gen
 			// Get unescaped code gen
+
 			var temp=document.createElement("pre");
 			var temp=document.createElement("pre");
 			temp.innerHTML = _codegen( true );
 			temp.innerHTML = _codegen( true );
 			temp = temp.firstChild.nodeValue;
 			temp = temp.firstChild.nodeValue;
@@ -31,7 +30,7 @@ var Code = function () {
 			temp = temp.replace("js/RequestAnimationFrame.js", "../examples/js/RequestAnimationFrame.js");
 			temp = temp.replace("js/RequestAnimationFrame.js", "../examples/js/RequestAnimationFrame.js");
 
 
 			console.log('test', temp);
 			console.log('test', temp);
-			
+
 			var opener = window.open('','myconsole',
 			var opener = window.open('','myconsole',
 			  'width=800,height=400'
 			  'width=800,height=400'
 			   +',menubar=1'
 			   +',menubar=1'
@@ -39,15 +38,14 @@ var Code = function () {
 			   +',status=1'
 			   +',status=1'
 			   +',scrollbars=1'
 			   +',scrollbars=1'
 			   +',resizable=1');
 			   +',resizable=1');
-			
-			
+
 			opener.document.writeln( temp );
 			opener.document.writeln( temp );
 			opener.document.close();
 			opener.document.close();
-			
+
 		}, false 
 		}, false 
 	);
 	);
 	_domElement.appendChild( _preview );
 	_domElement.appendChild( _preview );
-	
+
 
 
 	/*
 	/*
 	var _checkboxText = document.createElement( 'span' );
 	var _checkboxText = document.createElement( 'span' );
@@ -68,7 +66,7 @@ var Code = function () {
 	//
 	//
 
 
 	var _list = [];
 	var _list = [];
-	
+
 	var _codegen = function (html) {
 	var _codegen = function (html) {
 		var string = '';
 		var string = '';
 
 
@@ -113,7 +111,7 @@ var Code = function () {
 			'function render() {',
 			'function render() {',
 			'',
 			'',
 			'\trenderer.render( scene, camera );',
 			'\trenderer.render( scene, camera );',
-			'\trenderer.setSize( window.innerWidth, window.innerHeight );',			
+			'\trenderer.setSize( window.innerWidth, window.innerHeight );',
 			'',
 			'',
 			'}'
 			'}'
 
 
@@ -144,6 +142,13 @@ var Code = function () {
 
 
 			var object = scene.objects[ i ];
 			var object = scene.objects[ i ];
 
 
+			if ( object.geometry == undefined || object.geometry.gui == undefined ) {
+
+				_list.push( 'TODO' );
+				continue;
+
+			}
+
 			if ( object instanceof THREE.Mesh ) {
 			if ( object instanceof THREE.Mesh ) {
 
 
 				var string = '';
 				var string = '';

+ 1 - 35
src/cameras/Camera.js

@@ -14,8 +14,8 @@ THREE.Camera = function () {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
 
 
-	this.matrixWorldInverse = new THREE.Matrix4();
 	this.projectionMatrix = new THREE.Matrix4();
 	this.projectionMatrix = new THREE.Matrix4();
+	this.matrixWorldInverse = new THREE.Matrix4();
 
 
 };
 };
 
 
@@ -34,38 +34,4 @@ THREE.Camera.prototype.lookAt = function ( vector ) {
 
 
 	}
 	}
 
 
-}
-
-THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camera ) {
-
-	this.matrixAutoUpdate && this.updateMatrix();
-
-	if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
-
-		if ( parentMatrixWorld ) {
-
-			this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
-
-		} else {
-
-			this.matrixWorld.copy( this.matrix );
-
-		}
-
-		this.matrixWorldNeedsUpdate = false;
-		forceUpdate = true;
-
-		THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse );
-
-	}
-
-
-	// update children
-
-	for ( var i = 0; i < this.children.length; i ++ ) {
-
-		this.children[ i ].update( this.matrixWorld, forceUpdate, camera );
-
-	}
-
 };
 };

+ 10 - 4
src/core/Projector.js

@@ -14,8 +14,9 @@ THREE.Projector = function() {
 
 
 	_objectList = [], _renderList = [],
 	_objectList = [], _renderList = [],
 
 
-	_vector3 = new THREE.Vector4(),
+	_vector3 = new THREE.Vector3(),
 	_vector4 = new THREE.Vector4(),
 	_vector4 = new THREE.Vector4(),
+
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
 
 
@@ -36,11 +37,13 @@ THREE.Projector = function() {
 
 
 	this.projectVector = function ( vector, camera ) {
 	this.projectVector = function ( vector, camera ) {
 
 
+		THREE.Matrix4.makeInvert( camera.matrixWorld, camera.matrixWorldInverse );
+
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
 		_projScreenMatrix.multiplyVector3( vector );
 		_projScreenMatrix.multiplyVector3( vector );
 
 
 		return vector;
 		return vector;
-		
+
 	};
 	};
 
 
 	this.unprojectVector = function ( vector, camera ) {
 	this.unprojectVector = function ( vector, camera ) {
@@ -49,7 +52,7 @@ THREE.Projector = function() {
 		_projScreenMatrix.multiplyVector3( vector );
 		_projScreenMatrix.multiplyVector3( vector );
 
 
 		return vector;
 		return vector;
-		
+
 	};
 	};
 
 
 	/**
 	/**
@@ -73,7 +76,7 @@ THREE.Projector = function() {
 		end.subSelf( vector ).normalize();
 		end.subSelf( vector ).normalize();
 
 
 		return new THREE.Ray( vector, end );
 		return new THREE.Ray( vector, end );
-		
+
 	};
 	};
 
 
 	this.projectObjects = function ( scene, camera, sort ) {
 	this.projectObjects = function ( scene, camera, sort ) {
@@ -131,7 +134,10 @@ THREE.Projector = function() {
 
 
 		scene.update( undefined, false, camera );
 		scene.update( undefined, false, camera );
 
 
+		THREE.Matrix4.makeInvert( camera.matrixWorld, camera.matrixWorldInverse );
+
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
+
 		computeFrustum( _projScreenMatrix );
 		computeFrustum( _projScreenMatrix );
 
 
 		objects = this.projectObjects( scene, camera, true );
 		objects = this.projectObjects( scene, camera, true );

+ 7 - 11
src/extras/ShaderUtils.js

@@ -223,15 +223,13 @@ THREE.ShaderUtils = {
 							"vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );",
 							"vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );",
 							"float pointDistance = vPointLight[ i ].w;",
 							"float pointDistance = vPointLight[ i ].w;",
 
 
-							"float pointDotNormalHalf = dot( normal, pointHalfVector );",
+							"float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );",
 							"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 							"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 
 
-							"float pointSpecularWeight = 0.0;",
-							"if ( pointDotNormalHalf >= 0.0 )",
-								"pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );",
+							"float pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );",
 
 
 							"pointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;",
 							"pointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;",
-							"pointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight;",
+							"pointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;",
 
 
 						"}",
 						"}",
 
 
@@ -251,15 +249,13 @@ THREE.ShaderUtils = {
 							"vec3 dirVector = normalize( lDirection.xyz );",
 							"vec3 dirVector = normalize( lDirection.xyz );",
 							"vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );",
 							"vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );",
 
 
-							"float dirDotNormalHalf = dot( normal, dirHalfVector );",
+							"float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );",
 							"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 							"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 
 
-							"float dirSpecularWeight = 0.0;",
-							"if ( dirDotNormalHalf >= 0.0 )",
-								"dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );",
+							"float dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );",
 
 
 							"dirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;",
 							"dirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;",
-							"dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight;",
+							"dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;",
 
 
 						"}",
 						"}",
 
 
@@ -284,7 +280,7 @@ THREE.ShaderUtils = {
 
 
 					"#endif",
 					"#endif",
 
 
-					"gl_FragColor.xyz = gl_FragColor.xyz * totalDiffuse + totalSpecular + ambientLightColor * uAmbientColor;",
+					"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;",
 
 
 					"if ( enableReflection ) {",
 					"if ( enableReflection ) {",
 
 

+ 16 - 14
src/extras/loaders/JSONLoader.js

@@ -14,25 +14,27 @@ THREE.JSONLoader.prototype.constructor = THREE.JSONLoader;
 THREE.JSONLoader.prototype.supr = THREE.Loader.prototype;
 THREE.JSONLoader.prototype.supr = THREE.Loader.prototype;
 
 
 
 
-/**
- * Load models generated by slim OBJ converter with ASCII option (converter_obj_three_slim.py -t ascii)
- *  - parameters
- *  - model (required)
- *  - callback (required)
- *  - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
- */
+THREE.JSONLoader.prototype.load = function ( url, callback, texturePath ) {
 
 
-THREE.JSONLoader.prototype.load = function ( parameters ) {
+	var scope = this, worker;
 
 
-	var scope = this,
-		url = parameters.model,
-		callback = parameters.callback,
-		texture_path = parameters.texture_path ? parameters.texture_path : this.extractUrlbase( url ),
-		worker = new Worker( url );
+	if ( url instanceof Object ) {
+
+		console.warn( 'DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath ).' );
+
+		var object = url;
+		url = object.model;
+		callback = object.callback;
+		texturePath = object.texture_path;
+
+	}
+
+	worker = new Worker( url );
+	texturePath = texturePath ? texturePath : this.extractUrlbase( url ),
 
 
 	worker.onmessage = function ( event ) {
 	worker.onmessage = function ( event ) {
 
 
-		scope.createModel( event.data, callback, texture_path );
+		scope.createModel( event.data, callback, texturePath );
 		scope.onLoadComplete();
 		scope.onLoadComplete();
 
 
 	};
 	};

+ 162 - 0
src/extras/renderers/ParallaxBarrierWebGLRenderer.js

@@ -0,0 +1,162 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author marklundin / http://mark-lundin.com/
+ */
+
+if ( THREE.WebGLRenderer ) {
+
+	THREE.ParallaxBarrierWebGLRenderer = function ( parameters ) {
+
+		THREE.WebGLRenderer.call( this, parameters );
+
+		var _this = this, _setSize = this.setSize, _render = this.render;
+
+		var _cameraL = new THREE.PerspectiveCamera(),
+			_cameraR = new THREE.PerspectiveCamera();
+
+		var eyeRight = new THREE.Matrix4(),
+			eyeLeft = new THREE.Matrix4(),
+			focalLength = 125,
+			aspect, near, fov;
+
+		_cameraL.matrixAutoUpdate = _cameraR.matrixAutoUpdate = false;
+
+		var _params = { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat };
+
+		var _renderTargetL = new THREE.WebGLRenderTarget( 512, 512, _params ),
+			_renderTargetR = new THREE.WebGLRenderTarget( 512, 512, _params );
+
+		var _camera = new THREE.PerspectiveCamera( 53, 1, 1, 10000 );
+		_camera.position.z = 2;
+
+		_material = new THREE.ShaderMaterial( {
+
+			uniforms: {
+
+				"mapLeft": { type: "t", value: 0, texture: _renderTargetL },
+				"mapRight": { type: "t", value: 1, texture: _renderTargetR }
+
+			},
+
+			vertexShader: [
+
+				"varying vec2 vUv;",
+
+				"void main() {",
+
+					"vUv = vec2( uv.x, 1.0 - uv.y );",
+					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+				"}"
+
+			].join("\n"),
+
+			fragmentShader: [
+
+				"uniform sampler2D mapLeft;",
+				"uniform sampler2D mapRight;",
+				"varying vec2 vUv;",
+
+				"void main() {",
+
+					"vec2 uv = vUv;",
+
+					"if ( ( mod(gl_FragCoord.x, 2.0) ) > 1.00 ) {",
+
+						"gl_FragColor = texture2D( mapLeft, uv );",
+
+					"} else {",
+
+						"gl_FragColor = texture2D( mapRight, uv );",
+
+					"}",
+
+				"}"
+
+				].join("\n")
+
+		} );
+
+		var _scene = new THREE.Scene();
+		_scene.add( new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _material ) );
+
+		this.setSize = function ( width, height ) {
+
+			_setSize.call( _this, width, height );
+
+			_renderTargetL.width = width;
+			_renderTargetL.height = height;
+
+			_renderTargetR.width = width;
+			_renderTargetR.height = height;
+
+		};
+
+		/*
+		 * Renderer now uses an asymmetric perspective projection (http://paulbourke.net/miscellaneous/stereographics/stereorender/).
+		 * Each camera is offset by the eye seperation and its projection matrix is also skewed asymetrically back to converge on the same
+		 * projection plane. Added a focal length parameter to, this is where the parallax is equal to 0.
+		 */
+
+		this.render = function ( scene, camera, renderTarget, forceClear ) {
+
+			camera.update( null, true );
+
+			var hasCameraChanged = aspect !== camera.aspect || near !== camera.near || fov !== camera.fov;
+
+			if( hasCameraChanged ) {
+
+				aspect = camera.aspect;
+				near = camera.near;
+				fov = camera.fov;
+
+				var projectionMatrix = camera.projectionMatrix.clone(),
+					eyeSep = focalLength / 30 * 0.5,
+					eyeSepOnProjection = eyeSep * near / focalLength,
+					ymax = near * Math.tan( fov * Math.PI / 360 ),
+					xmin, xmax;
+
+				//translate xOffset
+
+				eyeRight.n14 = eyeSep;
+				eyeLeft.n14 = -eyeSep;
+
+				//For left eye
+
+				xmin = -ymax * aspect + eyeSepOnProjection;
+				xmax = ymax * aspect + eyeSepOnProjection;
+				projectionMatrix.n11 = 2 * near / ( xmax - xmin );
+				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				_cameraL.projectionMatrix = projectionMatrix.clone();
+
+				//for right eye
+
+				xmin = -ymax * aspect - eyeSepOnProjection;
+				xmax = ymax * aspect - eyeSepOnProjection;
+				projectionMatrix.n11 = 2 * near / ( xmax - xmin );
+				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				_cameraR.projectionMatrix = projectionMatrix.clone();
+
+			}
+
+			_cameraL.matrix = camera.matrixWorld.clone().multiplySelf( eyeLeft );
+			_cameraL.update( null, true );
+			_cameraL.position.copy( camera.position );
+			_cameraL.near = near;
+			_cameraL.far = camera.far;
+			_render.call( _this, scene, _cameraL, _renderTargetL, true );
+
+			_cameraR.matrix = camera.matrixWorld.clone().multiplySelf( eyeRight );
+			_cameraR.update( null, true );
+			_cameraR.position.copy( camera.position );
+			_cameraR.near = near;
+			_cameraR.far = camera.far;
+			_render.call( _this, scene, _cameraR, _renderTargetR, true );
+
+			_render.call( _this, _scene, _camera );
+
+		};
+
+	};
+
+};

+ 0 - 499
src/renderers/Projector.js

@@ -1,499 +0,0 @@
-/**
- * @author mr.doob / http://mrdoob.com/
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author julianwa / https://github.com/julianwa
- */
-
-THREE.Projector = function() {
-
-	var _object, _objectCount, _objectPool = [],
-	_vertex, _vertexCount, _vertexPool = [],
-	_face, _face3Count, _face3Pool = [], _face4Count, _face4Pool = [],
-	_line, _lineCount, _linePool = [],
-	_particle, _particleCount, _particlePool = [],
-
-	_objectList = [], _renderList = [],
-
-	_vector3 = new THREE.Vector4(),
-	_vector4 = new THREE.Vector4(),
-	_projScreenMatrix = new THREE.Matrix4(),
-	_projScreenObjectMatrix = new THREE.Matrix4(),
-
-	_frustum = [
-		new THREE.Vector4(),
-		new THREE.Vector4(),
-		new THREE.Vector4(),
-		new THREE.Vector4(),
-		new THREE.Vector4(),
-		new THREE.Vector4()
-	 ],
-
-	_clippedVertex1PositionScreen = new THREE.Vector4(),
-	_clippedVertex2PositionScreen = new THREE.Vector4(),
-
-	_face3VertexNormals;
-
-
-	this.projectVector = function ( vector, camera ) {
-
-		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
-		_projScreenMatrix.multiplyVector3( vector );
-
-		return vector;
-
-	};
-
-	this.unprojectVector = function ( vector, camera ) {
-
-		_projScreenMatrix.multiply( camera.matrixWorld, THREE.Matrix4.makeInvert( camera.projectionMatrix ) );
-		_projScreenMatrix.multiplyVector3( vector );
-
-		return vector;
-
-	};
-
-	this.projectObjects = function ( scene, camera, sort ) {
-
-		var o, ol, objects, object, matrix;
-
-		_objectList.length = 0;
-		_objectCount = 0;
-
-		objects = scene.objects;
-
-		for ( o = 0, ol = objects.length; o < ol; o ++ ) {
-
-			object = objects[ o ];
-
-			if ( !object.visible || ( object instanceof THREE.Mesh && !( object.frustumCulled && isInFrustum( object ) ) ) ) continue;
-
-			_object = getNextObjectInPool();
-
-			_vector3.copy( object.position );
-			_projScreenMatrix.multiplyVector3( _vector3 );
-
-			_object.object = object;
-			_object.z = _vector3.z;
-
-			_objectList.push( _object );
-
-		}
-
-		sort && _objectList.sort( painterSort );
-
-		return _objectList;
-
-	};
-
-	// TODO: Rename to projectElements?
-
-	this.projectScene = function ( scene, camera, sort ) {
-
-		var near = camera.near, far = camera.far,
-		o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object,
-		objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw,
-		geometry, vertices, vertex, vertexPositionScreen,
-		faces, face, faceVertexNormals, normal, faceVertexUvs, uvs,
-		v1, v2, v3, v4;
-
-		_renderList.length = 0;
-
-		_face3Count = 0;
-		_face4Count = 0;
-		_lineCount = 0;
-		_particleCount = 0;
-
-		camera.matrixAutoUpdate && camera.update( undefined, true );
-
-		scene.update( undefined, false, camera );
-
-		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
-		computeFrustum( _projScreenMatrix );
-
-		objects = this.projectObjects( scene, camera, true );
-
-		for ( o = 0, ol = objects.length; o < ol; o++ ) {
-
-			object = objects[ o ].object;
-
-			if ( !object.visible ) continue;
-
-			objectMatrix = object.matrixWorld;
-			objectMatrixRotation = object.matrixRotationWorld;
-
-			objectMaterials = object.materials;
-			objectOverdraw = object.overdraw;
-
-			_vertexCount = 0;
-
-			if ( object instanceof THREE.Mesh ) {
-
-				geometry = object.geometry;
-				vertices = geometry.vertices;
-				faces = geometry.faces;
-				faceVertexUvs = geometry.faceVertexUvs;
-
-				for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
-
-					_vertex = getNextVertexInPool();
-					_vertex.positionWorld.copy( vertices[ v ].position );
-
-					objectMatrix.multiplyVector3( _vertex.positionWorld );
-
-					_vertex.positionScreen.copy( _vertex.positionWorld );
-					_projScreenMatrix.multiplyVector4( _vertex.positionScreen );
-
-					_vertex.positionScreen.x /= _vertex.positionScreen.w;
-					_vertex.positionScreen.y /= _vertex.positionScreen.w;
-
-					_vertex.visible = _vertex.positionScreen.z > near && _vertex.positionScreen.z < far;
-
-				}
-
-				for ( f = 0, fl = faces.length; f < fl; f ++ ) {
-
-					face = faces[ f ];
-
-					if ( face instanceof THREE.Face3 ) {
-
-						v1 = _vertexPool[ face.a ];
-						v2 = _vertexPool[ face.b ];
-						v3 = _vertexPool[ face.c ];
-
-						if ( v1.visible && v2.visible && v3.visible &&
-							( object.doubleSided || ( object.flipSided !=
-							( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
-							( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) {
-
-							_face = getNextFace3InPool();
-
-							_face.v1.copy( v1 );
-							_face.v2.copy( v2 );
-							_face.v3.copy( v3 );
-
-						} else {
-
-							continue;
-
-						}
-
-					} else if ( face instanceof THREE.Face4 ) {
-
-						v1 = _vertexPool[ face.a ];
-						v2 = _vertexPool[ face.b ];
-						v3 = _vertexPool[ face.c ];
-						v4 = _vertexPool[ face.d ];
-
-						if ( v1.visible && v2.visible && v3.visible && v4.visible &&
-							( object.doubleSided || ( object.flipSided !=
-							( ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
-							( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ||
-							( v2.positionScreen.x - v3.positionScreen.x ) * ( v4.positionScreen.y - v3.positionScreen.y ) -
-							( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) {
-
-							_face = getNextFace4InPool();
-
-							_face.v1.copy( v1 );
-							_face.v2.copy( v2 );
-							_face.v3.copy( v3 );
-							_face.v4.copy( v4 );
-
-						} else {
-
-							continue;
-
-						}
-
-					}
-
-					_face.normalWorld.copy( face.normal );
-					objectMatrixRotation.multiplyVector3( _face.normalWorld );
-
-					_face.centroidWorld.copy( face.centroid );
-					objectMatrix.multiplyVector3( _face.centroidWorld );
-
-					_face.centroidScreen.copy( _face.centroidWorld );
-					_projScreenMatrix.multiplyVector3( _face.centroidScreen );
-
-					faceVertexNormals = face.vertexNormals;
-
-					for ( n = 0, nl = faceVertexNormals.length; n < nl; n ++ ) {
-
-						normal = _face.vertexNormalsWorld[ n ];
-						normal.copy( faceVertexNormals[ n ] );
-						objectMatrixRotation.multiplyVector3( normal );
-
-					}
-
-					for ( c = 0, cl = faceVertexUvs.length; c < cl; c ++ ) {
-
-						uvs = faceVertexUvs[ c ][ f ];
-
-						if ( !uvs ) continue;
-
-						for ( u = 0, ul = uvs.length; u < ul; u ++ ) {
-
-							_face.uvs[ c ][ u ] = uvs[ u ];
-
-						}
-
-					}
-
-					_face.meshMaterials = objectMaterials;
-					_face.faceMaterials = face.materials;
-					_face.overdraw = objectOverdraw;
-
-					_face.z = _face.centroidScreen.z;
-
-					_renderList.push( _face );
-
-				}
-
-			} else if ( object instanceof THREE.Line ) {
-
-				_projScreenObjectMatrix.multiply( _projScreenMatrix, objectMatrix );
-
-				vertices = object.geometry.vertices;
-
-				v1 = getNextVertexInPool();
-				v1.positionScreen.copy( vertices[ 0 ].position );
-				_projScreenObjectMatrix.multiplyVector4( v1.positionScreen );
-
-				for ( v = 1, vl = vertices.length; v < vl; v++ ) {
-
-					v1 = getNextVertexInPool();
-					v1.positionScreen.copy( vertices[ v ].position );
-					_projScreenObjectMatrix.multiplyVector4( v1.positionScreen );
-
-					v2 = _vertexPool[ _vertexCount - 2 ];
-
-					_clippedVertex1PositionScreen.copy( v1.positionScreen );
-					_clippedVertex2PositionScreen.copy( v2.positionScreen );
-
-					if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) ) {
-
-						// Perform the perspective divide
-						_clippedVertex1PositionScreen.multiplyScalar( 1 / _clippedVertex1PositionScreen.w );
-						_clippedVertex2PositionScreen.multiplyScalar( 1 / _clippedVertex2PositionScreen.w );
-
-						_line = getNextLineInPool();
-						_line.v1.positionScreen.copy( _clippedVertex1PositionScreen );
-						_line.v2.positionScreen.copy( _clippedVertex2PositionScreen );
-
-						_line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z );
-
-						_line.materials = object.materials;
-
-						_renderList.push( _line );
-
-					}
-				}
-
-			} else if ( object instanceof THREE.Particle ) {
-
-				_vector4.set( object.matrixWorld.n14, object.matrixWorld.n24, object.matrixWorld.n34, 1 );
-				_projScreenMatrix.multiplyVector4( _vector4 );
-
-				_vector4.z /= _vector4.w;
-
-				if ( _vector4.z > 0 && _vector4.z < 1 ) {
-
-					_particle = getNextParticleInPool();
-					_particle.x = _vector4.x / _vector4.w;
-					_particle.y = _vector4.y / _vector4.w;
-					_particle.z = _vector4.z;
-
-					_particle.rotation = object.rotation.z;
-
-					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) );
-					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) );
-
-					_particle.materials = object.materials;
-
-					_renderList.push( _particle );
-
-				}
-
-			}
-
-		}
-
-		sort && _renderList.sort( painterSort );
-
-		return _renderList;
-
-	};
-
-	// Pools
-
-	function getNextObjectInPool() {
-
-		var object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject();
-
-		_objectCount ++;
-
-		return object;
-
-	}
-
-	function getNextVertexInPool() {
-
-		var vertex = _vertexPool[ _vertexCount ] = _vertexPool[ _vertexCount ] || new THREE.RenderableVertex();
-
-		_vertexCount ++;
-
-		return vertex;
-
-	}
-
-	function getNextFace3InPool() {
-
-		var face = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3();
-
-		_face3Count ++;
-
-		return face;
-
-	}
-
-	function getNextFace4InPool() {
-
-		var face = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4();
-
-		_face4Count ++;
-
-		return face;
-
-	}
-
-	function getNextLineInPool() {
-
-		var line = _linePool[ _lineCount ] = _linePool[ _lineCount ] || new THREE.RenderableLine();
-
-		_lineCount ++;
-
-		return line;
-
-	}
-
-	function getNextParticleInPool() {
-
-		var particle = _particlePool[ _particleCount ] = _particlePool[ _particleCount ] || new THREE.RenderableParticle();
-		_particleCount ++;
-		return particle;
-
-	}
-
-	//
-
-	function painterSort( a, b ) {
-
-		return b.z - a.z;
-
-	}
-
-	function computeFrustum( m ) {
-
-		_frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 );
-		_frustum[ 1 ].set( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 );
-		_frustum[ 2 ].set( m.n41 + m.n21, m.n42 + m.n22, m.n43 + m.n23, m.n44 + m.n24 );
-		_frustum[ 3 ].set( m.n41 - m.n21, m.n42 - m.n22, m.n43 - m.n23, m.n44 - m.n24 );
-		_frustum[ 4 ].set( m.n41 - m.n31, m.n42 - m.n32, m.n43 - m.n33, m.n44 - m.n34 );
-		_frustum[ 5 ].set( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 );
-
-		for ( var i = 0; i < 6; i ++ ) {
-
-			var plane = _frustum[ i ];
-			plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) );
-
-		}
-
-	}
-
-	function isInFrustum( object ) {
-
-		var distance, matrix = object.matrixWorld,
-		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
-
-		for ( var i = 0; i < 6; i ++ ) {
-
-			distance = _frustum[ i ].x * matrix.n14 + _frustum[ i ].y * matrix.n24 + _frustum[ i ].z * matrix.n34 + _frustum[ i ].w;
-			if ( distance <= radius ) return false;
-
-		}
-
-		return true;
-
-	};
-
-	function clipLine( s1, s2 ) {
-
-		var alpha1 = 0, alpha2 = 1,
-
-		// Calculate the boundary coordinate of each vertex for the near and far clip planes,
-		// Z = -1 and Z = +1, respectively.
-		bc1near =  s1.z + s1.w,
-		bc2near =  s2.z + s2.w,
-		bc1far =  - s1.z + s1.w,
-		bc2far =  - s2.z + s2.w;
-
-		if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) {
-
-			// Both vertices lie entirely within all clip planes.
-			return true;
-
-		} else if ( ( bc1near < 0 && bc2near < 0) || (bc1far < 0 && bc2far < 0 ) ) {
-
-			// Both vertices lie entirely outside one of the clip planes.
-			return false;
-
-		} else {
-
-			// The line segment spans at least one clip plane.
-
-			if ( bc1near < 0 ) {
-
-				// v1 lies outside the near plane, v2 inside
-				alpha1 = Math.max( alpha1, bc1near / ( bc1near - bc2near ) );
-
-			} else if ( bc2near < 0 ) {
-
-				// v2 lies outside the near plane, v1 inside
-				alpha2 = Math.min( alpha2, bc1near / ( bc1near - bc2near ) );
-
-			}
-
-			if ( bc1far < 0 ) {
-
-				// v1 lies outside the far plane, v2 inside
-				alpha1 = Math.max( alpha1, bc1far / ( bc1far - bc2far ) );
-
-			} else if ( bc2far < 0 ) {
-
-				// v2 lies outside the far plane, v2 inside
-				alpha2 = Math.min( alpha2, bc1far / ( bc1far - bc2far ) );
-
-			}
-
-			if ( alpha2 < alpha1 ) {
-
-				// The line segment spans two boundaries, but is outside both of them.
-				// (This can't happen when we're only clipping against just near/far but good
-				//  to leave the check here for future usage if other clip planes are added.)
-				return false;
-
-			} else {
-
-				// Update the s1 and s2 vertices to match the clipped line segment.
-				s1.lerpSelf( s2, alpha1 );
-				s2.lerpSelf( s1, 1 - alpha2 );
-
-				return true;
-
-			}
-
-		}
-
-	}
-
-};

+ 21 - 6
src/renderers/WebGLRenderer.js

@@ -2893,7 +2893,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		attributes = program.attributes;
 		attributes = program.attributes;
 
 
 		var updateBuffers = false,
 		var updateBuffers = false,
-			geometryGroupHash = geometryGroup.id * 0xffffff + program.id;
+			wireframeBit = material.wireframe ? 1 : 0,
+			geometryGroupHash = ( geometryGroup.id * 0xffffff ) + ( program.id * 2 ) + wireframeBit;
 
 
 		if ( geometryGroupHash != _currentGeometryGroupHash ) {
 		if ( geometryGroupHash != _currentGeometryGroupHash ) {
 
 
@@ -3522,12 +3523,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				scene.update( undefined, false, _cameraLight );
 				scene.update( undefined, false, _cameraLight );
 
 
+				THREE.Matrix4.makeInvert( _cameraLight.matrixWorld, _cameraLight.matrixWorldInverse );
+
 				// compute shadow matrix
 				// compute shadow matrix
 
 
-				shadowMatrix.set( 0.5, 0.0, 0.0, 0.5,
-								  0.0, 0.5, 0.0, 0.5,
-								  0.0, 0.0, 0.5, 0.5,
-								  0.0, 0.0, 0.0, 1.0 );
+				shadowMatrix.set(
+					0.5, 0.0, 0.0, 0.5,
+					0.0, 0.5, 0.0, 0.5,
+					0.0, 0.0, 0.5, 0.5,
+					0.0, 0.0, 0.0, 1.0
+				);
 
 
 				shadowMatrix.multiplySelf( _cameraLight.projectionMatrix );
 				shadowMatrix.multiplySelf( _cameraLight.projectionMatrix );
 				shadowMatrix.multiplySelf( _cameraLight.matrixWorldInverse );
 				shadowMatrix.multiplySelf( _cameraLight.matrixWorldInverse );
@@ -3538,6 +3543,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 				_cameraLight.projectionMatrix.flattenToArray( _projectionMatrixArray );
 				_cameraLight.projectionMatrix.flattenToArray( _projectionMatrixArray );
 
 
 				_projScreenMatrix.multiply( _cameraLight.projectionMatrix, _cameraLight.matrixWorldInverse );
 				_projScreenMatrix.multiply( _cameraLight.projectionMatrix, _cameraLight.matrixWorldInverse );
+
 				computeFrustum( _projScreenMatrix );
 				computeFrustum( _projScreenMatrix );
 
 
 				_this.initWebGLObjects( scene );
 				_this.initWebGLObjects( scene );
@@ -3694,16 +3700,25 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_this.info.render.faces = 0;
 		_this.info.render.faces = 0;
 
 
 		// hack: find parent of camera.
 		// hack: find parent of camera.
-		if (camera.matrixAutoUpdate) {
+
+		if ( camera.matrixAutoUpdate ) {
+
 			var parent = camera;
 			var parent = camera;
+
 			while ( parent.parent ) {
 			while ( parent.parent ) {
+
 				parent = parent.parent;
 				parent = parent.parent;
+
 			}
 			}
+
 			parent.update( undefined, true );
 			parent.update( undefined, true );
+
 		}
 		}
 
 
 		scene.update( undefined, false, camera );
 		scene.update( undefined, false, camera );
 
 
+		THREE.Matrix4.makeInvert( camera.matrixWorld, camera.matrixWorldInverse );
+
 		camera.matrixWorldInverse.flattenToArray( _viewMatrixArray );
 		camera.matrixWorldInverse.flattenToArray( _viewMatrixArray );
 		camera.projectionMatrix.flattenToArray( _projectionMatrixArray );
 		camera.projectionMatrix.flattenToArray( _projectionMatrixArray );
 
 

+ 7 - 13
src/renderers/WebGLShaders.js

@@ -385,16 +385,13 @@ THREE.ShaderChunk = {
 				"vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );",
 				"vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );",
 				"float pointDistance = vPointLight[ i ].w;",
 				"float pointDistance = vPointLight[ i ].w;",
 
 
-				"float pointDotNormalHalf = dot( normal, pointHalfVector );",
+				"float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );",
 				"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 				"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 
 
-				"float pointSpecularWeight = 0.0;",
-
-				"if ( pointDotNormalHalf >= 0.0 )",
-					"pointSpecularWeight = pow( pointDotNormalHalf, shininess );",
+				"float pointSpecularWeight = pow( pointDotNormalHalf, shininess );",
 
 
 				"pointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;",
 				"pointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;",
-				"pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDistance;",
+				"pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;",
 
 
 			"}",
 			"}",
 
 
@@ -412,16 +409,13 @@ THREE.ShaderChunk = {
 				"vec3 dirVector = normalize( lDirection.xyz );",
 				"vec3 dirVector = normalize( lDirection.xyz );",
 				"vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );",
 				"vec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );",
 
 
-				"float dirDotNormalHalf = dot( normal, dirHalfVector );",
-
+				"float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );",
 				"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 				"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 
 
-				"float dirSpecularWeight = 0.0;",
-				"if ( dirDotNormalHalf >= 0.0 )",
-					"dirSpecularWeight = pow( dirDotNormalHalf, shininess );",
+				"float dirSpecularWeight = pow( dirDotNormalHalf, shininess );",
 
 
 				"dirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;",
 				"dirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;",
-				"dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight;",
+				"dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;",
 
 
 			"}",
 			"}",
 
 
@@ -444,7 +438,7 @@ THREE.ShaderChunk = {
 
 
 		"#endif",
 		"#endif",
 
 
-		"gl_FragColor.xyz = gl_FragColor.xyz * totalDiffuse + totalSpecular + ambientLightColor * ambient;"
+		"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;"
 
 
 	].join("\n"),
 	].join("\n"),
 
 

Some files were not shown because too many files changed in this diff