@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
134 lines (133 loc) • 2.87 kB
JavaScript
;
import { NamedFunction0, NamedFunction1, NamedFunction2, NamedFunction3, NamedFunction4, NamedFunction5 } from "./_Base";
import {
clamp as _clamp,
smoothstep as _smoothstep,
smootherstep as _smootherstep,
fit as _fit,
fitClamp as _fitClamp,
mod as _mod,
mix as _mix,
randFloat as _randFloat,
degToRad as _degToRad,
radToDeg as _radToDeg
} from "../../core/math/_Module";
import { dummyReadRefVal } from "../../core/reactivity/CoreReactivity";
import { isBoolean } from "../../core/Type";
export class clamp extends NamedFunction3 {
static type() {
return "clamp";
}
func(value, min, max) {
return _clamp(value, min, max);
}
}
export class complement extends NamedFunction1 {
static type() {
return "complement";
}
func(value) {
return 1 - value;
}
}
export class degToRad extends NamedFunction1 {
static type() {
return "degToRad";
}
func(value) {
return _degToRad(value);
}
}
export class radToDeg extends NamedFunction1 {
static type() {
return "radToDeg";
}
func(value) {
return _radToDeg(value);
}
}
export class fit extends NamedFunction5 {
static type() {
return "fit";
}
func(value, srcMin, srcMax, destMin, destMax) {
return _fit(value, srcMin, srcMax, destMin, destMax);
}
}
export class fitClamp extends NamedFunction5 {
static type() {
return "fitClamp";
}
func(value, srcMin, srcMax, destMin, destMax) {
return _fitClamp(value, srcMin, srcMax, destMin, destMax);
}
}
export class mix extends NamedFunction3 {
static type() {
return "mix";
}
func(value0, value1, blend) {
return _mix(value0, value1, blend);
}
}
export class mod extends NamedFunction2 {
static type() {
return "mod";
}
func(v1, v2) {
return _mod(v1, v2);
}
}
export class multAdd extends NamedFunction4 {
static type() {
return "multAdd";
}
func(value, preAdd, mult, postAdd) {
return (value + preAdd) * mult + postAdd;
}
}
export class negate extends NamedFunction1 {
static type() {
return "negate";
}
func(value) {
if (isBoolean(value)) {
return !value;
} else {
return -value;
}
}
}
export class rand extends NamedFunction2 {
static type() {
return "rand";
}
func(value0, value1) {
return _randFloat(value0, value1);
}
}
export class random extends NamedFunction0 {
static type() {
return "random";
}
func() {
dummyReadRefVal(this.timeController.timeUniform().value);
return Math.random();
}
}
export class smoothstep extends NamedFunction3 {
static type() {
return "smoothstep";
}
func(value, min, max) {
return _smoothstep(value, min, max);
}
}
export class smootherstep extends NamedFunction3 {
static type() {
return "smootherstep";
}
func(value, min, max) {
return _smootherstep(value, min, max);
}
}