babbleon Posted June 6, 2018 Share Posted June 6, 2018 Hello, I have this function to remove certain meshes & materials: function removePiece(rand) { var meshes = scene.getMeshesByTags('mesh' + rand); for (var i = 0; i < meshes.length; i++) { console.log(meshes[i].name); meshes[i].dispose(); } var materials = scene.getMaterialByTags('material' + rand); for (var i = 0; i < materials.length; i++) { console.log(materials[i].name); materials[i].dispose(); } } I have added tags to the textures, but as we don't seem to have a getTexturesByTags it's probably not the right way. Does anyone have a bright idea how do I go about removing textures? Thank you, Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted June 6, 2018 Share Posted June 6, 2018 Hello Babbleon ! I don't know about dealing with Texture only, but the dispose method of material accepts additionnal parameters to force the dispose of textures. Take a look at : https://doc.babylonjs.com/api/classes/babylon.material#dispose babbleon 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted June 6, 2018 Author Share Posted June 6, 2018 Great! Thank you @Amarth2Estel, Works a treat. Solved! function removePiece(rand) { var meshes = scene.getMeshesByTags('mesh' + rand); for (var i = 0; i < meshes.length; i++) { console.log(meshes[i].name); meshes[i].dispose(); } var materials = scene.getMaterialByTags('material' + rand); for (var i = 0; i < materials.length; i++) { console.log(materials[i].name); materials[i].dispose(false, true); } } Amarth2Estel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.