polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
47 lines (46 loc) • 1.56 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
import {AttribClassMenuEntries, AttribClass} from "../../../core/geometry/Constant";
import {InputCloneMode as InputCloneMode2} from "../../poly/InputCloneMode";
class AttribRenameSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.class = ParamConfig.INTEGER(AttribClass.VERTEX, {
menu: {
entries: AttribClassMenuEntries
}
});
this.oldName = ParamConfig.STRING();
this.newName = ParamConfig.STRING();
}
}
const ParamsConfig2 = new AttribRenameSopParamsConfig();
export class AttribRenameSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "attribRename";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(InputCloneMode2.FROM_NODE);
this.scene().dispatchController.onAddListener(() => {
this.params.onParamsCreated("params_label", () => {
this.params.label.init([this.p.oldName, this.p.newName], () => {
if (this.pv.oldName != "" && this.pv.newName != "") {
return `${this.pv.oldName} -> ${this.pv.newName}`;
} else {
return "";
}
});
});
});
}
cook(input_contents) {
const core_group = input_contents[0];
core_group.renameAttrib(this.pv.oldName, this.pv.newName, this.pv.class);
this.setCoreGroup(core_group);
}
}