1
1
/**
2
2
* @author mr.doob / http://mrdoob.com/
3
+ * @author alteredq / http://alteredqualia.com/
3
4
*/
4
5
5
6
THREE . Mesh = function ( geometry , material , normUVs ) {
@@ -14,8 +15,6 @@ THREE.Mesh = function ( geometry, material, normUVs ) {
14
15
15
16
this . overdraw = false ;
16
17
17
- this . materialFaceGroup = { } ;
18
- this . sortFacesByMaterial ( ) ;
19
18
if ( normUVs ) this . normalizeUVs ( ) ;
20
19
21
20
this . geometry . computeBoundingBox ( ) ;
@@ -25,81 +24,6 @@ THREE.Mesh = function ( geometry, material, normUVs ) {
25
24
THREE . Mesh . prototype = new THREE . Object3D ( ) ;
26
25
THREE . Mesh . prototype . constructor = THREE . Mesh ;
27
26
28
- THREE . Mesh . prototype . sortFacesByMaterial = function ( ) {
29
-
30
- // TODO
31
- // Should optimize by grouping faces with ColorFill / ColorStroke materials
32
- // which could then use vertex color attributes instead of each being
33
- // in its separate VBO
34
-
35
- var i , l , f , fl , face , material , vertices , mhash , ghash , hash_map = { } ;
36
-
37
- function materialHash ( material ) {
38
-
39
- var hash_array = [ ] ;
40
-
41
- for ( i = 0 , l = material . length ; i < l ; i ++ ) {
42
-
43
- if ( material [ i ] == undefined ) {
44
-
45
- hash_array . push ( "undefined" ) ;
46
-
47
- } else {
48
-
49
- hash_array . push ( material [ i ] . toString ( ) ) ;
50
-
51
- }
52
-
53
- }
54
-
55
- return hash_array . join ( '_' ) ;
56
-
57
- }
58
-
59
- for ( f = 0 , fl = this . geometry . faces . length ; f < fl ; f ++ ) {
60
-
61
- face = this . geometry . faces [ f ] ;
62
- material = face . material ;
63
-
64
- mhash = materialHash ( material ) ;
65
-
66
- if ( hash_map [ mhash ] == undefined ) {
67
-
68
- hash_map [ mhash ] = { 'hash' : mhash , 'counter' : 0 } ;
69
-
70
- }
71
-
72
- ghash = hash_map [ mhash ] . hash + '_' + hash_map [ mhash ] . counter ;
73
-
74
- if ( this . materialFaceGroup [ ghash ] == undefined ) {
75
-
76
- this . materialFaceGroup [ ghash ] = { 'faces' : [ ] , 'material' : material , 'vertices' : 0 } ;
77
-
78
- }
79
-
80
- vertices = face instanceof THREE . Face3 ? 3 : 4 ;
81
-
82
- if ( this . materialFaceGroup [ ghash ] . vertices + vertices > 65535 ) {
83
-
84
- hash_map [ mhash ] . counter += 1 ;
85
- ghash = hash_map [ mhash ] . hash + '_' + hash_map [ mhash ] . counter ;
86
-
87
- if ( this . materialFaceGroup [ ghash ] == undefined ) {
88
-
89
- this . materialFaceGroup [ ghash ] = { 'faces' : [ ] , 'material' : material , 'vertices' : 0 } ;
90
-
91
- }
92
-
93
- }
94
-
95
- this . materialFaceGroup [ ghash ] . faces . push ( f ) ;
96
- this . materialFaceGroup [ ghash ] . vertices += vertices ;
97
-
98
-
99
- }
100
-
101
- } ;
102
-
103
27
THREE . Mesh . prototype . normalizeUVs = function ( ) {
104
28
105
29
var i , il , j , jl , uvs ;
0 commit comments