Add Velocity Signal Functionality #942
Labels
a-core
Relates to the core package
b-enhancement
New feature or request
c-accepted
The issue is ready to be worked on
Description
I propose the addition of Velocity Signal functionality to Motion Canvas, providing users with a powerful tool for creating motion blur effects and enhancing dynamic animations. This feature is especially valuable for users aiming to achieve realistic or stylized motion effects, such as stretching on high velocities and shrinking when slowing down.
Proposed Solution
I suggest introducing a utility function named
derivateSignal
to simplify the process of obtaining the velocity of a signal. This function would take a signal as an argument and return a new signal representing the velocity.Example usage:
Composability Example
One of the strengths of this feature is its composability. Users can take the derivative of a velocity signal to obtain the acceleration of the original signal. Here's a simple example:
With this approach, users can easily explore and incorporate higher-order derivatives into their animations, providing a rich set of tools for crafting intricate and dynamic motion effects.
Why This Feature?
Simplified API: Introducing a utility function for velocity provides a clean and straightforward way to access node velocity.
Enhanced Readability: The updated usage makes it easier for users to understand and implement motion effects based on node velocity.
Current possible implementation
To acchieve velocity signals currently, @aarthificial provided the following classes.
VelocitySignalContext for numbers:
VelocityVectorSignalContext for Vector2:
With these you can opt in to the signals that track the delta only when you need them.
Adding the Delta to Number and Vector2 Signals
An additional consideration is to automatically provide all number based signals with their derivative signal, accessible through the
delta
property of the signal:Since
delta
is a signal, users can also invoke it to obtain the current value:While this approach streamlines the process and ensures users have access to the velocity signal without explicit opt-ins, it comes with a caveat. There might be a potential performance overhead even when the functionality is not actively utilized. Consequently, careful consideration should be given to the trade-off between convenience and potential performance impact when deciding on this option.
The text was updated successfully, but these errors were encountered: