Imported mesh scaling not working

I want to change the scale of the imported mesh. This works in the playground simplified example using either:

meshes[0].scaling = new BABYLON.Vector3(1.25, 0.25, 0.25);
or
meshes[0].scaling.x = .5;

But it won’t work in my local solution. I wondered if there could be some kind of conflict or something I’m missing.

https://www.babylonjs-playground.com/#YIU90M#123

Thank you!

That will be hard to tell for us if you can’t reproduce the problem with a playground…

Maybe try to call computeWorldMatrix() on your mesh (after you change the scaling), in case it would not be computed automatically…

1 Like

Make sure you didn’t call freezeWorldMatrix on the mesh

Or call unfreezeWorldMatrix first

1 Like

Thanks for the help folks, I tried both of these with no luck so may need to put a playground together

What’s the issue? Babylon.js Playground
This works

Not to be preachy, but scaling of a single mesh at run time can cause all kinds of problems. These are usually based on the fact different meshes have their own origin, & location. If you can take the time to bake all the scales of meshes which are not (1, 1, 1) prior to export, I would do that.

For work which might at some point will go into a WebXR scene / device, I would standardize all meshes to look correct when viewed in a meter scaled scene. Reason being, as the person walks through the scene, the camera will be advanced by the headset hardware in terms of meters.

Hey @ryannewelluk…would love to help.

I just tried scaling an asset in one of my own local projects and it worked just fine…same as @Givo.

Let us know if there’s anything else we can do to help

Replying here because I had the same problem and found no solution on the internet, and this was the first forum post to come up.

What I had was meshes[0].position = new BABYLON.Vector3(1, 1, 1) and the position of the mesh in the scene wasnt changed, but when I did console.log(meshes[0]), I saw that it’s position was what I set it to.

What solved this problem for me, and it’s worth trying if you have the same issue, is using meshes[1] instead of meshes[0]. I downloaded my .obj file from the internet, so that might be why I needed to use mesh at index 1.

use newMeshes[0] instead of meshes. it works properly.
kindly see the image to get much more reference.

image

Hi and welcome to the Forum,
May be you noticed you replied to an old topic that should have been closed.
Although your solution might be applicable (for scaling all new meshes), there are also other (eventually better) solutions for it.
In any case, since this topic has not seen any activity for the past 9-months or something I believe it should have been closed. I think you could make better use of your time and skills answering more recent, currently ‘open’ topics. And so could I :grin:
@carolhmj, What’s your say? " Could you kindly close this topic, since I can’t?

Hmm valid, since this seems to be a very specific problem to the type of mesh people are importing, it’s better that anyone having this problem opens a new topic with a Playground reproduction of their setup