@openhps/core
Version:
Open Hybrid Positioning System - Core component
50 lines (46 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.oscTriangle = exports.oscSquare = exports.oscSine = exports.oscSawtooth = void 0;
var _Timer = require("./Timer.js");
/**
* Generates a sine wave oscillation based on a timer.
*
* @tsl
* @function
* @param {Node<float>} t - The timer to generate the oscillation with.
* @return {Node<float>} The oscillation node.
*/
const oscSine = (t = _Timer.time) => t.add(0.75).mul(Math.PI * 2).sin().mul(0.5).add(0.5);
/**
* Generates a square wave oscillation based on a timer.
*
* @tsl
* @function
* @param {Node<float>} t - The timer to generate the oscillation with.
* @return {Node<float>} The oscillation node.
*/
exports.oscSine = oscSine;
const oscSquare = (t = _Timer.time) => t.fract().round();
/**
* Generates a triangle wave oscillation based on a timer.
*
* @tsl
* @function
* @param {Node<float>} t - The timer to generate the oscillation with.
* @return {Node<float>} The oscillation node.
*/
exports.oscSquare = oscSquare;
const oscTriangle = (t = _Timer.time) => t.add(0.5).fract().mul(2).sub(1).abs();
/**
* Generates a sawtooth wave oscillation based on a timer.
*
* @tsl
* @function
* @param {Node<float>} t - The timer to generate the oscillation with.
* @return {Node<float>} The oscillation node.
*/
exports.oscTriangle = oscTriangle;
const oscSawtooth = (t = _Timer.time) => t.fract();
exports.oscSawtooth = oscSawtooth;