@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
38 lines (37 loc) • 1.19 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { CenterSopOperation, CENTER_MODES } from "../../operations/sop/Center";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const DEFAULT = CenterSopOperation.DEFAULT_PARAMS;
class CenterSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.mode = ParamConfig.INTEGER(DEFAULT.mode, {
menu: {
entries: CENTER_MODES.map((name, value) => ({ name, value }))
}
});
}
}
const ParamsConfig = new CenterSopParamsConfig();
export class CenterSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "center";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(CenterSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new CenterSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
setMode(mode) {
this.p.mode.set(CENTER_MODES.indexOf(mode));
}
}