UNPKG

@polygonjs/polygonjs

Version:

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

50 lines (49 loc) 1.79 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { CircleSopOperation } from "../../operations/sop/Circle"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = CircleSopOperation.DEFAULT_PARAMS; class CircleSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param circle radius */ this.radius = ParamConfig.FLOAT(DEFAULT.radius); /** @param segments count */ this.segments = ParamConfig.INTEGER(DEFAULT.segments, { range: [1, 50], rangeLocked: [true, false] }); /** @param toggle on to have an arc instead of a closed circle */ this.open = ParamConfig.BOOLEAN(DEFAULT.open); /** @param connects last dot for open circle */ this.connectLastPoint = ParamConfig.BOOLEAN(DEFAULT.connectLastPoint, { visibleIf: { open: 1 } }); /** @param angle fo the arc */ this.arcAngle = ParamConfig.FLOAT(DEFAULT.arcAngle, { range: [0, 360], rangeLocked: [false, false], visibleIf: { open: 1 } }); /** @param direction of the axis perpendicular to the circle plane */ this.direction = ParamConfig.VECTOR3(DEFAULT.direction); /** @param center */ this.center = ParamConfig.VECTOR3(DEFAULT.center); } } const ParamsConfig = new CircleSopParamsConfig(); export class CircleSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.CIRCLE; } cook() { this._operation = this._operation || new CircleSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook([], this.pv); this.setCoreGroup(coreGroup); } }