UNPKG

@polygonjs/polygonjs

Version:

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

39 lines (38 loc) 1.54 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { AttribAddMultSopOperation } from "../../operations/sop/AttribAddMult"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = AttribAddMultSopOperation.DEFAULT_PARAMS; class AttribAddMultSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param attribute name */ this.name = ParamConfig.STRING(DEFAULT.name); /** @param value to add before the multiplication */ this.preAdd = ParamConfig.FLOAT(DEFAULT.preAdd, { range: [-1, 1] }); /** @param value to multiply */ this.mult = ParamConfig.FLOAT(DEFAULT.mult, { range: [-1, 1] }); /** @param value to add after the multiplication */ this.postAdd = ParamConfig.FLOAT(DEFAULT.postAdd, { range: [-1, 1] }); } } const ParamsConfig = new AttribAddMultSopParamsConfig(); export class AttribAddMultSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.ATTRIB_ADD_MULT; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(AttribAddMultSopOperation.INPUT_CLONED_STATE); } cook(input_contents) { this._operation = this._operation || new AttribAddMultSopOperation(this.scene(), this.states, this); const core_group = this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }