ReactiveModule
The ReactiveModule class exposes methods for reactive programming.
Example
//==============================================================================
// The following example demonstrates how to perform mathematical operations on
// signals and constant values.
//==============================================================================
// Load in the required modules
const Diagnostics = require('Diagnostics');
const FaceTracking = require('FaceTracking');
const Reactive = require('Reactive');
// Store a reference to the mouth openness (scalar)signal of a detected face
const mouthOpenness = FaceTracking.face(0).mouth.openness;
// Add 1 to the signal using the scalarSignal add method
const mouthOpennessPlusOne = mouthOpenness.add(1);
// Multiply the signal by 2 using the reactive mul method
const doubleMouthOpenness = Reactive.mul(mouthOpenness,2);
// Store a constant mouth openness value when this code is executed
const lastMouthOpenness = mouthOpenness.pinLastValue();
// Watch the signal values in the Console
Diagnostics.watch('Mouth Openness =>', mouthOpenness);
Diagnostics.watch('Mouth Openness + 1 =>', mouthOpennessPlusOne);
Diagnostics.watch('Mouth Openness * 2 =>', doubleMouthOpenness);
// Log the constant value in the Console
Diagnostics.log(lastMouthOpenness);Properties
This module exposes no properties.
Methods
| Method | Description |
|---|---|
|
Returns a signal with the value that is the absolute value of the given signal. See Also: |
|
Returns a signal with the value that is the inverse cosine of the value of the given signal (interpreted as radians). |
|
Returns a signal with the value that is the sum of the values of the given signals. Note: See Also: |
|
Returns a signal with the value that is the logical conjunction of the values of the given signals. It is See Also: |
|
Returns a signal with the value that is the logical and of the values in an array |
|
Returns a signal that estimates the anti derivative of the given signal with respect to time (measured in milliseconds). Note: Since the antiderivative is inherently unbound the min/max parameters must be provided to prevent overflow. when |
|
Returns a signal with the value that is the inverse sine of the value of the given signal (interpreted as radians). |
|
Returns a signal with the value that is the inverse tangent of the value of the given signal (interpreted as radians). |
|
Returns a signal with the value that is the angle in radians between the x-axis and the ray from (0, 0) to (x, y) where x and y are the values of the specified signals. The range is -PI to +PI. See Also: |
|
Returns a signal with the value that is the smallest integer that is greater than or equal to the value of the given signal. See Also: |
|
Returns a signal with the value that is the value of the given Note: The behavior is undefined if |
|
Returns a See Also: |
|
Returns a signal with the value that is the cosine of the value of the given signal (interpreted as radians). |
|
Returns a vector signal with the value that is the cross product of the given signals. See Also: |
|
Returns a signal that estimates the derivative of the given signal with respect to time (measured in milliseconds). Note: the value of the derivative at the initial point of time is always set to zero. Note: the returned signal might be noisy for certain types of input signals, especially those received from the face tracking. It is recommended to pass the input signal to |
|
Returns the distance from the point to another point as a |
|
Returns a signal with the value that is the value of the first signal divided by the value of the second signal. See Also: |
|
Returns a scalar signal with the value that is the dot product of the given signals. See Also: |
|
Returns a Boolean signal that takes the value of Note: the scalar values are tested for exact equality. For some applications it might be reasonable to perform a non-strict comparison allowing the values to be within a small distance one from another. See Also: |
|
Returns a signal with the value that is e (the Euler's constant 2.718...) to the power of the value of the given signal. |
|
Smoothes a variable signal using exponential averaging over time. The argument specifies the dampening time constant in milliseconds. Note: See also Note: The smoothed transformation for a signal that specifies a rigid body transformation is guaranteed to be a rigid body transformation. The rotation component is smoothed in spherical coordinates using Slerp (spherical linear interpolation). |
|
Returns a signal with the value that is the largest integer that is less than or equal to the value of the given signal. See Also: |
|
Maps x from [min, max] range to [0.0, 1.0] range. |
|
Returns a Boolean signal that takes the value of See Also: |
|
Returns a Boolean signal that takes the value of See Also: |
|
Combines four signals and returns the result as an Note: Hue value is also specified in the range between 0.0 and 1.0. |
|
Returns a Boolean signal that takes the value of See Also: |
|
Returns a signal with the value that is the natural logarithm of the value of the given signal. |
|
Returns a Boolean signal that takes the value of See Also: |
|
Returns the magnitude of the vector as a |
|
Returns a signal with the value that is the greater of the values of the given signals. |
|
Returns a signal with the value that is the lesser of the values of the given signals. |
|
|
|
Returns a signal with the value that is the floating-point remainder of the division of the value of the first signal by the value of the second signal. See Also: |
|
Returns an
where Note: By default, there is no event fired for the initial value of the signal. If See Also: |
|
Returns a signal with the value that is the product of the values of the given signals. See Also: |
|
Returns a signal with the value that is the product of the values in an array |
|
Returns a Boolean signal that takes the value of Note: the scalar values are tested for exact equality. For some applications it might be reasonable to perform a non-strict comparison allowing the values to be within a small distance one from another. See Also: |
|
Returns a signal with the negated value of the given signal. See Also: |
|
Returns the normalized (unit) vector in the direction of the original vector as a |
|
Returns a signal with the logically negated value of the given signal. See Also: |
|
Returns an |
|
Returns a signal with the value that is the logical disjunction of the values of the given signals. It is See Also: |
|
Returns a signal with the value that is the logical or of the values in an array |
|
Packs two Scalar or Point signals into a bigger Point signal. |
|
Packs three Scalar or Point signals into a bigger Point signal. |
|
Packs four |
|
Combines three signals and returns the result as a |
|
Combines two signals and returns the result as a |
|
Returns a signal with the value that is the base signal raised to the power of the exponent signal. The result is undefined if the base is negative, or if the base is zero and the exponent is not positive. See Also: |
|
Calculates the reflection direction for an incident vector and a normal as a |
|
Combines four signals and returns the result as an Note: RGB components are interpreted in sRGB space. |
|
Creates 'Rotation' from quaternion components. |
|
Returns a signal with the value that is the rounded value of the given signal. Note: When the fractional part is 0.5, it rounds the number away from zero, which is at odds with JavaScript standard behavior of rounding it always up in such cases. Therefore, this function is NOT exactly the reactive counterpart of the standard JavaScript See Also: |
|
Combines three signals and returns the result as a |
|
Returns a Boolean signal that is Note: The initialValue is assumed to be |
|
Returns a signal with the value that is the sign of the given signal. Possible sign values: NaN, -0.0, 0.0, -1.0, 1.0. Note: this function is the reactive counterpart of the standard JavaScript See Also: |
|
Returns a signal with the value that is the sine of the value of the given signal (interpreted as radians). |
|
Returns 0.0 if x is less than edge0, and 1.0 if x is greater than edge1. If x is between edge0 and edge1, smooth Hermite interpolation is performed. |
|
Returns a signal with the value that is the square root of the value of the given signal. See Also: |
|
Returns 0.0 if x is less than edge, and 1.0 is returned otherwise. |
|
Returns a signal with the value that is the difference of the values of the given signals. See Also: |
|
Returns a signal with the value that is the sum of the values of the given signals. Note: See Also: |
|
Returns a signal with the value that is the sum of the values in an array |
|
Returns a signal with the value that is the tangent of the value of the given signal (interpreted as radians). |
|
Maps x from [0.0, 1.0] range to [min, max] range. |
|
Returns a signal that has a constant value which is specified by the argument. Note: Primitive types are implicitly converted to constant signals when passed as function or property-setter arguments, therefore using |
|
Combines three signals and returns the result as a |
|
Returns a signal with the value that is the logical exclusive disjunction of the values of the given signals. It is Note: It is equivalent to See Also: |
|
Returns a signal with the value that is the logical xor of the values in an array |
Classes
| Class | Description |
|---|---|
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The | |
The |
Enums
| Enum | Description |
|---|---|
The |