@@ -61,7 +61,11 @@ export class Simple {
61
61
* @return {Array } array
62
62
*/
63
63
removeList ( array : DisplayObjectWithCullingArray ) : DisplayObjectWithCullingArray {
64
- this . lists . splice ( this . lists . indexOf ( array ) , 1 )
64
+ const index = this . lists . indexOf ( array )
65
+ if ( index === - 1 ) {
66
+ return array
67
+ }
68
+ this . lists . splice ( index , 1 )
65
69
return array
66
70
}
67
71
@@ -92,7 +96,11 @@ export class Simple {
92
96
* @return {DisplayObjectWithCulling } object
93
97
*/
94
98
remove ( object : DisplayObjectWithCulling ) : DisplayObjectWithCulling {
95
- this . lists [ 0 ] . splice ( this . lists [ 0 ] . indexOf ( object ) , 1 )
99
+ const index = this . lists [ 0 ] . indexOf ( object )
100
+ if ( index === - 1 ) {
101
+ return object
102
+ }
103
+ this . lists [ 0 ] . splice ( index , 1 )
96
104
return object
97
105
}
98
106
@@ -174,7 +182,8 @@ export class Simple {
174
182
for ( let list of this . lists ) {
175
183
for ( let object of list ) {
176
184
const box = object . AABB
177
- if ( box . x + box . width > bounds . x && box . x - box . width < bounds . x + bounds . width &&
185
+ if ( box &&
186
+ box . x + box . width > bounds . x && box . x - box . width < bounds . x + bounds . width &&
178
187
box . y + box . height > bounds . y && box . y - box . height < bounds . y + bounds . height ) {
179
188
results . push ( object )
180
189
}
@@ -194,7 +203,8 @@ export class Simple {
194
203
for ( let list of this . lists ) {
195
204
for ( let object of list ) {
196
205
const box = object . AABB
197
- if ( box . x + box . width > bounds . x && box . x - box . width < bounds . x + bounds . width &&
206
+ if ( box &&
207
+ box . x + box . width > bounds . x && box . x - box . width < bounds . x + bounds . width &&
198
208
box . y + box . height > bounds . y && box . y - box . height < bounds . y + bounds . height ) {
199
209
if ( callback ( object ) ) {
200
210
return true
0 commit comments