public static byte[] ToGlbBytes(this glTF self) { var f = new JsonFormatter(); GltfSerializer.Serialize(f, self); var json = f.ToString().ParseAsJson().ToString(" "); self.RemoveUnusedExtensions(json); return(Glb.ToBytes(json, self.buffers[0].GetBytes())); }
public static (string, List <glTFBuffer>) ToGltf(this glTF self, string gltfPath) { var f = new JsonFormatter(); // fix buffer path if (self.buffers.Count == 1) { var withoutExt = Path.GetFileNameWithoutExtension(gltfPath); self.buffers[0].uri = $"{withoutExt}.bin"; } else { throw new NotImplementedException(); } GltfSerializer.Serialize(f, self); var json = f.ToString().ParseAsJson().ToString(" "); self.RemoveUnusedExtensions(json); return(json, self.buffers); }