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

Fix bug to get correct bounding box of a mesh node. #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix bug to get correct bounding box of a mesh node. #115

wants to merge 1 commit into from

Conversation

birdinforest
Copy link
Contributor

When we call Node.prototype.getBoundingBox to get the bounding box of a node contains geometry (mesh), the returned bounding box has applied world transform of that node. So that it shouldn't union with bounding box of geometry.

Unless there are other cases in which we do need to do union. Please advice. Thanks.

…ould not be union with geometry's bounding box.
@pissang
Copy link
Owner

pissang commented Feb 6, 2020

Hi @birdinforest

Node#getBoundingBox returns a local bounding box including all the children and itself, if it has geometry. The bounding box is relative to the node transform and won't be applied world transform,

Are you meeting some issues when using this function?

@birdinforest
Copy link
Contributor Author

birdinforest commented Feb 7, 2020

Hi @pissang

Thanks for your response. Sorry it was incorrect to say the node has been 'transformed by world transform'.

According to my understanding, Node#getBoundingBox returns a bounding box relative to its parent node. If the world transform of a node isn't identity, bounding box of that node will be transformed relatively to its parent. So that it might cause problem to do union with original geometry bounding box.

I did encounter an issue to get the bounding box in that scenario. Please reference following screen shots:

claygl_bbox_issue

node.worldTransform: 
[0.2857008901599777, 0, 0.7414056445312012, 0, 0, 0.7332189, 0, 0, -0.6031628217506998, 0, 0.23242897644047653, 0, 106.715439, -4.00169754, -9.18224049, 1]

node._parent.worldTransform:
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]

node.geometry.getBoundingBox:
min: [-0.7505188, -0.104103565, -0.403491974] 
max: [0.66633606, 2.11563349, 0.8133888]

Expected bounding box (In world view and relative to parent):
min: [106.01040922696978, -4.078028241415379, -9.832462591165552] 
max: [107.1491831630793, -2.4504750796590393, -8.499160047729172]

Returned bounding box:
min: [-0.7505188, -0.104103565, -0.403491974] 
max: [107.1491831630793, -2.4504750796590393, -8.499160047729172]

Expected result:
claygl_bbox_correct

Please advice.

By the way, thanks for your work on clayGL. I have learned a lot from it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants