UNPKG

@polygonjs/polygonjs

Version:

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

45 lines (44 loc) 2.11 kB
"use strict"; import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { inputObject3DMaterial, setObject3DOutputLine } from "./_BaseObject3D"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class BaseSetMaterialFloatJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param float */ this.float = ParamConfig.FLOAT(1); /** @param lerp factor */ this.lerp = ParamConfig.FLOAT(1); } } const ParamsConfig = new BaseSetMaterialFloatJsParamsConfig(); export class BaseSetMaterialFloatJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS), new JsConnectionPoint(JsConnectionPointType.MATERIAL, JsConnectionPointType.MATERIAL, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER), new JsConnectionPoint(JsConnectionPointType.MATERIAL, JsConnectionPointType.MATERIAL, CONNECTION_OPTIONS) ]); } setLines(linesController) { setObject3DOutputLine(this, linesController); } setTriggerableLines(shadersCollectionController) { const material = inputObject3DMaterial(this, shadersCollectionController); const float = this.variableForInputParam(shadersCollectionController, this.p.float); const lerp = this.variableForInputParam(shadersCollectionController, this.p.lerp); const func = Poly.namedFunctionsRegister.getFunction(this._functionName(), this, shadersCollectionController); const bodyLine = func.asString(material, float, lerp); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }