I now generate the directory tree by reading json in the scene, but only some paths and file names are in json, so when I remove the node, I want to delete the corresponding mesh, but I have a problem. I can only remove the path of the mesh, but the model still exists in the scene, so what should I do?
Hi RW. If I understand correctly, you have no good name for mesh to be disposed, so you cannot do scene.getMeshByName(“that_mesh_name”).setEnabled(false); [or maybe.dispose()]
As scene is built… BJS assigns numbers to each bjsNode created… called .uniqueId
During scene/file loading, could YOU build a database (arrays) that store the uniqueId’s for each loaded bjsNode? (a light, mesh, or camera)
Scene object has helper called getMeshByUniqueID(uniqueId)… it could help you look-up which mesh were loaded in which path/file. Warning: Be mindful of capital-letters/lowercase-letters for ‘id’.
In simple words, during load… YOU build database of uniqueId’s for each loaded mesh for each path/file. Then when you turn-off htmlNode, you somehow find WHICH arrayOfUniqueIds… to iterate-thru, and disable/dispose all mesh in THAT arrayOfUniqueIds.
I dunno if this would work well, or not. Just an idea. BJS adds numeric bjsNode.uniqueId automatically, as scene loads. It’s like automatic naming… but you need to store those numbers somehow, during the onSuccess area of EACH loaded file. Then you know which uniqueId’s arrived in which files.
Another thing you should look-at… is renderingGroupId. Perhaps you could have 255 renderingGroups. Remove one htmlNode, and ITS renderingGroup could be disposed/disabled. Not sure about this… read and test.
Lastly, each bjsNode (light, mesh, cam)… has an .id property (a string), and a .metadata property (ANY data type). SO, again, AS the mesh loads-in, YOU can set values for these (inside EACH file-load onSuccess area).
Later… you can use scene.getMeshById() and/or scene.getMeshesById() [returns an array of meshes, for when you have given MANY meshes… the same .id]. You can iterate thru those, disabling/disposing all mesh with THAT .id.
There is no scene.getMeshByMetadata()… sorry. .metadata is a property you can use for whatever you wish. It is like a suitcase that the bjsNode (cam, light, mesh) carries with it.
And there is the BJS Tags System, which is a powerful pattern-matching regexp-ish… search for nodes with certain tags/tag-text-patterns. I know little about that.
I dunno if ANY of this… helps you. As mesh load-in, YOU have the power to set .name, .id, .metadata… on all loaded things. But remember that .uniqueId… is set to a number automatically during the load-in. No other bjsNode in the scene… will have that same number.
I hope I understand topic.