polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
37 lines (33 loc) • 1.1 kB
text/typescript
/**
* Subdivides a geometry
*
*
*/
import {TypedSopNode} from './_Base';
import {NodeParamsConfig, ParamConfig} from '../utils/params/ParamsConfig';
import {CoreGroup} from '../../../core/geometry/Group';
import {SubdivideSopOperation} from '../../../core/operations/sop/Subdivide';
const DEFAULT = SubdivideSopOperation.DEFAULT_PARAMS;
class SubdivideSopParamsConfig extends NodeParamsConfig {
/** @param number of subdivisions */
subdivisions = ParamConfig.INTEGER(DEFAULT.subdivisions, {
range: [0, 5],
rangeLocked: [true, false],
});
}
const ParamsConfig = new SubdivideSopParamsConfig();
export class SubdivideSopNode extends TypedSopNode<SubdivideSopParamsConfig> {
params_config = ParamsConfig;
static type() {
return 'subdivide';
}
initializeNode() {
this.io.inputs.setCount(1);
}
private _operation: SubdivideSopOperation | undefined;
cook(input_contents: CoreGroup[]) {
this._operation = this._operation || new SubdivideSopOperation(this.scene(), this.states);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}