Rotating Imported Blender Mesh?

Hi,

I am trying to import a blender mesh in .glb format. I can successfully import it using the following function:

            // Import table from Blender file
            function importPicnicTable() {
                var picnicTable = BABYLON.SceneLoader.ImportMesh("Wooden Table", "models/", "table.glb", scene, function (meshes) {
                    scene.createDefaultCameraOrLight(false,false,false);
                });
                picnicTable.rotation = new BABYLON.Vector3(0, 1.5708, 0);

            }
            importPicnicTable();

However, when trying to rotate or do any other operations on it, nothing happens. Does anyone have any idea why this is happening?

Thanks!

1 Like

When you import meshes it’ll appear as an array with the first element being the “root”. You’d have to use meshes[0] if you want to rotate everything.

Try this:
meshes[0].rotation = new BABYLON.Vector3(0, 1.5708, 0);

You can do this within the successCallback you provided. If you have multiple meshes you’d have to specify which mesh within the meshes array to rotate, such as “meshes[2]”. Hope that helps!

2 Likes