Matrakatak
Matrakatak

Reputation: 25

THREE.js - Change property of one, all object change

I have an issue. I put properties in my spheres array as opacity/visible etc.. When (in MouseDown event) I want change only one sphere property, but all of them change. I don't understand why... I describe you my part of code.

for (var i = 0; i < data.nodes.length; i++) 
        {
         //coordinates of spheres and others properties
         spheres[i].material.transparent=true;
         spheres[i].material.opacity=0.2;
         scene.add(spheres[i]);
         force.start();
         }
         spheres[anyone].material.opacity=0.8;

sorry, but my English is not very good. Thank you in advance!

Upvotes: 0

Views: 176

Answers (1)

2pha
2pha

Reputation: 10155

I suspect it is due to all the spheres using the same material instance, therefore changing one will change them all.
Adding unique materials to each of your spheres will probably overcome your problem.

Upvotes: 2

Related Questions