# Is there any easy way to check if a point is in front of a camera?

So, I was wondering if there is an easy way to check if a point is in front of the camera. Currently, this is my solution:

``````function isClose(camera,point,distance){
let dis = BABYLON.Vector3.Distance(camera.position,point);
//let fromCam = camera.getDirection(new BABYLON.Vector3(0,0,dis));
let fromCam = camera.getFrontPosition(dis); //<- edit
return BABYLON.Vector3.Distance(fromCam,point) <= distance
}
``````

Is there any better way to check?

Can get the angle between the camera forward vector and the vector between the camera and point with the dot product. This to me sounds like the same amount of complexity.

If you wanted to optimize you can go for a `DistanceSquared` check instead of a distance. Will save you an expensive sqrt call.

2 Likes

Thanks! Good idea!

1 Like

I was looking through the doc, and was wondering what the `normals` parameter of `Vector3.GetAngleBetweenVectors` does/is.

This helps understanding how you go from one to the other either in a positive or negative way without it it would be impossible to differentiate the inner from the outer angle formed between vectors.

2 Likes

Thank you!