Scene

Reference for the Scene singleton, which tracks all entities, handles scene‐wide fog and provides methods to clear or reset the scene.

Scene

scene is the global instance created by Ursina when you start the app. It maintains the list of all active entities and collidables, and offers scene‑wide settings such as fog.

Overview

The scene object is your root for managing everything in the 3D world. It keeps track of every Entity that’s been added, lets you clear the scene, and configure global fog effects.

Fields

NameTypeDescription
.entitieslistAll entities currently in the scene.
.collidablessetEntities with active colliders for raycasts.

Properties

PropertyDescription
.fog_colorColor used when rendering exponential or linear fog.
.fog_densityExponential fog density (when set to a single float).
.childrenAlias for .entities (for hierarchical use cases).

Methods

MethodDescription
set_up()Internal initialization called by Ursina.
clear()Remove all entities from the scene (resets .entities and .collidables).
fog_density(value)Configure fog. Pass a single float for exponential fog density, or a (start, end) tuple for linear fog.

Example Usage

from ursina import *

app = Ursina()

# add a large ground plane
ground = Entity(model='plane', color=color.black, scale=100)

# allow WASD camera control
EditorCamera()

# add a skybox
sky = Sky()

def input(key):
    if key == 'l':
        # list all entity names
        for e in scene.entities:
            print(e.name)

    if key == 'd':
        # clear and spawn a cube
        scene.clear()
        Entity(model='cube', color=color.azure)

# exponential fog
scene.fog_density = 0.1

# or linear fog from 50 to 200 units
scene.fog_density = (50, 200)

app.run()