@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 1.61 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { ClipSopOperation } from "../../operations/sop/Clip";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const DEFAULT = ClipSopOperation.DEFAULT_PARAMS;
class ClipSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param origin */
this.origin = ParamConfig.VECTOR3(DEFAULT.origin);
/** @param distance */
this.distance = ParamConfig.FLOAT(DEFAULT.distance, {
range: [-10, 10],
rangeLocked: [false, false]
});
/** @param direction */
this.direction = ParamConfig.VECTOR3(DEFAULT.direction, {
separatorAfter: true
});
/** @param intersectionEdges */
this.intersectionEdges = ParamConfig.BOOLEAN(DEFAULT.intersectionEdges);
/** @param keepBelowPlane */
this.keepBelowPlane = ParamConfig.BOOLEAN(DEFAULT.keepBelowPlane);
/** @param keepAbovePlane */
this.keepAbovePlane = ParamConfig.BOOLEAN(DEFAULT.keepAbovePlane);
}
}
const ParamsConfig = new ClipSopParamsConfig();
export class ClipSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "clip";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(ClipSopOperation.INPUT_CLONED_STATE);
}
cook(inputCoreGroups) {
this._operation = this._operation || new ClipSopOperation(this._scene, this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}