2 releases

0.1.1 Mar 16, 2023
0.1.0 Mar 16, 2023

#342 in #3d

25 downloads per month
Used in yuxii

MIT/Apache

16KB
380 lines

Yuxii is an ECS-based 3D game engine.

Main purpose is to be very simple to use and learn.

Warning! Nothing is done yet.

Getting started:

Nodes

In Yuxii Node is a logic and a scene at once.

Lets see an Example:

/* file: src/my_node/mod.rs */

#[node]
pub struct MyNode;

#[node]
impl MyNode{
  fn init(&self){ }
  fn frame(&self) { }
  fn scene() -> Scene { }
}

Alright, we just created a node.

init is called when we start the program

frame is called each frame asynchronically . You can put there systems to execute.

scene is for spawning entities and their modifiers

But without connecting this node to main program it cant do any logic

So lets fix it and plug our node logic in the world:

/* file: src/main.rs */
fn main(){
    MyNode.plug();

    // We can also spawn this node content:
    MyNode::spawn();

    // Run
    Yuxii::run();

}

Structure of the node looks like this:

NodeName (Folder)
    mod.rs
    resources.rs
    scene.ron
    systems.rs

Systems

You can easily add system from any part of your project, but after Yuxii::run()

#[system]
fn my_system(){ /* do something */ }

and add it:

fn frame(&self){
    my_system();
}

Queries

Queries are very powerfull in this engine (should be, not yet) Lets get into example:

#[system]
fn my_system(){
    // This query will be removed by macro and will not appear in docs
    /// *GetMut, &GetRef, Added+, &OptionRef?
    {
        get_mut.field = "oh, hey";
    }

    // And we have even better parenting
    /// Parent:: *GetMut
    {
        parent_get_mut.field = "looks easy";

    }
    // Custom naming
    /// *[my_vel]Velocity
    {
        my_vel;
    }
}

Resources

Components

#[derive(Component)]
pub struct MyComponent{
    /// def 9
    pub field: i32,
    /// def "Hello World"
    pub private: String
}

It will automatically implement Default according to docs attributes.

Add component:

let entity = World::spawn();

entity << MyComponent{ field: 65, ..default() };

Globals

#[derive(Global)]
pub struct MyGlobal{
    /// def "It is global" 
    pub info: String
}

globals instances are automatically adding to the world at their definition. It means, you can access it after its definition.

fn system(){
    let lock = MyGlobal::read();

    log << "MyGlobal info: " << lock.info;
}

Signals

todo!();

Dependencies

~1.5MB
~33K SLoC