UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

135 lines (134 loc) 2.54 kB
"use strict"; import { NamedFunction1, NamedFunction2, NamedFunction3, NamedFunction4, NamedFunction5 } from "./_Base"; export class boolToInt extends NamedFunction1 { static type() { return "boolToInt"; } func(b) { return b ? 1 : 0; } } export class intToBool extends NamedFunction1 { static type() { return "intToBool"; } func(v) { return Boolean(v); } } export class floatToInt extends NamedFunction1 { static type() { return "floatToInt"; } func(v) { return Math.round(v); } } export class intToFloat extends NamedFunction1 { static type() { return "intToFloat"; } func(v) { return v; } } export class floatToColor extends NamedFunction4 { static type() { return "floatToColor"; } func(r, g, b, target) { target.r = r; target.g = g; target.b = b; return target; } } export class floatToVec2 extends NamedFunction3 { static type() { return "floatToVec2"; } func(x, y, target) { target.x = x; target.y = y; return target; } } export class floatToVec3 extends NamedFunction4 { static type() { return "floatToVec3"; } func(x, y, z, target) { target.x = x; target.y = y; target.z = z; return target; } } export class floatToVec4 extends NamedFunction5 { static type() { return "floatToVec4"; } func(x, y, z, w, target) { target.x = x; target.y = y; target.z = z; target.w = w; return target; } } export class vec2ToVec3 extends NamedFunction3 { static type() { return "vec2ToVec3"; } func(src, z, target) { target.x = src.x; target.y = src.y; target.z = z; return target; } } export class vec3ToVec4 extends NamedFunction3 { static type() { return "vec3ToVec4"; } func(src, w, target) { target.x = src.x; target.y = src.y; target.z = src.z; target.w = w; return target; } } export class vec3ToColor extends NamedFunction2 { static type() { return "vec3ToColor"; } func(src, target) { target.r = src.x; target.g = src.y; target.b = src.z; return target; } } export class colorToVec3 extends NamedFunction2 { static type() { return "colorToVec3"; } func(src, target) { target.x = src.r; target.y = src.g; target.z = src.b; return target; } } export class Vec3ToColor extends NamedFunction2 { static type() { return "vec3ToColor"; } func(src, target) { target.r = src.x; target.g = src.y; target.b = src.z; return target; } }