I want to add and remove objects to my scene in clicks.
Simply I use scene.add(object) and scene.remove(object).
Is there any way to check whether the object is present in the scene?
When adding your object to scene, add name to that object like
object.name = 'object_name';
Then you can check if your object exist in scene by
scene.getObjectByName('object_name');
If it return any object it means object exist in scene.
Probably more efficient:
object.parent === scene
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With