Jump to content

objFileLoader: alpha of material not recognized


Recommended Posts

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?


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 () {
       if (frame == 100) {
         var mbyname = demo.scene.getMaterialByName("Mat1"); <== OK , Material is bound to the mesh



Link to comment
Share on other sites

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.

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...