@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
41 lines (40 loc) • 1.4 kB
JavaScript
;
import { Color } from "three";
import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { TypedJsNode } from "./_Base";
import { Poly } from "../../Poly";
class HsvToRgbParamsJsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.hsv = ParamConfig.VECTOR3([0, 0, 0]);
}
}
const ParamsConfig_HsvToRgb = new HsvToRgbParamsJsConfig();
export class HsvToRgbJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig_HsvToRgb;
}
static type() {
return "hsvToRgb";
}
initializeNode() {
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.COLOR, JsConnectionPointType.COLOR)
]);
}
setLines(linesController) {
const linesData = [];
const vec3 = this.variableForInputParam(linesController, this.p.hsv);
const varName = this.jsVarName(JsConnectionPointType.COLOR);
const tmpVar = linesController.addVariable(this, new Color());
const func = Poly.namedFunctionsRegister.getFunction("hsvToRgb", this, linesController);
linesData.push({
dataType: JsConnectionPointType.COLOR,
varName,
value: func.asString(vec3, tmpVar)
});
linesController.addBodyOrComputed(this, linesData);
}
}