add function to check whether node is fully, partially or not inside the frustum

This commit is contained in:
mschuetz 2015-05-16 09:27:04 +02:00
parent 83dc252ef2
commit e8022ccd67

View File

@ -275,6 +275,36 @@ Potree.utils.rightView = function(camera, controls, pointcloud){
}
}
/**
*
* 0: no intersection
* 1: intersection
* 2: fully inside
*/
Potree.utils.frustumSphereIntersection = function(frustum, sphere){
var planes = frustum.planes;
var center = sphere.center;
var negRadius = - sphere.radius;
var minDistance = Number.MAX_VALUE;
for ( var i = 0; i < 6; i ++ ) {
var distance = planes[ i ].distanceToPoint( center );
if ( distance < negRadius ) {
return 0;
}
minDistance = Math.min(minDistance, distance);
}
return (minDistance >= sphere.radius) ? 2 : 1;
};