@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 1.77 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { AttribNormalizeSopOperation, NORMALIZE_MODES } from "../../operations/sop/AttribNormalize";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const DEFAULT = AttribNormalizeSopOperation.DEFAULT_PARAMS;
class AttribNormalizeSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param defines if the value should be normalized between 0 and 1, or for vectors if the length should be 1 */
this.mode = ParamConfig.INTEGER(DEFAULT.mode, {
menu: {
entries: NORMALIZE_MODES.map((name, value) => {
return { name, value };
})
}
});
/** @param attribute to normalize */
this.name = ParamConfig.STRING(DEFAULT.name);
/** @param toggle to change the name of the attribute */
this.changeName = ParamConfig.BOOLEAN(DEFAULT.changeName);
/** @param new attribute name */
this.newName = ParamConfig.STRING(DEFAULT.newName, { visibleIf: { changeName: 1 } });
}
}
const ParamsConfig = new AttribNormalizeSopParamsConfig();
export class AttribNormalizeSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "attribNormalize";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(AttribNormalizeSopOperation.INPUT_CLONED_STATE);
}
set_mode(mode) {
this.p.mode.set(NORMALIZE_MODES.indexOf(mode));
}
cook(input_contents) {
this._operation = this._operation || new AttribNormalizeSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}