Alenvei

Exported file transparency issue.

Recommended Posts

Hi guys 😀

I have one question about exported .babylon file. Is it posibel chagne alpha(transparency)  of exported .babylon file? I want to make it slowly disepeat or sotmhig like that.

When i change the aplha to 0 nothing happens.

BABYLON.SceneLoader.ImportMesh("", "textures", "myObj.babylon", scene, function (newMeshes) {
  var myObj = newMeshes[0];
      myObj.alpha = 0; 
}

So I looked in the exported property whith console.log(myObj).

BABYLON.SceneLoader.ImportMesh("", "textures", "myObj.babylon", scene, function (newMeshes) {
  var myObj = newMeshes[0];
      console.log(myObj);
}

it shows me, that alpha is set NaN. And when I again change the alpha to 0 and looked in the property ... alpha was set  0 but again nothing happens.

Why is like that ?

Sorry for my bad english. 😁

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

Hey,

I believe you want to change the alpha on the material for the mesh, not the mesh itself.

https://doc.babylonjs.com/babylon101/materials#transparent-color-example

So your code would look something like this:

BABYLON.SceneLoader.ImportMesh("", "textures", "myObj.babylon", scene, function (newMeshes) {
  var myObj = newMeshes[0];
      if(myObj.material)
      {
          myObj.material.alpha = 0; 
      }
});

 

Share this post


Link to post
Share on other sites

You could either use the inspector: https://doc.babylonjs.com/how_to/debug_layer or console.log(myObj.material) to look at what materials are coming in with your mesh without putting a new StandardMaterial onto them.

My guess is that they are coming in with materials and you just need to set the alpha on them.

If you could upload the myObj.babylon file I could take a look.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.