simvx.core.resource_loader

Background resource loading – threaded loading with progress tracking.

Provides a Godot-style interface for background resource loading with status polling, suitable for loading screens and smooth level transitions.

Public API: from simvx.core.resource_loader import ResourceLoader

ResourceLoader.load_threaded_request("mesh://sphere")
while True:
    status, progress = ResourceLoader.load_threaded_get_status()
    if status == "loaded":
        resource = ResourceLoader.load_threaded_get()
        break
    update_loading_bar(progress)

Module Contents

Classes

LoadStatus

Status of a background load request.

ResourceLoader

Singleton threaded resource loader with progress tracking.

Data

API

simvx.core.resource_loader.log

‘getLogger(…)’

simvx.core.resource_loader.__all__

[‘ResourceLoader’, ‘LoadStatus’]

class simvx.core.resource_loader.LoadStatus

Bases: enum.Enum

Status of a background load request.

IDLE

‘idle’

LOADING

‘loading’

LOADED

‘loaded’

ERROR

‘error’

__new__(value)
__repr__()
__str__()
__dir__()
__format__(format_spec)
__hash__()
__reduce_ex__(proto)
__deepcopy__(memo)
__copy__()
name()
value()
class simvx.core.resource_loader.ResourceLoader

Singleton threaded resource loader with progress tracking.

Supports loading any resource type via registered loaders. Built-in loaders handle mesh:// and audio:// URIs via ResourceCache.

Initialization

classmethod get() simvx.core.resource_loader.ResourceLoader

Return the singleton instance.

classmethod reset()

Reset the singleton (for tests). Shuts down the thread pool.

register_loader(scheme: str, loader: collections.abc.Callable[[str], Any]) None

Register a custom loader for a URI scheme.

Args: scheme: URI scheme (e.g., “texture”, “model”). loader: Callable that takes a URI string and returns the loaded resource.

classmethod load_threaded_request(path: str, loader: collections.abc.Callable[[str], Any] | None = None) None

Start loading a resource in the background.

Args: path: Resource URI (e.g., “mesh://sphere”, “audio://sfx/boom.wav”). loader: Optional custom loader function. If None, uses registered loader.

classmethod load_threaded_get_status(path: str = '') tuple[str, float]

Check the status of a background load.

Args: path: Resource URI. If empty, returns status of the most recent request.

Returns: Tuple of (status_string, progress_float). Status is one of: “idle”, “loading”, “loaded”, “error”.

classmethod load_threaded_get(path: str = '') Any

Get the loaded resource (blocks if still loading).

Args: path: Resource URI. If empty, gets the most recent request.

Returns: The loaded resource object.

Raises: RuntimeError: If loading failed or no request exists.

classmethod is_loading() bool

Check if any resources are currently loading.

classmethod get_progress() float

Get overall loading progress across all pending requests (0.0 to 1.0).