N00b question on why calling .x on Vector3 shows different values in console log

I have a left wall, right wall and floor in my scene. I have a left shelf which is attached to the left wall.

Now, I’m trying to place objects on the left shelf. For that I wanted to get the bottom corner of the shelf for which I did

leftShelf.getBoundingInfo().boundingBox.minimumWorld.x

I also tried vectorsWorld[0].x

Now the console.log of leftShelf.getBoundingInfo().boundingBox.minimumWorld gives me a Vector3 with (-6,2.9,-5) as seen in the screenshot but console logging the .x function i.e. leftShelf.getBoundingInfo().boundingBox.minimumWorld.x on the Vector3 results in value of -1 and not -6.

I can’t figure out what I’m doing wrong. Any help?

It is because it has not been computed yet at the time you log and then later on the internal value changes on the first rendered frame.

So your console shows the value at the time you expand the object (after the first frame hence computed 6) whilst the .x will display the actual value before computation so -1.

You can force computing the bounding info before logging by calling computeWorldMatrix() https://playground.babylonjs.com/#KBS9I5#21608

2 Likes

Hello just checking in, was your question answered? @evidanary

yes it was

1 Like