import Bot from './objects/bot';

const SCREEN_WIDTH = window.innerWidth;
const SCREEN_HEIGHT = window.innerHeight;
const VIEW_ANGLE = 45;
const ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT;
const NEAR = 1;
const FAR = 10000;

let scene;
let camera;
let renderer;
let axesHelper;
let gridHelper;
let controls;
let pointLight;
let ambientLight;

let prevTime = Date.now();

const origin = new THREE.Vector3(0, 0, 0);

const botCount = 4;
const bots = [];

for (let i = 0; i < botCount; i += 1) {
  const red = Math.round(Math.random() * 255);
  const green = Math.round(Math.random() * 255);
  const blue = Math.round(Math.random() * 255);
  const color  =(red * 256 ** 0) + (green * 256 ** 1) + (blue * 256 ** 2);
  const bot = new Bot({
    name: 'Bot',
    radius: 20 - (i * 5),
    color,
    speed: 25 + (i * 25),
    boundary: {
      x1: -50,
      x2: 50,
      z1: -50,
      z2: 50,
    },
  });
  bots.push(bot);
}

function init() {
  scene = new THREE.Scene();

  gridHelper = new THREE.GridHelper(100, 10);
  scene.add(gridHelper);

  axesHelper = new THREE.AxesHelper(100);
  scene.add(axesHelper);

  camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
  camera.position.set(200, 200, 200);
  camera.lookAt(origin);

  bots.forEach(bot => scene.add(bot));

  ambientLight = new THREE.AmbientLight(0x444444);
  scene.add(ambientLight);

  pointLight = new THREE.PointLight(0x0000ff, 1, 1000);
  pointLight.position.set(100, 100, 100);
  scene.add(pointLight);

  renderer = new THREE.WebGLRenderer({ antialias: true });
  renderer.setSize(window.innerWidth, window.innerHeight);

  controls = new THREE.OrbitControls(camera, renderer.domElement);

  THREEx.WindowResize(renderer, camera);

  document.body.appendChild(renderer.domElement);
}

// let angle = 0;

function update() {
  const time = Date.now();
  const delta = time - prevTime;
  prevTime = time;

  bots.forEach(bot => bot.update(delta));
  controls.update();
}

function render() {
  renderer.render(scene, camera);
}

function tick() {
  update();
  render();
  requestAnimationFrame(tick);
}

init();
tick();

@@ -420,17 +420,18 @@
 Count = 
-4
+51
 ;%0Aconst 
@@ -442,16 +442,146 @@
  = %5B%5D;%0A%0A
+const minSize = 5;%0Aconst maxSize = 30;%0Aconst intervalCount = botCount - 1;%0Aconst interval = (maxSize - minSize) / intervalCount;%0A%0A
 for (let
@@ -770,18 +770,18 @@
 t color 
- 
 =
+ 
 (red * 2
@@ -888,19 +888,31 @@
 us: 
-20 - (i * 5
+maxSize - (interval * i
 ),%0A 
@@ -936,20 +936,32 @@
 ed: 
-25 + (i * 25
+ maxSize - (interval * i
 ),%0A 
@@ -982,25 +982,26 @@
 %0A      x1: -
-5
+10
 0,%0A      x2:
@@ -1001,17 +1001,18 @@
     x2: 
-5
+10
 0,%0A     
@@ -1017,17 +1017,18 @@
    z1: -
-5
+10
 0,%0A     
@@ -1032,17 +1032,18 @@
     z2: 
-5
+10
 0,%0A    %7D
@@ -1155,17 +1155,17 @@
 dHelper(
-1
+2
 00, 10);

Improve radius and movement.