UNPKG

@polygonjs/polygonjs

Version:

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

27 lines (26 loc) 950 B
"use strict"; import { BaseNodeGlMathFunctionArg1GlNode } from "./_BaseMathFunction"; import { ThreeToGl } from "../../../core/ThreeToGl"; export class NegateGlNode extends BaseNodeGlMathFunctionArg1GlNode { static type() { return "negate"; } initializeNode() { super.initializeNode(); this.io.connection_points.set_input_name_function((index) => ["in"][index]); } _gl_input_name(index) { return ["in"][index]; } setLines(shaders_collection_controller) { const connectionPoints = this.io.inputs.namedInputConnectionPoints(); if (!connectionPoints) { return; } const in_value = ThreeToGl.any(this.variableForInput(this._gl_input_name(0))); const gl_type = connectionPoints[0].type(); const out = this.glVarName(this.io.connection_points.output_name(0)); const body_line = `${gl_type} ${out} = -1.0 * ${in_value}`; shaders_collection_controller.addBodyLines(this, [body_line]); } }