simvx.core.resource

Resource system — URI-based resource resolution with caching.

Mesh resource identifiers: “mesh://cube” → Mesh.cube() “mesh://sphere?radius=2&rings=16” → Mesh.sphere(radius=2, rings=16) “mesh://obj?path=models/ship.obj” → Mesh.from_obj(“models/ship.obj”)

Audio resource identifiers: “audio://music/theme.ogg” → AudioStream(“music/theme.ogg”) “audio://sfx/explosion.wav” → AudioStream(“sfx/explosion.wav”)

Public API: ResourceCache.get().resolve_mesh(uri) ResourceCache.get().resolve_audio(uri)

Module Contents

Classes

MeshURI

Builder for mesh resource URIs.

ResourceCache

Singleton cache that resolves resource URIs to objects.

Data

log

API

simvx.core.resource.log[source]

‘getLogger(…)’

class simvx.core.resource.MeshURI[source]

Builder for mesh resource URIs.

Usage: MeshURI.CUBE # “mesh://cube” MeshURI.SPHERE # “mesh://sphere” MeshURI.cube(size=0.5) # “mesh://cube?size=0.5” MeshURI.sphere(radius=2, rings=32) # “mesh://sphere?radius=2&rings=32” MeshURI.obj(“models/ship.obj”) # “mesh://obj?path=models/ship.obj”

CUBE

‘mesh://cube’

SPHERE

‘mesh://sphere’

CONE

‘mesh://cone’

CYLINDER

‘mesh://cylinder’

static cube(size: float = 1.0) str[source]
static sphere(radius: float = 1.0, rings: int = 16, segments: int = 16) str[source]
static cone(radius: float = 0.5, height: float = 1.0, segments: int = 16) str[source]
static cylinder(radius: float = 0.5, height: float = 1.0, segments: int = 16) str[source]
static obj(path: str) str[source]
class simvx.core.resource.ResourceCache[source]

Singleton cache that resolves resource URIs to objects.

Initialization

classmethod get() simvx.core.resource.ResourceCache[source]

Return the singleton instance, creating it if needed.

resolve_mesh(uri: str) simvx.core.graphics.mesh.Mesh[source]

Resolve a mesh:// URI to a Mesh object. Results are cached by URI.

resolve_audio(uri: str) simvx.core.audio.AudioStream[source]

Resolve an audio:// URI to an AudioStream object. Results are cached by URI.

unload(uri: str) bool[source]

Remove a single resource from the cache.

Returns True if the resource was found and removed, False otherwise. Callers holding references to the unloaded resource retain them, but re-resolving the same URI will create a fresh object.

cached_uris() list[str][source]

Return all currently cached resource URIs.

clear()[source]

Clear all cached resources.

classmethod reset()[source]

Reset the singleton (useful for tests).