Bounding info slow update?

I was working on a test concept, and copied the Polygon example from the meshBuilder docs.

it was a little big for my needs, so i scaled it, and attempted to get the new radius.

the radius never changes for the sphere, and the diagonalLength value updates at some point in the future.

I looked through the docs, and I did not see anything that looked like an event or observable related to bounding info changes. i tried the geometry property (onGeometryUpdated) and i tried onRebuildObservable. no joy.

Two questions:

1

How can I know when the bounding info has finished re-building?

2

Why does the sphere radius never seem to change? I like using radius because often I work with round objects, and it’s pretty simple. I can change to use the diagonalLength, that’s essentially the same thing I think, but see question 1 for that :slight_smile:

PG

https://playground.babylonjs.com/#67L058#1

Bounding infos are refreshed as soon the call to refreshBoundingInfo() return, there is no delay / async operations.

The bounding sphere radius does not change because you don’t change the geometry (meaning the vertices of your polygon).

However, if you want to get the radius after the worldMatrix is applied, use .radiusWorld instead of .radius: you will see that .radiusWorld is indeed scaled by your scalingDeterminant value.

Last thing: you want to call polygon.computeWorldMatrix(); after you have set the value for scalingDeterminant, so that the bounding box infos based on world coordinates (like diagonalLength) are correct.

See: https://playground.babylonjs.com/#67L058#3

3 Likes

Thank you sir for the explanation.

Is any of this in the docs? I haven’t seen many details like this from my searching, but maybe I missed it?

I would say it not in the docs but in the source (API library also helps to understand how it works).

Well, radiusWorld is in the doc.

Being a “world” thing (like diagonalLength), it’s expected to be dependent on the world matrix being up to date when querying these values.

Regarding refreshBoundingInfo() not being async, I would say that if the docs don’t say specifically it is async (it would have, had the function been async), you should assume it’s not (anyway, it would have been strange for this function to be async).

2 Likes