@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
30 lines (29 loc) • 959 B
JavaScript
;
import { UpdateMatNode } from "./_Base";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { ColorsController, ColorParamConfig, isValidColoredMaterial } from "./utils/ColorsController";
class ColorMatParamsConfig extends ColorParamConfig(NodeParamsConfig) {
}
const ParamsConfig = new ColorMatParamsConfig();
export class ColorMatNode extends UpdateMatNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
this.controllers = {
colors: new ColorsController(this)
};
}
static type() {
return "color";
}
async cook(inputMaterials) {
const inputMaterial = inputMaterials[0];
const controller = this.controllers.colors;
if (isValidColoredMaterial(inputMaterial)) {
controller.updateMaterial(inputMaterial);
this.setMaterial(inputMaterial);
} else {
this.states.error.set("input material does not have color properties");
}
}
}