Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Overview

Portals for Bevy

crates.io MIT/Apache 2.0 Bevy tracking

Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Those portals are (for now) purely visual and can be used to make mirrors, indoor renderings, crystal balls, and more!

Portal Cube example Moving portals and destination example Mirror example

Basic Usage

This example illustrates how to create a simple portal, it uses a single sphere that will be displayed two times on screen thanks to the portal:

use bevy::prelude::*;
use bevy_basic_portals::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(PortalsPlugin::default())
        .add_startup_system(setup)
        .run();
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
) {
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-20.0, 0., 20.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..default()
    });

    let portal_mesh = meshes.add(Mesh::from(shape::Quad::new(Vec2::new(10., 10.))));
    commands.spawn(CreatePortalBundle {
        mesh: portal_mesh,
        // This component will be deleted and things that are needed to create the portal will be created
        create_portal: CreatePortal {
            destination: AsPortalDestination::Create(CreatePortalDestination {
                transform: Transform::from_xyz(20., 0., 0.),
                ..default()
            }),
            // Uncomment this to see the portal
            /*debug: Some(DebugPortal {
                show_window: false,
                ..default()
            }),*/
            ..default()
        },
        ..default()
    });

    let sphere_mesh = meshes.add(Mesh::from(shape::UVSphere{radius: 2., ..default()}));
    commands.spawn(PbrBundle {
        mesh: sphere_mesh,
        transform: Transform::from_xyz(20.,0.,-5.),
        ..default()
    });
}

More complex examples are available in the examples folder.

Vocabulary

  • A Portal is an entity used to visualise the effect
  • A Main Camera is a camera used to visualize the effect
  • A (portal) Destination is an entity representing the point in space where a portal is "looking"
  • A Portal Camera is a camera being used to render the effect, its position to the destination is the same as the main camera's position to the portal

Known limitations

(may be fixed in the future)

  • this crate doesn't define a correct frustum, which can pose a problem if an object is between the portal camera and the portal destination and also can reduce perfomance by rendering things that are not displayed (see (https://tomhulton.blogspot.com/2015/08/portal-rendering-with-offscreen-render.html) and (https://www.youtube.com/watch?v=cWpFZbjtSQg))
  • portals created by this crate are uni-directionnal, you can only look from one space to the other, if you want a bidirectional portal you can crate two portals manually
  • this crate doesn't handle "portal recursion", as in viewing a portal through another portal
  • portals created by this crate have no visible borders (not counting aliasing artifacts), you can "see" them with DebugPortal
  • this crate doesn't handle moving stuff through the portal, it is only visual, more like a crystal ball
  • this crate doesn't handle raycasting through the portal, it has to be done manually
  • this crate doesn't handle resizing window/viewport of the main camera
  • this crate doesn't handle changing the portal's or the destination's scale
You might also like...
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

An attempt to create an easily customizable MMORPG game engine. Sky not included.

skyless Proof of concept of an easily customizable MMORPG game engine. Getting started Copy environment variables cp .env.example .env Start the engi

A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves
A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

bevy_pen_tool A Bevy Engine plugin for making 2D paths and smooth animations with Bezier curves TODO: Mesh-making functionality for building 2D shapes

Bevy engine + miniquad render plugin

Bevy engine + miniquad renderer This is a plugin for Bevy engine that replaces default windowing and rendering plugins with miniquad based one. Usage

Simple RUST game with the Bevy Engine

Simple RUST Game using the Bevy Engine YouTube videos for this code base: Episode 1 - Rust Game Development tutorial from Scratch with Bevy Engine Epi

Bevy is a refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy.

Bevy Ineffable A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy. Core tenets Make accessibili

A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

2-player game made with Rust and
2-player game made with Rust and "ggez" engine, based on "Conway's Game of Life"

fight-for-your-life A 2-player game based on the "Conway's Game of Life", made with Rust and the game engine "ggez". Create shapes on the grid that wi

Comments
  • Add register type and some derive reflects

    Add register type and some derive reflects

    For compatibility with bevy_inspector_egui, this could be handy ; maybe we should consider providing it behind a feature ? I'd say it's fine like that but I'll let you judge :)

    opened by Vrixyz 2
  • find first camera rather than get_single

    find first camera rather than get_single

    naive approach to the camera get_single ; also another idea for formatting, but we might want to support more editors, so it's quickly a lot of conf files :/

    opened by Vrixyz 2
  • format

    format

    to start a discussion about cargo fmt, consider where the default is not good, whether we can configure it and/or want it.

    I think it's important if we ever want contributors, because a lot of rust users have cargo fmt on save so it's a bummer when we have hundreds of changes applied in this repo.

    There is also https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#ignore which allows us to clearly say "don't run cargo fmt", but it's unstable so it might not be a good option. We could try to bump the issue or try to contribute...

    opened by Vrixyz 0
Releases(v0.1.0)
Owner
Sélène Amanita
Sélène Amanita
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

Jakob Hellermann 517 Dec 31, 2022
Crossterm plugin for the bevy game engine

What is bevy_crossterm? bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users

null 79 Nov 2, 2022
Hanabi — a particle system plugin for the Bevy game engine.

Hanabi — a particle system plugin for the Bevy game engine

Jerome Humbert 256 Dec 30, 2022
Tweening animation plugin for the Bevy game engine.

?? Bevy Tweening Tweening animation plugin for the Bevy game engine. Features Animate any field of any component or asset, including custom ones. Run

Jerome Humbert 135 Dec 23, 2022
A plugin to enable random number generation for the Bevy game engine.

bevy_turborand A plugin to enable random number generation for the Bevy game engine, built upon turborand. Implements ideas from Bevy's Deterministic

Gonçalo Rica Pais da Silva 15 Dec 23, 2022
A spectator camera plugin for the Bevy game engine

bevy_spectator A spectator camera plugin for the Bevy game engine. Controls Action Key Forward W Left A Backward S Right D Up Space Down LControl Alt.

Jonah Henriksson 5 Jan 2, 2023
A Bevy plugin to easily create and manage windows that remember where they were.

bevy-persistent-windows A Bevy plugin to easily create and manage windows that remember where they were. Background When you're developing a game, thu

Umut 4 Aug 12, 2023
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021