https://www.babylonjs-playground.com/#WG3JQT
It seems odd to me that when I scale a mesh, in the bounding info, the extendsSize is 1 and the extendsSizeWorld is 2.
It seems as if the scale only gets applied to the world properties (minimumWorld, maximumWorld, extendsSizeWorld). Is this intentional? Also, even after applying a scale, the scaling determinant is 1. What does that effect?
Thanks!
The bounding info will be updated after a call to mesh.computeWorldMatrix()
Updated playground: https://www.babylonjs-playground.com/#WG3JQT#1
Still seems to have weird behavior where only the world properties take into account the scale
Oh I misunderstood your ask. Yes this is how it is supposed to work
minimum and maxium are in object space. Setting scaling, rotation or position will update the world matrix and then update the word values of the bounding info
Just out of curiosity, what is the reasoning? To my knowledge, the local “extent” of a bounding box should describe how far that object extends in local space. So in the playground attached, the sphere, since it has no parent, should have identical local and world extents. Is there a benefit to not having the scaling built in to the local bounds?
scaling is part of the world transform. The sphere has a diameter of 2 so its object space bouding box is from -1,-1,-1 to 1,1,1.
When you set a scale, that does not change the inner nature of the sphere. It is still a sphere with a diameter of 2 which gets scaled into the world by 2 on x axis ending up having this bounding box in the world:
if you want to force the change to be in object space, you can use
sphere.bakeCurrentTransformIntoVertices();
https://www.babylonjs-playground.com/#WG3JQT#2
and then the vertices will be updated and thus the object space will be changed:
1 Like
Ah that makes sense. Thank you!
Hello,
If I can build from that… is it possible to quickly scale an object without specifying every time the scale axis?
On a test model I wrote like this
const chair = BABYLON.SceneLoader.ImportMeshAsync (“”, “https://madquake.github.io/babylon/”, “chair.glb”).then((result) => {
result.meshes[0].position.x = 0;
var scalee = 0.2;
result.meshes[0].scaling.x = scalee;
result.meshes[0].scaling.y = scalee;
result.meshes[0].scaling.z = scalee;
});
Is there a way to scale everything in one go?
Something like:
result.meshes[0].scaling[x, y, z] = 1.5;
Thank you!!!
Hi @Madquake, this might be a little late but there is a way to achieve what you want.
The scaling property of a Mesh is a Vector3 object, so you can simply set it in one line by assigning it a new Vector3 with the desired scaling values, like this :
result.meshes[0].scaling = new BABYLON.Vector3(1.5, 1.5, 1.5);