polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
64 lines (63 loc) • 2.32 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {AttribClassMenuEntries} from "../../../core/geometry/Constant";
import {AttribPromoteSopOperation, AttribPromoteMode} from "../../../core/operations/sop/AttribPromote";
const PromoteModeMenuEntries = [
{name: "min", value: AttribPromoteMode.MIN},
{name: "max", value: AttribPromoteMode.MAX},
{name: "first_found", value: AttribPromoteMode.FIRST_FOUND}
];
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
const DEFAULT = AttribPromoteSopOperation.DEFAULT_PARAMS;
class AttribPromoteSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.classFrom = ParamConfig.INTEGER(DEFAULT.classFrom, {
menu: {
entries: AttribClassMenuEntries
}
});
this.classTo = ParamConfig.INTEGER(DEFAULT.classTo, {
menu: {
entries: AttribClassMenuEntries
}
});
this.mode = ParamConfig.INTEGER(DEFAULT.mode, {
menu: {
entries: PromoteModeMenuEntries
}
});
this.name = ParamConfig.STRING(DEFAULT.name);
}
}
const ParamsConfig2 = new AttribPromoteSopParamsConfig();
export class AttribPromoteSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "attribPromote";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(AttribPromoteSopOperation.INPUT_CLONED_STATE);
this.scene().dispatchController.onAddListener(() => {
this.params.onParamsCreated("params_label", () => {
this.params.label.init([this.p.name, this.p.classFrom, this.p.classTo], () => {
if (this.pv.name != "") {
const from_s = AttribClassMenuEntries.filter((entry) => entry.value == this.pv.classFrom)[0].name;
const to_s = AttribClassMenuEntries.filter((entry) => entry.value == this.pv.classTo)[0].name;
return `${this.pv.name} (${from_s} -> ${to_s})`;
} else {
return "";
}
});
});
});
}
cook(input_contents) {
this._operation = this._operation || new AttribPromoteSopOperation(this.scene(), this.states);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}