"""
Example on how to use the rendering module
"""
import tempfile
import numpy as np
from navipy.rendering.bee_sampling import BeeSampling

# create a bee sampling
bee_samp = BeeSampling()
# Create a list of point from which we want to render images
# Careful three d meshing grow quickly.
x = np.linspace(-5, 5, 3)
y = np.linspace(-5, 5, 3)
z = np.linspace(1.8, 1.8, 1)
alpha_1 = np.array([0]) + np.pi / 2
alpha_2 = np.array([0])
alpha_3 = np.array([0])
bee_samp.create_sampling_grid(
    x, y, z, alpha1=alpha_1, alpha2=alpha_2, alpha3=alpha_3)
# Assign maximum world dimension. Otherwise the distance
# will go to infinity, and the distance to objects after compression
# will be set to 0
world_dim = 50 * np.sqrt(2)
bee_samp.world_dim = world_dim
# set the number of sample for rendring in blender
bee_samp.cycle_samples = 5
# Rendering in a tmp folder
with tempfile.TemporaryDirectory() as folder:
    bee_samp.render(folder + '/database.db')