Skip to content
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

Node: Ensure that the child nodes are processed first for events #30228

Merged
merged 6 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,9 @@ class Node extends EventDispatcher {

}

// return a outputNode if exists
return null;
// return a outputNode if exists or null

return nodeProperties.outputNode || null;

}

Expand Down Expand Up @@ -609,17 +610,19 @@ class Node extends EventDispatcher {

if ( properties.initialized !== true ) {

const stackNodesBeforeSetup = builder.stack.nodes.length;
//const stackNodesBeforeSetup = builder.stack.nodes.length;

properties.initialized = true;
properties.outputNode = this.setup( builder );

if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
const outputNode = this.setup( builder ); // return a node or null
const isNodeOutput = outputNode && outputNode.isNode === true;

/*if ( isNodeOutput && builder.stack.nodes.length !== stackNodesBeforeSetup ) {

// !! no outputNode !!
//properties.outputNode = builder.stack;
//outputNode = builder.stack;

}
}*/

for ( const childNode of Object.values( properties ) ) {

Expand All @@ -631,6 +634,14 @@ class Node extends EventDispatcher {

}

if ( isNodeOutput ) {

outputNode.build( builder );

}

properties.outputNode = outputNode;

}

} else if ( buildStage === 'analyze' ) {
Expand Down
1 change: 1 addition & 0 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ class NodeBuilder {
/**
* It is used to add Nodes that will be used as FRAME and RENDER events,
* and need to follow a certain sequence in the calls to work correctly.
* This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
*
* @param {Node} node - The node to add.
*/
Expand Down
Loading