@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
52 lines (51 loc) • 1.81 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { TangentSopOperation, TANGENT_MODES, TangentMode } from "../../operations/sop/Tangent";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = TangentSopOperation.DEFAULT_PARAMS;
class TangentSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param select which objects this applies the actor behavior to */
this.group = ParamConfig.STRING(DEFAULT.group, {
objectMask: true
});
/** @param mode */
this.mode = ParamConfig.INTEGER(DEFAULT.mode, {
menu: {
entries: TANGENT_MODES.map((name, value) => ({ name, value }))
}
});
/** @param closed */
this.closed = ParamConfig.BOOLEAN(DEFAULT.closed, {
visibleIf: { mode: TANGENT_MODES.indexOf(TangentMode.CURVE) }
});
/** @param tangent attribute name */
this.tangentName = ParamConfig.STRING(DEFAULT.tangentName, {
visibleIf: { mode: TANGENT_MODES.indexOf(TangentMode.CURVE) }
});
}
}
const ParamsConfig = new TangentSopParamsConfig();
export class TangentSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.TANGENT;
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(TangentSopOperation.INPUT_CLONED_STATE);
}
cook(inputCoreGroups) {
this._operation = this._operation || new TangentSopOperation(this._scene, this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
setMode(mode) {
this.p.mode.set(TANGENT_MODES.indexOf(mode));
}
}