javalang Posted April 9, 2017 Share Posted April 9, 2017 Hi, I've some trouble though debugging so much..I have an obj/mtl file and the mesh and textutre is basically loading well, so far so good. But the texture (png) is an alpha image and this isn't transparent after loading. This is technically OK because there is no implementation inside objFileLoader for this case. I just want to set mesh.material.diffuseTexture.hasAlpha = true in the success-callbak of the ImportMesh-function , but the material isn't bound at this time. So, where to set "hasAlpha=true" , at which time is the material bound to the mesh? Thanks PS: I can enable it in the render loop (hack, because it's undeterminable how much frames I must wait), I also can activate hasAlpha with the DebugLayer manually BABYLON.SceneLoader.ImportMesh("", "blabla", "blabla.obj", scene, function (meshes) { var m = meshes[0]; m.material <== NOT AVAILABLE scene.getMaterialByName("Mat1"); <== scene.materials==empty }); scene.registerBeforeRender(function () { frame++; if (frame == 100) { var mbyname = demo.scene.getMaterialByName("Mat1"); <== OK , Material is bound to the mesh } Quote Link to comment Share on other sites More sharing options...
RedMax Posted April 10, 2017 Share Posted April 10, 2017 I do something like this within the ImportMesh callback. Are you sure that meshes[0] is the one you want and not just one empty parent mesh? In my code I can access m.material there without any problem, if it's not an empty dummy mesh. Quote Link to comment Share on other sites More sharing options...
javalang Posted April 11, 2017 Author Share Posted April 11, 2017 yes I'm sure, I have doublechecked it and several frames later the material can be changed without errors. It seems that there is another async task behind. see demo 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.