Editor: Fix selection box update when reparenting objects in hierarchy#30904
Conversation
|
For testing: https://rawcdn.githack.com/lixinde/three.js/editor-fix/editor/index.html Your PR indeed fixes the issue 👍 . Do you mind reverting the screenshot update? Sometimes this particular example fails and a simple rerun of the CI solves the issue. |
This reverts commit cbb40c4.
I've reverted the screenshot update. Thanks for confirming the fix works properly! |
|
I found and fixed another related bug while working on this PR. I'm attaching a video that demonstrates the issue. The additional fix addresses this problem while maintaining the original fix's functionality. 20250411-103319.mp4For testing: https://rawcdn.githack.com/lixinde/three.js/editor-fix/editor/index.html |
Issue
When moving objects in the hierarchy panel to become children of other objects, the selection box in the viewport didn't update to reflect the object's new world transformation, causing a visual discrepancy between the actual object position and its selection highlight.
threejs-editor-selectionBoxIssue.mp4
Solution
Added appropriate signal dispatch in the MoveObjectCommand's execute() and undo() methods to ensure the selection box properly updates when objects are reparented. This ensures the selection box correctly reflects the object's new world transformation after hierarchy changes.
The fix properly leverages the existing signal system to update the selection box geometry without requiring changes to the Viewport.js implementation, which already handles the selectionBox updates when receiving objectChanged signals.
Testing
Verified that when dragging objects in the hierarchy panel to become children of other objects, the selection box now properly updates to match the object's new position in the scene.
threejs-editor-fixed.mp4