@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
35 lines (34 loc) • 1.42 kB
JavaScript
;
import { BaseNodeGlMathFunctionArg2GlNode } from "./_BaseMathFunction";
import { ThreeToGl } from "../../../core/ThreeToGl";
import { GlConnectionPointType } from "../utils/io/connections/Gl";
export class BaseNodeGlMathFunctionArgBoolean2GlNode extends BaseNodeGlMathFunctionArg2GlNode {
initializeNode() {
super.initializeNode();
this.io.connection_points.set_expected_input_types_function(this._expected_input_types.bind(this));
this.io.connection_points.set_expected_output_types_function(this._expected_output_types.bind(this));
}
_expected_input_types() {
return [GlConnectionPointType.BOOL, GlConnectionPointType.BOOL];
}
_expected_output_types() {
return [GlConnectionPointType.BOOL];
}
boolean_operation() {
return "boolean_operation to be defined";
}
setLines(shaders_collection_controller) {
const connectionPoints = this.io.inputs.namedInputConnectionPoints();
if (!connectionPoints) {
return;
}
const args = connectionPoints.map((named_input, i) => {
const name = named_input.name();
return ThreeToGl.any(this.variableForInput(name));
});
const joined_args = args.join(` ${this.boolean_operation()} `);
const sum = this.glVarName(this.io.connection_points.output_name(0));
const body_line = `bool ${sum} = ${joined_args}`;
shaders_collection_controller.addBodyLines(this, [body_line]);
}
}