@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
49 lines (48 loc) • 1.92 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { PlaneSopOperation } from "../../operations/sop/Plane";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = PlaneSopOperation.DEFAULT_PARAMS;
class PlaneSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param size of the plane */
this.size = ParamConfig.VECTOR2(DEFAULT.size);
/** @param defines if the plane resolution is sets via the number of segments or via the step size */
this.useSegmentsCount = ParamConfig.BOOLEAN(DEFAULT.useSegmentsCount);
/** @param step size */
this.stepSize = ParamConfig.FLOAT(DEFAULT.stepSize, {
range: [1e-3, 2],
rangeLocked: [false, false],
visibleIf: { useSegmentsCount: 0 }
});
/** @param segments count */
this.segments = ParamConfig.VECTOR2(DEFAULT.segments, { visibleIf: { useSegmentsCount: 1 } });
/** @param axis perpendicular to the plane */
this.direction = ParamConfig.VECTOR3(DEFAULT.direction);
/** @param center of the plane */
this.center = ParamConfig.VECTOR3(DEFAULT.center);
/** @param create lines instead of polygons */
this.asLines = ParamConfig.BOOLEAN(DEFAULT.asLines);
}
}
const ParamsConfig = new PlaneSopParamsConfig();
export class PlaneSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.PLANE;
}
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, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}