polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
43 lines (42 loc) • 1.69 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {NodeContext as NodeContext2} from "../../poly/NodeContext";
import {InputCloneMode as InputCloneMode2} from "../../poly/InputCloneMode";
import {AttribFromTextureSopOperation} from "../../../core/operations/sop/AttribFromTexture";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
const DEFAULT = AttribFromTextureSopOperation.DEFAULT_PARAMS;
class AttribFromTextureSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.texture = ParamConfig.NODE_PATH(DEFAULT.texture.path(), {
nodeSelection: {context: NodeContext2.COP}
});
this.uvAttrib = ParamConfig.STRING(DEFAULT.uvAttrib);
this.attrib = ParamConfig.STRING(DEFAULT.attrib);
this.add = ParamConfig.FLOAT(DEFAULT.add);
this.mult = ParamConfig.FLOAT(DEFAULT.mult);
}
}
const ParamsConfig2 = new AttribFromTextureSopParamsConfig();
export class AttribFromTextureSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "attribFromTexture";
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(InputCloneMode2.FROM_NODE);
this.scene().dispatchController.onAddListener(() => {
this.params.onParamsCreated("params_label", () => {
this.params.label.init([this.p.attrib]);
});
});
}
async cook(input_contents) {
this._operation = this._operation || new AttribFromTextureSopOperation(this.scene(), this.states);
const core_group = await this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}