UNPKG

@polygonjs/polygonjs

Version:

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

32 lines (31 loc) 1.11 kB
"use strict"; import { Poly } from "../../Poly"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { TypedJsNode } from "./_Base"; const OUTPUT_NAME = "random"; class RandomJsParamsConfig extends NodeParamsConfig { } const ParamsConfig = new RandomJsParamsConfig(); export class RandomJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "random"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.FLOAT) ]); } setLines(shadersCollectionController) { const varName = this.jsVarName(OUTPUT_NAME); const _func = Poly.namedFunctionsRegister.getFunction("random", this, shadersCollectionController).asString(); shadersCollectionController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.FLOAT, varName, value: _func } ]); } }