@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.44 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { BoxSopOperation } from "../../operations/sop/Box";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = BoxSopOperation.DEFAULT_PARAMS;
class BoxSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param size of the box */
this.size = ParamConfig.FLOAT(DEFAULT.size, {
range: [0, 2],
rangeLocked: [true, false]
});
/** @param sizes on each axis */
this.sizes = ParamConfig.VECTOR3(DEFAULT.sizes);
/** @param number of segments on each axis */
this.divisions = ParamConfig.VECTOR3(DEFAULT.divisions);
/** @param center of the geometry */
this.center = ParamConfig.VECTOR3(DEFAULT.center);
}
}
const ParamsConfig = new BoxSopParamsConfig();
export class BoxSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.BOX;
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(BoxSopOperation.INPUT_CLONED_STATE);
}
cook(inputCoreGroups) {
this._operation = this._operation || new BoxSopOperation(this._scene, this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}