public byte[] ToGlbBytes(SerializerTypes serializer = SerializerTypes.UniJSON) { string json; if (serializer == SerializerTypes.UniJSON) { var c = new JsonSchemaValidationContext(this) { EnableDiagnosisForNotRequiredFields = true, }; json = JsonSchema.FromType(GetType()).Serialize(this, c); } else if (serializer == SerializerTypes.Generated) { var f = new JsonFormatter(); f.GenSerialize(this); json = f.ToString().ParseAsJson().ToString(" "); } else if (serializer == SerializerTypes.JsonSerializable) { // Obsolete json = ToJson(); } else { throw new Exception("[UniVRM Export Error] unknown serializer type"); } RemoveUnusedExtensions(json); return(Glb.ToBytes(json, buffers[0].GetBytes())); }
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 byte[] ToGlbBytes(bool UseUniJSONSerializer = false) { string json; if (UseUniJSONSerializer) { json = JsonSchema.FromType(GetType()).Serialize(this); } else { json = ToJson(); } RemoveUnusedExtensions(json); return(Glb.ToBytes(json, buffers[0].GetBytes())); }
public byte[] ToGlbBytes(ArraySegment <Byte> bytes, bool UseUniJSONSerializer = false) { string json; if (UseUniJSONSerializer) { json = JsonSchema.FromType(GetType()).Serialize(this); } else { json = ToJson(); } RemoveUnusedExtensions(json); return(Glb.ToBytes(json, bytes)); }
public byte[] ToGlbBytes(ArraySegment <Byte> bytes, bool UseUniJSONSerializer = false) { string json; if (UseUniJSONSerializer) { var f = new JsonFormatter(); f.Serialize(this); json = Encoding.UTF8.GetString(f.GetStoreBytes().ToArray()); } else { json = ToJson(); } RemoveUnusedExtensions(json); return(Glb.ToBytes(json, bytes)); }
public byte[] ToGlbBytes(bool UseUniJSONSerializer = false) { string json; if (UseUniJSONSerializer) { var c = new JsonSchemaValidationContext(this) { EnableDiagnosisForNotRequiredFields = true, }; json = JsonSchema.FromType(GetType()).Serialize(this, c); } else { json = ToJson(); } RemoveUnusedExtensions(json); return(Glb.ToBytes(json, buffers[0].GetBytes())); }