UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

56 lines (55 loc) 1.99 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { CurveGetPointSopOperation } from "../../operations/sop/CurveGetPoint"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SplineCurveType, SPLINE_CURVE_TYPES } from "../../../core/geometry/Curve"; const DEFAULT = CurveGetPointSopOperation.DEFAULT_PARAMS; class CurveGetPointSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param t */ this.t = ParamConfig.FLOAT(DEFAULT.t, { range: [0, 1], rangeLocked: [false, 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 } }); } } const ParamsConfig = new CurveGetPointSopParamsConfig(); export class CurveGetPointSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "curveGetPoint"; } initializeNode() { this.io.inputs.setCount(0, 1); this.io.inputs.initInputsClonedState(CurveGetPointSopOperation.INPUT_CLONED_STATE); } cook(inputCoreGroups) { this._operation = this._operation || new CurveGetPointSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }