Vuer

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

python
class SceneGraph

Source

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

python
def __init__(self)

Source

SceneGraph.data

python
def data(self) -> Optional[Dict[str, Any]]

Source

Get raw scene data as dict.

SceneGraph.set_scene

python
def set_scene(self, scene_data: Dict[str, Any]) -> None

Source

Set the entire scene.

SceneGraph.get

python
def get(self, key: str) -> Optional[Dict[str, Any]]

Source

Get element by key (recursive search).

SceneGraph.add

python
def add(self, node: Dict[str, Any], to: Optional[str]=None) -> None

Source

Add a node to the scene.

SceneGraph.update

python
def update(self, node: Dict[str, Any]) -> None

Source

Update an existing node by key.

SceneGraph.upsert

python
def upsert(self, node: Dict[str, Any], to: Optional[str]=None) -> None

Source

Update if exists, otherwise add.

SceneGraph.remove

python
def remove(self, key: str) -> None

Source

Remove a node by key.

SceneGraph.to_scene

python
def to_scene(self) -> Optional[Scene]

Source

Hydrate the scene data back to a Scene object.

SubscriptionContext

python
class SubscriptionContext

Source

Context manager for session subscription.

SubscriptionContext.init

python
def __init__(self, store: 'SceneStore', session: 'VuerSession')

Source

SceneStore

python
class SceneStore(SceneOps)

Source

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

python
def __init__(self)

Source

SceneStore.history

python
def history(self) -> List[Dict[str, Any]]

Source

Get complete history of all operations.

SceneStore.scene

python
def scene(self) -> Optional[Scene]

Source

Get current scene as a hydrated Scene object.

SceneStore.scene_data

python
def scene_data(self) -> Optional[Dict[str, Any]]

Source

Get current scene state as raw dict.

SceneStore.get

python
def get(self, key: str) -> Optional[Dict[str, Any]]

Source

Get element by key.

SceneStore.subscribe

python
def subscribe(self, session: 'VuerSession') -> SubscriptionContext

Source

Subscribe a session to receive broadcasts.

Inherited members

Public imports

These symbols are available from this module. Their definitions are documented in the linked modules.

  • Addvuer.events.Add
  • Removevuer.events.Remove
  • Setvuer.events.Set
  • Updatevuer.events.Update
  • Upsertvuer.events.Upsert
  • Scenevuer.schemas.scene_components.Scene
  • SceneOpsvuer.server.SceneOps