Browse Source

add more animals

Gregg Tavares 6 years ago
parent
commit
2e9e14b983
2 changed files with 20 additions and 3 deletions
  1. 1 0
      .eslintrc.js
  2. 19 3
      threejs/threejs-game-conga-line-w-notes.html

+ 1 - 0
.eslintrc.js

@@ -77,6 +77,7 @@ module.exports = {
     "no-comma-dangle": [0],
     "no-irregular-whitespace": 2,
     "no-multi-spaces": [0],
+    "no-loop-func": 0,
     "no-obj-calls": 2,
     "no-redeclare": [0],
     "no-shadow": [0],

+ 19 - 3
threejs/threejs-game-conga-line-w-notes.html

@@ -917,11 +917,27 @@ function main() {
       'zebra',
       'horse',
     ];
-    animalModelNames.forEach((name, ndx) => {
+    const base = new THREE.Object3D();
+    const offset = new THREE.Object3D();
+    base.add(offset);
+
+    // position animals in a spiral.
+    const numAnimals = 28;
+    const arc = 10;
+    const b = 10 / (2 * Math.PI);
+    let r = 10;
+    let phi = r / b;
+    for (let i = 0; i < numAnimals; ++i) {
+      const name = animalModelNames[rand(animalModelNames.length) | 0];
       const gameObject = gameObjectManager.createGameObject(scene, name);
       gameObject.addComponent(Animal, models[name]);
-      gameObject.transform.position.x = (ndx + 1) * 5;
-    });
+      base.rotation.y = phi;
+      offset.position.x = r;
+      offset.updateWorldMatrix(true, false);
+      offset.getWorldPosition(gameObject.transform.position);
+      phi += arc / r;
+      r = b * phi;
+    }
   }
 
   function resizeRendererToDisplaySize(renderer) {