Fixed isInViewport() function for entities.