-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
StandardMaterial
easings?
#8
Comments
OK, figured out how to use custom easings finally. Just thought it would be a good idea to summarize what I did, if anyone else stumbles upon this: #[derive(Debug, Default)]
struct MyEaseValue<T>(pub T);
impl Lerp for MyEaseValue<Color> {
type Scalar = f32;
fn lerp(&self, other: &Self, scalar: &Self::Scalar) -> Self {
MyEaseValue(self.0 + (other.0 + (self.0 * -1.)) * *scalar)
}
} And then created a helper function to add an #[derive(Debug)]
struct Fade;
fn fade_to(
commands: &mut Commands,
entity: Entity,
from: Color,
to: Color,
millis: u64,
) {
commands.set_current_entity(entity);
commands.with(Fade).with(MyEaseValue(from)).with(
MyEaseValue(from).ease_to(
MyEaseValue(to),
EaseFunction::QuadraticOut,
EasingType::Once {
duration: Duration::from_millis(millis),
},
),
);
}
fn fade(
mut materials: ResMut<Assets<StandardMaterial>>,
mut query: Query<
(&MyEaseValue<Color>, &Handle<StandardMaterial>),
With<Fade>,
>,
) {
for (color, mat_handle) in query.iter_mut() {
materials.set(mat_handle, color.0.into());
}
} Finally, the systems should be added: app
.add_system(fade.system())
.add_system(custom_ease_system::<MyEaseValue<Color>>.system()) Feel free to close this issue. I don't know if it's a good idea to have |
great! thank you for digging into this! |
Any plan on adding
StandardMaterial
as an available easing target? I'm fumbling around with trying it myself, but I'm running into problems due to lack of skills.Current attempt:
Which is more or less copied from your implementation for
ColorMaterial
. Getting problems with how to add easings for my materials with this.The text was updated successfully, but these errors were encountered: