Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is recommended to mention the name field in the documentation #22

Open
wang1212 opened this issue Mar 31, 2023 · 1 comment
Open

Comments

@wang1212
Copy link

A common programming idiom is to call add() when the object (interactive) is created, and then call remove() when the object is destroyed.

However, due to the lack of understanding of the source code details, if the name field of the object is not assigned, it will cause all objects called remove() to be removed.

https://github.com/markuslerner/THREE.Interactive/blob/v1.6.1/src/index.ts#L223

remove() {
   if (!object) return;
   const filterSet = new Set<string>(
     childNames.length > 0 ? childNames : [object.name]  // If `name` is `undefined` ?
   );

  this.interactiveObjects = this.interactiveObjects.filter(
    (o) => !filterSet.has(o.name)  // If `name` is `undefined` ?
  );
}

So, if I understand correctly, the name field value of a 3D object should be unique? If yes, is this critical and should it be specifically mentioned in the docs?

@markuslerner
Copy link
Owner

Hi @wang1212, thank you for pointing this out. There was indeed a bug in the remove function. The intention was not to make object.name mandatory. I just published release 1.7.0, which fixes this. Now all objects, whose name is undefined won't be removed when calling InteractionManager.remove(...) with an object whose name is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants