Browse Source

Geometry: Added sortFacesByMaterial(). See #7211.

Mr.doob 9 years ago
parent
commit
9ca9003e16
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/core/Geometry.js

+ 12 - 0
src/core/Geometry.js

@@ -863,6 +863,18 @@ THREE.Geometry.prototype = {
 
 	},
 
+	sortFacesByMaterial: function () {
+
+		function materialSort( a, b ) {
+
+			return a.materialIndex - b.materialIndex;
+
+		}
+
+		this.faces.sort( materialSort );
+
+	},
+
 	toJSON: function () {
 
 		var data = {