@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
45 lines (44 loc) • 1.67 kB
JavaScript
;
import { BaseNodeGlMathFunctionArg4GlNode } from "./_BaseMathFunction";
import { ThreeToGl } from "../../../core/ThreeToGl";
const DefaultValues = {
mult: 1
};
var MultAddGlNodeInputName = /* @__PURE__ */ ((MultAddGlNodeInputName2) => {
MultAddGlNodeInputName2["VALUE"] = "value";
MultAddGlNodeInputName2["PRE_ADD"] = "preAdd";
MultAddGlNodeInputName2["MULT"] = "mult";
MultAddGlNodeInputName2["POST_ADD"] = "postAdd";
return MultAddGlNodeInputName2;
})(MultAddGlNodeInputName || {});
export class MultAddGlNode extends BaseNodeGlMathFunctionArg4GlNode {
static type() {
return "multAdd";
}
_gl_input_name(index) {
return [
"value" /* VALUE */,
"preAdd" /* PRE_ADD */,
"mult" /* MULT */,
"postAdd" /* POST_ADD */
][index];
}
paramDefaultValue(name) {
return DefaultValues[name];
}
setLines(shaders_collection_controller) {
const ouputConnectionPoints = this.io.outputs.namedOutputConnectionPoints();
if (!ouputConnectionPoints) {
return;
}
const value = ThreeToGl.any(this.variableForInput("value" /* VALUE */));
const preAdd = ThreeToGl.any(this.variableForInput("preAdd" /* PRE_ADD */));
const mult = ThreeToGl.any(this.variableForInput("mult" /* MULT */));
const postAdd = ThreeToGl.any(this.variableForInput("postAdd" /* POST_ADD */));
const gl_type = this._expected_output_types()[0];
const out_name = ouputConnectionPoints[0].name();
const out = this.glVarName(out_name);
const body_line = `${gl_type} ${out} = (${mult}*(${value} + ${preAdd})) + ${postAdd}`;
shaders_collection_controller.addBodyLines(this, [body_line]);
}
}