@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
45 lines (44 loc) • 1.76 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 { CameraSopNodeType } from "../../poly/NodeContext";
import { CoreMask } from "../../../core/geometry/Mask";
const _CameraCSSRendererSopOperation = class extends BaseSopOperation {
static type() {
return CameraSopNodeType.CSS_RENDERER;
}
cook(inputCoreGroups, params) {
const coreGroup = inputCoreGroups[0];
const objects = CoreMask.filterObjects(coreGroup, {
group: params.group
});
if (this._node) {
_CameraCSSRendererSopOperation.updateObject({ objects, params, node: this._node, active: true });
}
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.CSS_RENDERER_NODE_ID, nodeId);
}
} else {
for (let object of objects) {
ThreejsCoreObject.deleteAttribute(object, CameraAttribute.CSS_RENDERER_NODE_ID);
}
}
}
};
export let CameraCSSRendererSopOperation = _CameraCSSRendererSopOperation;
CameraCSSRendererSopOperation.DEFAULT_PARAMS = {
group: "",
node: new TypedNodePathParamValue("")
};
CameraCSSRendererSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;