computeGroups is not optimized to get minimum count of group

 for ( var i = 0; i < faces.length; i ++ ) {

			var face = faces[ i ];

			// materials

			if ( face.materialIndex !== materialIndex ) {

				materialIndex = face.materialIndex;

				if ( group !== undefined ) {

					group.count = ( i * 3 ) - group.start;
					groups.push( group );


				group = {
					start: i * 3,
					materialIndex: materialIndex



In this code of geometry, if faces are not sorted by materialIndex (by some reason), computeGroups create many groups with same materialIndex.
==> Bad performance of rendering.

Three.js version
  • r85
  • All of them
  • All of them
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “computeGroups is not optimized to get minimum count of group

  1. @whatisor
    sorting costs time. If you geometry is properly sorted ahead of time – you don’t have to pay that price. Having poor performance on poorly optimized meshes makes sense to me, based on your needs – you can optimize a mesh when you load it. In some cases it might make sense to just wrap standard model loader and sort faces every time, like you suggested.
    For my use cases – i prefer to have optimized models that take as little time to load as possible.

Comments are closed.