UNPKG

@polygonjs/polygonjs

Version:

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

58 lines (57 loc) 2.06 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { TorusSopOperation } from "../../operations/sop/Torus"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = TorusSopOperation.DEFAULT_PARAMS; class TorusSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param large radius */ this.radius = ParamConfig.FLOAT(DEFAULT.radius, { range: [0, 1] }); /** @param radius of the tube */ this.radiusTube = ParamConfig.FLOAT(DEFAULT.radiusTube, { range: [0, 1] }); /** @param number of segments along the length of the torus */ this.segmentsRadial = ParamConfig.INTEGER(DEFAULT.segmentsRadial, { range: [2, 50], rangeLocked: [true, false] }); /** @param number of segments along the tube */ this.segmentsTube = ParamConfig.INTEGER(DEFAULT.segmentsTube, { range: [1, 50], rangeLocked: [true, false] }); /** @param open */ this.open = ParamConfig.BOOLEAN(DEFAULT.open); /** @param arc */ this.arc = ParamConfig.FLOAT("$PI*2", { step: 1e-5, range: [0, Math.PI * 2], rangeLocked: [true, true], visibleIf: { open: 1 } }); /** @param create caps */ this.cap = ParamConfig.BOOLEAN(DEFAULT.cap, { visibleIf: { open: 1 } }); /** @param axis perpendicular to the torus */ this.direction = ParamConfig.VECTOR3(DEFAULT.direction); /** @param center of the torus */ this.center = ParamConfig.VECTOR3(DEFAULT.center); } } const ParamsConfig = new TorusSopParamsConfig(); export class TorusSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.TORUS; } cook(input_contents) { this._operation = this._operation || new TorusSopOperation(this.scene(), this.states, this); const coreGroup = this._operation.cook(input_contents, this.pv); this.setCoreGroup(coreGroup); } }