UNPKG

@polygonjs/polygonjs

Version:

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

43 lines (42 loc) 1.93 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { InputCloneMode } from "../../poly/InputCloneMode"; import { RestAttributesSopOperation } from "../../operations/sop/RestAttributes"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; const DEFAULT = RestAttributesSopOperation.DEFAULT_PARAMS; class RestAttributesSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param toggle on to create a rest position */ this.tposition = ParamConfig.BOOLEAN(DEFAULT.tposition); /** @param name of the position attribute */ this.position = ParamConfig.STRING(DEFAULT.position, { visibleIf: { tposition: true } }); /** @param name of the rest position attribute, on which the position will be copied on */ this.restP = ParamConfig.STRING(DEFAULT.restP, { visibleIf: { tposition: true } }); /** @param toggle on to create a rest normal */ this.tnormal = ParamConfig.BOOLEAN(DEFAULT.tnormal); /** @param name of the normal attribute */ this.normal = ParamConfig.STRING(DEFAULT.normal, { visibleIf: { tnormal: true } }); /** @param name of the rest normal attribute, on which the normal will be copied on */ this.restN = ParamConfig.STRING(DEFAULT.restN, { visibleIf: { tnormal: true } }); } } const ParamsConfig = new RestAttributesSopParamsConfig(); export class RestAttributesSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "restAttributes"; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState([InputCloneMode.FROM_NODE]); } cook(input_contents) { this._operation = this._operation || new RestAttributesSopOperation(this.scene(), this.states, this); const core_group = this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }