Skip to content

Actor2d/overlay layering support #3209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 3, 2025
14 changes: 4 additions & 10 deletions Sources/Rendering/OpenGL/Renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,10 @@ function vtkOpenGLRenderer(publicAPI, model) {
publicAPI.updateLights();
publicAPI.prepareNodes();
publicAPI.addMissingNode(model.renderable.getActiveCamera());
// Force all actor2D instances to be sorted and re-pushed as scenegraph nodes.
// This ensures that they are rendered in the correct order.
const actors2D = model.renderable.getActors2D();
actors2D.forEach((ac) => {
const vn = publicAPI.getViewNodeFor(ac);
if (vn !== undefined) {
publicAPI.removeNode(vn);
}
});
publicAPI.addMissingNodes(model.renderable.getViewPropsWithNestedProps());
publicAPI.addMissingNodes(
model.renderable.getViewPropsWithNestedProps(),
true
);
publicAPI.removeUnusedNodes();
}
};
Expand Down
17 changes: 15 additions & 2 deletions Sources/Rendering/SceneGraph/ViewNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,27 @@ function vtkViewNode(publicAPI, model) {

// add missing nodes/children for the passed in renderables. This should
// be called only in between prepareNodes and removeUnusedNodes
publicAPI.addMissingNodes = (dataObjs) => {
publicAPI.addMissingNodes = (dataObjs, enforceOrder = false) => {
if (!dataObjs || !dataObjs.length) {
return;
}

for (let index = 0; index < dataObjs.length; ++index) {
const dobj = dataObjs[index];
publicAPI.addMissingNode(dobj);
const node = publicAPI.addMissingNode(dobj);
if (
enforceOrder &&
node !== undefined &&
model.children[index] !== node
) {
for (let i = index + 1; i < model.children.length; ++i) {
if (model.children[i] === node) {
model.children.splice(i, 1);
model.children.splice(index, 0, node);
break;
}
}
}
}
};

Expand Down