Camera

Reference for the Camera singleton, which manages 3D and UI cameras, projection mode, clipping and post‑processing.

Camera

camera is instantiated automatically when you import Ursina. It inherits from Entity and lives under scene.

Overview

The global camera object provides both the 3D view and a UI camera. You can switch between perspective and orthographic projection, adjust field of view and clipping planes, and apply fullscreen post‑processing shaders.

Fields

NameTypeDescription
.parentEntityAlways scene.
.namestr"camera".
.eternalboolTrue—never destroyed on scene clear.
.ui_sizeintSize of the UI coordinate space.
.perspective_lens_nodeLensNodePanda3D node for perspective projection.
.orthographic_lens_nodeLensNodePanda3D node for orthographic projection.
.uiEntityRoot UI entity (parented to camera.ui).
.overlayEntityFullscreen quad for post‑processing (under UI).

Properties

PropertyDescription
.orthographicGet/set orthographic mode (True or False).
.fovGet/set horizontal field of view.
.clip_plane_nearGet/set near clipping plane distance.
.clip_plane_farGet/set far clipping plane distance.
.aspect_ratioRead‑only current window aspect ratio.
.shaderApply a post‑processing Shader to the overlay quad.

Methods

MethodDescription
set_up()Initialize Panda3D lens nodes, display regions and UI camera. Called internally by Ursina.
set_shader_input(name, value)Send a uniform or texture to the post‑processing shader.

Example Usage

from ursina import *
from ursina import Ursina, camera, Entity, EditorCamera
from ursina.shaders import camera_grayscale_shader

app = Ursina()

# switch to orthographic projection
camera.orthographic = True

# spawn some colored quads at different depths
for x in (-2, 0, 2):
    e = Entity(model='quad', color=color.random_color(), position=(x, 0, 10))

# add an editor camera for free movement
EditorCamera()

# apply a grayscale post‑processing shader
camera.shader = camera_grayscale_shader

app.run()