|
@@ -917,11 +917,27 @@ function main() {
|
|
'zebra',
|
|
'zebra',
|
|
'horse',
|
|
'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);
|
|
const gameObject = gameObjectManager.createGameObject(scene, name);
|
|
gameObject.addComponent(Animal, models[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) {
|
|
function resizeRendererToDisplaySize(renderer) {
|