@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
43 lines (42 loc) • 1.58 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { InputCloneMode } from "../../poly/InputCloneMode";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { PolywireSopOperation } from "../../operations/sop/Polywire";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = PolywireSopOperation.DEFAULT_PARAMS;
class PolywireSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param radius */
this.radius = ParamConfig.FLOAT(DEFAULT.radius);
/** @param segments count on the circle used */
this.segmentsRadial = ParamConfig.INTEGER(DEFAULT.segmentsRadial, {
range: [3, 20],
rangeLocked: [true, false]
});
/** @param toggle on for the geometry to close back on itself */
this.closed = ParamConfig.BOOLEAN(DEFAULT.closed);
/** @param attributesToCopy */
this.attributesToCopy = ParamConfig.STRING(DEFAULT.attributesToCopy);
}
}
const ParamsConfig = new PolywireSopParamsConfig();
export class PolywireSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.POLYWIRE;
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(InputCloneMode.NEVER);
}
cook(inputCoreGroups) {
this._operation = this._operation || new PolywireSopOperation(this._scene, this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}