Jump to content

Identifying and contoling mesh


Recommended Posts

Hi there, i am a Bab3D junior.

I was wondering how do i identify and control an imported mesh i.e. (newMeshes[0].position.x=100;)

My mesh is newMeshes[0] other meshes [1] [2] etc.

myMesh = newMeshes[0];

myMesh.position=''; //Babylon

myMesh.css("display","none"); //jQuery object.style.opacity




Link to comment
Share on other sites

@Mpman hy there and welcome to Bjs, you can use var mesh = scene.getMeshById("put the name of the mesh you need here);

you can use the debugLayer to find the submeshes in your imported mesh, you can find the name of the mesh that you want there.

The debugLayer is really a great tool for this

Link to comment
Share on other sites

Hi Mpman,

If the imported meshes are from the SceneLoader then you can change their properties after loading:

BABYLON.SceneLoader.ImportMesh("", "/dir/", "file.obj", scene, function (loadedMeshes) {
  loadedMeshes.forEach(function(loadedMesh) {
    console.log(`loaded ${loadedMesh.name}`, loadedMesh)

If you want to hide a mesh instead of using css, try to set it's visibility property to 0.  So, in the code above you could do:

if (loadedMesh.name === 'hideme' ) {
  loadedMesh.visibility = 0

If you share the file you are importing and where you are stuck we can be more helpful.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...