{ "$schema":                        "https://json-schema.org/draft/2020-12/schema",
  "$id":                            "https://schemas.mpai.community/OSD/V1.5/data/3DModelObject.json",
  "title":                          "3D Model Object V1.5",
  "type":                           "object",
  "additionalProperties":           false,
  "required":                       [ "Header", "MInstanceID", "3DModelObjectID", "3DModelObjectSpaceTime" ],

  "properties":                     {

    "Header":                       { "type": "string", "pattern": "^OSD-3MO-[0-9]{1,2}[.][0-9]{1,2}$",
                                      "description": "3D Model Object Header – Standard OSD-3MO-Vx.y" },
    "MInstanceID":                  { "type": "string", "description": "Identifier of the M-Instance (Virtual Space) where this object is or is intended to be located." },
    "UEnvironmentID":               { "type": "string", "description": "Identifier of the U-Environment (Real Space) where this object is or is intended to be located." },
    "3DModelObjectID":              { "type": "string", "description": "Unique identifier of this 3D Model Object." },
    "3DModelObjectTime":            { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json", "description": "Time this 3D Model Object schema was produced." },

    "3DModelObjectSpaceTime":       { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SimpleTime.json", "description": "Space and Time of this 3D Model Object." },

    "3DModelObjectProperties":      { "type": "object", "additionalProperties": false, "description": "Physical and rendering properties of this 3D Model Object.", "properties": {
      "Mass":                       { "type": "number", "description": "Mass of the 3D Model Object in kilograms." },
      "Material":                   { "type": "string", "description": "Material type or descriptor applied to this 3D Model Object." },
      "Gravity":                    { "type": "boolean", "description": "Indicates whether gravity applies to this 3D Model Object." },
      "TextureMap":                 { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/TextureMap.json",
                                      "description": "Texture map applied to the surface of this 3D Model Object." } } },

    "ParentObjectIDs":              { "type": "array", "minItems": 0, "items": { "type": "string" },
                                      "description": "IDs of 3D Model Objects at a preceding time step that spawned this object. Empty if the object has no known parent at a previous time step." },

    "Basic3DModelObjectCount":      { "type": "integer", "minimum": 0, "description": "Number of Basic 3D Model Objects contained in this 3D Model Object." },

    "Basic3DModelObjects":          { "type": "array", "minItems": 0, "description": "Set of Basic 3D Model Objects contained in this 3D Model Object.",
                                      "items": { "type": "object", "required": [ "B3DObjectIDOrB3DObject" ], "additionalProperties": false, "properties": {
      "Basic3DObjectSpaceTime":     { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SpaceTime.json",
                                      "description": "Space-Time of this Basic 3D Model Object within the containing 3D Model Object. If absent, the Space-Time of the containing object applies." },
      "B3DObjectIDOrB3DObject":     { "$ref": "#/$defs/B3DObjectIDOrB3DObject", "description": "Either the ID of a Basic 3D Model Object or the Basic 3D Model Object itself." } } } },

    "Sub3DModelObjectCount":        { "type": "integer", "minimum": 0, "description": "Number of child 3D Model Objects contained in this 3D Model Object." },

    "Sub3DModelObjects":            { "type": "array", "minItems": 0, "description": "Set of child 3D Model Objects contained in this 3D Model Object.",
                                      "items": { "type": "object", "additionalProperties": false, 
                                                 "properties": {
      "Sub3DModelObjectSpaceTime":  { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/SpaceTime.json",
                                      "description": "Space-Time of this child 3D Model Object within the containing 3D Model Object. If absent, the Space-Time of the containing object applies." },
      "Sub3DObjectIDOrSub3DObject": { "$ref": "#/$defs/Sub3DObjectIDOrSub3DObject",
                                      "description": "Either the ID of a child 3D Model Object or the child 3D Model Object itself." } } } },

    "B3DObjectOr3DObject":          { "$ref": "#/$defs/B3DObjectOr3DObject", "description": "A mixed array of Basic 3D Model Objects and child 3D Model Objects contained in this 3D Model Object." },

    "DataXMData":                   { "$ref": "https://schemas.mpai.community/PTF/V1.0/data/DataExchangeMetadata.json",
                                      "description": "MPAI-PTF Data Exchange Metadata providing provenance, authorisation, legal, security, and confidence information associated with this 3D Model Object in a trusted data exchange context." },
    "DescrMetadata":                { "type": "string", "maxLength": 2048, "description": "Human-readable descriptive metadata of the 3D Model Object (plain text, max 2048 characters)." } },

  "$defs": {

    "B3DObjectOr3DObject":          { "type": "array", "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/Basic3DModelObject.json" },
                                    { "$ref": "#/$defs/B3DObjectOr3DObject" } ] } },

    "B3DObjectIDOrB3DObject":       { "type": "array", "minItems": 1, "maxItems": 1, "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/Basic3DModelObject.json" },
                                    { "type": "string" } ] } },

    "Sub3DObjectIDOrSub3DObject":   { "type": "array", "minItems": 1, "maxItems": 1, "items": { "oneOf": [
                                    { "$ref": "https://schemas.mpai.community/OSD/V1.5/data/3DModelObject.json" },
                                    { "type": "string" } ] } } } }
