소스 검색

Fixed Ray bug.

alteredq 13 년 전
부모
커밋
291d56186c
6개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      build/Three.js
  2. 1 1
      build/custom/ThreeCanvas.js
  3. 1 1
      build/custom/ThreeDOM.js
  4. 1 1
      build/custom/ThreeSVG.js
  5. 1 1
      build/custom/ThreeWebGL.js
  6. 1 1
      src/core/Ray.js

+ 1 - 1
build/Three.js

@@ -18,7 +18,7 @@ normalize:function(){return this.divideScalar(this.length())},setLength:function
 THREE.Ray=function(a,c){function b(a,b,c){o.sub(c,a);r=o.dot(b);if(r<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(r));return q=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);t=o.dot(o);w=o.dot(p);u=o.dot(m);B=p.dot(p);F=p.dot(m);A=1/(t*B-w*w);x=(B*u-w*F)*A;y=(t*F-w*u)*A;return x>=0&&y>=0&&x+y<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,f=new THREE.Vector3,e=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,c=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3;this.intersectObject=function(m){for(var n,o=[],p=0,r=m.children.length;p<r;p++)Array.prototype.push.apply(o,this.intersectObject(m.children[p]));if(m instanceof THREE.Particle){p=
 b(this.origin,this.direction,m.matrixWorld.getPosition());if(p===null||p>m.scale.x)return[];n={distance:p,point:m.position,face:null,object:m};o.push(n)}else if(m instanceof THREE.Mesh){p=b(this.origin,this.direction,m.matrixWorld.getPosition());if(p===null||p>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return o;var q,t=m.geometry,w=t.vertices,u;m.matrixRotationWorld.extractRotation(m.matrixWorld);p=0;for(r=t.faces.length;p<r;p++)if(n=t.faces[p],a.copy(this.origin),
-c.copy(this.direction),u=m.matrixWorld,i=u.multiplyVector3(i.copy(n.centroid)).subSelf(a),q=i.dot(c),!(q<=0)&&(g=u.multiplyVector3(g.copy(w[n.a].position)),f=u.multiplyVector3(f.copy(w[n.b].position)),e=u.multiplyVector3(e.copy(w[n.c].position)),h=n instanceof THREE.Face4?u.multiplyVector3(h.copy(w[n.d].position)):null,l=m.matrixRotationWorld.multiplyVector3(l.copy(n.normal)),q=c.dot(l),m.doubleSided||(m.flipSided?q>0:q<0)))if(q=l.dot(i.sub(g,a))/q,k.add(a,c.multiplyScalar(q)),n instanceof THREE.Face3)d(k,
+c.copy(this.direction),u=m.matrixWorld,i=u.multiplyVector3(i.copy(n.centroid)).subSelf(a),q=i.dot(c),!(q<=0)&&(g=u.multiplyVector3(g.copy(w[n.a].position)),f=u.multiplyVector3(f.copy(w[n.b].position)),e=u.multiplyVector3(e.copy(w[n.c].position)),n instanceof THREE.Face4&&(h=u.multiplyVector3(h.copy(w[n.d].position))),l=m.matrixRotationWorld.multiplyVector3(l.copy(n.normal)),q=c.dot(l),m.doubleSided||(m.flipSided?q>0:q<0)))if(q=l.dot(i.sub(g,a))/q,k.add(a,c.multiplyScalar(q)),n instanceof THREE.Face3)d(k,
 g,f,e)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n));else if(n instanceof THREE.Face4&&(d(k,g,f,h)||d(k,f,e,h)))n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,r,n,q,t,w,u,B,F,A,x,y};
 THREE.Rectangle=function(){function a(){f=d-c;e=g-b}var c,b,d,g,f,e,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return f};this.getHeight=function(){return e};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(f,e,k,o){h=!1;c=f;b=e;d=k;g=o;a()};this.addPoint=function(f,e){h?(h=!1,c=f,b=e,d=f,g=e):(c=c<f?c:f,b=b<e?b:e,d=d>f?d:f,g=g>e?g:e);a()};this.add3Points=
 function(f,e,k,o,p,m){h?(h=!1,c=f<k?f<p?f:p:k<p?k:p,b=e<o?e<m?e:m:o<m?o:m,d=f>k?f>p?f:p:k>p?k:p,g=e>o?e>m?e:m:o>m?o:m):(c=f<k?f<p?f<c?f:c:p<c?p:c:k<p?k<c?k:c:p<c?p:c,b=e<o?e<m?e<b?e:b:m<b?m:b:o<m?o<b?o:b:m<b?m:b,d=f>k?f>p?f>d?f:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,g=e>o?e>m?e>g?e:g:m>g?m:g:o>m?o>g?o:g:m>g?m:g);a()};this.addRectangle=function(f){h?(h=!1,c=f.getLeft(),b=f.getTop(),d=f.getRight(),g=f.getBottom()):(c=c<f.getLeft()?c:f.getLeft(),b=b<f.getTop()?b:f.getTop(),d=d>f.getRight()?d:f.getRight(),g=g>

+ 1 - 1
build/custom/ThreeCanvas.js

@@ -17,7 +17,7 @@ normalize:function(){return this.divideScalar(this.length())},setLength:function
 THREE.Ray=function(a,b){function c(a,b,c){i.sub(c,a);p=i.dot(b);if(p<=0)return null;k=n.add(a,o.copy(b).multiplyScalar(p));return s=c.distanceTo(k)}function d(a,b,c,d){i.sub(d,b);n.sub(c,b);o.sub(a,b);K=i.dot(i);C=i.dot(n);Q=i.dot(o);O=n.dot(n);w=n.dot(o);F=1/(K*O-C*C);z=(O*Q-C*w)*F;D=(K*w-C*Q)*F;return z>=0&&D>=0&&z+D<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,m=new THREE.Vector3,l=new THREE.Vector3,j=new THREE.Vector3;this.intersectObject=function(k){for(var i,o=[],n=0,W=k.children.length;n<W;n++)Array.prototype.push.apply(o,this.intersectObject(k.children[n]));if(k instanceof THREE.Particle){n=
 c(this.origin,this.direction,k.matrixWorld.getPosition());if(n===null||n>k.scale.x)return[];i={distance:n,point:k.position,face:null,object:k};o.push(i)}else if(k instanceof THREE.Mesh){n=c(this.origin,this.direction,k.matrixWorld.getPosition());if(n===null||n>k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)))return o;var p,G=k.geometry,H=G.vertices,I;k.matrixRotationWorld.extractRotation(k.matrixWorld);n=0;for(W=G.faces.length;n<W;n++)if(i=G.faces[n],a.copy(this.origin),
-b.copy(this.direction),I=k.matrixWorld,m=I.multiplyVector3(m.copy(i.centroid)).subSelf(a),p=m.dot(b),!(p<=0)&&(f=I.multiplyVector3(f.copy(H[i.a].position)),e=I.multiplyVector3(e.copy(H[i.b].position)),g=I.multiplyVector3(g.copy(H[i.c].position)),h=i instanceof THREE.Face4?I.multiplyVector3(h.copy(H[i.d].position)):null,l=k.matrixRotationWorld.multiplyVector3(l.copy(i.normal)),p=b.dot(l),k.doubleSided||(k.flipSided?p>0:p<0)))if(p=l.dot(m.sub(f,a))/p,j.add(a,b.multiplyScalar(p)),i instanceof THREE.Face3)d(j,
+b.copy(this.direction),I=k.matrixWorld,m=I.multiplyVector3(m.copy(i.centroid)).subSelf(a),p=m.dot(b),!(p<=0)&&(f=I.multiplyVector3(f.copy(H[i.a].position)),e=I.multiplyVector3(e.copy(H[i.b].position)),g=I.multiplyVector3(g.copy(H[i.c].position)),i instanceof THREE.Face4&&(h=I.multiplyVector3(h.copy(H[i.d].position))),l=k.matrixRotationWorld.multiplyVector3(l.copy(i.normal)),p=b.dot(l),k.doubleSided||(k.flipSided?p>0:p<0)))if(p=l.dot(m.sub(f,a))/p,j.add(a,b.multiplyScalar(p)),i instanceof THREE.Face3)d(j,
 f,e,g)&&(i={distance:a.distanceTo(j),point:j.clone(),face:i,object:k},o.push(i));else if(i instanceof THREE.Face4&&(d(j,f,e,h)||d(j,e,g,h)))i={distance:a.distanceTo(j),point:j.clone(),face:i,object:k},o.push(i)}return o};var i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3,p,k,s,K,C,Q,O,w,F,z,D};
 THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,j,i){h=!1;b=e;c=g;d=j;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=b<e?b:e,c=c<g?c:g,d=d>e?d:e,f=f>g?f:g);a()};this.add3Points=
 function(e,g,j,i,n,o){h?(h=!1,b=e<j?e<n?e:n:j<n?j:n,c=g<i?g<o?g:o:i<o?i:o,d=e>j?e>n?e:n:j>n?j:n,f=g>i?g>o?g:o:i>o?i:o):(b=e<j?e<n?e<b?e:b:n<b?n:b:j<n?j<b?j:b:n<b?n:b,c=g<i?g<o?g<c?g:c:o<c?o:c:i<o?i<c?i:c:o<c?o:c,d=e>j?e>n?e>d?e:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,f=g>i?g>o?g>f?g:f:o>f?o:f:i>o?i>f?i:f:o>f?o:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),f=f>

+ 1 - 1
build/custom/ThreeDOM.js

@@ -17,7 +17,7 @@ normalize:function(){return this.divideScalar(this.length())},setLength:function
 THREE.Ray=function(a,b){function c(a,b,c){i.sub(c,a);p=i.dot(b);if(p<=0)return null;o=l.add(a,n.copy(b).multiplyScalar(p));return r=c.distanceTo(o)}function d(a,b,c,d){i.sub(d,b);l.sub(c,b);n.sub(a,b);I=i.dot(i);u=i.dot(l);D=i.dot(n);J=l.dot(l);s=l.dot(n);A=1/(I*J-u*u);t=(J*D-u*s)*A;w=(I*s-u*D)*A;return t>=0&&w>=0&&t+w<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,j=new THREE.Vector3;this.intersectObject=function(i){for(var l,n=[],o=0,P=i.children.length;o<P;o++)Array.prototype.push.apply(n,this.intersectObject(i.children[o]));if(i instanceof THREE.Particle){o=
 c(this.origin,this.direction,i.matrixWorld.getPosition());if(o===null||o>i.scale.x)return[];l={distance:o,point:i.position,face:null,object:i};n.push(l)}else if(i instanceof THREE.Mesh){o=c(this.origin,this.direction,i.matrixWorld.getPosition());if(o===null||o>i.geometry.boundingSphere.radius*Math.max(i.scale.x,Math.max(i.scale.y,i.scale.z)))return n;var E,p=i.geometry,M=p.vertices,K;i.matrixRotationWorld.extractRotation(i.matrixWorld);o=0;for(P=p.faces.length;o<P;o++)if(l=p.faces[o],a.copy(this.origin),
-b.copy(this.direction),K=i.matrixWorld,k=K.multiplyVector3(k.copy(l.centroid)).subSelf(a),E=k.dot(b),!(E<=0)&&(e=K.multiplyVector3(e.copy(M[l.a].position)),f=K.multiplyVector3(f.copy(M[l.b].position)),g=K.multiplyVector3(g.copy(M[l.c].position)),h=l instanceof THREE.Face4?K.multiplyVector3(h.copy(M[l.d].position)):null,m=i.matrixRotationWorld.multiplyVector3(m.copy(l.normal)),E=b.dot(m),i.doubleSided||(i.flipSided?E>0:E<0)))if(E=m.dot(k.sub(e,a))/E,j.add(a,b.multiplyScalar(E)),l instanceof THREE.Face3)d(j,
+b.copy(this.direction),K=i.matrixWorld,k=K.multiplyVector3(k.copy(l.centroid)).subSelf(a),E=k.dot(b),!(E<=0)&&(e=K.multiplyVector3(e.copy(M[l.a].position)),f=K.multiplyVector3(f.copy(M[l.b].position)),g=K.multiplyVector3(g.copy(M[l.c].position)),l instanceof THREE.Face4&&(h=K.multiplyVector3(h.copy(M[l.d].position))),m=i.matrixRotationWorld.multiplyVector3(m.copy(l.normal)),E=b.dot(m),i.doubleSided||(i.flipSided?E>0:E<0)))if(E=m.dot(k.sub(e,a))/E,j.add(a,b.multiplyScalar(E)),l instanceof THREE.Face3)d(j,
 e,f,g)&&(l={distance:a.distanceTo(j),point:j.clone(),face:l,object:i},n.push(l));else if(l instanceof THREE.Face4&&(d(j,e,f,h)||d(j,f,g,h)))l={distance:a.distanceTo(j),point:j.clone(),face:l,object:i},n.push(l)}return n};var i=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p,o,r,I,u,D,J,s,A,t,w};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(k,f,g,i){h=!1;b=k;c=f;d=g;e=i;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 function(f,g,j,i,l,n){h?(h=!1,b=f<j?f<l?f:l:j<l?j:l,c=g<i?g<n?g:n:i<n?i:n,d=f>j?f>l?f:l:j>l?j:l,e=g>i?g>n?g:n:i>n?i:n):(b=f<j?f<l?f<b?f:b:l<b?l:b:j<l?j<b?j:b:l<b?l:b,c=g<i?g<n?g<c?g:c:n<c?n:c:i<n?i<c?i:c:n<c?n:c,d=f>j?f>l?f>d?f:d:l>d?l:d:j>l?j>d?j:d:l>d?l:d,e=g>i?g>n?g>e?g:e:n>e?n:e:i>n?i>e?i:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>

+ 1 - 1
build/custom/ThreeSVG.js

@@ -17,7 +17,7 @@ normalize:function(){return this.divideScalar(this.length())},setLength:function
 THREE.Ray=function(a,b){function c(a,b,c){j.sub(c,a);o=j.dot(b);if(o<=0)return null;p=n.add(a,k.copy(b).multiplyScalar(o));return u=c.distanceTo(p)}function d(a,b,c,d){j.sub(d,b);n.sub(c,b);k.sub(a,b);I=j.dot(j);v=j.dot(n);E=j.dot(k);s=n.dot(n);t=n.dot(k);C=1/(I*s-v*v);y=(s*E-v*t)*C;z=(I*t-v*E)*C;return y>=0&&z>=0&&y+z<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,l=new THREE.Vector3,m=new THREE.Vector3,i=new THREE.Vector3;this.intersectObject=function(j){for(var k,n=[],o=0,K=j.children.length;o<K;o++)Array.prototype.push.apply(n,this.intersectObject(j.children[o]));if(j instanceof THREE.Particle){o=
 c(this.origin,this.direction,j.matrixWorld.getPosition());if(o===null||o>j.scale.x)return[];k={distance:o,point:j.position,face:null,object:j};n.push(k)}else if(j instanceof THREE.Mesh){o=c(this.origin,this.direction,j.matrixWorld.getPosition());if(o===null||o>j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)))return n;var J,p=j.geometry,N=p.vertices,s;j.matrixRotationWorld.extractRotation(j.matrixWorld);o=0;for(K=p.faces.length;o<K;o++)if(k=p.faces[o],a.copy(this.origin),
-b.copy(this.direction),s=j.matrixWorld,l=s.multiplyVector3(l.copy(k.centroid)).subSelf(a),J=l.dot(b),!(J<=0)&&(f=s.multiplyVector3(f.copy(N[k.a].position)),e=s.multiplyVector3(e.copy(N[k.b].position)),g=s.multiplyVector3(g.copy(N[k.c].position)),h=k instanceof THREE.Face4?s.multiplyVector3(h.copy(N[k.d].position)):null,m=j.matrixRotationWorld.multiplyVector3(m.copy(k.normal)),J=b.dot(m),j.doubleSided||(j.flipSided?J>0:J<0)))if(J=m.dot(l.sub(f,a))/J,i.add(a,b.multiplyScalar(J)),k instanceof THREE.Face3)d(i,
+b.copy(this.direction),s=j.matrixWorld,l=s.multiplyVector3(l.copy(k.centroid)).subSelf(a),J=l.dot(b),!(J<=0)&&(f=s.multiplyVector3(f.copy(N[k.a].position)),e=s.multiplyVector3(e.copy(N[k.b].position)),g=s.multiplyVector3(g.copy(N[k.c].position)),k instanceof THREE.Face4&&(h=s.multiplyVector3(h.copy(N[k.d].position))),m=j.matrixRotationWorld.multiplyVector3(m.copy(k.normal)),J=b.dot(m),j.doubleSided||(j.flipSided?J>0:J<0)))if(J=m.dot(l.sub(f,a))/J,i.add(a,b.multiplyScalar(J)),k instanceof THREE.Face3)d(i,
 f,e,g)&&(k={distance:a.distanceTo(i),point:i.clone(),face:k,object:j},n.push(k));else if(k instanceof THREE.Face4&&(d(i,f,e,h)||d(i,e,g,h)))k={distance:a.distanceTo(i),point:i.clone(),face:k,object:j},n.push(k)}return n};var j=new THREE.Vector3,n=new THREE.Vector3,k=new THREE.Vector3,o,p,u,I,v,E,s,t,C,y,z};
 THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,i,j){h=!1;b=e;c=g;d=i;f=j;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=b<e?b:e,c=c<g?c:g,d=d>e?d:e,f=f>g?f:g);a()};this.add3Points=
 function(e,g,i,j,n,k){h?(h=!1,b=e<i?e<n?e:n:i<n?i:n,c=g<j?g<k?g:k:j<k?j:k,d=e>i?e>n?e:n:i>n?i:n,f=g>j?g>k?g:k:j>k?j:k):(b=e<i?e<n?e<b?e:b:n<b?n:b:i<n?i<b?i:b:n<b?n:b,c=g<j?g<k?g<c?g:c:k<c?k:c:j<k?j<c?j:c:k<c?k:c,d=e>i?e>n?e>d?e:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,f=g>j?g>k?g>f?g:f:k>f?k:f:j>k?j>f?j:f:k>f?k:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),f=f>

+ 1 - 1
build/custom/ThreeWebGL.js

@@ -17,7 +17,7 @@ normalize:function(){return this.divideScalar(this.length())},setLength:function
 THREE.Ray=function(a,b){function c(a,b,c){p.sub(c,a);y=p.dot(b);if(y<=0)return null;I=A.add(a,r.copy(b).multiplyScalar(y));return R=c.distanceTo(I)}function e(a,b,c,e){p.sub(e,b);A.sub(c,b);r.sub(a,b);va=p.dot(p);ha=p.dot(A);ja=p.dot(r);ga=A.dot(A);L=A.dot(r);S=1/(va*ga-ha*ha);F=(ga*ja-ha*L)*S;N=(va*L-ha*ja)*S;return F>=0&&N>=0&&F+N<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=
 function(a){var b,c,e=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(e,this.intersectObject(a[b]));e.sort(function(a,b){return a.distance-b.distance});return e};var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,n=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3;this.intersectObject=function(r){for(var p,y=[],A=0,oa=r.children.length;A<oa;A++)Array.prototype.push.apply(y,this.intersectObject(r.children[A]));
 if(r instanceof THREE.Particle){A=c(this.origin,this.direction,r.matrixWorld.getPosition());if(A===null||A>r.scale.x)return[];p={distance:A,point:r.position,face:null,object:r};y.push(p)}else if(r instanceof THREE.Mesh){A=c(this.origin,this.direction,r.matrixWorld.getPosition());if(A===null||A>r.geometry.boundingSphere.radius*Math.max(r.scale.x,Math.max(r.scale.y,r.scale.z)))return y;var I,R=r.geometry,Q=R.vertices,L;r.matrixRotationWorld.extractRotation(r.matrixWorld);A=0;for(oa=R.faces.length;A<
-oa;A++)if(p=R.faces[A],a.copy(this.origin),b.copy(this.direction),L=r.matrixWorld,n=L.multiplyVector3(n.copy(p.centroid)).subSelf(a),I=n.dot(b),!(I<=0)&&(f=L.multiplyVector3(f.copy(Q[p.a].position)),g=L.multiplyVector3(g.copy(Q[p.b].position)),h=L.multiplyVector3(h.copy(Q[p.c].position)),i=p instanceof THREE.Face4?L.multiplyVector3(i.copy(Q[p.d].position)):null,k=r.matrixRotationWorld.multiplyVector3(k.copy(p.normal)),I=b.dot(k),r.doubleSided||(r.flipSided?I>0:I<0)))if(I=k.dot(n.sub(f,a))/I,l.add(a,
+oa;A++)if(p=R.faces[A],a.copy(this.origin),b.copy(this.direction),L=r.matrixWorld,n=L.multiplyVector3(n.copy(p.centroid)).subSelf(a),I=n.dot(b),!(I<=0)&&(f=L.multiplyVector3(f.copy(Q[p.a].position)),g=L.multiplyVector3(g.copy(Q[p.b].position)),h=L.multiplyVector3(h.copy(Q[p.c].position)),p instanceof THREE.Face4&&(i=L.multiplyVector3(i.copy(Q[p.d].position))),k=r.matrixRotationWorld.multiplyVector3(k.copy(p.normal)),I=b.dot(k),r.doubleSided||(r.flipSided?I>0:I<0)))if(I=k.dot(n.sub(f,a))/I,l.add(a,
 b.multiplyScalar(I)),p instanceof THREE.Face3)e(l,f,g,h)&&(p={distance:a.distanceTo(l),point:l.clone(),face:p,object:r},y.push(p));else if(p instanceof THREE.Face4&&(e(l,f,g,i)||e(l,g,h,i)))p={distance:a.distanceTo(l),point:l.clone(),face:p,object:r},y.push(p)}return y};var p=new THREE.Vector3,A=new THREE.Vector3,r=new THREE.Vector3,y,I,R,va,ha,ja,ga,L,S,F,N};
 THREE.Rectangle=function(){function a(){g=e-b;h=f-c}var b,c,e,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,h,l,p){i=!1;b=g;c=h;e=l;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,e=g,f=h):(b=b<g?b:g,c=c<h?c:h,e=e>g?e:g,f=f>h?f:h);a()};this.add3Points=
 function(g,h,l,p,A,r){i?(i=!1,b=g<l?g<A?g:A:l<A?l:A,c=h<p?h<r?h:r:p<r?p:r,e=g>l?g>A?g:A:l>A?l:A,f=h>p?h>r?h:r:p>r?p:r):(b=g<l?g<A?g<b?g:b:A<b?A:b:l<A?l<b?l:b:A<b?A:b,c=h<p?h<r?h<c?h:c:r<c?r:c:p<r?p<c?p:c:r<c?r:c,e=g>l?g>A?g>e?g:e:A>e?A:e:l>A?l>e?l:e:A>e?A:e,f=h>p?h>r?h>f?h:f:r>f?r:f:p>r?p>f?p:f:r>f?r:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),e=g.getRight(),f=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),e=e>g.getRight()?e:g.getRight(),f=f>

+ 1 - 1
src/core/Ray.js

@@ -114,7 +114,7 @@ THREE.Ray = function ( origin, direction ) {
 				a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
 				b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
 				c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
-				d = face instanceof THREE.Face4 ? objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) ) : null;
+				if ( face instanceof THREE.Face4 ) d = objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) );
 
 				normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) );
 				dot = direction.dot( normal );