@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
52 lines (51 loc) • 2.03 kB
JavaScript
;
import { BaseSopOperation } from "./_Base";
import { InputCloneMode } from "../../../engine/poly/InputCloneMode";
import { TypedNodePathParamValue } from "../../../core/Walker";
import { ThreejsCoreObject } from "../../../core/geometry/modules/three/ThreejsCoreObject";
import { CameraAttribute } from "../../../core/camera/CoreCamera";
import { isBooleanTrue } from "../../../core/Type";
import { CameraSopNodeType } from "../../poly/NodeContext";
import { CoreMask } from "../../../core/geometry/Mask";
export class CameraPostProcessSopOperation extends BaseSopOperation {
static type() {
return CameraSopNodeType.POST_PROCESS;
}
cook(inputCoreGroups, params) {
var _a;
const coreGroup = inputCoreGroups[0];
const objects = CoreMask.filterObjects(coreGroup, {
group: params.group
});
const relativeOrAbsolutePath = params.node.path();
const node = isBooleanTrue(params.useOtherNode) ? (_a = this._node) == null ? void 0 : _a.node(relativeOrAbsolutePath) : this._node;
if (node) {
const nodeId = node.graphNodeId();
for (let object of objects) {
ThreejsCoreObject.addAttribute(object, CameraAttribute.POST_PROCESS_NODE_ID, nodeId);
}
}
return coreGroup;
}
static updateObject(options) {
const { objects, params, node, active } = options;
const relativeOrAbsolutePath = params.node.path();
const foundNode = node.node(relativeOrAbsolutePath);
if (foundNode && active) {
const nodeId = foundNode.graphNodeId();
for (let object of objects) {
ThreejsCoreObject.addAttribute(object, CameraAttribute.POST_PROCESS_NODE_ID, nodeId);
}
} else {
for (let object of objects) {
ThreejsCoreObject.deleteAttribute(object, CameraAttribute.POST_PROCESS_NODE_ID);
}
}
}
}
CameraPostProcessSopOperation.DEFAULT_PARAMS = {
group: "",
useOtherNode: false,
node: new TypedNodePathParamValue("")
};
CameraPostProcessSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;