Renderer memory texture dispose problems

Hey guys! I’m trying to optimize my scene, and while I tried to check renderer.info.memory.textures I realized that it’s constantly growing.

Background:

  • I want to create a 3D scene with many online users. Since users can choose between many characters I created a model map, where once a new character is joining I load the model from the disk.
  • If a new character joins with the same model (which already was loaded) I’m using SkeletonUtils’ clone function. (So I think nothing special)
  • Once a user leaves the server I run through the model and dispose everything I find.

The real puzzler is that the renderer.info.memory.texture still growing, hence I don’t have any textures on the model.
Since I don’t have any textures I can’t remove them.

//Get the model from my map
const model = await this.objectLoader.characterLoader(player.character);
const clonedModel = <THREE.Group>SkeletonUtils.clone(model.scene);

const character = new OnlineCharacter(sessionId, clonedModel, model.animations, player.name, initialPosition, initialQuaternion, player.state);

Once the user leaves the server, dispose everything:

private dispose(): void
{
	this.model.traverse((object: THREE.Object3D) => {
		if (!object.isMesh) return

		console.log('dispose geometry!')
		object.geometry.dispose()

		if (object.material.isMaterial) {
			this.cleanMaterial(object.material)
		}

	})
}

private cleanMaterial(material: THREE.Material) {
	console.log("dispose material");
	material.dispose();

	// dispose textures
	Object.values(material).forEach(property => {
		if (property && property.isTexture) {
			console.log("dispose texture"); // But I don't have any textures!
			property.dispose();
		}
	});
}

After the user left the server the geometries are cleared, but the texture info stays the same.
I created a load tester where I joined 200 user (with the same model!) to the server, and after that I had ~1400 loaded textures but only one active user.

image


So my question is that it’s only a display problem or somewhere I have these textures and I need to clean them somehow?


Another interesting question is that my draw calls increased (of course) while the 200 users were loaded to the scene. I know I could use instancing but not every user will have the same models.
I need to accept the fact that many users mean many draw calls or there is some magic I can use here?

I got my models from Quaternius: Quaternius • Ultimate Animated Character Pack