Skip to content

Commit

Permalink
fix(2d): account for spawners in scene graph (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarthificial committed Feb 5, 2024
1 parent f99f97c commit ca325f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/2d/src/editor/tree/NodeElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function NodeElement({node, depth = 0}: NodeElementProps) {

const children = useComputed(() => {
afterRender.value;
return nodeSignal.value.children();
return nodeSignal.value.peekChildren();
});

useSignalEffect(() => {
Expand Down
13 changes: 13 additions & 0 deletions packages/2d/src/lib/components/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,19 @@ export class Node implements Promisable<Node> {
this.setParsedChildren([]);
}

/**
* Get the current children of this node.
*
* @remarks
* Unlike {@link children}, this method does not have any side effects.
* It does not register the `children` signal as a dependency, and it does not
* spawn any children. It can be used to safely retrieve the current state of
* the scene graph for debugging purposes.
*/
public peekChildren(): readonly Node[] {
return this.realChildren;
}

/**
* Find all descendants of this node that match the given predicate.
*
Expand Down

0 comments on commit ca325f5

Please sign in to comment.