vuer.rtc.scene_store
SceneStore - A reactive scene graph store that maintains state and broadcasts.
Mirrors the VuerSession API (set, add, upsert, update, remove) but also maintains internal state and broadcasts to all subscribed sessions.
Usage: from vuer import Vuer, VuerSession from vuer.rtc import SceneStore from vuer.schemas import Box, Scene
app = Vuer() store = SceneStore()
@app.spawn(start=True) async def main(sess: VuerSession): async with store.subscribe(sess): store.set @ Scene(Box(key="box")) store.upsert @ Box(key="box2", position=[1, 0, 0])
Query state
print(store.scene) # Returns hydrated Scene object print(store.get("box")) # Get element by key print(store.history) # Complete operation history
SceneGraph
Scene state model that manages the scene graph as a nested dict structure.
Provides methods for manipulating the scene: set, add, update, upsert, remove. Can hydrate back to a Scene object via to_scene().
SceneGraph.init
SceneGraph.data
Get raw scene data as dict.
SceneGraph.set_scene
Set the entire scene.
SceneGraph.get
Get element by key (recursive search).
SceneGraph.add
Add a node to the scene.
SceneGraph.update
Update an existing node by key.
SceneGraph.upsert
Update if exists, otherwise add.
SceneGraph.remove
Remove a node by key.
SceneGraph.to_scene
Hydrate the scene data back to a Scene object.
SubscriptionContext
Context manager for session subscription.
SubscriptionContext.init
SceneStore
A reactive store that maintains scene state and broadcasts to subscribers.
Inherits from SceneOps which provides: set, add, upsert, update, remove. Uses SceneGraph internally for state management.
Example: store = SceneStore()
@app.spawn(start=True) async def main(sess: VuerSession): async with store.subscribe(sess): store.set @ Scene(Box(key="box")) store.upsert @ Sphere(key="sphere", position=[1, 0, 0])
Query state
print(store.get("box")) print(store.scene) # Returns Scene object print(store.history)
SceneStore.init
SceneStore.history
Get complete history of all operations.
SceneStore.scene
Get current scene as a hydrated Scene object.
SceneStore.scene_data
Get current scene state as raw dict.
SceneStore.get
Get element by key.
SceneStore.subscribe
Subscribe a session to receive broadcasts.
Inherited members
set— fromvuer.server.SceneOpsupdate— fromvuer.server.SceneOpsadd— fromvuer.server.SceneOpsupsert— fromvuer.server.SceneOpsremove— fromvuer.server.SceneOps
Public imports
These symbols are available from this module. Their definitions are documented in the linked modules.