Browse Source

Merge remote-tracking branch 'alteredq/dev' into dev

Mr.doob 13 years ago
parent
commit
3f1c390ee5

+ 6 - 6
build/Three.js

@@ -73,12 +73,12 @@ P.positionScreen.x)))ga=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ga,l.v1.copy(
 ca.positionScreen.y)-(Q.positionScreen.y-ca.positionScreen.y)*(ga.positionScreen.x-ca.positionScreen.x))))na=q[o]=q[o]||new THREE.RenderableFace4,o++,l=na,l.v1.copy(P),l.v2.copy(Q),l.v3.copy(ca),l.v4.copy(ga);else continue;l.normalWorld.copy(y.normal);aa.multiplyVector3(l.normalWorld);l.centroidWorld.copy(y.centroid);T.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);C.multiplyVector3(l.centroidScreen);ca=y.vertexNormals;for(P=0,Q=ca.length;P<Q;P++)ga=l.vertexNormalsWorld[P],
 ga.copy(ca[P]),aa.multiplyVector3(ga);for(P=0,Q=Ra.length;P<Q;P++)if(na=Ra[P][F])for(ca=0,ga=na.length;ca<ga;ca++)l.uvs[P][ca]=na[ca];l.material=S;l.faceMaterial=null!==y.materialIndex?$[y.materialIndex]:null;l.z=l.centroidScreen.z;v.elements.push(l)}}else if(ba instanceof THREE.Line){A.multiply(C,T);F=ba.geometry.vertices;P=b();P.positionScreen.copy(F[0].position);A.multiplyVector4(P.positionScreen);for(B=1,y=F.length;B<y;B++)if(P=b(),P.positionScreen.copy(F[B].position),A.multiplyVector4(P.positionScreen),
 Q=k[i-2],J.copy(P.positionScreen),N.copy(Q.positionScreen),d(J,N))J.multiplyScalar(1/J.w),N.multiplyScalar(1/N.w),ba=s[r]=s[r]||new THREE.RenderableLine,r++,m=ba,m.v1.positionScreen.copy(J),m.v2.positionScreen.copy(N),m.z=Math.max(J.z,N.z),m.material=S,v.elements.push(m)}for(a=0,j=v.sprites.length;a<j;a++)if(ba=v.sprites[a].object,T=ba.matrixWorld,ba instanceof THREE.Particle&&(D.set(T.n14,T.n24,T.n34,1),C.multiplyVector4(D),D.z/=D.w,0<D.z&&1>D.z))g=x[u]=x[u]||new THREE.RenderableParticle,u++,t=g,
-t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=ba.rotation.z,t.scale.x=ba.scale.x*Math.abs(t.x-(D.x+f.projectionMatrix.n11)/(D.w+f.projectionMatrix.n14)),t.scale.y=ba.scale.y*Math.abs(t.y-(D.y+f.projectionMatrix.n22)/(D.w+f.projectionMatrix.n24)),t.material=ba.material,v.elements.push(t);e&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),e=a*b,h=d*f;this.w=e*g-h*c;this.x=e*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f*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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
-this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,i=this.w,k=i*c+e*f-h*d,l=i*d+h*c-g*f,p=i*f+g*d-e*c,c=-g*
-c-e*d-h*f;b.x=k*i+c*-g+l*-h-p*-e;b.y=l*i+c*-e+p*-g-k*-h;b.z=p*i+c*-h+k*-e-l*-g;return b}};
+t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=ba.rotation.z,t.scale.x=ba.scale.x*Math.abs(t.x-(D.x+f.projectionMatrix.n11)/(D.w+f.projectionMatrix.n14)),t.scale.y=ba.scale.y*Math.abs(t.y-(D.y+f.projectionMatrix.n22)/(D.w+f.projectionMatrix.n24)),t.material=ba.material,v.elements.push(t);e&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),g=Math.cos(c),c=Math.sin(c),e=a*b,h=d*f;this.w=e*g-h*c;this.x=e*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f*
+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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?
+-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=
+this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=
+a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,i=this.w,k=i*c+e*f-h*d,l=i*d+h*c-g*f,p=i*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=k*i+c*-g+l*-h-p*-e;b.y=l*i+c*-e+p*-g-k*-h;b.z=p*i+c*-h+k*-e-l*-g;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>f?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(1<=Math.abs(f))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(0.0010>Math.abs(f))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,f,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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};

+ 6 - 6
build/custom/ThreeCanvas.js

@@ -72,12 +72,12 @@ y.positionScreen.x)))V=n[o]=n[o]||new THREE.RenderableFace3,o++,l=V,l.v1.copy(y)
 (O.positionScreen.y-M.positionScreen.y)*(V.positionScreen.x-M.positionScreen.x))))ea=p[j]=p[j]||new THREE.RenderableFace4,j++,l=ea,l.v1.copy(y),l.v2.copy(O),l.v3.copy(M),l.v4.copy(V);else continue;l.normalWorld.copy(t.normal);C.multiplyVector3(l.normalWorld);l.centroidWorld.copy(t.centroid);u.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);F.multiplyVector3(l.centroidScreen);M=t.vertexNormals;for(y=0,O=M.length;y<O;y++)V=l.vertexNormalsWorld[y],V.copy(M[y]),C.multiplyVector3(V);
 for(y=0,O=ka.length;y<O;y++)if(ea=ka[y][Q])for(M=0,V=ea.length;M<V;M++)l.uvs[y][M]=ea[M];l.material=z;l.faceMaterial=null!==t.materialIndex?B[t.materialIndex]:null;l.z=l.centroidScreen.z;w.elements.push(l)}}else if(K instanceof THREE.Line){r.multiply(F,u);Q=K.geometry.vertices;y=b();y.positionScreen.copy(Q[0].position);r.multiplyVector4(y.positionScreen);for(E=1,t=Q.length;E<t;E++)if(y=b(),y.positionScreen.copy(Q[E].position),r.multiplyVector4(y.positionScreen),O=h[m-2],D.copy(y.positionScreen),J.copy(O.positionScreen),
 d(D,J))D.multiplyScalar(1/D.w),J.multiplyScalar(1/J.w),K=x[q]=x[q]||new THREE.RenderableLine,q++,k=K,k.v1.positionScreen.copy(D),k.v2.positionScreen.copy(J),k.z=Math.max(D.z,J.z),k.material=z,w.elements.push(k)}for(a=0,T=w.sprites.length;a<T;a++)if(K=w.sprites[a].object,u=K.matrixWorld,K instanceof THREE.Particle&&(A.set(u.n14,u.n24,u.n34,1),F.multiplyVector4(A),A.z/=A.w,0<A.z&&1>A.z))g=G[I]=G[I]||new THREE.RenderableParticle,I++,v=g,v.x=A.x/A.w,v.y=A.y/A.w,v.z=A.z,v.rotation=K.rotation.z,v.scale.x=
-K.scale.x*Math.abs(v.x-(A.x+e.projectionMatrix.n11)/(A.w+e.projectionMatrix.n14)),v.scale.y=K.scale.y*Math.abs(v.y-(A.y+e.projectionMatrix.n22)/(A.w+e.projectionMatrix.n24)),v.material=K.material,w.elements.push(v);f&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
-this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
-this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,m=this.w,h=m*c+g*e-i*d,l=m*d+i*c-f*e,o=m*e+f*d-g*c,c=-f*
-c-g*d-i*e;b.x=h*m+c*-f+l*-i-o*-g;b.y=l*m+c*-g+o*-f-h*-i;b.z=o*m+c*-i+h*-g-l*-f;return b}};
+K.scale.x*Math.abs(v.x-(A.x+e.projectionMatrix.n11)/(A.w+e.projectionMatrix.n14)),v.scale.y=K.scale.y*Math.abs(v.y-(A.y+e.projectionMatrix.n22)/(A.w+e.projectionMatrix.n24)),v.material=K.material,w.elements.push(v);f&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*
+f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?
+-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=
+this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=
+a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,m=this.w,h=m*c+g*e-i*d,l=m*d+i*c-f*e,o=m*e+f*d-g*c,c=-f*c-g*d-i*e;b.x=h*m+c*-f+l*-i-o*-g;b.y=l*m+c*-g+o*-f-h*-i;b.z=o*m+c*-i+h*-g-l*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};

+ 6 - 6
build/custom/ThreeDOM.js

@@ -72,12 +72,12 @@ t.positionScreen.x)))E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(t)
 (C.positionScreen.y-A.positionScreen.y)*(E.positionScreen.x-A.positionScreen.x))))N=q[m]=q[m]||new THREE.RenderableFace4,m++,j=N,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A),j.v4.copy(E);else continue;j.normalWorld.copy(u.normal);M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(u.centroid);L.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);A=u.vertexNormals;for(t=0,C=A.length;t<C;t++)E=j.vertexNormalsWorld[t],E.copy(A[t]),M.multiplyVector3(E);
 for(t=0,C=W.length;t<C;t++)if(N=W[t][G])for(A=0,E=N.length;A<E;A++)j.uvs[t][A]=N[A];j.material=U;j.faceMaterial=null!==u.materialIndex?X[u.materialIndex]:null;j.z=j.centroidScreen.z;s.elements.push(j)}}else if(y instanceof THREE.Line){F.multiply(z,L);G=y.geometry.vertices;t=b();t.positionScreen.copy(G[0].position);F.multiplyVector4(t.positionScreen);for(K=1,u=G.length;K<u;K++)if(t=b(),t.positionScreen.copy(G[K].position),F.multiplyVector4(t.positionScreen),C=i[k-2],H.copy(t.positionScreen),I.copy(C.positionScreen),
 d(H,I))H.multiplyScalar(1/H.w),I.multiplyScalar(1/I.w),y=v[p]=v[p]||new THREE.RenderableLine,p++,o=y,o.v1.positionScreen.copy(H),o.v2.positionScreen.copy(I),o.z=Math.max(H.z,I.z),o.material=U,s.elements.push(o)}for(a=0,T=s.sprites.length;a<T;a++)if(y=s.sprites[a].object,L=y.matrixWorld,y instanceof THREE.Particle&&(x.set(L.n14,L.n24,L.n34,1),z.multiplyVector4(x),x.z/=x.w,0<x.z&&1>x.z))g=D[w]=D[w]||new THREE.RenderableParticle,w++,r=g,r.x=x.x/x.w,r.y=x.y/x.w,r.z=x.z,r.rotation=y.rotation.z,r.scale.x=
-y.scale.x*Math.abs(r.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),r.scale.y=y.scale.y*Math.abs(r.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),r.material=y.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
-this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
-this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,i=k*c+g*e-h*d,j=k*d+h*c-f*e,l=k*e+f*d-g*c,c=-f*
-c-g*d-h*e;b.x=i*k+c*-f+j*-h-l*-g;b.y=j*k+c*-g+l*-f-i*-h;b.z=l*k+c*-h+i*-g-j*-f;return b}};
+y.scale.x*Math.abs(r.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),r.scale.y=y.scale.y*Math.abs(r.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),r.material=y.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*
+f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?
+-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=
+this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=
+a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,i=k*c+g*e-h*d,j=k*d+h*c-f*e,l=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*k+c*-f+j*-h-l*-g;b.y=j*k+c*-g+l*-f-i*-h;b.z=l*k+c*-h+i*-g-j*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};

+ 6 - 6
build/custom/ThreeSVG.js

@@ -72,12 +72,12 @@ x.positionScreen.x)))J=n[m]=n[m]||new THREE.RenderableFace3,m++,i=J,i.v1.copy(x)
 (D.positionScreen.y-F.positionScreen.y)*(J.positionScreen.x-F.positionScreen.x))))R=p[k]=p[k]||new THREE.RenderableFace4,k++,i=R,i.v1.copy(x),i.v2.copy(D),i.v3.copy(F),i.v4.copy(J);else continue;i.normalWorld.copy(r.normal);P.multiplyVector3(i.normalWorld);i.centroidWorld.copy(r.centroid);O.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);z.multiplyVector3(i.centroidScreen);F=r.vertexNormals;for(x=0,D=F.length;x<D;x++)J=i.vertexNormalsWorld[x],J.copy(F[x]),P.multiplyVector3(J);
 for(x=0,D=W.length;x<D;x++)if(R=W[x][s])for(F=0,J=R.length;F<J;F++)i.uvs[x][F]=R[F];i.material=U;i.faceMaterial=null!==r.materialIndex?X[r.materialIndex]:null;i.z=i.centroidScreen.z;v.elements.push(i)}}else if(H instanceof THREE.Line){G.multiply(z,O);s=H.geometry.vertices;x=b();x.positionScreen.copy(s[0].position);G.multiplyVector4(x.positionScreen);for(N=1,r=s.length;N<r;N++)if(x=b(),x.positionScreen.copy(s[N].position),G.multiplyVector4(x.positionScreen),D=j[l-2],I.copy(x.positionScreen),A.copy(D.positionScreen),
 d(I,A))I.multiplyScalar(1/I.w),A.multiplyScalar(1/A.w),H=y[q]=y[q]||new THREE.RenderableLine,q++,o=H,o.v1.positionScreen.copy(I),o.v2.positionScreen.copy(A),o.z=Math.max(I.z,A.z),o.material=U,v.elements.push(o)}for(a=0,T=v.sprites.length;a<T;a++)if(H=v.sprites[a].object,O=H.matrixWorld,H instanceof THREE.Particle&&(w.set(O.n14,O.n24,O.n34,1),z.multiplyVector4(w),w.z/=w.w,0<w.z&&1>w.z))g=t[E]=t[E]||new THREE.RenderableParticle,E++,u=g,u.x=w.x/w.w,u.y=w.y/w.w,u.z=w.z,u.rotation=H.rotation.z,u.scale.x=
-H.scale.x*Math.abs(u.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),u.scale.y=H.scale.y*Math.abs(u.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),u.material=H.material,v.elements.push(u);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
-this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
-this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,l=this.w,j=l*c+g*e-h*d,i=l*d+h*c-f*e,m=l*e+f*d-g*c,c=-f*
-c-g*d-h*e;b.x=j*l+c*-f+i*-h-m*-g;b.y=i*l+c*-g+m*-f-j*-h;b.z=m*l+c*-h+j*-g-i*-f;return b}};
+H.scale.x*Math.abs(u.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),u.scale.y=H.scale.y*Math.abs(u.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),u.material=H.material,v.elements.push(u);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*
+f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?
+-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=
+this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=
+a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,l=this.w,j=l*c+g*e-h*d,i=l*d+h*c-f*e,m=l*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*l+c*-f+i*-h-m*-g;b.y=i*l+c*-g+m*-f-j*-h;b.z=m*l+c*-h+j*-g-i*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};

+ 6 - 6
build/custom/ThreeWebGL.js

@@ -72,12 +72,12 @@ Q.positionScreen.y)*(L.positionScreen.x-Q.positionScreen.x)))ya=p[n]=p[n]||new T
 W.positionScreen.x)*(ya.positionScreen.y-W.positionScreen.y)-(L.positionScreen.y-W.positionScreen.y)*(ya.positionScreen.x-W.positionScreen.x))))Ua=m[o]=m[o]||new THREE.RenderableFace4,o++,j=Ua,j.v1.copy(Q),j.v2.copy(L),j.v3.copy(W),j.v4.copy(ya);else continue;j.normalWorld.copy(ba.normal);Ba.multiplyVector3(j.normalWorld);j.centroidWorld.copy(ba.centroid);Ea.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);A.multiplyVector3(j.centroidScreen);W=ba.vertexNormals;for(Q=0,L=W.length;Q<
 L;Q++)ya=j.vertexNormalsWorld[Q],ya.copy(W[Q]),Ba.multiplyVector3(ya);for(Q=0,L=Ta.length;Q<L;Q++)if(Ua=Ta[Q][pa])for(W=0,ya=Ua.length;W<ya;W++)j.uvs[Q][W]=Ua[W];j.material=Na;j.faceMaterial=null!==ba.materialIndex?Oa[ba.materialIndex]:null;j.z=j.centroidScreen.z;u.elements.push(j)}}else if(ca instanceof THREE.Line){M.multiply(A,Ea);pa=ca.geometry.vertices;Q=b();Q.positionScreen.copy(pa[0].position);M.multiplyVector4(Q.positionScreen);for(B=1,ba=pa.length;B<ba;B++)if(Q=b(),Q.positionScreen.copy(pa[B].position),
 M.multiplyVector4(Q.positionScreen),L=l[k-2],I.copy(Q.positionScreen),S.copy(L.positionScreen),d(I,S))I.multiplyScalar(1/I.w),S.multiplyScalar(1/S.w),ca=z[t]=z[t]||new THREE.RenderableLine,t++,r=ca,r.v1.positionScreen.copy(I),r.v2.positionScreen.copy(S),r.z=Math.max(I.z,S.z),r.material=Na,u.elements.push(r)}for(a=0,g=u.sprites.length;a<g;a++)if(ca=u.sprites[a].object,Ea=ca.matrixWorld,ca instanceof THREE.Particle&&(H.set(Ea.n14,Ea.n24,Ea.n34,1),A.multiplyVector4(H),H.z/=H.w,0<H.z&&1>H.z))h=K[J]=K[J]||
-new THREE.RenderableParticle,J++,y=h,y.x=H.x/H.w,y.y=H.y/H.w,y.z=H.z,y.rotation=ca.rotation.z,y.scale.x=ca.scale.x*Math.abs(y.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),y.scale.y=ca.scale.y*Math.abs(y.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),y.material=ca.material,u.elements.push(y);f&&u.elements.sort(c);return u}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),h=a*b,i=d*e;this.w=h*f-i*c;this.x=h*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
-this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
-this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,e=this.w,f=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*h;this.y=c*a+e*h+d*f-b*i;this.z=d*a+e*i+b*h-c*f;this.w=e*a-b*f-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*e-i*d,j=k*d+i*c-f*e,n=k*e+f*d-h*c,c=-f*
-c-h*d-i*e;b.x=l*k+c*-f+j*-i-n*-h;b.y=j*k+c*-h+n*-f-l*-i;b.z=n*k+c*-i+l*-h-j*-f;return b}};
+new THREE.RenderableParticle,J++,y=h,y.x=H.x/H.w,y.y=H.y/H.w,y.z=H.z,y.rotation=ca.rotation.z,y.scale.x=ca.scale.x*Math.abs(y.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),y.scale.y=ca.scale.y*Math.abs(y.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),y.material=ca.material,u.elements.push(y);f&&u.elements.sort(c);return u}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),h=a*b,i=d*e;this.w=h*f-i*c;this.x=h*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*
+f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?
+-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=
+this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*h;this.y=c*a+e*h+d*f-b*i;this.z=d*a+e*i+b*h-c*f;this.w=e*a-b*f-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=
+a);var c=a.x,d=a.y,e=a.z,f=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*e-i*d,j=k*d+i*c-f*e,n=k*e+f*d-h*c,c=-f*c-h*d-i*e;b.x=l*k+c*-f+j*-i-n*-h;b.y=j*k+c*-h+n*-f-l*-i;b.z=n*k+c*-i+l*-h-j*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};

+ 16 - 8
docs/api/core/Matrix3.rst

@@ -1,30 +1,38 @@
 Matrix3 - A 3x3 matrix
 ----------------------
 
+.. ...............................................................................
 .. rubric:: Constructor
+.. ...............................................................................
 
 .. class:: Matrix3()
 
     A 3x3 matrix
-    
+
+.. ...............................................................................
 .. rubric:: Attributes
+.. ...............................................................................
 
 .. attribute:: Matrix3.m
 
-    //todo:description
+    Array with matrix values
 
+.. ...............................................................................
 .. rubric:: Methods
+.. ...............................................................................
 
 .. function:: Matrix3.transpose()
 
-    //todo::description
+    Transposes this matrix in place
 
-.. function:: Matrix3.transposeIntoArray(r)
+    :returns: This matrix
+    :rtype: :class:`Matrix3`
 
-    //todo::description
+.. function:: Matrix3.transposeIntoArray( r )
 
-.. rubric:: Example(s)
+    Transposes this matrix into supplied array ``r``
 
-::
+    This matrix is unmodified
 
-//todo:example
+    :returns: This matrix
+    :rtype: :class:`Matrix3`

+ 292 - 142
docs/api/core/Matrix4.rst

@@ -5,7 +5,7 @@ Matrix4 - A 4x4 Matrix
 .. rubric:: Constructor
 .. ...............................................................................
 
-.. class:: Matrix4( [ n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43,n44 ] )
+.. class:: Matrix4( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44  )
 
     A 4x4 Matrix
 
@@ -35,287 +35,420 @@ Matrix4 - A 4x4 Matrix
 .. rubric:: Methods
 .. ...............................................................................
 
-.. function:: Matrix4.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43,n44)
+.. function:: Matrix4.clone( )
+
+    Clones this matrix
+
+    :returns: New instance identical to this matrix
+    :rtype: :class:`Matrix4`
+
+.. function:: Matrix4.set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 )
 
     Sets all fields of this matrix
 
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
+
 .. function:: Matrix4.identity()
 
-    //todo:description
+    Resets this matrix to identity
+
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.copy(m)
+.. function:: Matrix4.copy( m )
 
-    Copies a matrix into this matrix
+    Copies a matrix ``m`` into this matrix
 
     :param Matrix4 m: Matrix to be copied
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.lookAt(eye,center,up)
+.. function:: Matrix4.lookAt( eye, center, up )
 
-    //todo:description
+    Constructs rotation matrix, looking from ``eye`` towards ``center`` with defined ``up`` vector
 
-    :param Vector3 eye: //todo
-    :param Vector3 center: //todo
-    :param Vector3 up: //todo
+    :param Vector3 eye: vector
+    :param Vector3 center: vector
+    :param Vector3 up: vector
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.multiply(a,b)
+.. function:: Matrix4.multiply( a, b )
 
-    //todo:description
+    Sets this matrix to ``a * b``
 
-    :param Matrix4 a: //todo
-    :param Matrix4 b: //todo
+    :param Matrix4 a: source matrix A
+    :param Matrix4 b: source matrix B
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.multiplySelf(a)
+.. function:: Matrix4.multiplyToArray( a, b, r )
 
-    //todo:description
+    Sets this matrix to ``a * b`` and sets result into flat array ``r``
 
-    :param Matrix4 a: //todo
+    Destination array can be regular JS array or Typed Array
 
-.. function:: Matrix4.multiplyToArray(a,b,r)
+    :param Matrix4 a: source matrix A
+    :param Matrix4 b: source matrix B
+    :param array r: destination array
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.multiplySelf( a )
 
-    :param Matrix4 a: //todo
-    :param Matrix4 b: //todo
-    :param array r: //todo
+    Multiplies this matrix by ``a``
 
-.. function:: Matrix4.multiplyScalar(s)
+    :param Matrix4 a: matrix
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.multiplyScalar( s )
 
-    :param float  a: //todo
+    Multiplies this matrix by ``s``
 
-.. function:: Matrix4.multiplyVector3(v)
+    :param float  a: number
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    Applys this matrix to a :class:`Vector3`
+.. function:: Matrix4.multiplyVector3( v )
 
-    :param Vector3 v: //todo
-    :rtype: Vector3
+    Applies this matrix to a :class:`Vector3`
 
-.. function:: Matrix4.multiplyVector4(v)
+    :param Vector3 v: vector
+    :returns: Multiplied vector
+    :rtype: :class:`Vector3`
 
-    Applys this matrix to a :class:`Vector4`
+.. function:: Matrix4.multiplyVector4( v )
 
-    :param Vector4 v: //todo
-    :rtype: Vector4
+    Applies this matrix to a :class:`Vector4`
 
-.. function:: Matrix4.rotateAxis(v)
+    :param Vector4 v: vector
+    :returns: Multiplied vector
+    :rtype: :class:`Vector4`
 
-    //todo:description
+.. function:: Matrix4.rotateAxis( v )
 
-    :param Vector3 v: //todo
+    Applies rotation submatrix of this matrix to vector ``v`` and then normalizes it
 
-.. function:: Matrix4.crossVector(a)
+    :param Vector3 v: vector
+    :returns: Rotated vector
+    :rtype: :class:`Vector3`
+
+.. function:: Matrix4.crossVector( a )
 
     //todo:description
 
-    :param Vector4 a: //todo
+    :param Vector4 a: vector
+    :rtype: :class:`Vector4`
 
 .. function:: Matrix4.determinant()
 
-    //todo:description
+    Computes determinant of this matrix
 
-.. function:: Matrix4.transpose()
+    Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
 
-    //todo:description
+    :returns: Determinant
+    :rtype: float
 
-.. function:: Matrix4.clone()
+.. function:: Matrix4.transpose()
 
-    Clones this matrix
+    Transposes this matrix
 
-    :returns: New instance of this matrix
-    :rtype: Matrix4
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
 .. function:: Matrix4.flatten()
 
-    //todo:description
+    Flattens this matrix into internal :attr:`Matrix4.flat` array
 
-.. function:: Matrix4.flattenToArray(flat)
+    :returns: Flat array with this matrix values
+    :rtype: array
 
-    //todo:description
+.. function:: Matrix4.flattenToArray( flat )
 
-    :param array flat: //todo
+    Flattens this matrix into supplied ``flat`` array
+
+    :param array flat: array
+    :returns: Flat array with this matrix values
     :rtype: array
 
-.. function:: Matrix4.flattenToArrayOffset(flat,offset)
+.. function:: Matrix4.flattenToArrayOffset( flat, offset )
 
-    //todo:description
+    Flattens this matrix into supplied ``flat`` array starting from ``offset`` position in the array
 
-    :param array flat: //todo
-    :param integer offset: //todo
+    :param array flat: array
+    :param integer offset: offset
+    :returns: Flat array with this matrix values
     :rtype: array
 
-.. function:: Matrix4.setTranslation(x,y,z)
+.. function:: Matrix4.setTranslation( x, y, z )
 
-    //todo:description
+    Sets this matrix as translation transform
 
-    :param float x: //todo
-    :param float y: //todo
-    :param float z: //todo
+    :param float x: x-translation
+    :param float y: y-translation
+    :param float z: z-translation
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setScale(x,y,z)
+.. function:: Matrix4.setScale( x, y, z )
 
-    //todo:description
+    Sets this matrix as scale transform
 
-    :param float x: //todo
-    :param float y: //todo
-    :param float z: //todo
+    :param float x: x-scale
+    :param float y: y-scale
+    :param float z: z-scale
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setRotationX(theta)
+.. function:: Matrix4.setRotationX( theta )
+
+    Sets this matrix as rotation transform around x-axis by ``theta`` radians
 
-    //todo:description
     :param float theta: Rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setRotationY(theta)
+.. function:: Matrix4.setRotationY( theta )
+
+    Sets this matrix as rotation transform around y-axis by ``theta`` radians
 
-    //todo:description
     :param float theta: Rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setRotationZ(theta)
+.. function:: Matrix4.setRotationZ( theta )
+
+    Sets this matrix as rotation transform around z-axis by ``theta`` radians
 
-    //todo:description
     :param float theta: Rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setRotationAxis(axis,angle)
+.. function:: Matrix4.setRotationAxis( axis, angle )
 
-    //todo:description
+    Sets this matrix as rotation transform around ``axis`` by ``angle`` radians
 
-    :param Vector3 axis: //todo:description
-    :param float angle: //todo:description
+    Based on http://www.gamedev.net/reference/articles/article1199.asp
 
-.. function:: Matrix4.setPosition(v)
+    :param Vector3 axis: Rotation axis
+    :param float angle: Rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.setPosition( v )
+
+    Sets just position component for this matrix from vector ``v``
 
-    :param Vector3 v: //todo
+    :param Vector3 v: position vector
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
 .. function:: Matrix4.getPosition()
 
-    //todo:description
+    Returns position component from this matrix
+
+    Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
+
+    :returns: Vector with position
+    :rtype: :class:`Vector3`
 
 .. function:: Matrix4.getColumnX()
 
-    //todo:description
+    Returns x-column component from this matrix
+
+    Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
+
+    :returns: Vector with x-column
+    :rtype: :class:`Vector3`
 
 .. function:: Matrix4.getColumnY()
 
-    //todo:description
+    Returns y-column component from this matrix
+
+    Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
+
+    :returns: Vector with y-column
+    :rtype: :class:`Vector3`
 
 .. function:: Matrix4.getColumnZ()
 
-    //todo:description
+    Returns z-column component from this matrix
 
-.. function:: Matrix4.getInverse(m)
+    Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
 
-    //todo:description
+    :returns: Vector with z-column
+    :rtype: :class:`Vector3`
 
-    :param Matrix4 m: //todo
+.. function:: Matrix4.getInverse( m )
 
-.. function:: Matrix4.setRotationFromEuler(v,order)
+    Sets this matrix to inverse of matrix ``m``
 
-    //todo:description
+    Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
+
+    :param Matrix4 m: source matrix
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
+
+.. function:: Matrix4.setRotationFromEuler( v, order )
+
+    Sets rotation submatrix of this matrix to rotation specified by Euler angles
+
+    Default order ``XYZ``
 
     :param Vector3 v: Vector3 with all the rotations
     :param string order: The order of rotations eg. 'XYZ'
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.setRotationFromQuaternion(q)
+.. function:: Matrix4.setRotationFromQuaternion( q )
 
-    //todo:description
+    Sets rotation submatrix of this matrix to rotation specified by quaternion
 
-    :param Quaternion q: //todo
+    :param Quaternion q: rotation
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.scale(v)
+.. function:: Matrix4.scale( v )
 
-    //todo:description
+    Multiplies columns of this matrix by vector ``v``
 
-    :param Vector3 v: //todo
+    :param Vector3 v: scale vector
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.compose(translation, rotation, scale)
+.. function:: Matrix4.compose( translation, rotation, scale )
 
-    //todo:description
+    Sets this matrix to transform composed of ``translation``, ``rotation`` and ``scale``
 
-    :param Vector3 translation: //todo
-    :param Quaternion rotation: //todo
-    :param Vector3 scale: //todo
+    :param Vector3 translation: vector
+    :param Quaternion rotation: quaternion
+    :param Vector3 scale: vector
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-.. function:: Matrix4.decompose(translation, rotation, scale)
+.. function:: Matrix4.decompose( translation, rotation, scale )
 
-    //todo:description
+    Decomposes this matrix into `translation``, ``rotation`` and ``scale`` components
 
-    :param Vector3 translation: //todo
-    :param Quaternion rotation: //todo
-    :param Vector3 scale: //todo
-    :returns: //todo
-    :rtype: //todo
+    If parameters are not supplied, new instances will be created
 
-.. function:: Matrix4.extractPosition(m)
+    :param Vector3 translation: destination translation vector
+    :param Quaternion rotation: destination rotation quaternion
+    :param Vector3 scale: destination scale vector
+    :returns: Array [ translation, rotation, scale ]
+    :rtype: Array
 
-    //todo:description
+.. function:: Matrix4.extractPosition( m )
 
-    :param Matrix4 m:
+    Copies translation component of supplied matrix ``m`` into this matrix translation
 
-.. function:: Matrix4.extractRotation(m)
+    :param Matrix4 m: source matrix
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.extractRotation( m )
 
-    :param Matrix4 m:
+    Copies rotation component of supplied matrix ``m`` into this matrix rotation
 
-.. function:: Matrix4.rotateByAxis(axis,angle)
+    :param Matrix4 m: source matrix
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.rotateByAxis( axis, angle )
 
-    :param Vector3 axis: //todo:description
-    :param float angle: //todo:description
+    Rotates this matrix around supplied ``axis`` by ``angle``
 
-.. function:: Matrix4.rotateX(angle)
+    :param Vector3 axis: rotation axis
+    :param float angle: rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.rotateX( angle )
 
-    :param float angle: //todo:description
+    Rotates this matrix around x-axis by ``angle``
 
-.. function:: Matrix4.rotateY(angle)
+    :param float angle: rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.rotateY( angle )
 
-    :param float angle: //todo:description
+    Rotates this matrix around y-axis by ``angle``
 
-.. function:: Matrix4.rotateZ(angle)
+    :param float angle: rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description
+.. function:: Matrix4.rotateZ( angle )
 
-    :param float angle: //todo:description
+    Rotates this matrix around z-axis by ``angle``
 
-.. function:: Matrix4.translate(v)
+    :param float angle: rotation angle in radians
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
 
-    :param Vector3 v: //todo:description
+.. function:: Matrix4.translate( v )
 
-.. function:: Matrix4.makeInvert3x3(m)(static)
+    Translates this matrix by vector ``v``
 
-    //todo:description
+    :param Vector3 v: translation vector
+    :returns: This matrix
+    :rtype: :class:`Matrix4`
+
+.. ...............................................................................
+.. rubric:: Static methods
+.. ...............................................................................
 
-    :param Matrix4 v:
-    :returns: A 3x3 Matrix
-    :rtype: Matrix3
+.. function:: Matrix4.makeInvert3x3( m )
 
-.. function:: Matrix4.makeFrustum( left, right, bottom, top, near, far )(static)
+    Inverts just rotation submatrix of matrix ``m``
 
-    //todo:description and parameters
+    Note: this method returns a reference to internal 3x3 matrix, make copy or clone if you don't use it right away.
 
-    :returns: //todo
-    :rtype: Matrix4
+    Based on http://code.google.com/p/webgl-mjs/
 
-.. function:: Matrix4.makePerspective( fov, aspect, near, far )(static)
+    :param Matrix4 m: source matrix
+    :returns: inverted submatrix
+    :rtype: :class:`Matrix3`
 
-    //todo:description and parameters
+.. function:: Matrix4.makeFrustum( left, right, bottom, top, near, far )
 
-    :returns: //todo
-    :rtype: Matrix4
+    Creates frustum matrix
 
-.. function:: Matrix4.makeOrtho( left, right, top, bottom, near, far )(static)
+    :param float left: left
+    :param float right: right
+    :param float bottom: bottom
+    :param float top: top
+    :param float near: near
+    :param float far: far
+    :returns: New instance of frustum matrix
+    :rtype: :class:`Matrix4`
 
-    //todo:description and parameters
+.. function:: Matrix4.makePerspective( fov, aspect, near, far )
 
-    :returns: //todo
-    :rtype: Matrix4
+    Creates perspective projection matrix
+
+    :param float fov: vertical field of view in degrees
+    :param float aspect: aspect ratio
+    :param float near: near plane
+    :param float far: far plane
+    :returns: New instance of projection matrix
+    :rtype: :class:`Matrix4`
+
+.. function:: Matrix4.makeOrtho( left, right, top, bottom, near, far )
+
+    Creates orthographic projection matrix
+
+    :param float left: left
+    :param float right: right
+    :param float top: top
+    :param float bottom: bottom
+    :param float near: near plane
+    :param float far: far plane
+    :returns: New instance of projection matrix
+    :rtype: :class:`Matrix4`
 
 .. ...............................................................................
 .. rubric:: Example
@@ -323,4 +456,21 @@ Matrix4 - A 4x4 Matrix
 
 ::
 
-//todo::example
+    // simple rig for rotation around 3 axes
+
+    var m = new THREE.Matrix4();
+
+    var m1 = new THREE.Matrix4();
+    var m2 = new THREE.Matrix4();
+    var m3 = new THREE.Matrix4();
+
+    var alpha = 0;
+    var beta = Math.PI;
+    var gamma = Math.PI/2;
+
+    m1.setRotationX( alpha );
+    m2.setRotationY( beta );
+    m3.setRotationZ( gamma );
+
+    m.multiply( m1, m2 );
+    m.multiplySelf( m3 );

+ 159 - 4
docs/api/core/Quaternion.rst

@@ -1,14 +1,169 @@
 Quaternion - Implementation of a quaternion
 -------------------------------------------
 
+.. ...............................................................................
 .. rubric:: Constructor
+.. ...............................................................................
 
-.. class:: Quaternion()
+.. class:: Quaternion( x, y, z, w )
 
     Implementation of a quaternion
-    
+
+    :param float x: x-coordinate
+    :param float y: y-coordinate
+    :param float z: z-coordinate
+    :param float w: w-coordinate
+
+.. ...............................................................................
 .. rubric:: Attributes
+.. ...............................................................................
+
+.. attribute:: Quaternion.x
+
+    float - default ``0``
+
+.. attribute:: Quaternion.y
+
+    float - default ``0``
+
+.. attribute:: Quaternion.z
+
+    float - default ``0``
+
+.. attribute:: Quaternion.w
+
+    float - default ``1``
+
+.. ...............................................................................
+.. rubric:: Methods
+.. ...............................................................................
+
+.. function:: Quaternion.clone( )
+
+    Clones this quaternion
+
+    :returns: New instance identical to this quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.set( x, y, z, w )
+
+    Sets value of this vector
+
+    :param float x: x-coordinate
+    :param float y: y-coordinate
+    :param float z: z-coordinate
+    :param float w: w-coordinate
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.copy( q )
+
+    Copies value of ``q`` to this quaternion
+
+    :param Quaternion v: source quaternion
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.setFromEuler ( vec3 )
+
+    Sets this quaternion from rotation specified by Euler angles
+
+    Angles are in degrees
+
+    :param Vector3 vec3: Euler angles vector
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.setFromAxisAngle ( axis, angle )
+
+    Sets this quaternion from rotation specified by axis and angle
+
+    Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
+
+    Axis have to be normalized, angle is in radians
+
+    :param Vector3 axis: axis vector
+    :param float angle: angle
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.setFromRotationMatrix ( m )
+
+    Sets this quaternion from rotation specified by matrix
+
+    Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
+
+    :param Matrix4 m: rotation matrix
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.calculateW( )
+
+    Calculates ``w`` component of this quaternion
+
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.inverse( )
+
+    Inverts this quaternion
+
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.length( )
+
+    Computes length of this quaternion
+
+    :returns: length
+    :rtype: float
+
+.. function:: Quaternion.normalize( )
+
+    Normalizes this quaternion
+
+    :returns: This vector
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.multiplySelf( quat2 )
+
+    Multiplies this quaternion by ``quat2``
+
+    :param Quaternion quat2: quaternion
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.multiply( q1, q2 )
+
+    Sets this quaternion to ``q1 * q2``
+
+    Adapted from: http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
+
+    :param Quaternion q1: quaternion 1
+    :param Quaternion q2: quaternion 2
+    :returns: This quaternion
+    :rtype: :class:`Quaternion`
+
+.. function:: Quaternion.multiplyVector3( vec, dest )
+
+    Rotates ``vec`` by this quaternion into ``dest``
+
+    If ``dest`` is not specified, result goes to ``vec``
+
+    :param Vector3 vec: source vector
+    :param Vector3 dest: destination vector
+    :returns: Rotated vector
+    :rtype: :class:`Vector3`
+
+
+.. ...............................................................................
+.. rubric:: Example
+.. ...............................................................................
+
+::
 
-.. rubric:: Method
+    var q = new THREE.Quaternion();
+    q.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
 
-.. rubric:: Example(s)
+    var v = new THREE.Vector3( 1, 0, 0 );
+    q.multiplyVector3( v );

+ 1 - 1
docs/static/nature.css

@@ -365,7 +365,7 @@ th.field-name {
 dl.function {
 	border-left: 0px solid #aaa;
 	border-top: 0px solid #aaa;
-	padding: 1em 0;
+	padding: 0.25em 0 1em;
 }
 
 dl.function dt {

+ 4 - 0
src/core/Matrix3.js

@@ -1,3 +1,7 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
 THREE.Matrix3 = function () {
 
 	this.m = [];

+ 6 - 5
src/core/Matrix4.js

@@ -770,7 +770,8 @@ THREE.Matrix4.prototype = {
 
 	rotateByAxis: function ( axis, angle ) {
 
-  		// optimize by checking axis
+		// optimize by checking axis
+
 		if ( axis.x === 1 && axis.y === 0 && axis.z === 0 ) {
 
 			return this.rotateX( angle );
@@ -797,8 +798,8 @@ THREE.Matrix4.prototype = {
 		var xx = x * x,
 			yy = y * y,
 			zz = z * z,
-			c = Math.cos(angle),
-			s = Math.sin(angle),
+			c = Math.cos( angle ),
+			s = Math.sin( angle ),
 			oneMinusCosine = 1 - c,
 			xy = x * y * oneMinusCosine,
 			xz = x * z * oneMinusCosine,
@@ -863,8 +864,8 @@ THREE.Matrix4.prototype = {
 			m23 = this.n23,
 			m33 = this.n33,
 			m43 = this.n43,
-			c = Math.cos(angle),
-			s = Math.sin(angle);
+			c = Math.cos( angle ),
+			s = Math.sin( angle );
 
 		this.n12 = c * m12 + s * m13;
 		this.n22 = c * m22 + s * m23;

+ 21 - 12
src/core/Quaternion.js

@@ -5,14 +5,10 @@
 
 THREE.Quaternion = function( x, y, z, w ) {
 
-	this.set(
-
-		x || 0,
-		y || 0,
-		z || 0,
-		w !== undefined ? w : 1
-
-	);
+	this.x = x || 0;
+	this.y = y || 0;
+	this.z = z || 0;
+	this.w = ( w !== undefined ) ? w : 1;
 
 };
 
@@ -42,6 +38,12 @@ THREE.Quaternion.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new THREE.Quaternion( this.x, this.y, this.z, this.w );
+
+	},
+
 	setFromEuler: function ( vec3 ) {
 
 		var c = Math.PI / 360, // 0.5 * Math.PI / 360, // 0.5 is an optimization
@@ -86,11 +88,16 @@ THREE.Quaternion.prototype = {
 	},
 
 	setFromRotationMatrix: function ( m ) {
+
 		// Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
-		function copySign(a, b) {
-			return b < 0 ? -Math.abs(a) : Math.abs(a);
+
+		function copySign( a, b ) {
+
+			return b < 0 ? -Math.abs( a ) : Math.abs( a );
+
 		}
-		var absQ = Math.pow(m.determinant(), 1.0 / 3.0);
+
+		var absQ = Math.pow( m.determinant(), 1.0 / 3.0 );
 		this.w = Math.sqrt( Math.max( 0, absQ + m.n11 + m.n22 + m.n33 ) ) / 2;
 		this.x = Math.sqrt( Math.max( 0, absQ + m.n11 - m.n22 - m.n33 ) ) / 2;
 		this.y = Math.sqrt( Math.max( 0, absQ - m.n11 + m.n22 - m.n33 ) ) / 2;
@@ -99,7 +106,9 @@ THREE.Quaternion.prototype = {
 		this.y = copySign( this.y, ( m.n13 - m.n31 ) );
 		this.z = copySign( this.z, ( m.n21 - m.n12 ) );
 		this.normalize();
+
 		return this;
+
 	},
 
 	calculateW : function () {
@@ -181,7 +190,7 @@ THREE.Quaternion.prototype = {
 
 	multiplyVector3: function ( vec, dest ) {
 
-		if( !dest ) { dest = vec; }
+		if ( !dest ) { dest = vec; }
 
 		var x    = vec.x,  y  = vec.y,  z  = vec.z,
 			qx   = this.x, qy = this.y, qz = this.z, qw = this.w;