A 3d gizmo for transforming entities in Bevy.

Related tags

Graphics gizmo bevy
Overview

Bevy Transform Gizmo

This Bevy plugin adds a transform gizmo to entities in the scene, allowing you to drag and rotate meshes with your mouse.

Demo.mp4

Demo

Run a minimal implementation of the gizmo by cloning this repository and running:

cargo run --example minimal

Features

  • Prebuilt transform gizmo appears when you select a designated mesh
  • Translation handles
  • Rotation handles
  • Gizmo always renders on top of the main render pass
  • Gizmo scales at it moves closer/further from the camera

Usage

This plugin is built on and relies on bevy_mod_picking for 3d mouse interaction with the scene.

Add the plugin to the [dependencies] in Cargo.toml

bevy_transform_gizmo = { git = "https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo", branch = "main" }

You will need to add the transform gizmo plugin, as well as make sure you have also brought in the picking plugin.

.add_plugin(bevy_mod_picking::DefaultPickingPlugins)
.add_plugin(bevy_transform_gizmo::TransformGizmoPlugin)

Next, you will need to mark your picking camera as your gizmo camera:

.insert_bundle(bevy_mod_picking::PickingCameraBundle::default())
.insert(bevy_transform_gizmo::GizmoPickSource::default());

Finally, mark any meshes you want to be transformed with the gizmo; note they must also be selectable in the picking plugin:

.insert_bundle(bevy_mod_picking::PickableBundle::default())
.insert(bevy_transform_gizmo::GizmoTransformable);

See the minimal demo for an example of a minimal implementation.

Comments
  • Avoid spamming errors in unexpected situations

    Avoid spamming errors in unexpected situations

    Spamming errors greatly reduces the usability of a library, if every second, up to 500 errors are printed in the console, it is as good as if the library panicked.

    With this PR, bevy_transform_gizmo will only log stuff if it didn't already emit a similar message within the last second. (note that I downgraded the errors into warnings, since they fundamentally do not break stuff)

    I also use system chaining for logging, because of separation of concerns.

    opened by nicopap 5
  • ability to toggle gizmo while program is running

    ability to toggle gizmo while program is running

    It would be nice if it was possible to control whether the gizmo is shown while the program is running, e.g. for an in-program 'editor' like bevy_editor_pls.

    opened by jakobhellermann 4
  • Add a gizmo to whole scene

    Add a gizmo to whole scene

    @elpiel: creating this issue to discuss your question from your PR https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/18#issuecomment-1025533979

    Btw is there a way to add the gizmo to a whole scene?

    Could you provide a bit more detail? Do you want to:

    1. Select everything in the scene and transform it
    2. Make everything in the scene possible to transform individually
    3. Something else?
    opened by aevyrie 2
  • Run criteria attaching prototype

    Run criteria attaching prototype

    This is not inteded to be merged as is.

    A rough prototype of how to let users attach their own run criteria to systems of the plugin - this is the building block that lets enabling/disabling the plugin via user-defined states. I haven't considered if the criteria even make sense on all of these systems.

    The main hurdle in the way of making this less gnarly is that Bevy's run criteria (and thus states) are stage-specific. Plans to mitigate that do exist, but aren't quite ready yet; resolving this would make a single copy of a criteria (or label) sufficient for the entire config, instead of a producer function (aka bootleg clone).

    Another thing I'm not sure if I like is that the nested plugins have to rely on the same config struct as the top-level plugin. This might be possible to rework, but I don't know how valuable would that be in this context.

    opened by Ratysz 1
  • unknown `UpdateSetting` label

    unknown `UpdateSetting` label

    I find this warning when I use this great crate:

    2022-05-30T07:28:55.784722Z  WARN bevy_ecs::schedule::graph_utils: bevy_transform_gizmo::hover_gizmo wants to be after unknown label: UpdateSettings
    

    So I dive into the code and see this: https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/blob/5b27518eda2041f45316cdeef2d90bf15d0b5a33/src/lib.rs#L80-L113

    The UpdateSetting label is defined in PostUpdate stage (Line 101) but it is used in PreUpdate stage (Line 87).

    Is just deleting Line 87 is ok?

    opened by YoshieraHuang 0
  • Various improvements

    Various improvements

    • Allow disabling rotation gizmos
    • Add handles for movement in viewspace and movement locked to a plane

    Notes: requires https://github.com/aevyrie/bevy_mod_raycast/pulls/51 before this can be completed.

    opened by TheRawMeatball 0
  • Increased composability; suspend picking on gizmo hover

    Increased composability; suspend picking on gizmo hover

    Part of https://github.com/aevyrie/bevy_mod_raycast/pull/24, https://github.com/aevyrie/bevy_mod_picking/pull/106, and https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/13, a set of changes reworking the transform gizmo plugin stack to compose better.

    Depends on bevy_mod_raycast with https://github.com/aevyrie/bevy_mod_raycast/pull/24 merged, and bevy_mod_picking with https://github.com/aevyrie/bevy_mod_picking/pull/106 merged.

    Added global plugin on/off switch with GizmoSystemsEnabled, wired up through run criteria. Fixes #11.

    Reimplemented picking suspension on gizmo interaction (now with hovering, too!) using PickingBlocker introduced in https://github.com/aevyrie/bevy_mod_picking/pull/106.

    opened by Ratysz 0
  • Translation reverses at steep viewing angles

    Translation reverses at steep viewing angles

    When dragging while looking down the translation axis, if the mouse goes past the point of convergence, the gizmo will start going backward.

    https://user-images.githubusercontent.com/2632925/119240735-9477a900-bb06-11eb-840b-d61f94238448.mp4

    bug 
    opened by aevyrie 0
  • Update to Bevy 0.9

    Update to Bevy 0.9

    As of today Bevy is 2 open issues behind the 0.9 milestone. See: https://github.com/bevyengine/bevy/milestone/7 and this crate should support it asap ;)

    Bevy Migration

    remove deprecated API usage of spawn_bundle() and use spawn() instead

    opened by olegomon 0
  • Use more robust math for translation

    Use more robust math for translation

    Instead of the plane intersection method, should use vector math for finding the nearest point on skew vectors, something like:

    pub fn nearest_point(&self, other: &Ray) -> Option<Vec3> {
        let delta_p = other.origin - self.origin;
        let v1_squared = self.direction.dot(self.direction);
        let v2_squared = other.direction.dot(other.direction);
        let v1_dot_v2 = self.direction.dot(other.direction);
        let determinant = v1_dot_v2.powi(2) - v1_squared * v2_squared;
    
        if determinant.abs() > f32::MIN {
            let delta_p_v1 = delta_p.dot(self.direction);
            let delta_p_v2 = delta_p.dot(other.direction);
            let t = (1.0 / determinant) * (v2_squared * delta_p_v1 - v1_dot_v2 * delta_p_v2);
            let result = self.origin + self.direction * t;
            Some(result)
        } else {
            // The lines are parallel!
            None
        }
    }
    

    This should be more robust to camera view changes and translating at far distances with perspective cameras.

    enhancement 
    opened by aevyrie 0
  • wip: #8 2d axis only

    wip: #8 2d axis only

    A naive attempt to #8.

    I wanted to set up a minimal example in 2d using a orthographic camera, but materials used are 3d, so it makes it a bit more difficult than I'd like, anyway I'm sharing my approach in case anyone want to give it a try.

    opened by Vrixyz 0
Releases(v0.4.0)
  • v0.4.0(Nov 22, 2022)

    What's Changed

    • Realease port by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/39
    • Update to Bevy 0.9 by @olegomon in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/42

    New Contributors

    • @olegomon made their first contribution in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/42

    Full Changelog: https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/compare/v0.3.3...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Sep 16, 2022)

  • v0.3.1(Aug 11, 2022)

    What's Changed

    • remove after UpdateSettings label by @YoshieraHuang in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/26
    • Upstream stuff by @TheRawMeatball in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/29
    • bump crate version to 0.3 by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/30
    • 0.3 release merge by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/31
    • fix license by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/32
    • Use custom camera for rendering gizmo by @TheRawMeatball in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/34
    • remove unused system order label by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/35
    • Polish gizmo appearance, fix handle draw order by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/33

    New Contributors

    • @YoshieraHuang made their first contribution in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/26
    • @TheRawMeatball made their first contribution in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/29

    Full Changelog: https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/compare/v0.2.0...v0.3.1

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Aug 8, 2022)

    What's Changed

    • remove after UpdateSettings label by @YoshieraHuang in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/26
    • Upstream stuff by @TheRawMeatball in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/29

    New Contributors

    • @YoshieraHuang made their first contribution in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/26
    • @TheRawMeatball made their first contribution in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/29

    Full Changelog: https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/compare/v0.2.1...v0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Apr 20, 2022)

  • v0.2.0(Apr 20, 2022)

    What's Changed

    • Update Cargo.toml by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/22
    • Add CI Caching by @aevyrie in https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/pull/21

    Full Changelog: https://github.com/ForesightMiningSoftwareCorporation/bevy_transform_gizmo/compare/v0.1.0...v0.2.0

    Source code(tar.gz)
    Source code(zip)
Owner
Foresight
Building the next generation of IOT collaborative CAD systems
Foresight
Real-time 3D orientation visualization of a BNO055 IMU using Bissel and Bevy

orientation This is a demonstration of real-time visualization of the attitude of a BNO055 IMU across a wireless network to a Bevy app using the Bisse

chris m 4 Dec 10, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
3d transformation gizmo built on top of the egui library.

egui-gizmo 3d transformation gizmo built on top of the egui library. Try it out in a web demo Usage let gizmo = Gizmo::new("My gizmo") .view_matri

Urho Laukkarinen 69 Dec 10, 2022
🏷️ Markers for Bevy ECS Entities

Bevy ECS Markers Adds the support for marking entites and fetching them in queries Example View the whole example here #[derive(EntityMarker)] enum Pl

Chopped Studio 2 Dec 23, 2022
An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities

bevy_sparse_grid_2d An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities. Personally, I'm using it for simple stupi

Johan Klokkhammer Helsing 5 Feb 26, 2023
Attach Bevy's Handles/Entities statically to Types.

Easily attach bevy's Handles/Entities statically to types on startup and get them in any system, without using Resources. It's just a little less clut

Dekirisu 6 Sep 4, 2023
Bevy Entities are nice. Objects are better!

?? Moonshine Object An extension to Bevy which provides an ergonomic interface for managing complex Entity hierarchies. Entities are nice. Objects are

null 7 May 7, 2024
A common library and set of test cases for transforming OSM tags to lane specifications

osm2lanes See discussion for context. This repo is currently just for starting this experiment. No license chosen yet. Structure data tests.json—tests

A/B Street 29 Nov 16, 2022
PRQL is a modern language for transforming data — a simpler and more powerful SQL

PRQL Pipelined Relational Query Language, pronounced "Prequel". PRQL is a modern language for transforming data — a simpler and more powerful SQL. Lik

PRQL 6.5k Jan 5, 2023
Core Fiberplane data models and methods for transforming them (templates, providers, markdown conversion)

fiberplane This repository is a monorepo for Rust code that is used throughout Fiberplane's product. Overview base64uuid - A utility for working with

Fiberplane 18 Feb 22, 2023
Meet Rustacean GPT, an experimental project transforming OpenAi's GPT into a helpful, autonomous software engineer to support senior developers and simplify coding life! 🚀🤖🧠

Rustacean GPT Welcome, fellow coding enthusiasts! ?? ?? I am excited to introduce you to Rustacean GPT, my humble yet ambitious project that aims to t

Gary McDougall 3 May 10, 2023
Shaping, Processing, and Transforming Data with the Power of Sulfur with Rust

Sulfur WIP https://www.youtube.com/watch?v=PAAvNmoqDq0 "Shaping, Processing, and Transforming Data with the Power of Sulfur" Welcome to the Sulfur pro

Emre 6 Aug 22, 2023
Read-optimized cache of Cardano on-chain entities

Read-optimized cache of Cardano on-chain entities Intro Scrolls is a tool for building and maintaining read-optimized collections of Cardano's on-chai

TxPipe 58 Dec 2, 2022
Command-line tool to make Rust source code entities from Postgres tables.

pg2rs Command-line tool to make Rust source code entities from Postgres tables. Generates: enums structs which can be then used like mod structs; use

Stanislav 10 May 20, 2022
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
A example bevy application using bevy-kajiya for its renderer

☀️ bevy-kajiya playground A example bevy application using bevy-kajiya for its renderer NOTE: only tested on Windows. For more context, check out the

Sebastian Hamel 20 Dec 5, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

研究社交 208 Dec 27, 2022
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023