@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
50 lines (49 loc) • 1.53 kB
JavaScript
;
import { BaseSopOperation } from "./_Base";
import { InputCloneMode } from "../../../engine/poly/InputCloneMode";
import { isBooleanTrue } from "../../../core/BooleanValue";
import { updateMaterialSideWithShadow } from "../../nodes/mat/utils/helpers/MaterialSideHelper";
import { CoreMask } from "../../../core/geometry/Mask";
export class MaterialPropertiesSopOperation extends BaseSopOperation {
static type() {
return "materialProperties";
}
cook(inputCoreGroups, params) {
const coreGroup = inputCoreGroups[0];
const selectedObjects = CoreMask.filterThreejsObjects(coreGroup, params);
for (let selectedObject of selectedObjects) {
this._updateObject(selectedObject, params);
}
return coreGroup;
}
_updateObject(object, params) {
const material = object.material;
if (material) {
this._updateMaterial(material, params);
}
}
_updateMaterial(material, params) {
if (isBooleanTrue(params.tside)) {
updateMaterialSideWithShadow(material, params);
}
if (isBooleanTrue(params.twireframe)) {
if (material.wireframe != void 0) {
material.wireframe = params.wireframe;
}
}
}
}
MaterialPropertiesSopOperation.DEFAULT_PARAMS = {
group: "",
// side
tside: false,
doubleSided: false,
front: true,
overrideShadowSide: false,
shadowDoubleSided: false,
shadowFront: true,
// wireframe
twireframe: false,
wireframe: false
};
MaterialPropertiesSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;