Skip to content

Commit

Permalink
Fix notification after regeneration (#5733)
Browse files Browse the repository at this point in the history
* Fix grass

* Fix USE-DEF

* Finalize
  • Loading branch information
ad-daniel authored Jan 13, 2023
1 parent 5eb8a32 commit 84689d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 4 additions & 7 deletions resources/web/wwi/X3dScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,17 @@ export default class X3dScene {
let parentNode;
if (typeof parentId !== 'undefined') {
parentNode = WbWorld.instance.nodes.get('n' + parentId);
parentNode.isPreFinalizedCalled = false;
parentNode.isPostFinalizedCalled = false;
parentNode.unfinalize();
}

const parser = new Parser(webots.currentView.prefix);
parser.prefix = webots.currentView.prefix;
await parser.parse(x3dObject, this.renderer, false, parentNode, callback);

const node = WbWorld.instance.nodes.get(parser.rootNodeId);
if (typeof parentId !== 'undefined') {
node.finalize();
if (parentNode instanceof WbShape) // TODO: this might be improved with a onchange trigger
parentNode.updateAppearance();
} else
if (typeof parentId !== 'undefined')
parentNode.finalize();
else
node.finalize();
}

Expand Down
10 changes: 10 additions & 0 deletions resources/web/wwi/nodes/WbBaseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export default class WbBaseNode {
WbWorld.instance.nodes.delete(this.id);
}

unfinalize() {
this.isPreFinalizedCalled = false;
this.wrenObjectsCreatedCalled = false;
this.isPostFinalizedCalled = false;
for (const useId of this.useList) { // notify USE nodes to do the same
const useNode = WbWorld.instance.nodes.get(useId);
useNode?.unfinalize();
}
}

finalize() {
if (!this.isPreFinalizedCalled)
this.preFinalize();
Expand Down

0 comments on commit 84689d5

Please sign in to comment.