@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
59 lines (58 loc) • 2.71 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { MaterialPropertiesSopOperation } from "../../operations/sop/MaterialProperties";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = MaterialPropertiesSopOperation.DEFAULT_PARAMS;
class MaterialPropertiesSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param group to assign the material to */
this.group = ParamConfig.STRING(DEFAULT.group, {
objectMask: true
});
/** @param toggle on to allow updating the side properties of the materials */
this.tside = ParamConfig.BOOLEAN(DEFAULT.tside);
/** @param defines if the material is double sided or not */
this.doubleSided = ParamConfig.BOOLEAN(0, {
visibleIf: { tside: true }
});
/** @param if the material is not double sided, it can be front sided, or back sided */
this.front = ParamConfig.BOOLEAN(1, { visibleIf: { tside: true, doubleSided: false } });
/** @param override the default shadowSide behavior */
this.overrideShadowSide = ParamConfig.BOOLEAN(DEFAULT.overrideShadowSide, { visibleIf: { tside: true } });
/** @param defines which side(s) are used when rendering shadows */
this.shadowDoubleSided = ParamConfig.BOOLEAN(DEFAULT.shadowDoubleSided, {
visibleIf: { tside: true, overrideShadowSide: true }
});
/** @param if the material is not double sided, it can be front sided, or back sided, when computing shadows */
this.shadowFront = ParamConfig.BOOLEAN(1, {
visibleIf: { tside: true, overrideShadowSide: true, shadowDoubleSided: false }
});
/** @param toggle on to allow updating the wireframe properties of the materials */
this.twireframe = ParamConfig.BOOLEAN(DEFAULT.twireframe);
/** @param defines if the material is double sided or not */
this.wireframe = ParamConfig.BOOLEAN(DEFAULT.wireframe, {
visibleIf: { twireframe: true }
});
}
}
const ParamsConfig = new MaterialPropertiesSopParamsConfig();
export class MaterialPropertiesSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.MATERIAL_PROPERTIES;
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(MaterialPropertiesSopOperation.INPUT_CLONED_STATE);
}
cook(inputCoreGroups) {
this._operation = this._operation || new MaterialPropertiesSopOperation(this.scene(), this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}