I want to load a model and maintain the same unique id whenever loaded. When I unload a model, I remove it and dispose of the mesh geometry and mesh material and call localStorage.clear(). But when I reload the model the unique ids for all the meshes are different. The only way I can get the same id on each load is to also call location.reload(true). But I don't want to reload because in angular the entire application will restart. Any suggestions on how to clear the memory threejs uses in order to get reusable ids? Thanks in advance!
0
votes
1 Answers
1
votes
Three.js automatically assigns UUIDs to objects. However, there's no reason why you cannot overwrite this value:
const staticID = "9B60F750-C64F-433A-8C1E-9E88639DC503";
onLoad(object) {
object.uuid = staticID;
}
That way, each time you load your Object3D, it'll have the same "unique" ID as last time.
Object3D.toJSON()tothree.js's JSON format. When you useObjectLoaderfor loading, the same UUIDs are restored. - Mugen87