@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
44 lines (43 loc) • 1.69 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { AddSopOperation } from "../../operations/sop/Add";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = AddSopOperation.DEFAULT_PARAMS;
class AddSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param toggle to create points */
this.createPoint = ParamConfig.BOOLEAN(DEFAULT.createPoint);
/** @param define the number of points to create */
this.pointsCount = ParamConfig.INTEGER(DEFAULT.pointsCount, {
range: [1, 100],
rangeLocked: [true, false],
visibleIf: { createPoint: true }
});
/** @param the position of the created points */
this.position = ParamConfig.VECTOR3(DEFAULT.position, { visibleIf: { createPoint: true } });
/** @param toggle on to connect the points from the input geometry */
this.connectInputPoints = ParamConfig.BOOLEAN(DEFAULT.connectInputPoints);
/** @param check if the last point is connected */
this.connectToLastPoint = ParamConfig.BOOLEAN(DEFAULT.connectToLastPoint);
}
}
const ParamsConfig = new AddSopParamsConfig();
export class AddSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.ADD;
}
initializeNode() {
this.io.inputs.setCount(0, 1);
}
cook(input_contents) {
this._operation = this._operation || new AddSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}