11/* jshint unused: false */
22/* global console */
3- ( function ( Base , Vector , Circle ) {
3+ ( function ( Base , Vector , Logo ) {
44
55var sqrt , pow , Engine ;
66
@@ -23,15 +23,11 @@ Engine = Base.extend({
2323 scale : window . devicePixelRatio || 1 ,
2424 // scale:1,
2525
26+ shapes : [ ] ,
2627 particles : [ ] ,
27- _deferred : [ ] ,
2828
29- // points : [],
30- // polygons : [],
31- shapes : [ ] ,
32-
33- speed : 1 ,
34- accel : 0.08 ,
29+ _deferredParticles : [ ] ,
30+ _deferredShapes : [ ] ,
3531
3632 constructor : function ( canvas , bg ) {
3733 var image , el ;
@@ -96,8 +92,8 @@ Engine = Base.extend({
9692 ( this . height / 2 - 180 ) ,
9793 360 ,
9894 360 ,
99- Circle . Points ,
100- Circle . Polygons
95+ Logo . Points ,
96+ Logo . Polygons
10197 ) ;
10298 } ,
10399
@@ -123,7 +119,6 @@ Engine = Base.extend({
123119 this . now = Date . now ( ) / 1000 ;
124120
125121 tick = Math . min ( this . now - this . last , 0.017 ) ;
126- this . tick = this . speed * tick ;
127122
128123 this . renderStarfield ( this . now ) ;
129124 this . tick = tick ;
@@ -139,7 +134,7 @@ Engine = Base.extend({
139134
140135 renderTessellation : function ( ) {
141136 var scale = this . scale ,
142- p ;
137+ p , index ;
143138
144139 for ( p = 0 ; p < this . shapes . length ; p ++ ) {
145140 this . shapes [ p ] . update ( this ) ;
@@ -148,6 +143,14 @@ Engine = Base.extend({
148143
149144 this . logo . update ( this ) ;
150145 this . logo . draw ( this . context , scale ) ;
146+
147+ // Remove destroyed shapes
148+ for ( p = 0 ; p < this . _deferredShapes . length ; p ++ ) {
149+ index = this . shapes . indexOf ( this . _deferredShapes . pop ( ) ) ;
150+ if ( index >= 0 ) {
151+ this . shapes . splice ( index , 1 ) ;
152+ }
153+ }
151154 } ,
152155
153156 generateParticles : function ( num , fixed ) {
@@ -180,9 +183,9 @@ Engine = Base.extend({
180183 . draw ( this . context , scale ) ;
181184 }
182185
183- // Remove destroyed entities
184- for ( p = 0 ; p < this . _deferred . length ; p ++ ) {
185- index = this . particles . indexOf ( this . _deferred . pop ( ) ) ;
186+ // Remove destroyed particles
187+ for ( p = 0 ; p < this . _deferredParticles . length ; p ++ ) {
188+ index = this . particles . indexOf ( this . _deferredParticles . pop ( ) ) ;
186189 if ( index >= 0 ) {
187190 this . particles . splice ( index , 1 ) ;
188191 }
@@ -215,4 +218,4 @@ Engine.clone = function(ref) {
215218
216219window . Engine = Engine ;
217220
218- } ) ( window . Base , window . Vector , window . Circle ) ;
221+ } ) ( window . Base , window . Vector , window . Logo ) ;
0 commit comments