{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://building3d.app/design-schema.json",
  "title": "Building3D Design v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "building3d.design"
    },
    "version": {
      "const": 1
    },
    "units": {
      "const": "m"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "baseElevation": {
      "type": "number",
      "minimum": -30,
      "maximum": 30
    },
    "site": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "width": {
          "type": "number",
          "minimum": 8,
          "maximum": 100
        },
        "depth": {
          "type": "number",
          "minimum": 8,
          "maximum": 100
        },
        "setback": {
          "type": "number",
          "minimum": 0,
          "maximum": 49.99
        },
        "north": {
          "type": "number",
          "minimum": 0,
          "maximum": 360
        }
      },
      "required": [
        "width",
        "depth",
        "setback",
        "north"
      ]
    },
    "levels": {
      "type": "array",
      "minItems": 1,
      "maxItems": 60,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "height": {
            "type": "number",
            "minimum": 2.4,
            "maximum": 6
          },
          "roomLabels": {
            "type": "array",
            "maxItems": 150,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80
                },
                "x": {
                  "type": "number",
                  "minimum": -100,
                  "maximum": 100
                },
                "z": {
                  "type": "number",
                  "minimum": -100,
                  "maximum": 100
                }
              },
              "required": [
                "name",
                "x",
                "z"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "height"
        ]
      }
    },
    "elements": {
      "type": "array",
      "maxItems": 3000,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "type": {
                "enum": [
                  "floor",
                  "space",
                  "column",
                  "stairs"
                ]
              },
              "levelId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "use": {
                "enum": [
                  "Residential",
                  "Commercial",
                  "Office",
                  "Circulation",
                  "Service",
                  "Other"
                ]
              },
              "material": {
                "enum": [
                  "concrete",
                  "plaster",
                  "wood",
                  "steel",
                  "glass",
                  "limestone",
                  "stucco",
                  "brick",
                  "copper",
                  "terracotta"
                ]
              },
              "texture": {
                "enum": [
                  "none",
                  "concrete",
                  "stucco",
                  "stone",
                  "brick",
                  "wood",
                  "standing-seam",
                  "tiles"
                ]
              },
              "textureScale": {
                "type": "number",
                "minimum": 0.1,
                "maximum": 20
              },
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "stage": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "columnShape": {
                "enum": [
                  "square",
                  "round",
                  "classical",
                  "steel"
                ]
              },
              "stairShape": {
                "enum": [
                  "straight",
                  "quarter-turn",
                  "half-turn",
                  "spiral",
                  "exterior-entry",
                  "exterior-metal"
                ]
              },
              "curtainWall": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "shape": {
                    "enum": [
                      "flat",
                      "ellipse"
                    ]
                  },
                  "bays": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 80
                  },
                  "rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 8
                  }
                },
                "required": [
                  "shape",
                  "bays",
                  "rows"
                ]
              },
              "position": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "y": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "z": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  }
                },
                "required": [
                  "x",
                  "y",
                  "z"
                ]
              },
              "dimensions": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "width": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "height": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "depth": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  }
                },
                "required": [
                  "width",
                  "height",
                  "depth"
                ]
              },
              "rotation": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "y": {
                    "enum": [
                      0,
                      90,
                      180,
                      270
                    ]
                  }
                },
                "required": [
                  "y"
                ]
              }
            },
            "required": [
              "id",
              "type",
              "levelId",
              "position",
              "dimensions",
              "rotation"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "type": {
                "const": "wall"
              },
              "levelId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "use": {
                "enum": [
                  "Residential",
                  "Commercial",
                  "Office",
                  "Circulation",
                  "Service",
                  "Other"
                ]
              },
              "material": {
                "enum": [
                  "concrete",
                  "plaster",
                  "wood",
                  "steel",
                  "glass",
                  "limestone",
                  "stucco",
                  "brick",
                  "copper",
                  "terracotta"
                ]
              },
              "texture": {
                "enum": [
                  "none",
                  "concrete",
                  "stucco",
                  "stone",
                  "brick",
                  "wood",
                  "standing-seam",
                  "tiles"
                ]
              },
              "textureScale": {
                "type": "number",
                "minimum": 0.1,
                "maximum": 20
              },
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "stage": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "wallpaper": {
                "type": "string",
                "maxLength": 220000,
                "pattern": "^data:image/(jpeg|png|webp);base64,[A-Za-z0-9+/]+={0,2}$"
              },
              "curtainWall": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "shape": {
                    "enum": [
                      "flat",
                      "ellipse"
                    ]
                  },
                  "bays": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 80
                  },
                  "rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 8
                  }
                },
                "required": [
                  "shape",
                  "bays",
                  "rows"
                ]
              },
              "position": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "y": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "z": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  }
                },
                "required": [
                  "x",
                  "y",
                  "z"
                ]
              },
              "dimensions": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "width": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "height": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "depth": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  }
                },
                "required": [
                  "width",
                  "height",
                  "depth"
                ]
              },
              "rotation": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "y": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMaximum": 360
                  }
                },
                "required": [
                  "y"
                ]
              }
            },
            "required": [
              "id",
              "type",
              "levelId",
              "position",
              "dimensions",
              "rotation"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "type": {
                "enum": [
                  "door",
                  "window"
                ]
              },
              "levelId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "use": {
                "enum": [
                  "Residential",
                  "Commercial",
                  "Office",
                  "Circulation",
                  "Service",
                  "Other"
                ]
              },
              "material": {
                "enum": [
                  "concrete",
                  "plaster",
                  "wood",
                  "steel",
                  "glass",
                  "limestone",
                  "stucco",
                  "brick",
                  "copper",
                  "terracotta"
                ]
              },
              "texture": {
                "enum": [
                  "none",
                  "concrete",
                  "stucco",
                  "stone",
                  "brick",
                  "wood",
                  "standing-seam",
                  "tiles"
                ]
              },
              "textureScale": {
                "type": "number",
                "minimum": 0.1,
                "maximum": 20
              },
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "stage": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "doorStyle": {
                "enum": [
                  "flush",
                  "panel",
                  "double",
                  "french",
                  "sliding",
                  "arched",
                  "swinging",
                  "sliding-solid",
                  "french-clear",
                  "three-panel",
                  "romanesque",
                  "gothic",
                  "georgian",
                  "art-nouveau",
                  "moroccan",
                  "shoji",
                  "pivot",
                  "barn"
                ]
              },
              "openingStyle": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "shape": {
                    "enum": [
                      "rectangular",
                      "arch",
                      "pointed",
                      "scalloped"
                    ]
                  },
                  "columns": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 6
                  },
                  "rows": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 8
                  },
                  "frameWidth": {
                    "type": "number",
                    "minimum": 0.015,
                    "maximum": 0.15
                  },
                  "frameColor": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                  },
                  "trimWidth": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 0.5
                  },
                  "trimDepth": {
                    "type": "number",
                    "minimum": 0.01,
                    "maximum": 0.3
                  },
                  "trimColor": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                  }
                },
                "required": [
                  "shape",
                  "columns",
                  "rows",
                  "frameWidth",
                  "frameColor",
                  "trimWidth",
                  "trimDepth",
                  "trimColor"
                ]
              },
              "host": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "wallId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[A-Za-z0-9_-]+$"
                  },
                  "offset": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "sill": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 6
                  }
                },
                "required": [
                  "wallId",
                  "offset",
                  "sill"
                ]
              },
              "dimensions": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "width": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "height": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  }
                },
                "required": [
                  "width",
                  "height"
                ]
              }
            },
            "required": [
              "id",
              "type",
              "levelId",
              "host",
              "dimensions"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "type": {
                "const": "roof"
              },
              "levelId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "use": {
                "enum": [
                  "Residential",
                  "Commercial",
                  "Office",
                  "Circulation",
                  "Service",
                  "Other"
                ]
              },
              "material": {
                "enum": [
                  "concrete",
                  "plaster",
                  "wood",
                  "steel",
                  "glass",
                  "limestone",
                  "stucco",
                  "brick",
                  "copper",
                  "terracotta"
                ]
              },
              "texture": {
                "enum": [
                  "none",
                  "concrete",
                  "stucco",
                  "stone",
                  "brick",
                  "wood",
                  "standing-seam",
                  "tiles"
                ]
              },
              "textureScale": {
                "type": "number",
                "minimum": 0.1,
                "maximum": 20
              },
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "stage": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "shape": {
                "enum": [
                  "flat",
                  "gable",
                  "hip",
                  "pyramid",
                  "octagonal",
                  "shed"
                ]
              },
              "position": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  },
                  "y": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 30
                  },
                  "z": {
                    "type": "number",
                    "minimum": -100,
                    "maximum": 100
                  }
                },
                "required": [
                  "x",
                  "y",
                  "z"
                ]
              },
              "dimensions": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "width": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "height": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  },
                  "depth": {
                    "type": "number",
                    "minimum": 0.05,
                    "maximum": 100
                  }
                },
                "required": [
                  "width",
                  "height",
                  "depth"
                ]
              },
              "rotation": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "y": {
                    "enum": [
                      0,
                      90,
                      180,
                      270
                    ]
                  }
                },
                "required": [
                  "y"
                ]
              }
            },
            "required": [
              "id",
              "type",
              "levelId",
              "shape",
              "position",
              "dimensions",
              "rotation"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "format",
    "version",
    "units",
    "name",
    "baseElevation",
    "site",
    "levels",
    "elements"
  ]
}
