ThatOpen / engine_components

MIT License
304 stars 117 forks source link

Classifier - Last model is replacing old list values using the OBC.Classifier #403

Closed YannMermin closed 2 months ago

YannMermin commented 3 months ago

Describe the bug 📝

I am generating the model trees for all the models added into my scene. Using the classifier, I want to get the following lists :

For the first model loaded, no problem, it works fine and the lists are OK. But for all next models added into the scene, it will completly replace the previous classifier lists, and I can only access the last model's lists.

Here is the part of my code where I am getting the lists (call for all the models loaded)

`const classifier = components.get(OBC.Classifier); await classifier.dispose();

classifier.byModel(model.uuid, model);
classifier.byEntity(model);
await classifier.bySpatialStructure(model);`

Reproduction ▶️

No response

Steps to reproduce 🔢

  1. Install the @thatopen/components package
  2. Load multiple models into a scene
  3. For each models, use the OBC.Classifier with the following functions :
    • byModel
    • byEntity
    • bySpatialStructure 4.Check the values in the classifier.list, it will be only the last model loaded values.

System Info 💻

@thatopen/components - Google Chrome - React JS

Used Package Manager 📦

npm

Error Trace/Logs 📃

No response

Validations ✅

agviegas commented 2 months ago

Hi Yann! This happens because you are calling dispose(), which should be called only when your user walks away from your BIM viewer in your app to get rid of memory. If you remove that line, and only use it when you need to destroy the viewer, the issue should be solved. Let us know otherwise!