/// <summary> /// Create a Hypar Model from a list of Elements. /// </summary> /// <param name="elements">The list of Elements that should be added to the model.</param> /// <returns name="Model">The Hypar Model to write.</returns> public static Elements.Model FromElements(IList <object> elements) { var model = new Elements.Model(); var elems = elements.Cast <Elements.Element>().Where(e => e != null); model.AddElements(elems); return(model); }
/// <summary> /// Write a Hypar model to glTF. /// </summary> /// <param name="filePath">The path to write the JSON file.</param> /// <param name="model">The Hypar Model to write.</param> public static void WriteGlb(string filePath, Elements.Model model) { try { model.ToGlTF(filePath); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Write a Hypar model to JSON. /// </summary> /// <param name="filePath">The path to write the JSON file.</param> /// <param name="model">The Hypar Model to write.</param> public static void WriteJson(string filePath, Elements.Model model) { try { var json = model.ToJson(); System.IO.File.WriteAllText(filePath, json); } catch (Exception ex) { throw new Exception(ex.Message); } }