simvx.core.assets.server¶
AssetServer: orchestrates Sources, Loaders, and a worker pool.
Public entry point for asset loading. Routes a URI through the right
- class:
~simvx.core.assets.source.Sourceand :class:~simvx.core.assets.loaders.base.Loader, runs the I/O on a thread pool, and marshals completion notifications back onto the main thread via :meth:flush(called once perSceneTree.process(dt)tick).
Usage::
server = AssetServer.instance()
handle = server.load("pkg://game/textures/player.png")
handle.completed.connect(lambda h: print("loaded:", h.state))
batch = server.load_folder("pkg://game/textures/")
batch.item_completed.connect(lambda h: print("loaded one:", h.uri))
batch.completed.connect(lambda b: print("all done"))
The constructor is private-by-convention; use :meth:AssetServer.instance
to obtain the engine-wide singleton, or instantiate directly for
isolated tests.
Module Contents¶
Classes¶
Async typed-asset orchestrator with byte-budget caches per loader. |
Data¶
API¶
- simvx.core.assets.server.__all__¶
[‘AssetServer’]
- class simvx.core.assets.server.AssetServer(*, max_workers: int = 2)[source]¶
Async typed-asset orchestrator with byte-budget caches per loader.
Initialization
- classmethod instance() simvx.core.assets.server.AssetServer[source]¶
Return the engine-wide singleton, creating it on first access.
- register_source(source: simvx.core.assets.source.Source) None[source]¶
Install
sourcefor its declaredscheme.
- register_loader(loader: simvx.core.assets.loaders.base.Loader) None[source]¶
Install a typed loader. Order of registration is the lookup order.
- get_source(scheme: str) simvx.core.assets.source.Source[source]¶
- load(uri: str, *, cache: bool = True, loader: simvx.core.assets.loaders.base.Loader | None = None) simvx.core.assets.handle.Handle[source]¶
Submit
urifor asynchronous loading.Returns a :class:
Handlethat exposes progress, state, errors, and acompletedSignal. Uses the registered Source for the URI’s scheme and the first Loader whoseclaims(uri)returns True (or the explicitloader=override). Whencacheis True, both lookup and store go through the loader’s LRU.
- load_group(uris: collections.abc.Iterable[str], *, cache: bool = True, loader: simvx.core.assets.loaders.base.Loader | None = None) simvx.core.assets.handle.BatchHandle[source]¶
Load every URI in
urisconcurrently. Returns a :class:BatchHandle.
- load_folder(uri: str, *, cache: bool = True, loader: simvx.core.assets.loaders.base.Loader | None = None) simvx.core.assets.handle.BatchHandle[source]¶
Enumerate
urivia the Source’slist()and load each child.Sources that cannot list (e.g. HTTP) raise :class:
NotImplementedError; use :meth:load_manifestfor those.
- load_manifest(manifest_uri: str, *, cache: bool = True, loader: simvx.core.assets.loaders.base.Loader | None = None) simvx.core.assets.handle.BatchHandle[source]¶
Load the URI list from a JSON manifest, then load each entry.
The manifest must be a JSON array of URI strings, e.g.::
["pkg://game/level1/floor.png", "https://cdn.example.com/level1.ogg"]
This call blocks briefly to fetch + parse the manifest, then returns a BatchHandle for the listed assets.