Skip to content

Commit

Permalink
v0.4 : feature-gate svg and lottie, move to linebender (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau authored May 22, 2024
1 parent ff6181b commit 3b545da
Show file tree
Hide file tree
Showing 62 changed files with 1,846 additions and 470 deletions.
52 changes: 39 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,77 +10,103 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

## 0.4.0

### Added

- New `svg` example
- New `lottie` example

### Changed

- The GitHub repo has migrated into the linebender org: <https://github.com/linebender>
- You may need to update your git ref from `loopystudios` to `linebender`
- SVG and Lottie features are now feature-gated
- SVG (.svg) support is now added through a cargo feature `svg`.
- Lottie (.json) support is now added through the cargo feature `lottie`.
- experimental `dotLottie` features (`LottiePlayer`, `PlayerTransition`, `PlayerState`) are now feature-gated through the cargo feature `experimental-dotLottie`. This is only partial support, and a work in progress.
- `Theme` is now activated through the `lottie` feature, as it was only possible to style runtime lotties.
- `VelloAsset.metadata()` is no longer available, as it is specific to Lottie. There is now a trait, `LottieExt` that can be imported to call `.metadata()` on a `Composition` instead. This is no longer fallible as a result.
- `PlaybackAlphaOverride` was removed in favor of an `alpha` field on `VelloAsset`.
- `LottiePlayer` was renamed to `DotLottiePlayer`.
- Paths to several locations have changed, e.g. `bevy_vello::assets` -> `bevy_vello::integrations`

### Fixed

- A slow startup delay for lottie assets to begin rendering
- A dotLottie issue where the first frame can jump on web platforms.

## 0.3.3

### fixed
### Fixed

- Projects with a 2D and 3D camera should no longer conflict with `bevy_vello`'s queries.

## 0.3.2

### added
### Added

- Inverse `ZFunction` options added for `BbTop`, `BbBottom`, `BbLeft`, and `BbRight`.

### fixed
### Fixed

- A panic that can happen in the extract schedule of lottie files.
- Z-ordering now works correctly for `Bb` functions.

## 0.3.1 (2024-05-01)

### fixed
### Fixed

- `bevy_vello::prelude::Scene` was removed, since it conflicts with `bevy::prelude::Scene`.

## 0.3.0 (2024-05-01)

### added
### Added

- `VelloAssetAlignment` was added to the `VelloAssetBundle`.

### changed
### Changed

- `VectorFile` enum variants were flattened into tuple structs.

### removed
### Removed

- `bevy_vello::VelloPlugin` was removed from the prelude.

## 0.2.2 (2024-04-22)

### fixed
### Fixed

- Now when a `VelloScene` and `VelloText` have the same Z-Index, text will be rendered above the scene.

## 0.2.1 (2024-04-21)

### fixed
### Fixed

- `VelloTextAlignment` is now in the `bevy_vello::prelude`.
- The playhead now will now always be bounded
- A rare issue where, if an asset was not available, parts of a state would not transition properly.

## 0.2.0 (2024-04-17)

### added
### Added

- Added the `VelloTextAlignment` component to `VelloTextBundle`, which now helps control the alignment of text.
- Added the `VelloTextAlignment` to the `bevy_vello::prelude`.

### fixed
### Fixed

- Text bounding boxes are now tighter as they are capped by the baseline.

## 0.1.2 (2024-04-08)

### fixed
### Fixed

- Fixes a window hang issue in bevy on native platforms

## 0.1.1 (2024-04-04)

### fixed
### Fixed

- fixed panic on Windows when window is minimized

Expand Down
16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ members = [
"examples/text",
"examples/z_ordering",
"examples/scene",
"examples/svg",
"examples/lottie",
]

[workspace.package]
edition = "2021"
version = "0.3.3"
version = "0.4.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/loopystudios/bevy_vello"
repository = "https://github.com/linebender/bevy_vello"

[workspace.dependencies]
bevy = { version = "0.13.0", default-features = false, features = [
Expand Down Expand Up @@ -52,5 +54,15 @@ vello_svg = "0.1.0"
velato = "0.1.0"
once_cell = "1.19.0"

# TODO: Remove after https://github.com/linebender/velato/pull/19
serde_json = { optional = true, version = "1" }

[dev-dependencies]
wasm-bindgen-test = "0.3.42"

[features]
default = []
svg = []
# TODO: Remove `serde_json` after https://github.com/linebender/velato/pull/19
lottie = ["serde_json"]
experimental-dotLottie = ["lottie"]
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@

**A vector graphics rendering integration for [Bevy game engine](https://bevyengine.org) using [Vello](https://vello.dev).**

[![Discord](https://img.shields.io/discord/913957940560531456.svg?label=Loopy&logo=discord&logoColor=ffffff&color=ffffff&labelColor=000000)](https://discord.gg/zrjnQzdjCB)
[![Linebender Zulip](https://img.shields.io/badge/Linebender-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license)
[![Vello](https://img.shields.io/badge/vello-v0.1.0-purple.svg)](https://crates.io/crates/vello)
[![Following released Bevy versions](https://img.shields.io/badge/bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/quick-start/plugin-development/#main-branch-tracking)

[![Dependency status](https://deps.rs/repo/github/loopystudios/bevy_vello/status.svg)](https://deps.rs/repo/github/loopystudios/bevy_vello)
[![Following released Bevy versions](https://img.shields.io/badge/bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/quick-start/plugin-development/#main-branch-tracking)\
[![Dependency status](https://deps.rs/repo/github/linebender/bevy_vello/status.svg)](https://deps.rs/repo/github/linebender/bevy_vello)
[![Crates.io](https://img.shields.io/crates/v/bevy_vello.svg)](https://crates.io/crates/bevy_vello)
[![Docs](https://img.shields.io/docsrs/bevy_vello)](https://docs.rs/bevy_vello)
[![Build status](https://github.com/loopystudios/bevy_vello/workflows/CI/badge.svg)](https://github.com/loopystudios/bevy_vello/actions)
[![Build status](https://github.com/linebender/bevy_vello/workflows/CI/badge.svg)](https://github.com/linebender/bevy_vello/actions)

</div>

> [!WARNING]
> The support of SVG and Lottie is limited. If there is an SVG-related issue, please file the issue in [`vello_svg`](https://github.com/linebender/vello_svg). If there is a Lottie-related issue, please file the issue in [`velato`](https://github.com/linebender/velato). Please see the respective backends for for more information about limitations.
bevy_vello is a rendering integration for rendering vector graphics in the Bevy game engine. Currently it renders standard vello `Scene`s, as well as SVG and Lottie files.
`bevy_vello` is a cross-platform, 2D compute-centric vector graphics rendering library for Bevy. There is default support for rendering text and scenes, with additional opt-in features for SVG and Lottie. Experimental support for dotLottie is coming.

Quickstart to run the demo:

Expand All @@ -29,32 +25,23 @@ cargo run -p demo

![Alt text](image.png)

It uses several support backends for assets:

- [`vello_svg`](https://github.com/linebender/vello_svg) - Converting SVG files to a vello `Scene`
- [`velato`](https://github.com/linebender/velato) - Converting Lottie files to a vello `Scene`

Visual inconsistencies discovered should be reported to the respective backend.

## Bevy version support

**NOTE**: You must use a git rev for now, but we are planning a publish. See [issue #3](https://github.com/loopystudios/bevy_vello/issues/3).

|bevy|bevy_vello|
|---|---|
|0.13|0.1-0.3, main|
|0.13|0.1-0.4, main|
|< 0.13| unsupported |

## Features
## Cargo features

> [!WARNING]
> The support of SVG and Lottie is limited. If there is an SVG-related issue, please file the issue in [`vello_svg`](https://github.com/linebender/vello_svg). If there is a Lottie-related issue, please file the issue in [`velato`](https://github.com/linebender/velato). Please see the respective backends for for more information about limitations.
- Spawn vector graphics rendering in screen-space or world-space coordinates.
- Runtime color swapping of Lottie files with a `Theme` component.
- Augment playback options with a `PlaybackOptions` component.
- Limited state machine support with a `LottiePlayer` component.
- Text
- NOTE: To avoid conflict with bevy's built-in font loader, rename fonts used by `bevy_vello` to end with `*.vtff`. This is a limitation of the bevy game engine, and can probably be an improvement in the future.
- Debug drawing for bounding boxes and origin
- Render immediate-mode vello `Scene`s
|Cargo feature|Description|Default?|
|---|---|----|
|`svg`|Render `.svg` files with [`vello_svg`](https://github.com/linebender/vello_svg)|Yes|
|`lottie`|Render `.json` Lottie files with [`velato`](https://github.com/linebender/velato)|Yes|
|`experimental-dotLottie`|Render `.lottie` Lottie files. **Work in Progress**|No|

## Examples

Expand All @@ -79,14 +66,14 @@ rustup target add wasm32-unknown-unknown
cargo run_wasm -p text
```

There is also a web demo [available here](https://loopystudios.github.io/bevy_vello) on supporting web browsers.
There is also a web demo [available here](https://linebender.github.io/bevy_vello) on supporting web browsers.

> [!WARNING]
> The web is not currently a primary target for Vello, and WebGPU implementations are incomplete, so you might run into issues running this example.
## Community

All Loopy projects and development happens in the [Loopy Discord](https://discord.gg/zrjnQzdjCB). The discord is open to the public.
Discussion of Vello development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#gpu stream](https://xi.zulipchat.com/#narrow/stream/197075-gpu). All public content can be read without logging in.

Contributions are welcome by pull request. The [Rust code of conduct](https://www.rust-lang.org/policies/code-of-conduct) applies.

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy_vello = { path = "../../" }
bevy_vello = { path = "../../", features = ["experimental-dotLottie"] }
bevy = { workspace = true }
bevy_pancam = { version = "0.11", features = ["bevy_egui"] }
bevy_egui = "0.25"
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
..default()
})
.insert(
LottiePlayer::new("stopped")
DotLottiePlayer::new("stopped")
.with_state({
PlayerState::new("stopped")
.playback_options(PlaybackOptions {
Expand Down Expand Up @@ -74,10 +74,10 @@ fn print_metadata(
for ev in asset_ev.read() {
if let AssetEvent::LoadedWithDependencies { id } = ev {
let asset = assets.get(*id).unwrap();
if let Some(metadata) = asset.metadata() {
if let VectorFile::Lottie(composition) = &asset.file {
info!(
"Animated asset loaded. Layers:\n{:#?}",
metadata.get_layers().collect::<Vec<_>>()
composition.as_ref().get_layers().collect::<Vec<_>>()
);
}
}
Expand Down
7 changes: 3 additions & 4 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::time::Duration;
pub fn controls_ui(
mut contexts: EguiContexts,
mut player: Query<(
&mut LottiePlayer,
&mut DotLottiePlayer,
&mut Playhead,
&mut PlaybackOptions,
&mut Theme,
Expand All @@ -22,8 +22,7 @@ pub fn controls_ui(
};

let asset = assets.get(handle.id()).unwrap();
let metadata = asset.metadata().unwrap();
let VectorFile::Lottie(composition) = &asset.data else {
let VectorFile::Lottie(composition) = &asset.file else {
return;
};

Expand Down Expand Up @@ -243,7 +242,7 @@ pub fn controls_ui(
});

ui.heading("Theme");
for layer in metadata.get_layers() {
for layer in composition.as_ref().get_layers() {
let color = theme.get_mut(layer).cloned().unwrap_or_default();
let mut color_edit = [color.r(), color.g(), color.b(), color.a()];
ui.horizontal(|ui| {
Expand Down
12 changes: 12 additions & 0 deletions examples/lottie/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "lottie"
version.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy_vello = { path = "../../", features = ["lottie"] }
bevy = { workspace = true }
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/lottie/src/assets/Tiger.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions examples/lottie/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use bevy::asset::{embedded_asset, AssetMetaCheck};
use bevy::prelude::*;
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
let mut app = App::new();
app.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_systems(Startup, load_lottie);
embedded_asset!(app, "assets/Tiger.json");
app.run();
}

fn load_lottie(mut commands: Commands, asset_server: ResMut<AssetServer>) {
commands.spawn(Camera2dBundle::default());

// Yes, it's this simple.
commands.spawn(VelloAssetBundle {
vector: asset_server.load("embedded://lottie/assets/Tiger.json"),
debug_visualizations: DebugVisualizations::Visible,
transform: Transform::from_scale(Vec3::splat(0.5)),
..default()
});
}
12 changes: 12 additions & 0 deletions examples/svg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "svg"
version.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy_vello = { path = "../../", features = ["svg"] }
bevy = { workspace = true }
Loading

0 comments on commit 3b545da

Please sign in to comment.