I am trying to make a MMORPG. Being an MMORPG i have a big issue on quantity of avatars on screen. I already created a method of creating avatars when i am close and removing it when i am not looking.
I created a FBX file of an avatar that consists on 24 skinnedmeshes connected to a skeleton.
When i loaded the FBX file i had this situation on memory:
before avatar
memory-56525020 (from window.performance.memory.usedJSHeapSize)
textures-0
geometries-0
calls-0
triangles-0
After making a clone() of this loaded group and removing 11 pieces of clothes from the original file (with methods removeFromParent() and clear() on each cloth i wanted to remove) i had this situation:
after avatar
memory-58392564
textures-13
geometries-13
calls-13
triangles-12384
this is nice. I managed to get from the 24 meshes i had on my file only 13 on render.
Issue came when i tried to delete this 13 objects from render. Here is my code:
removeAvatar:function(){
if (this._threeObj){
this._threeObj.traverse(object => {
if (!object.isMesh) return
console.log('dispose geometry!')
object.geometry.dispose()
if (object.material.isMaterial) {
console.log('dispose material!')
object.material.dispose()
// dispose textures
for (const key of Object.keys(object.material)) {
const value = object.material[key]
if (value && typeof value === 'object' && 'minFilter' in value) {
console.log('dispose texture!')
value.dispose()
}
}
} else {
// an array of materials
for (const material of object.material) {
console.log('dispose material!')
object.material.dispose()
// dispose textures
for (const key of Object.keys(object.material)) {
const value = object.material[key]
if (value && typeof value === 'object' && 'minFilter' in value) {
console.log('dispose texture!')
value.dispose()
}
}
}
}
})
this._threeObj.clear()
this._threeObj.removeFromParent ()
}
},
Notice i dispose of every geometry and every material.
Still…after this procedure i get this result:
after avatar removal
memory-60624016
textures-13
geometries-13
calls-0
triangles-0
I have an increase of memory consumption and it didnt remove geometries or textures from render.
Notice: MY FBX dont have textures. I checked each material and it didnt have textures in it…only colors.
So whats wrong here?