UNPKG

@polygonjs/polygonjs

Version:

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

40 lines (39 loc) 1.23 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; const OUTPUT_NAME = JsConnectionPointType.VECTOR3; class Vector2JsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param vector value */ this.Vector2 = ParamConfig.VECTOR2([0, 0]); } } const ParamsConfig = new Vector2JsParamsConfig(); export class Vector2JsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "vector2"; } initializeNode() { super.initializeNode(); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.VECTOR2) ]); } setLines(shadersCollectionController) { const inputValue = this.variableForInputParam(shadersCollectionController, this.p.Vector2); const varName = this.jsVarName(OUTPUT_NAME); shadersCollectionController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.VECTOR2, varName, value: inputValue } ]); } }