Note
Go to the end to download the full example code.
Axis Helper 2
Example showing the axes and grid helpers with a perspective camera.
The grid spans the x-z plane (red and blue axis).
The green axis (y) stick up from the plane.
The red box fits snugly around the grid.

from rendercanvas.auto import RenderCanvas, loop
import pygfx as gfx
canvas = RenderCanvas()
renderer = gfx.renderers.WgpuRenderer(canvas)
scene = gfx.Scene()
axes = gfx.AxesHelper(size=40, thickness=8)
scene.add(axes)
grid = gfx.GridHelper(size=100, thickness=4)
scene.add(grid)
box = gfx.BoxHelper(size=100, thickness=4, color="red")
scene.add(box)
camera = gfx.PerspectiveCamera(70, 16 / 9, depth_range=(0.1, 2000))
camera.local.position = (75, 75, 75)
camera.show_pos((0, 0, 0))
controller = gfx.OrbitController(camera, register_events=renderer)
def animate():
renderer.render(scene, camera)
canvas.request_draw()
canvas.request_draw(animate)
if __name__ == "__main__":
print(__doc__)
loop.run()
Total running time of the script: (0 minutes 0.202 seconds)
Gallery generated by Sphinx-Gallery
Interactive example
Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser’s console for details.