@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
43 lines (42 loc) • 1.6 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { HexagonsSopOperation } from "../../operations/sop/Hexagons";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const DEFAULT = HexagonsSopOperation.DEFAULT_PARAMS;
class HexagonsSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param plane size */
this.size = ParamConfig.VECTOR2(DEFAULT.size);
/** @param hexagons size */
this.hexagonRadius = ParamConfig.FLOAT(DEFAULT.hexagonRadius, {
range: [1e-3, 1],
rangeLocked: [false, false]
});
/** @param axis perpendicular to the plane */
this.direction = ParamConfig.VECTOR3(DEFAULT.direction);
/** @param do not create polygons, only points */
this.pointsOnly = ParamConfig.BOOLEAN(DEFAULT.pointsOnly);
}
// no need to have centers, as all points are centers anyway
//this.add_param( ParamType.TOGGLE, 'centers_only', 0, {visibleIf: {pointsOnly: 1}})
}
const ParamsConfig = new HexagonsSopParamsConfig();
export class HexagonsSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "hexagons";
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(HexagonsSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new HexagonsSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}