rive-app / rive-bevy Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The wasm32 architecture should be supported, otherwise there's a big risk this rust bevy runtime doesn't amount to much. There are some pretty big issues with this, particularly that rive-rs
( the parser library companion to this ) is heavily relied on by C++ and build.rs magic (see rive-app/rive-rs#3).
Filing this issue to track wasm32 support.
I am developing an RTS game using Bevy with the Rive plugin for handling animations. I've encountered a problem concerning the selection and deselection of a building in the game. The selection logic (triggered by the S key) and building animation (triggered by the B key) are implemented. The issue arises in the way these interactions are handled across different layers: the selection logic is implemented in a separate layer from the main logic layer.
The building is expected to be selected when I press S and deselected when I press it again. However, the building remains marked as selected until I press the B key for the building animation at least once. This issue with the S and B logic in separate layers is just an isolated example within my project.
Expected Behavior:
Pressing S in the selection layer should select the building, and pressing it again should deselect it, regardless of the state of the building animation in the main layer.
Actual Behavior:
The building remains selected until I activate the building animation with the B key at least once, even after pressing S to deselect.
Code for reproduction:
use bevy::{prelude::*, render::render_resource::Extent3d, window};
use rive_bevy::{RivePlugin, SceneTarget, SpriteEntity, StateMachine, RiveStateMachine};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RivePlugin)
.add_systems(Startup, setup_animation)
.add_systems(Update, (window::close_on_esc, update))
.run()
}
fn setup_animation(
mut commands: Commands,
mut images: ResMut<Assets<Image>>,
asset_server: Res<AssetServer>,
) {
let mut image = Image::default();
image.resize(Extent3d {
width: 128,
height: 128,
..default()
});
let image_handle = images.add(image.clone());
commands.spawn(Camera2dBundle { ..default() });
let sprite_entity = commands
.spawn(SpriteBundle {
texture: image_handle.clone(),
transform: Transform::from_scale(Vec3::splat(1.0)),
..default()
})
.id();
let state_machine = StateMachine {
riv: asset_server.load("genesis.riv"),
..default()
};
commands.spawn(state_machine).insert(SceneTarget {
image: image_handle,
sprite: SpriteEntity {
entity: Some(sprite_entity),
},
..default()
});
}
fn update(input: Res<Input<KeyCode>>, query: Query<&mut RiveStateMachine>) {
let state_machine = query.single();
if input.just_pressed(KeyCode::C) {
state_machine.get_number("progress").unwrap().set(100.0);
}
if input.just_pressed(KeyCode::S) {
let mut selected = state_machine.get_bool("selected").unwrap();
selected.set(!selected.get());
}
if input.just_pressed(KeyCode::B) {
let mut build = state_machine.get_bool("build").unwrap();
build.set(!build.get());
}
}
Important: You need to press C first after application startup, to show the "building".
Attachments:
genesis.rev.txt
genesis.riv.txt
I had to rename with .txt
extension to attach to issue.
Dependencies of Cargo.toml
:
[dependencies]
bevy = "0.12.0"
rive-bevy = { git = "https://github.com/rive-app/rive-bevy" }
The convention for bevy plugin crates is bevy-<name>
Here is a list of dozens of community plugins: https://bevyengine.org/assets/#2d
I have the need to tessellate my vector graphics to receive a convex hull used for game physics.
I can easily do this with lottie and svg files, but rive doesn't seem to expose the underlying path data in the runtime.
Given framerate and animation length, Is there such a function of t, time, to receive the path geometry in that moment?
See: https://simbleau.github.io/rust/graphics/2023/11/20/using-vello-for-video-games.html#physics
This repository doesn't compile with bevy 0.13.0. Would be cool if we could fix it. :)
One of the core features of vector graphics is to be resizable. I don't see an example that allows dynamic resizing. In all of the examples the size is explicitly hardcoded.
e.g. -
animation_image.resize(Extent3d {
width: 1024,
height: 1024,
..default()
});
It would make sense to have an example that resizes all of the images when there's a bevy resize event.
Hi!
Thanks for the great work so far.
I'm seeing unwanted "pointer down" listeners firing when I release the mouse button.
Steps to reproduce
Note: This makes press-and-hold interactions impossible at the moment, as no "Pointer Up" listener is ever called.
All of the examples use the Bevy text sections, but how would one programmatically create text that is rendered by vello?
Is this out of scope and needs to be created separately, e.g. bevy-vello-fonts
, or is this something rive-bevy
should support?
We did this in bevy-vello
already, to take a font, and allow rendering to the surface. I would be happy adding a PR here, if needed.
The reason is pretty simple - It's inconvenient and seems unnecessary to need to create an Artboard or a use a file, and then change the text within it like in the rive-input
example.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.