Quellcode durchsuchen

Abstracted Ray::intersectScene into Ray::intersectArray.

Mr.doob vor 14 Jahren
Ursprung
Commit
71d3e32af6

+ 3 - 3
build/Three.js

@@ -11,9 +11,9 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,c,f){this.set(b||0,d||0,c||0,f||1)};
 THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(F,B,T,C){C=C.clone().subSelf(B);T=T.clone().subSelf(B);var V=F.clone().subSelf(B);F=C.dot(C);B=C.dot(T);C=C.dot(V);var P=T.dot(T);T=T.dot(V);V=1/(F*P-B*B);P=(P*C-B*T)*V;F=(F*T-B*C)*V;return P>0&&F>0&&P+F<1}var c,f,g,h,j,k,m,o,t,u,
-w,p=b.geometry,z=p.vertices,G=[];c=0;for(f=p.faces.length;c<f;c++){g=p.faces[c];u=this.origin.clone();w=this.direction.clone();m=b.matrixWorld;h=m.multiplyVector3(z[g.a].position.clone());j=m.multiplyVector3(z[g.b].position.clone());k=m.multiplyVector3(z[g.c].position.clone());m=g instanceof THREE.Face4?m.multiplyVector3(z[g.d].position.clone()):null;o=b.matrixRotationWorld.multiplyVector3(g.normal.clone());t=w.dot(o);if(b.doubleSided||(b.flipSided?t>0:t<0)){o=o.dot((new THREE.Vector3).sub(h,u))/
-t;u=u.addSelf(w.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,m)||d(u,j,k,m))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}}return G}};
+THREE.Ray.prototype={intersectScene:function(b){return this.intersectArray(b.objects)},intersectArray:function(b){var d,c,f,g=[];d=0;for(c=b.length;d<c;d++){f=b[d];f instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(f)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(F,B,T,C){C=C.clone().subSelf(B);T=T.clone().subSelf(B);var V=F.clone().subSelf(B);F=C.dot(C);B=C.dot(T);C=C.dot(V);var P=T.dot(T);T=T.dot(V);V=1/(F*P-B*B);P=(P*C-B*T)*V;F=(F*
+T-B*C)*V;return P>0&&F>0&&P+F<1}var c,f,g,h,j,k,m,o,t,u,w,p=b.geometry,z=p.vertices,G=[];c=0;for(f=p.faces.length;c<f;c++){g=p.faces[c];u=this.origin.clone();w=this.direction.clone();m=b.matrixWorld;h=m.multiplyVector3(z[g.a].position.clone());j=m.multiplyVector3(z[g.b].position.clone());k=m.multiplyVector3(z[g.c].position.clone());m=g instanceof THREE.Face4?m.multiplyVector3(z[g.d].position.clone()):null;o=b.matrixRotationWorld.multiplyVector3(g.normal.clone());t=w.dot(o);if(b.doubleSided||(b.flipSided?
+t>0:t<0)){o=o.dot((new THREE.Vector3).sub(h,u))/t;u=u.addSelf(w.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,m)||d(u,j,k,m))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}}return G}};
 THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,o,t,u){k=!1;d=m;c=o;f=t;g=u;b()};this.addPoint=function(m,o){if(k){k=!1;d=m;c=o;f=m;g=o}else{d=d<m?d:m;c=c<o?c:o;f=f>m?f:m;g=g>o?g:o}b()};
 this.add3Points=function(m,o,t,u,w,p){if(k){k=!1;d=m<t?m<w?m:w:t<w?t:w;c=o<u?o<p?o:p:u<p?u:p;f=m>t?m>w?m:w:t>w?t:w;g=o>u?o>p?o:p:u>p?u:p}else{d=m<t?m<w?m<d?m:d:w<d?w:d:t<w?t<d?t:d:w<d?w:d;c=o<u?o<p?o<c?o:c:p<c?p:c:u<p?u<c?u:c:p<c?p:c;f=m>t?m>w?m>f?m:f:w>f?w:f:t>w?t>f?t:f:w>f?w:f;g=o>u?o>p?o>g?o:g:p>g?p:g:u>p?u>g?u:g:p>g?p:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=d<m.getLeft()?d:m.getLeft();c=c<m.getTop()?c:m.getTop();f=f>m.getRight()?
 f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f<m.getRight()?f:m.getRight();g=g<m.getBottom()?g:m.getBottom();b()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(d,m.getLeft())>=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}};

+ 3 - 3
build/custom/ThreeCanvas.js

@@ -11,9 +11,9 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(D,x,W,X){X=X.clone().subSelf(x);W=W.clone().subSelf(x);var aa=D.clone().subSelf(x);D=X.dot(X);x=X.dot(W);X=X.dot(aa);var H=W.dot(W);W=W.dot(aa);aa=1/(D*H-x*x);H=(H*X-x*W)*aa;D=(D*W-x*X)*aa;return H>0&&D>0&&H+D<1}var c,d,e,g,f,i,h,
-j,p,n,o,k=a.geometry,t=k.vertices,w=[];c=0;for(d=k.faces.length;c<d;c++){e=k.faces[c];n=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(t[e.a].position.clone());f=h.multiplyVector3(t[e.b].position.clone());i=h.multiplyVector3(t[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(t[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());p=o.dot(j);if(a.doubleSided||(a.flipSided?p>0:p<0)){j=j.dot((new THREE.Vector3).sub(g,
-n))/p;n=n.addSelf(o.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(n,g,f,i)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,i,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}}return w}};
+THREE.Ray.prototype={intersectScene:function(a){return this.intersectArray(a.objects)},intersectArray:function(a){var b,c,d,e=[];b=0;for(c=a.length;b<c;b++){d=a[b];d instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(d)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(D,x,W,X){X=X.clone().subSelf(x);W=W.clone().subSelf(x);var aa=D.clone().subSelf(x);D=X.dot(X);x=X.dot(W);X=X.dot(aa);var H=W.dot(W);W=W.dot(aa);aa=1/(D*H-x*x);H=(H*X-x*W)*aa;
+D=(D*W-x*X)*aa;return H>0&&D>0&&H+D<1}var c,d,e,g,f,i,h,j,p,n,o,k=a.geometry,t=k.vertices,w=[];c=0;for(d=k.faces.length;c<d;c++){e=k.faces[c];n=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(t[e.a].position.clone());f=h.multiplyVector3(t[e.b].position.clone());i=h.multiplyVector3(t[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(t[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());p=o.dot(j);if(a.doubleSided||
+(a.flipSided?p>0:p<0)){j=j.dot((new THREE.Vector3).sub(g,n))/p;n=n.addSelf(o.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(n,g,f,i)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,i,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}}return w}};
 THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,j,p,n){i=!1;b=h;c=j;d=p;e=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;d=h;e=j}else{b=b<h?b:h;c=c<j?c:j;d=d>h?d:h;e=e>j?e:j}a()};
 this.add3Points=function(h,j,p,n,o,k){if(i){i=!1;b=h<p?h<o?h:o:p<o?p:o;c=j<n?j<k?j:k:n<k?n:k;d=h>p?h>o?h:o:p>o?p:o;e=j>n?j>k?j:k:n>k?n:k}else{b=h<p?h<o?h<b?h:b:o<b?o:b:p<o?p<b?p:b:o<b?o:b;c=j<n?j<k?j<c?j:c:k<c?k:c:n<k?n<c?n:c:k<c?k:c;d=h>p?h>o?h>d?h:d:o>d?o:d:p>o?p>d?p:d:o>d?o:d;e=j>n?j>k?j>e?j:e:k>e?k:e:n>k?n>e?n:e:k>e?k:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};

+ 3 - 3
build/custom/ThreeDOM.js

@@ -11,9 +11,9 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(t,r,C,G){G=G.clone().subSelf(r);C=C.clone().subSelf(r);var K=t.clone().subSelf(r);t=G.dot(G);r=G.dot(C);G=G.dot(K);var x=C.dot(C);C=C.dot(K);K=1/(t*x-r*r);x=(x*G-r*C)*K;t=(t*C-r*G)*K;return x>0&&t>0&&x+t<1}var c,d,e,h,f,j,g,i,l,k,
-m,n=a.geometry,p=n.vertices,q=[];c=0;for(d=n.faces.length;c<d;c++){e=n.faces[c];k=this.origin.clone();m=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(p[e.a].position.clone());f=g.multiplyVector3(p[e.b].position.clone());j=g.multiplyVector3(p[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(p[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());l=m.dot(i);if(a.doubleSided||(a.flipSided?l>0:l<0)){i=i.dot((new THREE.Vector3).sub(h,k))/
-l;k=k.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(k,h,f,j)){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};q.push(e)}}else if(e instanceof THREE.Face4&&(b(k,h,f,g)||b(k,f,j,g))){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};q.push(e)}}}return q}};
+THREE.Ray.prototype={intersectScene:function(a){return this.intersectArray(a.objects)},intersectArray:function(a){var b,c,d,e=[];b=0;for(c=a.length;b<c;b++){d=a[b];d instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(d)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(t,r,C,G){G=G.clone().subSelf(r);C=C.clone().subSelf(r);var K=t.clone().subSelf(r);t=G.dot(G);r=G.dot(C);G=G.dot(K);var x=C.dot(C);C=C.dot(K);K=1/(t*x-r*r);x=(x*G-r*C)*K;t=(t*
+C-r*G)*K;return x>0&&t>0&&x+t<1}var c,d,e,h,f,j,g,i,l,k,m,n=a.geometry,p=n.vertices,q=[];c=0;for(d=n.faces.length;c<d;c++){e=n.faces[c];k=this.origin.clone();m=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(p[e.a].position.clone());f=g.multiplyVector3(p[e.b].position.clone());j=g.multiplyVector3(p[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(p[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());l=m.dot(i);if(a.doubleSided||(a.flipSided?
+l>0:l<0)){i=i.dot((new THREE.Vector3).sub(h,k))/l;k=k.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(k,h,f,j)){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};q.push(e)}}else if(e instanceof THREE.Face4&&(b(k,h,f,g)||b(k,f,j,g))){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};q.push(e)}}}return q}};
 THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,l,k){j=!1;b=g;c=i;d=l;e=k;a()};this.addPoint=function(g,i){if(j){j=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
 this.add3Points=function(g,i,l,k,m,n){if(j){j=!1;b=g<l?g<m?g:m:l<m?l:m;c=i<k?i<n?i:n:k<n?k:n;d=g>l?g>m?g:m:l>m?l:m;e=i>k?i>n?i:n:k>n?k:n}else{b=g<l?g<m?g<b?g:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b;c=i<k?i<n?i<c?i:c:n<c?n:c:k<n?k<c?k:c:n<c?n:c;d=g>l?g>m?g>d?g:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;e=i>k?i>n?i>e?i:e:n>e?n:e:k>n?k>e?k:e:n>e?n:e}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
 d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};

+ 3 - 3
build/custom/ThreeSVG.js

@@ -11,9 +11,9 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(v,w,I,D){D=D.clone().subSelf(w);I=I.clone().subSelf(w);var N=v.clone().subSelf(w);v=D.dot(D);w=D.dot(I);D=D.dot(N);var x=I.dot(I);I=I.dot(N);N=1/(v*x-w*w);x=(x*D-w*I)*N;v=(v*I-w*D)*N;return x>0&&v>0&&x+v<1}var c,d,e,g,f,j,h,i,k,n,
-m,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];n=this.origin.clone();m=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(q[e.a].position.clone());f=h.multiplyVector3(q[e.b].position.clone());j=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());k=m.dot(i);if(a.doubleSided||(a.flipSided?k>0:k<0)){i=i.dot((new THREE.Vector3).sub(g,n))/
-k;n=n.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(n,g,f,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,j,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}}return r}};
+THREE.Ray.prototype={intersectScene:function(a){return this.intersectArray(a.objects)},intersectArray:function(a){var b,c,d,e=[];b=0;for(c=a.length;b<c;b++){d=a[b];d instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(d)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(v,w,I,D){D=D.clone().subSelf(w);I=I.clone().subSelf(w);var N=v.clone().subSelf(w);v=D.dot(D);w=D.dot(I);D=D.dot(N);var x=I.dot(I);I=I.dot(N);N=1/(v*x-w*w);x=(x*D-w*I)*N;v=(v*
+I-w*D)*N;return x>0&&v>0&&x+v<1}var c,d,e,g,f,j,h,i,k,n,m,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];n=this.origin.clone();m=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(q[e.a].position.clone());f=h.multiplyVector3(q[e.b].position.clone());j=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());k=m.dot(i);if(a.doubleSided||(a.flipSided?
+k>0:k<0)){i=i.dot((new THREE.Vector3).sub(g,n))/k;n=n.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(n,g,f,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,j,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}}return r}};
 THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,k,n){j=!1;b=h;c=i;d=k;e=n;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=b<h?b:h;c=c<i?c:i;d=d>h?d:h;e=e>i?e:i}a()};
 this.add3Points=function(h,i,k,n,m,o){if(j){j=!1;b=h<k?h<m?h:m:k<m?k:m;c=i<n?i<o?i:o:n<o?n:o;d=h>k?h>m?h:m:k>m?k:m;e=i>n?i>o?i:o:n>o?n:o}else{b=h<k?h<m?h<b?h:b:m<b?m:b:k<m?k<b?k:b:m<b?m:b;c=i<n?i<o?i<c?i:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;d=h>k?h>m?h>d?h:d:m>d?m:d:k>m?k>d?k:d:m>d?m:d;e=i>n?i>o?i>e?i:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};

+ 3 - 3
build/custom/ThreeWebGL.js

@@ -11,9 +11,9 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,e,g){this.set(b||0,d||0,e||0,g||1)};
 THREE.Vector4.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;this.w=g;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,e,g=b.objects,h=[];b=0;for(d=g.length;b<d;b++){e=g[b];e instanceof THREE.Mesh&&(h=h.concat(this.intersectObject(e)))}h.sort(function(o,n){return o.distance-n.distance});return h},intersectObject:function(b){function d(V,L,ra,da){da=da.clone().subSelf(L);ra=ra.clone().subSelf(L);var pa=V.clone().subSelf(L);V=da.dot(da);L=da.dot(ra);da=da.dot(pa);var $=ra.dot(ra);ra=ra.dot(pa);pa=1/(V*$-L*L);$=($*da-L*ra)*pa;V=(V*ra-L*da)*pa;return $>0&&V>0&&$+V<
-1}var e,g,h,o,n,q,r,v,E,F,H,I=b.geometry,M=I.vertices,N=[];e=0;for(g=I.faces.length;e<g;e++){h=I.faces[e];F=this.origin.clone();H=this.direction.clone();r=b.matrixWorld;o=r.multiplyVector3(M[h.a].position.clone());n=r.multiplyVector3(M[h.b].position.clone());q=r.multiplyVector3(M[h.c].position.clone());r=h instanceof THREE.Face4?r.multiplyVector3(M[h.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(h.normal.clone());E=H.dot(v);if(b.doubleSided||(b.flipSided?E>0:E<0)){v=v.dot((new THREE.Vector3).sub(o,
-F))/E;F=F.addSelf(H.multiplyScalar(v));if(h instanceof THREE.Face3){if(d(F,o,n,q)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}else if(h instanceof THREE.Face4&&(d(F,o,n,r)||d(F,n,q,r))){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}}return N}};
+THREE.Ray.prototype={intersectScene:function(b){return this.intersectArray(b.objects)},intersectArray:function(b){var d,e,g,h=[];d=0;for(e=b.length;d<e;d++){g=b[d];g instanceof THREE.Mesh&&(h=h.concat(this.intersectObject(g)))}h.sort(function(o,n){return o.distance-n.distance});return h},intersectObject:function(b){function d(V,L,ra,da){da=da.clone().subSelf(L);ra=ra.clone().subSelf(L);var pa=V.clone().subSelf(L);V=da.dot(da);L=da.dot(ra);da=da.dot(pa);var $=ra.dot(ra);ra=ra.dot(pa);pa=1/(V*$-L*L);
+$=($*da-L*ra)*pa;V=(V*ra-L*da)*pa;return $>0&&V>0&&$+V<1}var e,g,h,o,n,q,r,v,E,F,H,I=b.geometry,M=I.vertices,N=[];e=0;for(g=I.faces.length;e<g;e++){h=I.faces[e];F=this.origin.clone();H=this.direction.clone();r=b.matrixWorld;o=r.multiplyVector3(M[h.a].position.clone());n=r.multiplyVector3(M[h.b].position.clone());q=r.multiplyVector3(M[h.c].position.clone());r=h instanceof THREE.Face4?r.multiplyVector3(M[h.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(h.normal.clone());E=H.dot(v);
+if(b.doubleSided||(b.flipSided?E>0:E<0)){v=v.dot((new THREE.Vector3).sub(o,F))/E;F=F.addSelf(H.multiplyScalar(v));if(h instanceof THREE.Face3){if(d(F,o,n,q)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}else if(h instanceof THREE.Face4&&(d(F,o,n,r)||d(F,n,q,r))){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}}return N}};
 THREE.Rectangle=function(){function b(){o=g-d;n=h-e}var d,e,g,h,o,n,q=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return o};this.getHeight=function(){return n};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(r,v,E,F){q=!1;d=r;e=v;g=E;h=F;b()};this.addPoint=function(r,v){if(q){q=!1;d=r;e=v;g=r;h=v}else{d=d<r?d:r;e=e<v?e:v;g=g>r?g:r;h=h>v?h:v}b()};
 this.add3Points=function(r,v,E,F,H,I){if(q){q=!1;d=r<E?r<H?r:H:E<H?E:H;e=v<F?v<I?v:I:F<I?F:I;g=r>E?r>H?r:H:E>H?E:H;h=v>F?v>I?v:I:F>I?F:I}else{d=r<E?r<H?r<d?r:d:H<d?H:d:E<H?E<d?E:d:H<d?H:d;e=v<F?v<I?v<e?v:e:I<e?I:e:F<I?F<e?F:e:I<e?I:e;g=r>E?r>H?r>g?r:g:H>g?H:g:E>H?E>g?E:g:H>g?H:g;h=v>F?v>I?v>h?v:h:I>h?I:h:F>I?F>h?F:h:I>h?I:h}b()};this.addRectangle=function(r){if(q){q=!1;d=r.getLeft();e=r.getTop();g=r.getRight();h=r.getBottom()}else{d=d<r.getLeft()?d:r.getLeft();e=e<r.getTop()?e:r.getTop();g=g>r.getRight()?
 g:r.getRight();h=h>r.getBottom()?h:r.getBottom()}b()};this.inflate=function(r){d-=r;e-=r;g+=r;h+=r;b()};this.minSelf=function(r){d=d>r.getLeft()?d:r.getLeft();e=e>r.getTop()?e:r.getTop();g=g<r.getRight()?g:r.getRight();h=h<r.getBottom()?h:r.getBottom();b()};this.instersects=function(r){return Math.min(g,r.getRight())-Math.max(d,r.getLeft())>=0&&Math.min(h,r.getBottom())-Math.max(e,r.getTop())>=0};this.empty=function(){q=!0;h=g=e=d=0;b()};this.isEmpty=function(){return q}};

+ 8 - 3
src/core/Ray.js

@@ -13,13 +13,18 @@ THREE.Ray.prototype = {
 
 	intersectScene : function ( scene ) {
 
+		return this.intersectArray( scene.objects );
+
+	},
+
+	intersectArray : function ( array ) {
+
 		var i, l, object,
-		objects = scene.objects,
 		intersects = [];
 
-		for ( i = 0, l = objects.length; i < l; i++ ) {
+		for ( i = 0, l = array.length; i < l; i++ ) {
 
-			object = objects[i];
+			object = array[ i ];
 
 			if ( object instanceof THREE.Mesh ) {
 

+ 21 - 0
src/renderers/WebGLRenderer.js

@@ -1848,6 +1848,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		/*
+		delete geometryGroup.__colorArray;
+		delete geometryGroup.__normalArray;
+		delete geometryGroup.__tangentArray;
+		delete geometryGroup.__uvArray;
+		delete geometryGroup.__uv2Array;
+		delete geometryGroup.__faceArray;
+		delete geometryGroup.__vertexArray;
+		delete geometryGroup.__lineArray;
+		delete geometryGroup.__skinVertexAArray;
+		delete geometryGroup.__skinVertexBArray;
+		delete geometryGroup.__skinIndexArray;
+		delete geometryGroup.__skinWeightArray;
+		*/
+
 	};
 
 	function setLineBuffers ( geometry, hint ) {
@@ -4005,6 +4020,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}*/
 
+		/*
+		delete geometry.vertices;
+		delete geometry.faces;
+		delete geometryGroup.faces;
+		*/
+
 	};
 
 	function removeObject( object, scene ) {