-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Fix BoxHelper Bounding box update issue #18542
Conversation
@@ -47,6 +47,8 @@ BoxHelper.prototype.update = function ( object ) { | |||
|
|||
_box.setFromObject( this.object ); | |||
|
|||
this.geometry.boundingBox = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is correct. Can you please explain this issue in more detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi , recently we update to v111 and having an issue with these code:
var sourceBoxHelper = new THREE.BoxHelper(sourceObject)
var sourceBox = new THREE.Box3();
sourceBoxHelper.update()
sourceBox.setFromObject(sourceBoxHelper)
Here the sourceBox will not get the correct updated geometry information (which works fine before v111).
I found the problem is that the latest optimize for .expandByObject()
#17940 which will always set the boundingbox value when the BoxHelper first constructed.
Then afterwards when BoxHelper update() get called again, the boundingbox will not be set to the updated value (the boundingbox will not be calculated when update() get called, I think this is not a correct behavior).
What code is using BoxHelper uses three.js/src/helpers/BoxHelper.js Line 87 in e0e541b
|
Before r111, the geometry.boundingBox in BoxBoxHelper is always set to null, then when we call this method: sourceBox.setFromObject(sourceBoxHelper) the sourceBox will get a correct geometry boundingbox, since geometry.boundingBox in BoxBoxHelper is null and it will call the computeBoundingBox() function. after r111, the geometry.boundingBox in BoxBoxHelper is not null, and will not be updated properly. In the same situation, the sourceBox will not get the correct geometry (the computeBoundingBox() function will not be called). |
Why do you use a helper? Why don't you do this directly? sourceBox.setFromObject(sourceObject) |
Well, this code snippet is from the Bounding volume collision detection with THREE.js demo on mozilla doc site.
I am sure not only me is using BoxHelper this way and I think we should fix it. |
In this case, Mozilla docs need an update.
I don't think this statement is correct. Helpers are not intended for collision detection. |
Same situation after upgrading from r110 to r111. Obviously, |
Can you please demonstrate with a fiddle what's exactly is going wrong? I've prepared a template with As you can see in the demo, it seems the helper updates itself correctly. |
Sorry it was just out of viewport. I realised my |
@mrdoob This PR can be closed. IMHO, the suggested change is incorrect. |
The latest optimize for .expandByObject() #17940 (#17940) in r111 has caused an issue for the BoxHelper update() function. The boundingbox property will be set by expandByObject() at first and would not be updated afterwards.
This fix will reset the geometry boundingbox value to null, so the Box3 expandByObject() function will work properly.