|
@@ -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>
|