Handle blob removal in spawn system
This commit is contained in:
16
src/spawn.js
16
src/spawn.js
@@ -452,6 +452,21 @@
|
||||
});
|
||||
};
|
||||
|
||||
const removeBlob = (blobId) => {
|
||||
if (!blobId) return;
|
||||
const constraints = blobConstraints.get(blobId) || [];
|
||||
constraints.forEach((c) => World.remove(world, c));
|
||||
blobConstraints.delete(blobId);
|
||||
for (let i = balls.length - 1; i >= 0; i -= 1) {
|
||||
const ball = balls[i];
|
||||
if (ball.plugin?.blobId === blobId) {
|
||||
cleanupBall(ball);
|
||||
World.remove(world, ball);
|
||||
balls.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const resetSpawnState = () => {
|
||||
spawnCount = 0;
|
||||
};
|
||||
@@ -465,6 +480,7 @@
|
||||
updateBallRadius,
|
||||
computeBallRadius,
|
||||
cleanupBall,
|
||||
removeBlob,
|
||||
resetSpawnState,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user