Skip to main content

Crate maple

Crate maple 

Source
Expand description

ยง๐Ÿ Maple ๐Ÿ

A 3D game engine written in Rust with a focus on simplicity and ease of use.

ยงFeatures

  • 3D Rendering - Built-in primitives, GLTF model loading, and PBR materials
  • Physics - Integrated 3D physics with rapier for rigid body and collider nodes
  • Node-Based - Hierarchical scene graph with parent-child relationships
  • Behavior System - Event-driven behaviors using .on() handlers

ยงShowcase

Bistro Helmet

ยงQuick Start

Add Maple with Cargo:

cargo add maple

Create a basic scene:

pub use maple::prelude::*;

fn main() {
    App::default().add_plugin(Core3D).load_scene(scene).run()
}

fn scene(assets: &AssetLibrary) -> Scene {
    let scene = Scene::default();

    scene
        .spawn(Empty::default())
        .on::<FixedUpdate>(|ctx| {
            ctx.node_mut().transform.rotate_degrees((0.1, 1.0, 0.1), 0.1);
        })
        .spawn_child(DirectionalLight::builder().direction((1.0, -1.0, -1.0)));

    scene.spawn(
        Camera3D::builder()
            .position((2.0, 2.0, 2.0))
            .looking_at(Vec3::ZERO),
    );

    scene.spawn(
        MeshInstance3D::builder()
            .mesh(assets.add(Plane::default().size((2.0, 2.0))))
            .material(assets.add(Color::WHITE)),
    );

    scene.spawn(
        MeshInstance3D::builder()
            .mesh(assets.add(Cuboid::default().half_extent(0.1)))
            .material(assets.add(Color::BLUE))
            .position((0.0, 0.3, 0.0)),
    );

    scene
}

ยงExamples

Check out the examples by cloning this repo

# Physics demo
cargo run --example physics_demo

# First-person player controller
cargo run --example player_controller

# Model loading from GLTF
cargo run --example model_loading

ยงPlatform

Maple was primarily developed for desktop but does have limited WASM support.

ยงContributing

Contributions are welcome! If you have suggestions for improvements, feel free to create a pull request or open an issue.

ยงLicense

This project is licensed under the MIT License

ยงImprove performance on dev

cargo builds dependencies in debug mode which leaves them unoptimized. For Maple this can cause slow asset loading and low frame rates in dev builds.

Opting dependencies into full optimization fixes this while keeping your own crate compile times low for fast incremental builds.

[profile.dev.package."*"]
opt-level = 3

Re-exportsยง

pub use glam as math;
pub use maple_3d;
pub use maple_app as app;
pub use maple_audio as audio;
pub use maple_derive as derive;
pub use maple_engine as engine;
pub use maple_physics as physics;
pub use maple_renderer as renderer;

Modulesยง

default_plugins
prelude
the prelude exposes almost everything you need to get started