@@ -29,8 +29,6 @@ var Systems = new Class({
2929 this . config = config ;
3030 this . settings = Settings . create ( config ) ;
3131
32- this . sortChildrenFlag = false ;
33-
3432 // Set by the GlobalSceneManager
3533 this . canvas ;
3634 this . context ;
@@ -157,37 +155,23 @@ var Systems = new Class({
157155 return ;
158156 }
159157
160- // inlined to avoid branching
161- if ( this . sortChildrenFlag )
162- {
163- StableSort . inplace ( this . displayList . list , this . sortZ ) ;
158+ var displayList = this . displayList ;
164159
165- this . sortChildrenFlag = false ;
166- }
160+ displayList . process ( ) ;
167161
168- this . cameras . render ( renderer , this . displayList , interpolation ) ;
162+ this . cameras . render ( renderer , displayList , interpolation ) ;
169163 } ,
170164
171165 // Force a sort of the display list on the next render
172166 queueDepthSort : function ( )
173167 {
174- this . sortChildrenFlag = true ;
168+ this . displayList . queueDepthSort ( ) ;
175169 } ,
176170
177171 // Immediately sorts the display list if the flag is set
178172 depthSort : function ( )
179173 {
180- if ( this . sortChildrenFlag )
181- {
182- StableSort . inplace ( this . displayList . list , this . sortZ ) ;
183-
184- this . sortChildrenFlag = false ;
185- }
186- } ,
187-
188- sortZ : function ( childA , childB )
189- {
190- return childA . _depth - childB . _depth ;
174+ this . displayList . depthSort ( ) ;
191175 } ,
192176
193177 // A paused Scene still renders, it just doesn't run ANY of its update handlers or systems
0 commit comments