diff --git a/app/react/components/particle-worker.js b/app/react/components/particle-worker.js index 90822ea..73108c3 100644 --- a/app/react/components/particle-worker.js +++ b/app/react/components/particle-worker.js @@ -41,25 +41,19 @@ function tick(now) { ecs.tick(elapsed); emitter.tick(elapsed); const update = {}; - const lastNearby = new Set(memory); - for (const id in ecs.$$entities) { - const entity = ecs.$$entities[id]; - if (ecs.$$detached.has(entity.id)) { - continue; + for (const id in ecs.diff) { + if (false === ecs.diff[id]) { + memory.delete(id); + update[id] = false; } - lastNearby.delete(id); - if (!memory.has(id)) { - update[id] = entity.toJSON(); + else if (!memory.has(id)) { + update[id] = ecs.$$entities[id].toJSON(); } else if (ecs.diff[id]) { update[id] = ecs.diff[id]; } memory.add(id); } - for (const id of lastNearby) { - memory.delete(id); - update[id] = false; - } if ('1' in update) { delete update['1']; }