Skip to content

Commit

Permalink
feat: pass custom type for any asssets with phoenix bodytype (#34)
Browse files Browse the repository at this point in the history
* feat: pass custom type for any asssets with phoenix bodytype

* chore: refactor code

* chore: rename phoenix bodyType

* feat: update schema

---------

Co-authored-by: Raigo Kõvask <[email protected]>
  • Loading branch information
rk132 and Raigo Kõvask authored Oct 17, 2024
1 parent 0249faa commit bec6174
Showing 1 changed file with 188 additions and 163 deletions.
351 changes: 188 additions & 163 deletions schemas/gltf-asset.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"type": "Asset type should be a string."
}
},
"bodyType": {
"description": "The bodyType of asset.",
"type": "string",
"errorMessage": {
"type": "Body type should be a string."
}
},
"gltfErrors": {
"description": "The errors encountered during glTF validation.",
"type": "array",
Expand All @@ -30,187 +37,205 @@
"allOf": [
{
"if": {
"properties": {
"assetType": {
"enum": [
"outfit",
"beard",
"bottom",
"facewear",
"footwear",
"glasses",
"hair",
"headwear",
"costume",
"shirt",
"top"
]
}
}
},
"then": {
"allOf": [{ "$ref": "commonTransforms.schema.json" }]
}
},
{
"if": {
"not": {
"properties": {
"assetType": {
"enum": [
"outfit",
"beard",
"bottom",
"facewear",
"footwear",
"glasses",
"hair",
"headwear",
"costume",
"shirt",
"top"
]
}
"properties": {
"bodyType": {
"const": "cage-mesh-based"
}
}
},
"required": ["bodyType"]
},
"then": {
"allOf": [{ "$ref": "assetCustom.schema.json" }]
}
},
{
"if": {
"properties": { "assetType": { "const": "outfit" } },
"required": ["assetType"]
},
"then": {
"else": {
"allOf": [
{ "$ref": "assetOutfit.schema.json" },
{ "$ref": "assetOutfit.schema.json#/$defs/outfitTextureCount" }
]
},
"$comment": "Outfit is the default asset type if no assetType is set in the data."
},
{
"if": {
"properties": { "assetType": { "const": "beard" } },
"required": ["assetType"]
},
"then": { "$ref": "assetBeard.schema.json" }
},
{
"if": {
"properties": { "assetType": { "const": "bottom" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetBottom.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "facewear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetFacewear.schema.json" },
"if": {
"properties": {
"assetType": {
"enum": [
"outfit",
"beard",
"bottom",
"facewear",
"footwear",
"glasses",
"hair",
"headwear",
"costume",
"shirt",
"top"
]
}
}
},
"then": {
"allOf": [{ "$ref": "commonTransforms.schema.json" }]
}
},
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "footwear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetFootwear.schema.json" },
"if": {
"not": {
"properties": {
"assetType": {
"enum": [
"outfit",
"beard",
"bottom",
"facewear",
"footwear",
"glasses",
"hair",
"headwear",
"costume",
"shirt",
"top"
]
}
}
}
},
"then": {
"allOf": [{ "$ref": "assetCustom.schema.json" }]
}
},
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "glasses" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetGlasses.schema.json" },
"if": {
"properties": { "assetType": { "const": "outfit" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetOutfit.schema.json" },
{ "$ref": "assetOutfit.schema.json#/$defs/outfitTextureCount" }
]
},
"$comment": "Outfit is the default asset type if no assetType is set in the data."
},
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "hair" } },
"required": ["assetType"]
},
"then": { "$ref": "assetHair.schema.json" }
},
{
"if": {
"properties": { "assetType": { "const": "headwear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetHeadwear.schema.json" },
"if": {
"properties": { "assetType": { "const": "beard" } },
"required": ["assetType"]
},
"then": { "$ref": "assetBeard.schema.json" }
},
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "costume" } },
"required": ["assetType"]
},
"then": { "$ref": "assetCostume.schema.json" }
},
{
"if": {
"properties": { "assetType": { "const": "shirt" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetShirt.schema.json" },
"if": {
"properties": { "assetType": { "const": "bottom" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetBottom.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "top" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetTop.schema.json" },
"if": {
"properties": { "assetType": { "const": "facewear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetFacewear.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
"if": {
"properties": { "assetType": { "const": "footwear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetFootwear.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "glasses" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetGlasses.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "hair" } },
"required": ["assetType"]
},
"then": { "$ref": "assetHair.schema.json" }
},
{
"if": {
"properties": { "assetType": { "const": "headwear" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetHeadwear.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/dualMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "costume" } },
"required": ["assetType"]
},
"then": { "$ref": "assetCostume.schema.json" }
},
{
"if": {
"properties": { "assetType": { "const": "shirt" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetShirt.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
},
{
"if": {
"properties": { "assetType": { "const": "top" } },
"required": ["assetType"]
},
"then": {
"allOf": [
{ "$ref": "assetTop.schema.json" },
{
"$ref": "commonTexture.schema.json#/$defs/singleMaterialTextureCount"
}
]
}
}
]
}
}
],

"errorMessage": {
"type": "Validation data should be a JSON object.",
"required": {
Expand Down

0 comments on commit bec6174

Please sign in to comment.