Jump to content

Babylon.js change object color from user list


aaa
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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.

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