8#include <nlohmann/json.hpp>
10#include <glm/gtc/quaternion.hpp>
13 inline void to_json(nlohmann::json& j,
const glm::vec2& v) {
14 j = nlohmann::json{{
"x", v.x}, {
"y", v.y}};
16 inline void from_json(
const nlohmann::json& j, glm::vec2& v) {
17 if (j.contains(
"x")) j.at(
"x").get_to(v.x);
18 if (j.contains(
"y")) j.at(
"y").get_to(v.y);
23 inline void to_json(nlohmann::json& j,
const vec3& v) {
24 j = nlohmann::json::array({v.x, v.y, v.z});
28 inline void from_json(
const nlohmann::json& j, vec3& v) {
29 if(j.is_array() && j.size() >= 3) {
30 v.x = j[0]; v.y = j[1]; v.z = j[2];
35 inline void to_json(nlohmann::json& j,
const vec4& v) {
36 j = nlohmann::json::array({v.x, v.y, v.z, v.w});
40 inline void from_json(
const nlohmann::json& j, vec4& v) {
41 if(j.is_array() && j.size() >= 4) {
42 v.x = j[0]; v.y = j[1]; v.z = j[2]; v.w = j[3];
47 inline void to_json(nlohmann::json& j,
const quat& q) {
48 j = nlohmann::json::array({q.w, q.x, q.y, q.z});
51 inline void from_json(
const nlohmann::json& j, quat& q) {
52 if(j.is_array() && j.size() >= 4) {
53 q.w = j[0]; q.x = j[1]; q.y = j[2]; q.z = j[3];