#bevy #bevy-plugin #portal #gamedev #camera #gizmo #transform

bevy_easy_portals

Bevy plugin for easy-to-use portals

3 releases

new 0.2.2 Oct 20, 2024
0.2.1 Oct 20, 2024
0.2.0 Oct 20, 2024
0.1.0 Oct 20, 2024

#520 in Game dev

Download history 223/week @ 2024-10-16

223 downloads per month

MIT/Apache

420KB
356 lines

bevy_easy_portals

Easy-to-use portals for Bevy

screenshot showing a cube being reflected in a mirror using portals

Getting Started

First, add PortalPlugin to your app, then use the Portal component, et voila!

See the examples for more references.

Example usage
use bevy::prelude::*;
use bevy_easy_portals::{Portal, PortalPlugin}

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, PortalPlugin))
        .add_systems(Startup, setup)
        .run();
}

fn setup(
    mut commands: Commands,
    mut materials: ResMut<Assets<StandardMaterial>>,
    mut meshes: ResMut<Assets<Mesh>>,
) {
    let primary_camera = commands
        .spawn(Camera3dBundle {
            transform: Transform::from_xyz(0.0, 0.0, 10.0),
            ..default()
        })
        .id();

    // Where you want the portal to be located
    let portal_transform = Transform::default();

    // Where the portal's target camera should be
    let target_transform = Transform::from_xyz(10.0, 0.0, 10.0);

    // Spawn something for the portal to look at
    commands.spawn(PbrBundle {
        mesh: meshes.add(Cuboid::default()),
        material: materials.add(Color::WHITE),
        transform: Transform::from_xyz(10.0, 0.0, 0.0),
        ..default()
    });

    // Spawn the portal, omit a material since one will be added automatically
    commands.spawn((
        meshes.add(Rectangle::default()),
        SpatialBundle::from_transform(portal_transform),
        Portal::new(primary_camera, target_transform),
    ));
}

Compatibility

bevy_easy_portals bevy
0.1..0.2 0.14

Features

Feature Description
gizmos Use gizmos for the portal's aabb and camera transform

Contributing

Feel free to open a PR!

If possible, please try to keep it minimal and scoped.

Alternatives

Dependencies

~38–75MB
~1.5M SLoC