Heya - has anyone come across a problem that as your scene grows (cryptovoxels is loaded as you explore the world), PushMaterial starts taking an inordinate amount of time?
I’ve been digging into PushMaterial#constructor and Material#constructor and can’t see anything in there that would take so much time - am I missing something?
We’re using our own material class like this:
const material = new BoundMaterial('feature/image', this.scene)
material.bindMesh(this.mesh)
material.diffuseTexture = texture
material.alpha = 0.999
material.specularColor.set(0, 0, 0)
material.emissiveColor.set(1, 1, 1)
The thing is that getMaterialByID is looping over all existing materials in the scene until a match is found, if any. So there is always at least a full loop done over the existing materials when creating a new material. Maybe we should add a parameter to the Material constructor to allow disabling this loop? It was added some weeks ago to be sure to have unique material ids, but if people don’t want that / know they have unique ids in the first place they could save some performances.