Different Events Do Not Work in The Same Object

Hello to everyone.

I’m with you again with a crazy question. I have a complex object imported from my project. I’ll add this object to the scene as much as the user wants. See the example below. The front-end sail is clickable. Why does this click event not work correctly when I add two or more objects to the stage? Here is the sample playground. When you review the codes and click on the front sail, you will understand the problem. How can I solve this problem? I would also like to know if there is a different and more beautiful way to call the same object :grin:


I don’t know if it’s true, but when I change the name of the object I get with getMeshByName, the problem seems to be solved.

        obje128 = scene.getMeshByName("obje128");
        //Pay attention to this line.
        obje128.name = "newName";
        obje128.isPickable = true;

Here is the sample playground: Playground

Is this the right solution? Is there another way?

The problem comes from the fact that both meshes have the same name.
So when you call getMeshByName you always get the first one only.

Your fix is ok as you rename the first one so the second one can be reached as he will be the only one with the name “obje128”.

Here is another idea:

1 Like

Thank you for the answers, I love this family :sweat_smile: :smile:

1 Like