UNPKG

@polygonjs/polygonjs

Version:

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

49 lines (43 loc) 1.69 kB
/** * Creates a box made of lines. * * @remarks * What this node creates is different than a box mesh with a wireframe material applied, in the sense that this will not create triangles. * */ import {TypedSopNode} from './_Base'; import {CoreGroup} from '../../../core/geometry/Group'; import {BoxLinesSopOperation} from '../../operations/sop/BoxLines'; import {NodeParamsConfig, ParamConfig} from '../utils/params/ParamsConfig'; import {SopType} from '../../poly/registers/nodes/types/Sop'; const DEFAULT = BoxLinesSopOperation.DEFAULT_PARAMS; class BoxLinesSopParamsConfig extends NodeParamsConfig { /** @param size of the box */ size = ParamConfig.FLOAT(DEFAULT.size, { range: [0, 2], rangeLocked: [true, false], }); /** @param sizes on each axis */ sizes = ParamConfig.VECTOR3(DEFAULT.sizes); /** @param divisions on each axis */ divisions = ParamConfig.VECTOR3(DEFAULT.divisions); /** @param center of the geometry */ center = ParamConfig.VECTOR3(DEFAULT.center); } const ParamsConfig = new BoxLinesSopParamsConfig(); export class BoxLinesSopNode extends TypedSopNode<BoxLinesSopParamsConfig> { override readonly paramsConfig = ParamsConfig; static override type() { return SopType.BOX_LINES; } protected override initializeNode() { this.io.inputs.setCount(0, 1); this.io.inputs.initInputsClonedState(BoxLinesSopOperation.INPUT_CLONED_STATE); } private _operation: BoxLinesSopOperation | undefined; override cook(inputCoreGroups: CoreGroup[]) { this._operation = this._operation || new BoxLinesSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }