ScalarSignal
The ScalarSignal
class monitors a numerical value.
Example
// Load in the required modules const Animation = require('Animation'); const Scene = require('Scene'); const TouchGestures = require('TouchGestures'); // Access a plane inserted in the scene const plane = Scene.root.find('plane0'); // Use pinLastValue as a way of getting the intial Y position of the plane const planeInitialYPosition = plane.transform.y.pinLastValue(); // Define an end value using the negative Y value of the plane const planeEndYPosition = plane.transform.y.mul(1).pinLastValue(); // Create a timeDriver to set the duration of our animation const timeDriver = Animation.timeDriver({durationMilliseconds: 5000}); // Create a linear sampler using the positions defined above as the start and end points let linearSampler = Animation.samplers.linear(planeInitialYPosition,planeEndYPosition); // Bind the Y position of the plane to an animation using the driver and sampler and // start the timeDriver plane.transform.y = Animation.animate(timeDriver,linearSampler); timeDriver.start(); // Register a tap event on the plane TouchGestures.onTap(plane).subscribe(function() { // Redefine the linear sampler using the last Y value of the plane and the intial y value stored earlier linearSampler = Animation.samplers.linear(plane.transform.y.pinLastValue(), planeInitialYPosition); // Bind the Y position of the plane to an animation using the updated sampler and reset the time driver plane.transform.y = Animation.animate(timeDriver,linearSampler); timeDriver.reset(); });
Properties
Property  Description 


Specifies a number that represents the last value of the signal. Note: The signal value is updated during simulation tick. This means that the value of 
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 sum of the values of the given signals. Note: See Also: 

Returns a signal with the value that is the angle in radians between the xaxis 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 vector signal with the value that is the cross product of the given signals. See Also: 



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 nonstrict comparison allowing the values to be within a small distance one from another. See Also: 

Smoothes a variable signal using exponential averaging over time. The argument specifies the dampening time constant in milliseconds. Note: See also 

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: 

Converts a Note: 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: 

Returns an The emitted event (the argument passed to the callback function) has the value of corresponding Note: The threshold must be a positive number. Note: See Also: 

Returns a Boolean signal that takes the value of See Also: 

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 floatingpoint remainder of the division of the value of the first signal by the value of the second signal. See Also: 

Returns an
Note: By default, there is no event fired for the initial value of the signal. If 

Returns a signal with the value that is the product of the values of the given signals. See Also: 

Returns an The emitted event (the argument passed to the callback function) has the value of Note: The initial value of the signal is assumed to be 0.0. 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 nonstrict 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 

Returns 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 

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: 

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 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 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: 

Maps x from [0.0, 1.0] range to [min, max] range. 

Converts a Note: 

Returns an The emitted event (the argument passed to the callback function) has the value of Note: for positive thresholds, See Also: 