Add various generic models

This commit is contained in:
2026-10-12 17:56:47 -03:00
parent e5baeab193
commit d4eff11f3e
34 changed files with 786 additions and 251 deletions
+9 -1
View File
@@ -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;
}