begin_camera()#
The begin_camera()
and end_camera() functions enable advanced customization of the camera space.
Examples#
def setup():
py5.size(100, 100, py5.P3D)
py5.no_fill()
py5.begin_camera()
py5.camera()
py5.rotate_x(-py5.PI/6)
py5.end_camera()
py5.translate(50, 50, 0)
py5.rotate_y(py5.PI/3)
py5.box(45)
def setup():
py5.size(100, 100, py5.P3D)
py5.no_fill()
with py5.begin_camera():
py5.camera()
py5.rotate_x(-py5.PI/6)
py5.translate(50, 50, 0)
py5.rotate_y(py5.PI/3)
py5.box(45)
Description#
The 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
Signatures#
begin_camera() -> None
Updated on March 06, 2023 02:49:26am UTC