File tree 3 files changed +19
-5
lines changed 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,16 @@ export function createQueryResult<T extends QueryParameter[]>(
23
23
) : QueryResult < T > {
24
24
query . commitRemovals ( world ) ;
25
25
const entities = query . entities . dense . slice ( ) as Entity [ ] ;
26
+
26
27
// Clear so it can accumulate again.
27
- if ( query . isTracking ) query . entities . clear ( ) ;
28
+ if ( query . isTracking ) {
29
+ query . entities . clear ( ) ;
30
+
31
+ // @todo : Need to improve the performance of this loop.
32
+ for ( const eid of entities ) {
33
+ query . resetTrackingBitmasks ( eid ) ;
34
+ }
35
+ }
28
36
29
37
const stores : Store < any > [ ] = [ ] ;
30
38
const traits : Trait [ ] = [ ] ;
Original file line number Diff line number Diff line change @@ -290,7 +290,13 @@ export class Query {
290
290
const result = this . entities . dense . slice ( ) ;
291
291
292
292
// Clear so it can accumulate again.
293
- if ( this . isTracking ) this . entities . clear ( ) ;
293
+ if ( this . isTracking ) {
294
+ this . entities . clear ( ) ;
295
+
296
+ for ( const eid of result ) {
297
+ this . resetTrackingBitmasks ( eid ) ;
298
+ }
299
+ }
294
300
295
301
return result as Entity [ ] ;
296
302
}
Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ describe('Query modifiers', () => {
378
378
entityA . remove ( Foo ) ;
379
379
entityA . add ( Foo ) ;
380
380
entities = world . query ( Added ( Foo ) , Removed ( Bar ) ) ;
381
- expect ( entities [ 0 ] ) . toBe ( entityA ) ;
381
+ expect ( entities . length ) . toBe ( 0 ) ;
382
382
383
383
// Add Foo to entityB and remove Bar.
384
384
// This entity should now match the query.
@@ -460,7 +460,7 @@ describe('Query modifiers', () => {
460
460
expect ( entities2 . length ) . toBe ( 1 ) ;
461
461
} ) ;
462
462
463
- it . fails ( 'should only update a Changed query when the tracked trait is changed' , ( ) => {
463
+ it ( 'should only update a Changed query when the tracked trait is changed' , ( ) => {
464
464
const entity = world . spawn ( Foo , Bar ) ;
465
465
466
466
const Changed = createChanged ( ) ;
@@ -476,7 +476,7 @@ describe('Query modifiers', () => {
476
476
} ) ;
477
477
478
478
// @see https://github.com/pmndrs/koota/issues/115
479
- it . fails ( 'should not trigger Changed query when removing a different trait' , ( ) => {
479
+ it ( 'should not trigger Changed query when removing a different trait' , ( ) => {
480
480
const Changed = createChanged ( ) ;
481
481
const entity = world . spawn ( Position ) ;
482
482
You can’t perform that action at this time.
0 commit comments