add function to check whether node is fully, partially or not inside the frustum
This commit is contained in:
parent
83dc252ef2
commit
e8022ccd67
30
src/utils.js
30
src/utils.js
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user