No transformation in imported meshes

when i import a mesh from blender the methods of transformation like mesh.position.x and mesh.scaling.y … are not working .those are the right methods to use ? do i forget something ? please help me , i’m searching in about 6 hours

Hey @everything_mokrane! Welcome to the Babylon family! We’re sincerely glad you’re here!

Can you please provide us with a playground example of what’s going wrong?

Some more information would also be helpful. How are you getting your assets from Blender into Babylon? Are you exporting .gltf/.glb files out of Blender using the included exporter? Or some other method?

Thanks!

yes of course .
https://playground.babylonjs.com/#WRW3TI
as u can see. how i can reposition or scale or rotate an imported mesh?
and thank you so much for your time

Thank you! That’s very helpful!

As you can see in this version of the playground. https://playground.babylonjs.com/#WRW3TI#1

I’m writing the result of “importedMesh” to the console.

Doing so shows you this:

image

importedMesh is NOT a mesh, it is a promise…a collection of things that are returned.

What you’re after are the meshes inside of this promise:

I think this playground is what you want:
https://playground.babylonjs.com/#WRW3TI#3

Notice a couple of things.

  1. In line 1 I’m setting the createScene function to be an asynchronous function.
var createScene = async function () {

This is because you have chosen to use the “importMeshAsync” method for loading your asset into the scene. This method of loading will wait until this line has completed before continuing, but it will ONLY do-so if the entire encapsulating function is set to async.

  1. For line 16, I also made a change to enable waiting on the load to happen:
    const importedMesh = await BABYLON.SceneLoader.ImportMeshAsync("","https://assets.babylonjs.com/meshes/","box.babylon",scene);

Notice that I’m using the “await” before calling the new class.

This is the second step that’s necessary to use the ImportMeshAsync method.

  1. Finally since the importMeshAsync method returns a promise as I mentioned above, you need to dig into the promise to find the mesh. So line 17 is now correctly written to do what you were attempting to do - move the x position of the imported box 1.4 units.
importedMesh.meshes[0].position.x = 1.4;

Hopefully that helps steer you in the right direction. Again welcome to the family!!!

3 Likes

W0000000t @PirateJC is a coding GURU !!! GG

2 Likes

get it , what can i say . thank so much . i really really appreciated

2 Likes