vis = {
const sim = new AA.Simulation({
width: 550,
height: 550,
gridStep: 10,
beforeTick: () => {
for (let ac of sim.actors) ac.state.neighbor = false;
},
updateMassesAndRadii: false,
updatePointings: false,
updateSquareStates: false,
updateZoneStates: false,
applySteeringForces: false
}).vis({baseColor: 0xffffff});
invalidation.then(() => sim.end());
sim.populate({
n: Math.round(29 * nCircles / 30),
random: true,
overlap: true,
radius: 1.5,
setup: ac => ac.vis({tint: ac => ac.state.neighbor ? 0x0 : 0xaaaaaa})
});
sim.populate({
n: Math.round(nCircles / 30),
random: true,
radius: 3,
setup: ac => {
ac.wrap = true;
ac.vel = new AA.Vector(2, 2)
ac.state.moving = true;
ac.updateState = function() {
const neighbors = test === 'neighbors'
? this.neighbors(10, 'actor')
: this.nearest(10, null, 'actor');
for (let neighbor of neighbors || []) {
neighbor.state.neighbor = true;
}
};
ac.vis({tint: AV.colors.blue});
}
});
return AV.visObs(sim, {
stats: true,
backParticles: true,
updateRadii: false,
updatePointings: false
});
}