polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
42 lines (41 loc) • 1.53 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {PlaneSopOperation} from "../../../core/operations/sop/Plane";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
const DEFAULT = PlaneSopOperation.DEFAULT_PARAMS;
class PlaneSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.size = ParamConfig.VECTOR2(DEFAULT.size);
this.useSegmentsCount = ParamConfig.BOOLEAN(DEFAULT.useSegmentsCount);
this.stepSize = ParamConfig.FLOAT(DEFAULT.stepSize, {
range: [1e-3, 1],
rangeLocked: [false, false],
visibleIf: {useSegmentsCount: 0}
});
this.segments = ParamConfig.VECTOR2(DEFAULT.segments, {visibleIf: {useSegmentsCount: 1}});
this.direction = ParamConfig.VECTOR3(DEFAULT.direction);
this.center = ParamConfig.VECTOR3(DEFAULT.center);
}
}
const ParamsConfig2 = new PlaneSopParamsConfig();
export class PlaneSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "plane";
}
static displayedInputNames() {
return ["geometry to create plane from (optional)"];
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(PlaneSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new PlaneSopOperation(this.scene(), this.states);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}