I have created several hundred instances of houses in my scene (using Mesh.createInstance). I want to only delete the houses, excluding other meshes like the terrain for example.
What is the best way to do this without having to remember the houses that I created? Is there anything like a “layer” concept so that BJS could delete all meshes on a certain layer? I could assign a layer to the houses and I would then simply delete everything on that layer.
when you want to save everything to a layer, why not just saving it to an array? While creating the instances you can make housesArray.push(house) and when you want to delete all houses you just do housesArray.forEach(function (house){house.dispose();});
I agree with @CLB_ZReality, it seems best to track this yourself via an array or other datastructure and create methods to manage them.
When you load your mesh into the scene, there is no concept of what type of mesh it is or “layer” it should belong to (unlike an authoring program where this is more significant), that type of logic seems best left to the business logic to manage itself, rather than the engine.