Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egui-gizmo -> transform-gizmo #49

Merged
merged 48 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
33d4378
Initial transform-gizmo structure changes
urholaukkarinen Mar 29, 2024
8412f6b
Replaced LICENSE with LICENSE-APACHE/MIT files
urholaukkarinen Mar 29, 2024
73a9fcb
Removed old demo
urholaukkarinen Mar 29, 2024
506eea8
Gizmo can be used without egui
urholaukkarinen Mar 29, 2024
34d0fa1
Gizmo can have multiple modes at the same time
urholaukkarinen Mar 29, 2024
852c029
Updated egui to 0.27.1
urholaukkarinen Mar 29, 2024
08d0d05
Updated Rust toolchain to 1.77.1
urholaukkarinen Mar 29, 2024
f694e90
Added bevy integration
urholaukkarinen Mar 30, 2024
30a4af0
Floating point accuracy improvements
urholaukkarinen Mar 31, 2024
0e90a07
Added multi-mode support to transform-gizmo-bevy
urholaukkarinen Mar 31, 2024
dcf5edd
Reogranized config.rs
urholaukkarinen Mar 31, 2024
d199f08
Relative transform changes
urholaukkarinen Mar 31, 2024
563926e
Target matrix is given in update instead of in config
urholaukkarinen Mar 31, 2024
1c4f59d
Gizmo can have multiple targets
urholaukkarinen Mar 31, 2024
278f2c5
Gizmo targets are transformed as a group
urholaukkarinen Mar 31, 2024
81d79b8
Added initial demo app
urholaukkarinen Apr 1, 2024
debbed9
Moved picking logic to separate plugin
urholaukkarinen Apr 1, 2024
bcd0559
Fixed bevy gizmo rendering with differents viewports
urholaukkarinen Apr 1, 2024
909419b
Cleaned up bevy integration a bit
urholaukkarinen Apr 1, 2024
7a6e116
Gizmo target grouping can be configured in bevy integration
urholaukkarinen Apr 1, 2024
7e06ad7
Fixes to egui integration
urholaukkarinen Apr 1, 2024
9066087
Added initial gizmo options to demo
urholaukkarinen Apr 1, 2024
aaa74b3
Fix to gizmo scaling
urholaukkarinen Apr 1, 2024
1b87dc6
Improved multi-mode gizmo
urholaukkarinen Apr 1, 2024
f7ae151
Updated Egui to 0.27.2
urholaukkarinen Apr 2, 2024
3ac1446
Tweaked arrow lengths in multi-mode
urholaukkarinen Apr 2, 2024
3c2f07f
Added more stuff to the demo
urholaukkarinen Apr 2, 2024
303bbc6
Restored sector fill in rotation gizmo
urholaukkarinen Apr 2, 2024
92148b2
Removed value field from GizmoResult
urholaukkarinen Apr 3, 2024
a505dec
Added a lot of missing public documentation
urholaukkarinen Apr 3, 2024
6301d1a
Tweaked the gizmo colors
urholaukkarinen Apr 3, 2024
aded9bd
Removed grid temporarily from demo
urholaukkarinen Apr 4, 2024
4915066
Updated bevy_egui dependency
urholaukkarinen Apr 4, 2024
7cb6c95
Web demo is properly fullscreen
urholaukkarinen Apr 4, 2024
70ea13d
Tweaked colors a bit more
urholaukkarinen Apr 4, 2024
4ae3aa2
Fixed demo snapping
urholaukkarinen Apr 4, 2024
45d37c5
Updated readme
urholaukkarinen Apr 5, 2024
e09eb0f
Tweaks to gizmo result
urholaukkarinen Apr 5, 2024
af299b7
Active subgizmo is reset when gizmo modes change
urholaukkarinen Apr 5, 2024
0aa0bd9
Updated cargo metadata
urholaukkarinen Apr 5, 2024
86d612c
Fixed incorrect link in README.md
urholaukkarinen Apr 5, 2024
9b9b450
Fixed demo not working in web
urholaukkarinen Apr 5, 2024
1c93811
Moved examples to top level
urholaukkarinen Apr 5, 2024
1dc5282
Try fixing github workflow
urholaukkarinen Apr 5, 2024
b53e630
Fix cargo cranky
urholaukkarinen Apr 5, 2024
ef14487
Fixed transformations causing weird things at certain angles
urholaukkarinen Apr 6, 2024
28489c6
Fixed alpha blending in bevy integration
urholaukkarinen Apr 6, 2024
a40f29a
Updated web demo
urholaukkarinen Apr 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
with:
toolchain: 1.72.0

- name: install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev

- name: cache
uses: Swatinem/rust-cache@v2

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
Cargo.lock
/.idea
/.vscode
.DS_Store
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contribution guidelines

Thank you for considering to contribute!

## Filing an issue

If you encounter an issue or have a feature request, you can [open an issue](https://github.com/urholaukkarinen/transform-gizmo/issues/new/choose) for it.

Before opening an issue, check that there is not already a similar issue created by someone else.

## Opening a pull request

For things such as tiny bug fixes or version bumps, feel free to open a pull request without creating an issue first.

For larger changes, please file an issue first.

Keep pull requests focused. Avoid including multiple unrelated changes in the same pull request.
53 changes: 28 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
[package]
name = "egui-gizmo"
version = "0.16.2"
authors = ["Urho Laukkarinen <[email protected]>"]
edition = "2021"
[workspace]
resolver = "2"
members = ["crates/*", "examples/*"]

license-file = "LICENSE"
readme = "README.md"
description = "3d transform gizmo for the egui library"
homepage = "https://github.com/urholaukkarinen/egui-gizmo"
repository = "https://github.com/urholaukkarinen/egui-gizmo"
categories = ["gui", "game-development", "game-engines"]
keywords = ["egui", "gizmo"]
exclude = ["/docs"]
[workspace.package]
version = "0.1.0"
rust-version = "1.77.0"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/urholaukkarinen/transform-gizmo"
repository = "https://github.com/urholaukkarinen/transform-gizmo"
authors = ["Urho Laukkarinen <[email protected]>"]

[workspace]
members = ["demo"]
[workspace.dependencies]
transform-gizmo = { path = "crates/transform-gizmo" }
transform-gizmo-egui = { path = "crates/transform-gizmo-egui" }
transform-gizmo-bevy = { path = "crates/transform-gizmo-bevy" }

[dependencies]
egui = "0.26.2"
glam = { version = "0.25.0", features = ["mint"] }
egui = "0.27.2"
eframe = "0.27.2"
emath = "0.27.2"
epaint = "0.27.2"
ecolor = "0.27.2"
glam = { version = "0.27.0", features = ["mint"] }
mint = "0.5"
enum_dispatch = "0.3.12"
ahash = "0.8.7"
enumset = "1.1.3"
bevy = "0.13"
bevy_math = { version = "0.13", features = ["mint"] }

[profile.release]
opt-level = "s"
lto = "thin"

[lints]
workspace = true
panic = "abort"

[workspace.lints.rust]
elided_lifetimes_in_paths = "allow"
Expand Down Expand Up @@ -152,7 +157,7 @@ transmute_ptr_to_ptr = "deny"
tuple_array_conversions = "deny"
unchecked_duration_subtraction = "deny"
unimplemented = "deny"
uninlined_format_args = "deny"
uninlined_format_args = "allow"
unnecessary_box_returns = "deny"
unnecessary_safety_comment = "deny"
unnecessary_safety_doc = "deny"
Expand All @@ -177,5 +182,3 @@ unwrap_used = "allow"
wildcard_imports = "allow"
large-types-passed-by-value = "allow"
needless-pass-by-value = "allow"
needless_pass_by_ref_mut = "allow"
redundant_pub_crate = "allow"
201 changes: 201 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 1 addition & 1 deletion LICENSE → LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Urho Laukkarinen
Copyright (c) 2024 Urho Laukkarinen <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
# egui-gizmo
# transform-gizmo

[![Latest version](https://img.shields.io/crates/v/egui-gizmo.svg)](https://crates.io/crates/egui-gizmo)
[![Documentation](https://docs.rs/egui-gizmo/badge.svg)](https://docs.rs/egui-gizmo)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
[![Latest version](https://img.shields.io/crates/v/transform-gizmo.svg)](https://crates.io/crates/transform-gizmo)
[![Documentation](https://docs.rs/transform-gizmo/badge.svg)](https://docs.rs/transform-gizmo)
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/urholaukkarinen/transform-gizmo/blob/main/LICENSE-MIT)
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/urholaukkarinen/transform-gizmo/blob/main/LICENSE-APACHE)

3d transformation gizmo built on top of the [egui](https://github.com/emilk/egui) library.
`transform-gizmo` is a framework-agnostic Rust crate that provides a feature-rich and customizable 3D transformation gizmo for manipulating the position, rotation and scale of 3D entities.

[Try it out in a web demo](https://urholaukkarinen.github.io/egui-gizmo/)
[Try it out in a web demo](https://urholaukkarinen.github.io/transform-gizmo/)

![Rotation](media/rotation.png)
![Translation](media/translation.png)
![Scale](media/scale.png)
![All modes](media/all_modes.png)

## Usage

```rust
let gizmo = Gizmo::new("My gizmo")
.view_matrix(view_matrix)
.projection_matrix(projection_matrix)
.model_matrix(model_matrix)
.mode(GizmoMode::Rotate);
### Bevy

if let Some(response) = gizmo.interact(ui) {
model_matrix = response.transform();
}
```
[`transform-gizmo-bevy`](https://docs.rs/transform-gizmo-bevy) provides a Plugin for easy integration into the [Bevy Engine](https://bevyengine.org/).

For a more complete example, see the [demo source code](demo/src/main.rs).
### Egui

The gizmo exposes matrices and vectors as [mint](https://github.com/kvark/mint) types, which means it is easy to use with matrix types from various crates
[`transform-gizmo-egui`](https://docs.rs/transform-gizmo-egui) enables you to use the Gizmo wherever [Egui](https://github.com/emilk/egui) is used.

### Other

For interacting with the gizmo, all you will need to do is give `Gizmo::update` sufficient
information about user interaction, in the form of `GizmoInteraction`.

For rendering the gizmo, `Gizmo::draw` provides vertices in viewport coordinates that can be easily rendered
with your favorite graphics APIs.

## Other

The gizmo exposes mathematical types as [mint](https://github.com/kvark/mint) types, which means it is easy to use with types from various crates
such as [nalgebra](https://github.com/dimforge/nalgebra), [glam](https://github.com/bitshifter/glam-rs)
and [cgmath](https://github.com/rustgd/cgmath). You may need to enable a `mint` feature, depending on the math library.

## License

This crate is dual licensed under MIT and Apache 2.0.

## Contributing

Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)
Loading
Loading