Hi,
I have a little problem getBoundingInfo().boundingSphere.radiusWorld.
My box has a width of 1:
let radius = box.getBoundingInfo().boundingSphere.radiusWorld;
→ radius = 1.1874342087037917;
That’s OK.
Now I do the following:
box.scaling.x = 3;
let radius = box.getBoundingInfo().boundingSphere.radiusWorld;
→ radius = 1.1874342087037917;
That’s not OK, radius should be 3.562302626111375
I know I must use box.computeWorldMatrix(true) to get the right result
→ radius=3.562302626111375
Is this by design or why does getBoundingInfo() does not take the scaling into account?
Hey @Pe443,
Are you checking the getBoundingInfo exactly after setting the scalling box.scaling.x?
Or you do the check after the engine rendering loop make at least one step?
Hi,
II must do the check direct after the scale, the scene is NOT rendert.
This is because I have to calculate postions and so of other meshes bevor the scne is renderd.
Especially I need this for placing objects BEVOR the first rendering of a scene.
No this topic is why getBoundingInfo does give a wrong number and why?
For me it makes no sense to use computeWorldMatrix every time, or lets say, why must the scene be rendred bevor I can get getBoundingInfo().
We understand what the topic is about. The why? is explained by the link I gave.
When you have
box.scaling.x = 3
all this does is assign the value 3 to the x property of the scaling property of the box to 3.
No ‘scaling’ of the box takes place because no code has been called to do that. So no change has been made to the bounding info yet.
The code to do the ‘scaling’ comes when the following code is called
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function () {
scene.render();
});
Since there will be times, as in your case, when you want the ‘scaling’ or whatever to be in place before any rendering then Babylon.js exposes the computeWorldMatrix as a method so you can call it and have the ‘scaling’ take place as you require and the bounding info will be up to date.