@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
54 lines (53 loc) • 2.19 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { BooleanSopOperation, BOOLEAN_OPERATIONS } from "../../operations/sop/Boolean";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const DEFAULT = BooleanSopOperation.DEFAULT_PARAMS;
class BooleanSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param url to load the geometry from */
this.operation = ParamConfig.INTEGER(DEFAULT.operation, {
menu: {
entries: BOOLEAN_OPERATIONS.map((name, value) => {
return { name, value };
})
},
separatorAfter: true
});
/** @param preserves the color attribute of both input */
this.keepVertexColor = ParamConfig.BOOLEAN(DEFAULT.keepVertexColor);
/** @param add any additional attribute to be preserved */
this.additionalAttributes = ParamConfig.STRING(DEFAULT.additionalAttributes, {
separatorAfter: true
});
/** @param defines if only the material from the first input is used, or if the ones from both inputs should be used */
this.keepMaterials = ParamConfig.BOOLEAN(DEFAULT.keepMaterials);
/** @param if one of the input has multiple material for a single object, and you'd like to preserve those, toggle this on */
this.useInputGroups = ParamConfig.BOOLEAN(DEFAULT.useInputGroups);
/** @param intersectionEdgesOnly */
this.intersectionEdgesOnly = ParamConfig.BOOLEAN(DEFAULT.intersectionEdgesOnly);
}
}
const ParamsConfig = new BooleanSopParamsConfig();
export class BooleanSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "boolean";
}
initializeNode() {
this.io.inputs.setCount(2);
this.io.inputs.initInputsClonedState(BooleanSopOperation.INPUT_CLONED_STATE);
}
setOperation(operation) {
this.p.operation.set(BOOLEAN_OPERATIONS.indexOf(operation));
}
cook(inputCoreGroups) {
this._operation = this._operation || new BooleanSopOperation(this.scene(), this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}