{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://visualspec.dev/schema/1.0/modules/world.schema.json",
  "title": "World",
  "description": "Visual world, environments, identities, representations, lifecycle and semantic relationships.",
  "$defs": {
    "environment": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "kind": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/taxonomy"
        },
        "foreground": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "midground": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "background": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "sky": {
          "type": "object",
          "properties": {
            "color": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/appearance.schema.json#/$defs/color"
            },
            "assetRef": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
            },
            "type": {
              "enum": [
                "solid",
                "gradient",
                "image",
                "procedural"
              ]
            }
          },
          "additionalProperties": false
        },
        "terrain": {
          "type": "object",
          "properties": {
            "entityRef": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
            },
            "assetRef": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
            },
            "elevation": {
              "type": "number"
            }
          },
          "additionalProperties": false
        },
        "weather": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/taxonomy"
        },
        "timeOfDay": {
          "anyOf": [
            {
              "enum": [
                "dawn",
                "morning",
                "noon",
                "afternoon",
                "dusk",
                "night"
              ]
            },
            {
              "type": "string",
              "pattern": "^(?:[01][0-9]|2[0-3]):[0-5][0-9]$"
            }
          ]
        },
        "season": {
          "enum": [
            "spring",
            "summer",
            "autumn",
            "winter"
          ]
        },
        "temperature": {
          "type": "number"
        },
        "fog": {
          "type": "object",
          "properties": {
            "density": {
              "type": "number",
              "minimum": 0
            },
            "color": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/appearance.schema.json#/$defs/color"
            },
            "near": {
              "type": "number",
              "minimum": 0
            },
            "far": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false
        },
        "haze": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "lightRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "effectRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "entityRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "extensions": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/extensions"
        }
      },
      "required": [
        "kind"
      ],
      "additionalProperties": false
    },
    "representation": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "type": {
          "enum": [
            "image",
            "video",
            "vector",
            "3d",
            "illustration",
            "generated",
            "ui",
            "text",
            "procedural"
          ]
        },
        "assetRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "nodeRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "componentRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "sceneRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "variant": {
          "type": "string",
          "minLength": 1
        },
        "condition": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/condition"
        },
        "levelOfDetail": {
          "type": "integer",
          "minimum": 0
        },
        "referenceRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "extensions": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/extensions"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false
    },
    "entity": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "kind": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/taxonomy"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/taxonomy"
        },
        "geometry": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/geometry.schema.json#/$defs/geometry"
        },
        "transform": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/geometry.schema.json#/$defs/transform"
        },
        "appearance": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/appearance.schema.json#/$defs/appearance"
        },
        "representation": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/world.schema.json#/$defs/representation"
        },
        "representations": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/world.schema.json#/$defs/representation"
          },
          "minItems": 1
        },
        "visibility": {
          "type": "object",
          "properties": {
            "visible": {
              "type": "boolean"
            },
            "occluded": {
              "type": "boolean"
            },
            "opacity": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "layers": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            }
          },
          "additionalProperties": false
        },
        "presence": {
          "type": "object",
          "properties": {
            "from": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/time"
            },
            "to": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/time"
            },
            "condition": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/condition"
            },
            "sceneRefs": {
              "type": "array",
              "items": {
                "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
              },
              "uniqueItems": true
            }
          },
          "additionalProperties": false
        },
        "lifecycle": {
          "enum": [
            "persistent",
            "ephemeral",
            "generated",
            "derived",
            "conditional",
            "tracked",
            "procedural"
          ]
        },
        "parts": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "relationships": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "states": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "actions": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "motion": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "references": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "identity": {
          "type": "object",
          "properties": {
            "persistentKey": {
              "type": "string",
              "minLength": 1
            },
            "label": {
              "type": "string",
              "minLength": 1
            },
            "description": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "provenance": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/provenance"
        },
        "extensions": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/extensions"
        }
      },
      "required": [
        "id",
        "kind"
      ],
      "additionalProperties": false
    },
    "relationship": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "type": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/taxonomy"
        },
        "sourceRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "targetRef": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "strength": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "temporal": {
          "type": "object",
          "properties": {
            "from": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/time"
            },
            "to": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/time"
            }
          },
          "additionalProperties": false
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "provenance": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/provenance"
        },
        "extensions": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/extensions"
        }
      },
      "required": [
        "id",
        "type",
        "sourceRef",
        "targetRef"
      ],
      "additionalProperties": false
    },
    "world": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "environment": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/world.schema.json#/$defs/environment"
        },
        "sceneRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "entityRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "cameraRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "lightRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "effectRefs": {
          "type": "array",
          "items": {
            "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/id"
          },
          "uniqueItems": true
        },
        "coordinateSystem": {
          "type": "object",
          "properties": {
            "handedness": {
              "enum": [
                "left",
                "right"
              ]
            },
            "upAxis": {
              "enum": [
                "x",
                "y",
                "z"
              ]
            },
            "unit": {
              "enum": [
                "px",
                "m",
                "cm",
                "mm"
              ]
            },
            "origin": {
              "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/vector3"
            }
          },
          "additionalProperties": false
        },
        "extensions": {
          "$ref": "https://visualspec.dev/schema/1.0/modules/common.schema.json#/$defs/extensions"
        }
      },
      "additionalProperties": false
    }
  }
}
