Add various generic models
This commit is contained in:
+9
-1
@@ -775,8 +775,16 @@ function validate_shape(shape: unknown, where: string, top = 16): Problems {
|
||||
export function validate_model(json: unknown): Problems {
|
||||
if (!is_object(json)) return ["model must be an object"];
|
||||
const problems = validate_id(json.id, "id");
|
||||
if (json.parent !== undefined) problems.push(...validate_id(json.parent, "parent"));
|
||||
if (json.textures !== undefined) problems.push(...validate_textures(json.textures, "textures", true));
|
||||
if (!Array.isArray(json.elements) || json.elements.length === 0) {
|
||||
// a model can leave its elements to its parent, or be one that only gives texture defaults to its children
|
||||
if (json.elements === undefined) {
|
||||
if (json.parent === undefined && json.textures === undefined) {
|
||||
problems.push("a model needs elements, a parent, or textures for models that use it as theirs");
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
if (!Array.isArray(json.elements)) {
|
||||
problems.push("elements must be a list of boxes");
|
||||
return problems;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user