begin_camera() and end_camera() functions enable advanced customization of the camera space.
1def setup(): 2 py5.size(100, 100, py5.P3D) 3 py5.no_fill() 4 5 py5.begin_camera() 6 py5.camera() 7 py5.rotate_x(-py5.PI/6) 8 py5.end_camera() 9 10 py5.translate(50, 50, 0) 11 py5.rotate_y(py5.PI/3) 12 py5.box(45)
1def setup(): 2 py5.size(100, 100, py5.P3D) 3 py5.no_fill() 4 5 with py5.begin_camera(): 6 py5.camera() 7 py5.rotate_x(-py5.PI/6) 8 9 py5.translate(50, 50, 0) 10 py5.rotate_y(py5.PI/3) 11 12 py5.box(45)
begin_camera() and end_camera() functions enable advanced customization of the camera space. The functions are useful if you want to more control over camera movement, however for most users, the camera() function will be sufficient. The camera functions will replace any transformations (such as rotate() or translate()) that occur before them in
draw(), but they will not automatically replace the camera transform itself. For this reason, camera functions should be placed at the beginning of
draw() (so that transformations happen afterwards), and the camera() function can be used after
begin_camera() if you want to reset the camera before applying transformations.
This function sets the matrix mode to the camera matrix so calls such as translate(), rotate(), apply_matrix() and reset_matrix() affect the camera.
begin_camera() should always be used with a following end_camera() and pairs of
begin_camera() and end_camera() cannot be nested.
This method can be used as a context manager to ensure that end_camera() always gets called, as shown in the last example.
Underlying Processing method: beginCamera
begin_camera() -> None
Updated on November 12, 2021 11:30:58am UTC