def test_plot_texture(): """"Test adding a texture to a plot""" globe = examples.load_globe() texture = examples.load_globe_texture() plotter = pyvista.Plotter(off_screen=OFF_SCREEN) plotter.add_mesh(globe, texture=texture) plotter.show()
def test_plot_texture(): """"Test adding a texture to a plot""" globe = examples.load_globe() texture = examples.load_globe_texture() plotter = pyvista.Plotter() plotter.add_mesh(globe, texture=texture) plotter.show(before_close_callback=verify_cache_image)
def test_skybox(): texture = examples.load_globe_texture() texture.cube_map = False assert texture.cube_map is False texture.cube_map = True assert texture.cube_map is True skybox = texture.to_skybox() assert isinstance(skybox, vtk.vtkOpenGLSkybox)
def test_texture(): texture = pyvista.Texture(examples.mapfile) assert texture is not None image = texture.to_image() assert isinstance(image, pyvista.UniformGrid) arr = texture.to_array() assert isinstance(arr, np.ndarray) assert arr.shape[0] * arr.shape[1] == image.n_points texture.flip(0) texture.flip(1) texture = pyvista.Texture(examples.load_globe_texture()) assert texture is not None
mesh.plot(texture=tex) ############################################################################### # The helper method above does not always produce the desired texture # coordinates, so sometimes it must be done manually. Here is a great, user # contributed example from `this support issue <https://github.com/pyvista/pyvista-support/issues/257>`_ # # Manually create the texture coordinates for a globe map. First, we create # the mesh that will be used as the globe. Note the `start_theta` for a slight # overlappig sphere = pv.Sphere(radius=1, theta_resolution=120, phi_resolution=120, start_theta=270.001, end_theta=270) # Initialize the texture coordinates array sphere.t_coords = np.zeros((sphere.points.shape[0], 2)) # Populate by manually calculating for i in range(sphere.points.shape[0]): sphere.t_coords[i] = [0.5 + np.arctan2(-sphere.points[i, 0], sphere.points[i, 1])/(2 * np.pi), 0.5 + np.arcsin(sphere.points[i, 2])/np.pi] # And let's display it with a world map tex = examples.load_globe_texture() sphere.plot(texture=tex)