UNPKG

@polygonjs/polygonjs

Version:

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

47 lines (46 loc) 1.63 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { RoundedBoxSopOperation } from "../../operations/sop/RoundedBox"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = RoundedBoxSopOperation.DEFAULT_PARAMS; class RoundedBoxSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param size of the box */ this.size = ParamConfig.FLOAT(DEFAULT.size); /** @param size of the box */ this.sizes = ParamConfig.VECTOR3(DEFAULT.sizes); /** @param divisions count */ this.divisions = ParamConfig.INTEGER(DEFAULT.divisions, { range: [0, 10], rangeLocked: [true, false] }); /** @param bevel size */ this.bevel = ParamConfig.FLOAT(DEFAULT.bevel, { range: [0, 1], rangeLocked: [true, false] }); /** @param center of the box */ this.center = ParamConfig.VECTOR3(DEFAULT.center); } } const ParamsConfig = new RoundedBoxSopParamsConfig(); export class RoundedBoxSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.ROUNDED_BOX; } initializeNode() { this.io.inputs.setCount(0, 1); this.io.inputs.initInputsClonedState(RoundedBoxSopOperation.INPUT_CLONED_STATE); } cook(inputCoreGroups) { this._operation = this._operation || new RoundedBoxSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }