layerview.visualization.world.camera module

Camera controllers.

class layerview.visualization.world.camera.CameraController(camera: NodePath, camera_anchor: NodePath, focal_point, render: NodePath, mouse_watcher_node: MouseWatcher, win: GraphicsBuffer, speed: float)[source]

Bases: DirectObject, ABC

Generic camera controller.

_abc_impl = <_abc_data object>
_addTask(task)
property _camera_anchor_parent: NodePath

Return camera anchor’s parent.

_clearTask(task)
abstract _handle_mouse_pos_delta(delta_px_x: int, delta_px_y: int)[source]

Handle mouse position delta (change).

abstract property _key_combo_to_direction: Dict[KeyCombo, LVector3d]

Return dict that maps KeyCombo to Direction.

static _limit_hpr(val: float) float[source]

Sanitize the provided heading/pitch/rotation value.

_on_key(key_combo: KeyCombo, is_pressed: bool)[source]

Handle keypress event.

_on_mouse_button(mouse_button: MouseButton, is_pressed: bool)[source]

Handle mouse button event.

_on_scroll(is_scroll_up: bool)[source]

Handle scroll event.

_print_camera_status()[source]

Print camera (and camera anchor’s) position and HPR.

_setup_input()[source]

Setup keyboard event listeners.

_setup_tasks()[source]

Setup this controller’s tasks.

_task_handle_key(task)[source]

Handle keypress event.

This is a task function.

_task_handle_mouse(task)[source]

Handle mouse move event.

This is a task function.

accept(event, method, extraArgs=[])
acceptOnce(event, method, extraArgs=[])
accept_once(event, method, extraArgs=[])
activate()[source]

Activate this controller.

Starts relevant tasks.

addTask(*args, **kwargs)
add_task(*args, **kwargs)
deactivate()[source]

Deactivate this controller.

Stops any ongoing camera movement. Stops any running tasks.

detectLeaks()
detect_leaks()
doMethodLater(*args, **kwargs)
do_method_later(*args, **kwargs)
getAllAccepting()
get_all_accepting()
ignore(event)
ignoreAll()
ignore_all()
isAccepting(event)
isIgnoring(event)
is_accepting(event)
is_ignoring(event)
abstract look_at_focal_point()[source]

Focus the camera at focal point.

removeAllTasks()
removeTask(taskOrName)
remove_all_tasks()
remove_task(taskOrName)
stop_movement()[source]

Stop any ongoing camera movement.

class layerview.visualization.world.camera.Direction(value)[source]

Bases: Enum

Represents a direction vector.

BACKWARD = LVector3d(0, -1, 0)
DOWN = LVector3d(0, 0, -1)
FORWARD = LVector3d(0, 1, 0)
LEFT = LVector3d(-1, 0, 0)
RIGHT = LVector3d(1, 0, 0)
UP = LVector3d(0, 0, 1)
class layerview.visualization.world.camera.FreeCameraController(camera: NodePath, camera_anchor: NodePath, focal_point: LVector3d, render: NodePath, mouse_watcher_node: MouseWatcher, win, speed: float | None = 1.0)[source]

Bases: CameraController

Free camera controller.

Allows rotation around the camera’s position.

_KEY_COMBO_TO_DIRECTION: Dict[KeyCombo, LVector3d] = {<KeyCombo.W: 1>: LVector3d(0, 1, 0), <KeyCombo.A: 2>: LVector3d(-1, 0, 0), <KeyCombo.S: 3>: LVector3d(0, -1, 0), <KeyCombo.D: 4>: LVector3d(1, 0, 0), <KeyCombo.SPACE: 5>: LVector3d(0, 0, 1), <KeyCombo.SHIFT_SPACE: 6>: LVector3d(0, 0, -1)}
_abc_impl = <_abc_data object>
_addTask(task)
_camera: NodePath
_camera_anchor: NodePath
property _camera_anchor_parent: NodePath

Return camera anchor’s parent.

_clearTask(task)
_continue_tasks: bool
_handle_mouse_pos_delta(delta_px_x: int, delta_px_y: int)[source]

Handle mouse position delta (change).

property _key_combo_to_direction: Dict[KeyCombo, LVector3d]

Return dict that maps KeyCombo to Direction.

_key_combo_to_is_pressed: Dict[KeyCombo, bool]
static _limit_hpr(val: float) float

Sanitize the provided heading/pitch/rotation value.

_mouse_button_to_is_pressed: Dict[MouseButton, bool]
_mouse_watcher_node: NodePath
_on_key(key_combo: KeyCombo, is_pressed: bool)

Handle keypress event.

_on_mouse_button(mouse_button: MouseButton, is_pressed: bool)

Handle mouse button event.

_on_scroll(is_scroll_up: bool)[source]

Handle scroll event.

_print_camera_status()

Print camera (and camera anchor’s) position and HPR.

_render: NodePath
_setup_camera()[source]

Setup camera for this camera controller.

_setup_input()

Setup keyboard event listeners.

_setup_tasks()

Setup this controller’s tasks.

_task_handle_key(task)

Handle keypress event.

This is a task function.

_task_handle_mouse(task)

Handle mouse move event.

This is a task function.

accept(event, method, extraArgs=[])
acceptOnce(event, method, extraArgs=[])
accept_once(event, method, extraArgs=[])
activate()[source]

Activate this controller.

Starts relevant tasks.

addTask(*args, **kwargs)
add_task(*args, **kwargs)
deactivate()

Deactivate this controller.

Stops any ongoing camera movement. Stops any running tasks.

detectLeaks()
detect_leaks()
doMethodLater(*args, **kwargs)
do_method_later(*args, **kwargs)
getAllAccepting()
get_all_accepting()
ignore(event)
ignoreAll()
ignore_all()
isAccepting(event)
isIgnoring(event)
is_accepting(event)
is_ignoring(event)
look_at_focal_point()[source]

Focus the camera at focal point.

removeAllTasks()
removeTask(taskOrName)
remove_all_tasks()
remove_task(taskOrName)
stop_movement()

Stop any ongoing camera movement.

class layerview.visualization.world.camera.KeyCombo(value)[source]

Bases: Enum

Represents a keyboard key combination (aka key combo).

A = 2
D = 4
S = 3
SHIFT_SPACE = 6
SPACE = 5
W = 1
static get_wasd_keys() List[KeyCombo][source]

Return list containing W, A, S, D KeyCombos.

class layerview.visualization.world.camera.MouseButton(value)[source]

Bases: Enum

Represents a mouse button

LEFT = 1
MIDDLE = 2
RIGHT = 3
class layerview.visualization.world.camera.OrbitCameraController(camera: NodePath, camera_anchor: NodePath, focal_point: LVector3d, render: NodePath, mouse_watcher_node: MouseWatcher, win, speed: float | None = 1.0, distance_min: float | None = 1, distance_max: float | None = 2000)[source]

Bases: CameraController

Orbit camera controller (spherical).

Allows for rotation around a distant focal point. The camera is always focused on the focal point.

_KEY_COMBO_TO_DIRECTION: Dict[KeyCombo, LVector3d] = {<KeyCombo.W: 1>: LVector3d(0, -1, 0), <KeyCombo.A: 2>: LVector3d(1, 0, 0), <KeyCombo.S: 3>: LVector3d(0, 1, 0), <KeyCombo.D: 4>: LVector3d(-1, 0, 0), <KeyCombo.SPACE: 5>: LVector3d(0, 0, 1), <KeyCombo.SHIFT_SPACE: 6>: LVector3d(0, 0, -1)}
_abc_impl = <_abc_data object>
_addTask(task)
_camera: NodePath
_camera_anchor: NodePath
property _camera_anchor_parent: NodePath

Return camera anchor’s parent.

_clearTask(task)
_continue_tasks: bool
_handle_mouse_pos_delta(delta_px_x: int, delta_px_y: int)[source]

Handle mouse position delta (change).

property _key_combo_to_direction: Dict[KeyCombo, LVector3d]

Return dict that maps KeyCombo to Direction.

_key_combo_to_is_pressed: Dict[KeyCombo, bool]
static _limit_hpr(val: float) float

Sanitize the provided heading/pitch/rotation value.

_mouse_button_to_is_pressed: Dict[MouseButton, bool]
_mouse_watcher_node: NodePath
_on_key(key_combo: KeyCombo, is_pressed: bool)

Handle keypress event.

_on_mouse_button(mouse_button: MouseButton, is_pressed: bool)

Handle mouse button event.

_on_scroll(is_scroll_up: bool)[source]

Handle scroll event.

_print_camera_status()

Print camera (and camera anchor’s) position and HPR.

_render: NodePath
_setup_camera(focal_point: LVector3d)[source]

Setup camera for this camera controller.

_setup_input()

Setup keyboard event listeners.

_setup_tasks()

Setup this controller’s tasks.

_task_handle_key(task)

Handle keypress event.

This is a task function.

_task_handle_mouse(task)

Handle mouse move event.

This is a task function.

accept(event, method, extraArgs=[])
acceptOnce(event, method, extraArgs=[])
accept_once(event, method, extraArgs=[])
activate()[source]

Activate this controller.

Starts relevant tasks.

addTask(*args, **kwargs)
add_task(*args, **kwargs)
deactivate()

Deactivate this controller.

Stops any ongoing camera movement. Stops any running tasks.

detectLeaks()
detect_leaks()
doMethodLater(*args, **kwargs)
do_method_later(*args, **kwargs)
getAllAccepting()
get_all_accepting()
ignore(event)
ignoreAll()
ignore_all()
isAccepting(event)
isIgnoring(event)
is_accepting(event)
is_ignoring(event)
look_at_focal_point()[source]

Focus the camera at focal point.

removeAllTasks()
removeTask(taskOrName)
remove_all_tasks()
remove_task(taskOrName)
stop_movement()

Stop any ongoing camera movement.