Jump to content

meshes get same material


trollolloo
 Share

Recommended Posts

I'm using BabylonJS V3 with Blender 2.79 to create product visualizations. Many times, it is necessary for me to define more complex shaders in the JS code. I'm using lines like 

scene.meshes[1].material.emissiveColor = new BABYLON.Color3(1, 0, 0);

to define the shaders after export. Usually every mesh can get it's own shader this way. Unfortunately, I can't get it to work somehow. Even in small test scenes (one red icosphere, one green cube, a hemi lamp and a camera), both objects get the same material. When trying to change the appearance like shown above, both meshes change color.

When I navigate the camera, so that one object isn't visible, the right material gets loaded (green, in my sample scene). Here is a small video of the strange behavior: https://imgur.com/a/zYlLT

Both blender meshes have individual datablocks and individual materials. No duplication, instancing ...

Do the mesh indices change, when a mesh gets unloaded? Where could I have made the mistake? In blender or in my .js?

I am greatful for every hint!

Link to comment
Share on other sites

This probably won't get to the root of the problem, but did you try something like:

scene.meshes[1].material = scene.meshes[1].material.clone()
scene.meshes[1].emmissiveColor = ...

Just to make sure they aren't the same material - otherwise they should change color independently.  Possibly you have merged the meshes, in which case they would share the same material.

Link to comment
Share on other sites

Thank you all for your suggestions! Unfortunately, the problem still remains.

@brianzinn, adding material.clone() only made changes to the initial state of the materials. But both materials get changed by one line of code, and also the "old" (blender defined) material is loaded, when the other object leaves the screen.

@JCPalmer, it also happens without any changes to the material. Meshes seem to be "combined" (or materials linked) without any apparent reason. In my test scene this is true for both icospheres, in more complex scenes, several objects seem to be "combined".

I really don't know what is going on there, the problem never occurred before. I attached the test scene as blender file and our current framework. For the upload, I stripped out all products (for legal reasons) and only left the testscene in our framework. The materials for the ico spheres can be changed in line 119 in the tx-cgi.js file.

Right now, the changes in the .js file seem to have no effect on the spheres, for reasons I don't understand either. I am quite helpless right now, I hope you can make sense of the test scene.

babylon.zip

Link to comment
Share on other sites

Your framework does not concern me.  I looked at your .blend & .babylon.  I also loaded your .babylon in sandbox & zoomed so the spheres disappear, but nothing turns green.

Your .babylon is just 2 separate meshes, each referencing a separate standard material.  I think this is a down stream problem.  Kind of reminds me of the Firxfox "things turn green" bug.  I have not been updating my FireFox in a while for that reason. 

Sorry.

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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