scene ===== .. lua:class:: scene A high level scene structure used that integrates object hierarchy, rendering, input, physics and serialisation to simplify and streamline games and simulations .. lua:classattribute:: main: scene Sets the main Codea scene, which will be automatically drawn, updated and handle touch events .. code-block:: lua function setup() scene.main = scene.default3d() end .. lua:staticmethod:: scene.default3d([name]) Creates the default 3D scene containing a perspective camera, directional light and HDR environment, with an optional name :rtype: scene .. lua:staticmethod:: scene.default2d([name]) Creates the default 2D scene containing an orthographic camera, with an optional name :rtype: scene .. lua:staticmethod:: scene.read(key) Loads and returns a scene with the supplied asset key :rtype: scene .. lua:staticmethod:: scene.save(key, scene) Saves the supplied scene at the given asset key location .. lua:attribute:: name: string Gets or sets a name for this scene .. lua:attribute:: world2d: physics2d.world Gets the scene's 2D physics world, providing access to various physics functions and properties such as :lua:meth:`physics2d.world.applyForce` .. lua:attribute:: world3d: physics3d.world Gets the scene's 3D physics world, providing access to various physics functions and properties such as :lua:meth:`physics3d.world.applyForce` .. lua:attribute:: sky Sets the sky visuals, which will depend on the type used: - :lua:class:`asset.key` - Use an image pointed to by a given asset key - :lua:class:`image` - Use an image directly (assumed to be a cube image) - :lua:class:`color` - Use a solid color .. lua:attribute:: skyBlur : number The blur strength of the skybox .. lua:attribute:: skyExposure : number The brightness of the skybox .. lua:attribute:: camera : entity :return: The scene's camera entity (if it exists) :rtype: entity .. lua:attribute:: sun : entity :return: The scene's sun entity (if it exists) :rtype: entity .. lua:attribute:: canvas : ui.canvas :return: The main UI canvas of the scene :rtype: ui.canvas .. lua:attribute:: pixelsPerUnit : number The amount of pixels that are in a grid unit .. lua:method:: entity([name]) Creates a new blank :lua:class:`entity` with an optional name :rtype: entity .. lua:method:: findEntity(name) :rtype: entity .. lua:method:: entities([activeOnly = true]) Returns a table containing all root entities :param activeOnly: When set, returns only active root entities :rtype: table .. lua:method:: index(name) [metamethod] Returns the root entity with the given name (if it exists) :rtype: entity .. lua:method:: draw() Immediately draws the scene to the current context. When autoUpdate is enabled, ``update(dt)`` will be called as well If set as ``scene.main`` this will be called automatically right before the global ``draw()`` function .. lua:method:: update(deltaTime) Updates the scene, called automatically when ``draw()`` is called but can also be called manutally if needed