@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
59 lines (58 loc) • 2.22 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { CurveFromPointsSopOperation } from "../../operations/sop/CurveFromPoints";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SplineCurveType, SPLINE_CURVE_TYPES } from "../../../core/geometry/Curve";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = CurveFromPointsSopOperation.DEFAULT_PARAMS;
class CurveFromPointsSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param points Count */
this.pointsCount = ParamConfig.INTEGER(DEFAULT.pointsCount, {
range: [2, 1e3],
rangeLocked: [true, false]
});
/** @param closed */
this.closed = ParamConfig.BOOLEAN(DEFAULT.closed);
/** @param curve type */
this.curveType = ParamConfig.INTEGER(DEFAULT.curveType, {
menu: {
entries: SPLINE_CURVE_TYPES.map((name, value) => ({ name, value }))
}
});
/** @param tension */
this.tension = ParamConfig.FLOAT(DEFAULT.tension, {
range: [0, 1],
rangeLocked: [false, false],
visibleIf: { curveType: SPLINE_CURVE_TYPES.indexOf(SplineCurveType.CATMULLROM) }
});
/** @param add tangent attribute */
this.tTangent = ParamConfig.BOOLEAN(DEFAULT.tTangent);
/** @param tangent attribute name */
this.tangentName = ParamConfig.STRING(DEFAULT.tangentName, {
visibleIf: { tTangent: true }
});
}
/** @param attributes */
// attributesToInterpolate = ParamConfig.STRING(DEFAULT.attributesToInterpolate);
}
const ParamsConfig = new CurveFromPointsSopParamsConfig();
export class CurveFromPointsSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.CURVE_FROM_POINTS;
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(CurveFromPointsSopOperation.INPUT_CLONED_STATE);
}
cook(inputCoreGroups) {
this._operation = this._operation || new CurveFromPointsSopOperation(this._scene, this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}