aaa Posted December 1, 2017 Share Posted December 1, 2017 Helo i have a list of element populated form user database and i want to make their 3d representation in webgl or babylon.js I want to changing the object color depending to the user data from list I mean to set color green for object were there id or name are present in this list and set red for those absent How can i make this please ? Quote Link to comment Share on other sites More sharing options...
brianzinn Posted December 1, 2017 Share Posted December 1, 2017 You would set the material of the mesh with the one that has the right color. I made a PG (playground) for you:https://www.babylonjs-playground.com/#GPC38X#1 So, I made an array with only one mesh in it: var redMeshes = ['ribbon'] Then if it was in that array I used a different material (line 80). So, since 'box' wasn't in the list it ended up a different colour. There is a Set that can be used instead of an array ['ribbon'], but is perhaps more advanced. edit: just re-read your question, so I got green/red backwards, but hopefully that makes sense. Sebavan and aaa 1 1 Quote Link to comment Share on other sites More sharing options...
aaa Posted December 2, 2017 Author Share Posted December 2, 2017 Thank you @brianzinn this was interesting i appreciate your help this has solved well my problem it was aboute retrieving data from extra source like json or database and to set mention absent object by making their color on red thankyou again brianzinn 1 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.