Find primitives objects by id

Hi
In my application i’m getting data from the server using web sockets.

I’m using the data to create primitives and add them to the map (with id).

I’m now looking for a way to get the primitive instance in order to update/delete.

I can’t seem to find a getbyid function for primitives, is there another way to get it ?

Thanks

Nirko

Nirko,

You can either store the primitive’s index with the id and then use get(index) or keep a separate object that maps ids to primitives, e.g., primitivesById[id] = primitive. If the ids are small, I recommend the later because it is future-proof.

Patrick