Bounding Box - World Center

When getting the World Center (and world max, world min, etc) of a bounding box for a mesh I would expect to coordinates to be in world space but they are not. See the following:

I console out the world center of the bounding box at three different instances:
1: Right after I create the box. It is 0,0,0 as expected
2: Right after I set the box as a child of the root object. The root object is at 1,1,1 and I zero out the local position of the box so it’s global position is now 1,1,1. This also prints the world center as 0,0,0 but I expect it to be 1,1,1
3: Finally I un-parent the box and print the world center again. This time it is 1,1,1, as expected.

Bug or am I misunderstanding something?

You have written the code but the actions have not yet been carried out. What you see rendered on the canvas screen is the result of your code having been actioned. It is during the rendering process that any calculations are made as a result of your code. This includes updating the world matrix for your box.

The print out in the console log is done before any rendering so before any calculations on the code. You can force the calculations on the world matrix using computeWorldMatrix as in


Ah! That makes sense. Thanks.