UNPKG

@polygonjs/polygonjs

Version:

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

37 lines (36 loc) 1.24 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SubdivideSopOperation } from "../../operations/sop/Subdivide"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = SubdivideSopOperation.DEFAULT_PARAMS; class SubdivideSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param number of subdivisions */ this.subdivisions = ParamConfig.INTEGER(DEFAULT.subdivisions, { range: [0, 5], rangeLocked: [true, false] }); /** @param merge vertices */ this.mergeVertices = ParamConfig.BOOLEAN(DEFAULT.mergeVertices); } } const ParamsConfig = new SubdivideSopParamsConfig(); export class SubdivideSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.SUBDIVIDE; } initializeNode() { this.io.inputs.setCount(1); } cook(input_contents) { this._operation = this._operation || new SubdivideSopOperation(this.scene(), this.states, this); const core_group = this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }