Browse Source

Setting up flowers to be in a grid; adding different color swarms

Justin Gilman 4 years ago
parent
commit
382cd4b8da
2 changed files with 15 additions and 17 deletions
  1. 3 1
      js/Hive.js
  2. 12 16
      js/main.js

+ 3 - 1
js/Hive.js

@@ -11,7 +11,7 @@ export class Hive {
         this.position = new THREE.Vector3();
         this.rotation = new THREE.Vector3();
         this.model = null;
-        this.honeyReserve = 20;
+        this.honeyReserve = 0;
         this.beeSlots = 10;
         this.queenSlots = 1;
         this.entranceWaypoint = null;
@@ -111,6 +111,7 @@ export class Hive {
             this.beeSlots--;
             let newBee = new Bee();
             newBee.model = Bee.baseModel.clone();
+            newBee.model.material = newBee.model.material.clone();
             newBee.init();
             newBee.setSwarm(this.swarm);
             newBee.setHive(this);
@@ -126,6 +127,7 @@ export class Hive {
             this.queenSlots--;
             let newBee = new Bee();
             newBee.model = Bee.baseModel.clone();
+            newBee.model.material = newBee.model.material.clone();
             newBee.init();
             let claimedHives = Bee.collection.map(bee => bee.homeHive);
             let nextHive = Hive.collection.filter(hive => !claimedHives.includes(hive))[0];

+ 12 - 16
js/main.js

@@ -127,32 +127,28 @@ function fillScene() {
 
         Hive.collection.forEach(hive => hive.addToScene(scene));
 
-
-        for (let i = 0; i < 25; i++) {
+        for (let i = 0; i < 24; i++) {
             let flower = new Flower();
             await flower.load(result[1]);
-            flower.position.x = Math.floor(800 * Math.random()) - 400;
-            flower.position.z = Math.floor(800 * Math.random()) - 400;
+            flower.position.x = ((i % 6) / 6 * 400) - 200;
+            flower.position.z = (Math.floor(i / 6) / 6 * 300) + 150;
             flower.rotation.y = (2 * Math.PI) * Math.random();
 
-            if (i == 0) {
-                flower.position.x = 0;
-                flower.position.z = 100;
-            }
-            else {
-                // let randomHive = Hive.collection[Math.floor(Hive.collection.length * Math.random())];
-                // randomHive.addFlower(flower);
-            }
-
             Flower.collection.push(flower);
         }
 
         Flower.collection.forEach(flower => flower.addToScene(scene));
 
         Bee.baseModel = result[2];
-        Hive.collection[1].setSwarm(1);
-        Hive.collection[1].toggleFlower(Flower.collection[0]);
-        Hive.collection[1].spawnBee();
+        Hive.collection[0].setSwarm(1);
+        Hive.collection[0].honeyReserve = 20;
+        Hive.collection[0].toggleFlower(Flower.collection[0]);
+        Hive.collection[0].spawnBee();
+
+        Hive.collection[2].setSwarm(2);
+        Hive.collection[2].honeyReserve = 20;
+        Hive.collection[2].toggleFlower(Flower.collection[5]);
+        Hive.collection[2].spawnBee();
 
 
         for (let i = 0; i < Waypoint.collection.length; i++) {