Scenes & Serialization¶
SimVX scenes can be saved to JSON and loaded back, preserving the full node hierarchy and settings.
Save & Load¶
from simvx.core import save_scene, load_scene
# Save entire scene tree to JSON
save_scene(root_node, "scenes/level1.json")
# Load scene from file
scene = load_scene("scenes/level1.json")
tree.set_root(scene)
PackedScene¶
PackedScene creates reusable prefabs from scene branches:
from simvx.core import PackedScene
# Create a prefab from an existing node tree
packed = PackedScene(enemy_template)
# Instantiate copies
enemy1 = packed.instance()
enemy2 = packed.instance()
root.add_child(enemy1)
root.add_child(enemy2)
JSON Format¶
Scenes serialize as JSON with type annotations:
{
"__type__": "Node3D",
"name": "Player",
"settings": {
"position": [0, 1, 0]
},
"children": [
{
"__type__": "Camera3D",
"name": "Camera",
"settings": {
"fov": 75.0
}
}
]
}
API Reference¶
See simvx.core.scene for the complete serialization API.