hulahula Posted July 1, 2018 Share Posted July 1, 2018 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. ? Quote Link to comment Share on other sites More sharing options...
jeke Posted July 1, 2018 Share Posted July 1, 2018 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; } }); Quote Link to comment Share on other sites More sharing options...
hulahula Posted July 1, 2018 Author Share Posted July 1, 2018 no it doesn't works? ok it works now I forgot use this code? : var mySuperMaterial = new BABYLON.StandardMaterial("haha", scene); myObj.material = mySuperMaterial; myObj.material.alpha = 0; jeke 1 Quote Link to comment Share on other sites More sharing options...
jeke Posted July 1, 2018 Share Posted July 1, 2018 That was going to be my next suggestion. Nice work! Quote Link to comment Share on other sites More sharing options...
hulahula Posted July 1, 2018 Author Share Posted July 1, 2018 No I have other issue myObj is now white. Quote Link to comment Share on other sites More sharing options...
jeke Posted July 1, 2018 Share Posted July 1, 2018 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. Quote Link to comment Share on other sites More sharing options...
hulahula Posted July 2, 2018 Author Share Posted July 2, 2018 so I found other solution : https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered I used .visibility and it works like the .alpha... for now... I leave this issue open yet, because I am not 100% sure. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.