Building a scene in the editor¶
Build a small 3D scene in the SimVX editor, give one node behaviour with a class of your own, play it and save it. A scene the editor saves is an ordinary Python file, so everything here can also be written by hand.
Launch¶
simvx editor
From a source checkout, prefix commands with uv run.
The welcome screen lists recent projects. Choose + New Project, give it a name and a
location, and press Create; or Open Project for an existing one. To skip the welcome
screen, pass the project directory: simvx editor my_game.
The window¶
Area |
What it holds |
|---|---|
Top bar |
Menus (File, Edit, Scene, View, Help), the 3D / 2D / Code switcher, Play / Pause / Stop |
Left |
Scene Tree and File Browser tabs |
Centre |
The viewport and the code editor, as tabs |
Right |
Properties: the inspector for the selected node |
Bottom |
Output and Profiler tabs |
1. Start a scene¶
Press Ctrl+N and choose 3D Scene (Default). It comes populated: a floor, a cube, a sphere,
a cylinder, a sun, an orbit camera and a WorldEnvironment. The other choices start a bare 3D,
2D, UI or empty root.
2. Arrange it¶
Select the
Cubein the Scene Tree. The Properties panel shows its type, its name and a section per group of Properties, such as Transform.Rename it: press F2, type
Spinner, press Enter.Move it: in the Transform section, set Position Y to
1.5.Add a node: press + in the Scene Tree header. The Add Node dialog groups the node types by category, and its filter field takes focus: type
PointLight3D, press Down to step into the list, and Enter adds the light under the selected node.Undo anything with Ctrl+Z, and redo with Ctrl+Shift+Z. Delete removes the selected node and Ctrl+D duplicates it.
The inspector picks a widget from each Property’s type: a spin box for numbers, a check box for
bool, a text field for str, a drop-down for a str with enum, a colour picker for colours,
and a row of spin boxes for Vec2 and Vec3.
3. Save¶
Press Ctrl+S. The first save asks where to put the file; call it main.py. The scene is
written as Python source: the root is a Node subclass that builds its children, passing the
Properties you set as keyword arguments. Open it in any editor and read it.
4. Give a node behaviour¶
Select Spinner and press Convert to Custom Class in the Properties panel header (or
right-click it in the Scene Tree). Keep the class name, choose the Empty template and accept.
The editor writes a class file, points the scene at it and opens the file in the code workspace.
Give the class a Property and an on_update:
from simvx.core import MeshInstance3D, Property
class Spinner(MeshInstance3D):
speed = Property(1.5, range=(0, 10))
def on_update(self, dt: float):
self.rotate_y(self.speed * dt)
Save the file. speed is a Property, so it appears in the inspector like any built-in one.
5. Play¶
Press F5 to play the scene: the cube spins. F7 pauses and F6 stops. Stopping puts the scene back exactly as it was before you pressed Play, so nothing that happened while playing is saved by accident.
The saved scene runs outside the editor too:
simvx run main.py
Next steps¶
Your first 2D game and Your first 3D game: write a complete game in code.
From monolithic to composed: how to split a game into small nodes, which is also how the editor’s Scene Tree shows it.