6 releases

new 0.4.0 Jan 5, 2025
0.3.1 Dec 18, 2024
0.2.2 Oct 20, 2024
0.1.0 Oct 20, 2024

#323 in Game dev

Download history 203/week @ 2024-10-16 54/week @ 2024-10-23 2/week @ 2024-10-30 2/week @ 2024-11-06 1/week @ 2024-11-27 48/week @ 2024-12-04 105/week @ 2024-12-11 154/week @ 2024-12-18 6/week @ 2024-12-25 141/week @ 2025-01-01

451 downloads per month

MIT/Apache

425KB
586 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, PortalPlugins}

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, PortalPlugins))
        .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((Camera3d::default(), Transform::from_xyz(0.0, 0.0, 10.0)))
        .id();

    // Spawn something for the portal to look at
    commands.spawn((
        Mesh3d(meshes.add(Cuboid::default())),
        MeshMaterial3d(materials.add(Color::WHITE)),
        Transform::from_xyz(10.0, 0.0, 0.0),
    ));

    // Where the portal's target camera should be
    let target = commands.spawn(Transform::from_xyz(10.0, 0.0, 10.0)).id();
    // Where the portal should be located
    let portal_transform = Transform::default();
    // Spawn the portal, omit a material since one will be added automatically
    commands.spawn((
        Mesh3d(meshes.add(Rectangle::default())),
        portal_transform,
        Portal::new(primary_camera, target),
    ));
}

Compatibility

bevy_easy_portals bevy
0.3 0.15
0.1..0.2 0.14

Features

Feature Description
picking Support picking through portals with using your favourite backend
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

~41–73MB
~1.5M SLoC