How to control imported mesh?

First of all, please check this thread and demo at CharacterController Demo

As for your question how to control the mesh I’ll try to explain how it is going.

  1. You import you model (usually it is not just one mesh, but a bunch of them). Depending on your needs you may import it with simple standard function, with Asset Container, with Task Manager, with promises etc. All these ways are described in Documentation.

  2. After you import the model, you’ll need to find its Transform node in order to transform it - change position, scaling and rotation of the whole model. Here is small example how to do it - https://playground.babylonjs.com/#05Q46H#11

     BABYLON.SceneLoader.ImportMesh("", "scenes/", "skull.babylon", scene, function (newMeshes) {
     // Set the target of the camera to the first imported mesh
     camera.target = newMeshes[0];
     newMeshes[0].position.x = -20;
     newMeshes[0].scaling.y = 2;
     newMeshes.rotation.z = 1.2;    });
    

So, the function variable newMeshes[0] gets the Transform node (or root node). Actually here newMeshes is a simple array, so you will be able to find all other meshes of your model with the help of this variable.
These are just basics; please search Playground and forum for more examples since this is very popular question. You can also upload your model to Sandbox, open the Inspector and find all nodes of your model with their names, IDs etc.
Here is another example with WASD control and animation - https://www.babylonjs-playground.com/#15EY4F#15

4 Likes