We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Setting different colors for multiple objects

Home Forums Programming Setting different colors for multiple objects

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26710
    web
    Customer

    I’m wondering what is the best and most efficent way to set diffuse color for multiple objects programmatically.

    To be more precise:
    I got around 480-520 objects which are named unique. The all got the same material applied. After a certain user interaction I need to “group” these objects. Therefor I got an array with 4 different colors. These colors need to be applied to all the objects by their names. It is also necessary to apply the inital material after a certain user interaction.

    My current approach would be, to create 4 new materials (directly in js) with the different colors I need. And then apply each material to the appropriate object.
    When I dont need the colors anymore I would simply apply the intial material.

    Would this be the best way, or are there other approaches?

    #26720

    I think it should work well! :good:

    Chief 3D Verger | LinkedIn | Twitter

    #26738
    web
    Customer

    For the moment I created a new material for each object. Works so far.
    Just not sure if this will make the scene slow at some point, when this function is executed several times.

    #26787

    it’s ok to run this multiple times – it is a key to not perform heavy operations every frame

    Chief 3D Verger | LinkedIn | Twitter

    #26920
    Xen Wildman
    Customer

    You could also consider vertex color.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.