Skip to content

Commit

Permalink
feat(viewNode): Add getLastAncestorOfType method
Browse files Browse the repository at this point in the history
  • Loading branch information
bruyeret authored and finetjul committed Apr 11, 2024
1 parent dab4f05 commit c1197c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Rendering/SceneGraph/ViewNode/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export interface vtkViewNode extends vtkObject {
*/
getFirstAncestorOfType(type: any): void;

/**
* Find the last parent/grandparent of the desired type
* @param type
*/
getLastAncestorOfType(type: any): void;

/**
*
*/
Expand Down
14 changes: 14 additions & 0 deletions Sources/Rendering/SceneGraph/ViewNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ function vtkViewNode(publicAPI, model) {
return model._parent.getFirstAncestorOfType(type);
};

publicAPI.getLastAncestorOfType = (type) => {
if (!model._parent) {
return null;
}
const lastAncestor = model._parent.getLastAncestorOfType(type);
if (lastAncestor) {
return lastAncestor;
}
if (model._parent.isA(type)) {
return model._parent;
}
return null;
};

// add a missing node/child for the passed in renderables. This should
// be called only in between prepareNodes and removeUnusedNodes
publicAPI.addMissingNode = (dobj) => {
Expand Down

0 comments on commit c1197c3

Please sign in to comment.