Giter Site home page Giter Site logo

malekire / bevy_basic_portals Goto Github PK

View Code? Open in Web Editor NEW

This project forked from selene-amanita/bevy_basic_portals

0.0 0.0 0.0 156 KB

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

License: European Union Public License 1.2

Rust 98.86% WGSL 1.14%

bevy_basic_portals's Introduction

Portals for Bevy

crates.io docs.rs MIT/Apache 2.0 Bevy tracking

Bevy Basic 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,
            PortalsPlugin::MINIMAL
        ))
        .add_systems(Startup, 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)

  • 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

Bevy versions

Bevy version Bevy Basic Portals recommended version
0.11.1 0.3.0
0.10.* 0.2.1

bevy_basic_portals's People

Contributors

selene-amanita avatar vrixyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.