@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
39 lines (38 loc) • 1.32 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { SetGeometrySopOperation, SET_GEOMETRY_MODES } from "../../operations/sop/SetGeometry";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = SetGeometrySopOperation.DEFAULT_PARAMS;
class SetGeometrySopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.mode = ParamConfig.INTEGER(DEFAULT.mode, {
menu: {
entries: SET_GEOMETRY_MODES.map((name, value) => ({ name, value }))
}
});
}
}
const ParamsConfig = new SetGeometrySopParamsConfig();
export class SetGeometrySopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.SET_GEOMETRY;
}
initializeNode() {
this.io.inputs.setCount(2);
this.io.inputs.initInputsClonedState(SetGeometrySopOperation.INPUT_CLONED_STATE);
}
setMode(mode) {
this.p.mode.set(SET_GEOMETRY_MODES.indexOf(mode));
}
cook(inputCoreGroups) {
this._operation = this._operation || new SetGeometrySopOperation(this.scene(), this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}