#!/usr/bin/env python3 from kitty import draw_to_terminal from PIL import Image import numpy as np import trimesh import pyrender sphere = trimesh.creation.icosphere(subdivisions=3, radius=1.0) # create mesh mesh = pyrender.Mesh.from_trimesh(sphere, smooth=True, wireframe=True) # Create a scene and add the mesh scene = pyrender.Scene(bg_color = [0, 0, 0, 0]) scene.add(mesh) # Add a directional light to illuminate the sphere light = pyrender.DirectionalLight(color=np.ones(3), intensity=3.0) light_pose = np.eye(4) light_pose[:3, 3] = [0, 2, 2] # light from above and in front scene.add(light, pose=light_pose) # Add a camera camera = pyrender.PerspectiveCamera(yfov=np.pi / 3.0) camera_pose = np.array([ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 3.0], # Pull camera back [0.0, 0.0, 0.0, 1.0] ]) scene.add(camera, pose=camera_pose) r = pyrender.OffscreenRenderer(512, 512) flags = pyrender.RenderFlags.RGBA color, depth = r.render(scene, flags=flags) # im = Image.fromarray((color)) # .new("RGBA", (512, 512), (0, 0, 0, 0) ) draw_to_terminal(im)