Skip to content

Your first project

This page makes a scene with a camera, a light and a cube, then spins the cube from C#. It takes about ten minutes. You need Orblit and the .NET 10 SDK from Installing.

  1. Start the classic editor. The project manager opens.
  2. Choose Create.
  3. Type a Project Name, such as Spinner.
  4. Choose a Project Path in an empty folder.
  5. Leave the Renderer on Forward+.
  6. Choose Create. The editor opens on the new project.
  1. In the Scene panel, under Create Root Node, choose 3D Scene. This adds an Entity3D called Entity3D.
  2. With the root selected, choose Add Child Node. Search for MeshInstance3D and choose Create.
  3. In the Inspector, set the Mesh property to New BoxMesh. A cube appears in the viewport.
  4. Select the root again and add a Camera3D. In the Inspector, set its Position to 0, 1, 4.
  5. Add a DirectionalLight3D to the root. Set its Rotation to -45, 30, 0.
  6. Press Ctrl+S, or Cmd+S on macOS. Save the scene as main.oscn.
  1. Select the MeshInstance3D and choose Attach Script.
  2. Set Language to C#, set Path to res://Spinner.cs and choose Create. The editor also makes the project’s .csproj the first time.
  3. Replace the file’s contents with this:
using Orblit;
public partial class Spinner : MeshInstance3D
{
// Radians per second.
[Export]
public float Speed { get; set; } = 1.5f;
public override void OnStart()
{
Orb.Print("The cube is ready.");
}
public override void OnFrame(double delta)
{
RotateY(Speed * (float)delta);
}
}

The class name must match the file name. OnStart runs once, when the cube joins the running scene. OnFrame runs every frame, and delta is the seconds since the last one. [Export] shows Speed in the Inspector, so you can change it there without touching the code.

Press F5, or Cmd+B on macOS, or choose Run Project at the top right. The editor builds the C# first.

The first run asks for a main scene. Choose Select Current to use main.oscn. A window opens with the cube turning, and the Output panel shows The cube is ready.

  • The cube turns at a steady rate.
  • Change Speed in the Inspector and run again. The cube turns faster.
  • If the build fails, run dotnet --list-sdks and check for a line starting with 10..

The class reference lists everything an entity can do. Start with Entity3D for 3D or Entity2D for 2D.