simvx.core.scene¶
Scene serialization — save/load node trees as JSON or pickle.
Both backends serialize to the same plain-dict intermediate format. Pickle stores the dict (not raw Node objects), avoiding class-path brittleness and GPU state issues.
Public API: save_scene(node, path) # format inferred from extension (.py/.json/.pkl) load_scene(path, format=None) # auto-detects from extension
Module Contents¶
Classes¶
Reusable scene resource that loads once and can be instanced many times. |
Functions¶
Save a node tree to disk. |
|
Load a node tree from disk. |
Data¶
API¶
- simvx.core.scene.CURRENT_FORMAT_VERSION¶
1
- simvx.core.scene.MIGRATIONS: dict[tuple[int, int], collections.abc.Callable[[dict], dict]]¶
None
- simvx.core.scene.save_scene(node: simvx.core.node.Node, path: str | pathlib.Path, format: str | None = None)[source]¶
Save a node tree to disk.
Scenes are Python. When saving a scene, use a
.pyextension so the format auto-detects as"python"and the tree is emitted as Python source (the editor’s canonical scene format)."json"and"pickle"remain available for non-scene serialization (save files, checkpoints).Args: node: Root node to serialize. path: Output file path. format:
"python","json", or"pickle". IfNone(default), inferred from the path’s extension.
- simvx.core.scene.load_scene(path: str | pathlib.Path, format: str | None = None) simvx.core.node.Node[source]¶
Load a node tree from disk.
For
.pyscene files, imports the module and instantiates the primaryNodesubclass..json/.pklare supported for save-file deserialization.Args: path: Input file path. format:
"python","json","pickle", orNoneto auto-detect from extension.Returns: Reconstructed root Node.
- class simvx.core.scene.PackedScene(path: str | pathlib.Path)[source]¶
Reusable scene resource that loads once and can be instanced many times.
The scene file is lazily parsed on the first call to instance(). Subsequent calls deep-copy the cached data to produce independent node trees.
Initialization
- instance() simvx.core.node.Node[source]¶
Load and return a new node tree from the scene file.
- save(node: simvx.core.node.Node)[source]¶
Save a node tree to this PackedScene’s path.