polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
50 lines (49 loc) • 1.86 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {AttribCopySopOperation} from "../../../core/operations/sop/AttribCopy";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
const DEFAULT = AttribCopySopOperation.DEFAULT_PARAMS;
class AttribCopySopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.name = ParamConfig.STRING(DEFAULT.name);
this.tnewName = ParamConfig.BOOLEAN(DEFAULT.tnewName);
this.newName = ParamConfig.STRING(DEFAULT.newName, {visibleIf: {tnewName: 1}});
this.srcOffset = ParamConfig.INTEGER(DEFAULT.srcOffset, {
range: [0, 3],
rangeLocked: [true, true]
});
this.destOffset = ParamConfig.INTEGER(DEFAULT.destOffset, {
range: [0, 3],
rangeLocked: [true, true]
});
}
}
const ParamsConfig2 = new AttribCopySopParamsConfig();
export class AttribCopySopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "attribCopy";
}
static displayedInputNames() {
return ["geometry to copy attributes to", "geometry to copy attributes from"];
}
initializeNode() {
this.io.inputs.setCount(1, 2);
this.io.inputs.initInputsClonedState(AttribCopySopOperation.INPUT_CLONED_STATE);
this.scene().dispatchController.onAddListener(() => {
this.params.onParamsCreated("params_label", () => {
this.params.label.init([this.p.name, this.p.tnewName, this.p.newName], () => {
return this.pv.tnewName ? `${this.pv.name} -> ${this.pv.newName}` : this.pv.name;
});
});
});
}
cook(input_contents) {
this._operation = this._operation || new AttribCopySopOperation(this.scene(), this.states);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}