UNPKG

@polygonjs/polygonjs

Version:

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

48 lines (47 loc) 2.13 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 { Poly } from "../../Poly"; import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class SetCSSObjectClassJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param class */ this.class = ParamConfig.STRING("active"); /** @param set to true to add the class, or false to remove */ this.addRemove = ParamConfig.BOOLEAN(1); } } const ParamsConfig = new SetCSSObjectClassJsParamsConfig(); export class SetCSSObjectClassJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "setCSSObjectClass"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS), new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER), new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D) ]); } setLines(linesController) { setObject3DOutputLine(this, linesController); } setTriggerableLines(linesController) { const object3D = inputObject3D(this, linesController); const className = this.variableForInputParam(linesController, this.p.class); const addRemove = this.variableForInputParam(linesController, this.p.addRemove); const func = Poly.namedFunctionsRegister.getFunction("setCSSObjectClass", this, linesController); const bodyLine = func.asString(object3D, className, addRemove); linesController.addTriggerableLines(this, [bodyLine]); } }