|
@@ -33,10 +33,10 @@ THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements
|
|
|
THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),f=0;f<6;f++){b=c[f].x*d[12]+c[f].y*d[13]+c[f].z*d[14]+c[f].w;if(b<=a)return false}return true};THREE.Frustum.__v1=new THREE.Vector3;
|
|
|
THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,m=new THREE.Vector3,p=function(a,b){return a.distance-b.distance},q=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,s,t,u,z=function(a,b,c){q.sub(c,a);s=q.dot(b);t=n.add(a,r.copy(b).multiplyScalar(s));
|
|
|
return u=c.distanceTo(t)},x,A,B,C,v,J,F,O,P=function(a,b,c,d){q.sub(d,b);n.sub(c,b);r.sub(a,b);x=q.dot(q);A=q.dot(n);B=q.dot(r);C=n.dot(n);v=n.dot(r);J=1/(x*C-A*A);F=(C*B-A*v)*J;O=(x*v-A*B)*J;return F>=0&&O>=0&&F+O<1},G=1E-4;this.setPrecision=function(a){G=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var n=0,q=a.children.length;n<q;n++)Array.prototype.push.apply(d,this.intersectObject(a.children[n],b));if(a instanceof THREE.Particle){u=z(this.origin,this.direction,a.matrixWorld.getPosition());
|
|
|
-if(u>a.scale.x)return[];c={distance:u,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){n=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());n=a.geometry.boundingSphere.radius*Math.max(n.x,Math.max(n.y,n.z));u=z(this.origin,this.direction,a.matrixWorld.getPosition());if(u>n)return d;var r,s,t=a.geometry,v=t.vertices,x;a.matrixRotationWorld.extractRotation(a.matrixWorld);n=0;for(q=t.faces.length;n<
|
|
|
-q;n++){c=t.faces[n];i.copy(this.origin);j.copy(this.direction);x=a.matrixWorld;l=x.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=j.dot(o);if(!(Math.abs(r)<G)){s=o.dot(l)/r;if(!(s<0)&&(a.doubleSided||(a.flipSided?r>0:r<0))){m.add(i,j.multiplyScalar(s));u=i.distanceTo(m);if(!(u<this.near)&&!(u>this.far))if(c instanceof THREE.Face3){f=x.multiplyVector3(f.copy(v[c.a]));e=x.multiplyVector3(e.copy(v[c.b]));g=x.multiplyVector3(g.copy(v[c.c]));
|
|
|
-if(P(m,f,e,g)){c={distance:u,point:m.clone(),face:c,faceIndex:n,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=x.multiplyVector3(f.copy(v[c.a]));e=x.multiplyVector3(e.copy(v[c.b]));g=x.multiplyVector3(g.copy(v[c.c]));h=x.multiplyVector3(h.copy(v[c.d]));if(P(m,f,e,h)||P(m,e,g,h)){c={distance:u,point:m.clone(),face:c,faceIndex:n,object:a};d.push(c)}}}}}}d.sort(p);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,f=a.length;d<f;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],
|
|
|
-b));c.sort(p);return c}};
|
|
|
+if(u>a.scale.x)return[];c={distance:u,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){n=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());n=a.geometry.boundingSphere.radius*Math.max(n.x,Math.max(n.y,n.z));u=z(this.origin,this.direction,a.matrixWorld.getPosition());if(u>n)return d;var r,s,t=a.geometry,v=t.vertices,x,A,C,B;A=a.geometry.materials;C=a.material instanceof THREE.MeshFaceMaterial;
|
|
|
+a.matrixRotationWorld.extractRotation(a.matrixWorld);n=0;for(q=t.faces.length;n<q;n++){c=t.faces[n];r=C===true?A[c.materialIndex]:a.material;if(r!==void 0){B=r.side;i.copy(this.origin);j.copy(this.direction);x=a.matrixWorld;l=x.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=j.dot(o);if(!(Math.abs(r)<G)){s=o.dot(l)/r;if(!(s<0)&&(B===THREE.DoubleSide||(B===THREE.FrontSide?r<0:r>0))){m.add(i,j.multiplyScalar(s));u=i.distanceTo(m);if(!(u<this.near)&&
|
|
|
+!(u>this.far))if(c instanceof THREE.Face3){f=x.multiplyVector3(f.copy(v[c.a]));e=x.multiplyVector3(e.copy(v[c.b]));g=x.multiplyVector3(g.copy(v[c.c]));if(P(m,f,e,g)){c={distance:u,point:m.clone(),face:c,faceIndex:n,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=x.multiplyVector3(f.copy(v[c.a]));e=x.multiplyVector3(e.copy(v[c.b]));g=x.multiplyVector3(g.copy(v[c.c]));h=x.multiplyVector3(h.copy(v[c.d]));if(P(m,f,e,h)||P(m,e,g,h)){c={distance:u,point:m.clone(),face:c,faceIndex:n,object:a};d.push(c)}}}}}}}d.sort(p);
|
|
|
+return d};this.intersectObjects=function(a,b){for(var c=[],d=0,f=a.length;d<f;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],b));c.sort(p);return c}};
|
|
|
THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b=0,c=0,d=0,f=0,e=0,g=0,h=true;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,l,o){h=false;b=e;c=g;d=l;f=o;a()};this.addPoint=function(e,g){if(h===true){h=false;b=e;c=g;d=e;f=g}else{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,l,o,m,p){if(h===true){h=false;b=e<l?e<m?e:m:l<m?l:m;c=g<o?g<p?g:p:o<p?o:p;d=e>l?e>m?e:m:l>m?l:m;f=g>o?g>p?g:p:o>p?o:p}else{b=e<l?e<m?e<b?e:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b;c=g<o?g<p?g<c?g:c:p<c?p:c:o<p?o<c?o:c:p<c?p:c;d=e>l?e>m?e>d?e:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;f=g>o?g>p?g>f?g:f:p>f?p:f:o>p?o>f?o:f:p>f?p:f}a()};this.addRectangle=function(e){if(h===true){h=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();
|
|
|
c=c<e.getTop()?c:e.getTop();d=d>e.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||f<a.getTop()||c>a.getBottom()?false:true};this.empty=function(){h=true;f=d=c=b=0;a()};this.isEmpty=function(){return h}};
|