using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReadMolecule : MonoBehaviour
{
    public TextAsset jsonFile;

    void Start(){
        Molecules moleculesInJson = JsonUtility.FromJson<Molecules>(jsonFile.text);

        int molNum = 0;
        int dist = 5;
        foreach (Molecule molecule in moleculesInJson.molecules){

            GameObject moleculeObj = new GameObject(molecule.name);

            foreach (Atom atom in molecule.atoms){
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.parent = moleculeObj.transform;
                sphere.name = atom.element;
                sphere.transform.localPosition = new Vector3(atom.geometry[0], atom.geometry[1], atom.geometry[2]);
            }
            moleculeObj.transform.position = new Vector3(molNum*dist,0,0);
            molNum++;
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
