.. _stdlib_free_camera: =========== Free camera =========== This module contains the FreeCamera component, which represents a free camera that can be controlled by the user. The free camera can be enabled or disabled, and its position and rotation can be set. Note that all functions in this module create a new camera if one does not already exist. The free camera can be controlled using the following inputs: ``W``: move forward ``S``: move backward ``D``: move right ``A``: move left ``E``: move up ``C``: move down Middle mouse button: move the camera by dragging the mouse Right mouse button: rotate the camera by dragging the mouse Mouse wheel: move the camera forward or backward +++++++ Classes +++++++ .. _struct-free_camera-FreeCamera: .. das:attribute:: FreeCamera : Component Represents the free camera component. The current position of the camera :Fields: * **position** : float3 - The current rotation of the camera * **rotation** : :ref:`quat4 ` = quat4() - Whether to use scaled game time for the camera movement * **useScaledTime** : bool = false - The current euler angles of the camera .. _function-free_camera_FreeCamera_rq_set_state_FreeCamera_float3_quat4: .. das:function:: FreeCamera.set_state(pos: float3; rot: quat4) Sets the state of the free camera component with the given position and rotation. :Arguments: * **pos** : float3 * **rot** : :ref:`quat4 ` .. _function-free_camera_FreeCamera_float3_quat4: .. das:function:: FreeCamera(pos: float3; rot: quat4) : FreeCamera Initializes the free camera component with the given position and rotation. :Arguments: * **pos** : float3 * **rot** : :ref:`quat4 ` +++++++++ Functions +++++++++ * :ref:`create_free_camera (position: float3; rotation: quat4 = quat4()) : NodeId ` * :ref:`enable_free_camera (var freeCamera: NodeId&; isActive: bool = true) ` * :ref:`is_active_free_camera (freeCamera: NodeId) : bool ` * :ref:`toggle_free_camera (var freeCamera: NodeId&; position: float3; rotation: quat4; isActive: bool = true) ` .. _function-free_camera_create_free_camera_float3_quat4: .. das:function:: create_free_camera(position: float3; rotation: quat4 = quat4()) : NodeId Creates a free camera in the scene with default parameters fov=65, znear=0.01, zfar=10000. :Arguments: * **position** : float3 - the initial position of the camera * **rotation** : :ref:`quat4 ` - the initial quaternion rotation of the camera :Returns: * :ref:`NodeId ` - the ID of the created camera node Usage example:: let freeCamera = create_free_camera(float3(0)) .. _function-free_camera_enable_free_camera_NodeId_bool: .. das:function:: enable_free_camera(freeCamera: NodeId&; isActive: bool = true) Changes the active state of the free camera. :Arguments: * **freeCamera** : :ref:`NodeId ` & - the ID of the free camera node * **isActive** : bool - the new active state of the camera (true by default) .. _function-free_camera_is_active_free_camera_NodeId: .. das:function:: is_active_free_camera(freeCamera: NodeId) : bool Checks if the free camera is active. :Arguments: * **freeCamera** : :ref:`NodeId ` & - the ID of the free camera node :Returns: * bool - true if the free camera is active, false otherwise .. _function-free_camera_toggle_free_camera_NodeId_float3_quat4_bool: .. das:function:: toggle_free_camera(freeCamera: NodeId&; position: float3; rotation: quat4; isActive: bool = true) Toggles the state of the free camera and sets its position, rotation and active state (true by default). :Arguments: * **freeCamera** : :ref:`NodeId ` & - the ID of the free camera node * **position** : float3 - the new position of the camera * **rotation** : :ref:`quat4 ` - the new rotation of the camera * **isActive** : bool - the new active state of the camera