{
	"$id": "https://motorcortex.io/grid/v-3d.schema.json",
	"$schema": "http://motorcortex.io/grid/v-3d-schema#",
	"title": "Grid 3D widget schema",
	"type": "object",
	"additionalProperties": false,
	"definitions": {
		"file": {
			"type": "object",
			"required": [
				"file"
			],
			"properties": {
				"file": {
					"type": "string",
					"description": "The path and filename of the model file to load."
				},
				"name": {
					"type": "string",
					"description": "The name this model will get in the 3D scene."
				},
				"parent": {
					"type": "string",
					"description": "The name of the parent object in the 3D scene that this object will become a child of. The global position, orientation and scale of the object will be unchanged, if the object should be moved/aligned to the parent frame, use position and rotationZYX properties to set the local (relative) position/orientation of the child object."
				},
				"position": {
					"type": "array",
					"minItems": 3,
					"maxItems": 3,
					"description": "Position of the object [x, y, z]",
					"items": {
						"type": "number"
					}
				},
				"rotationZYX": {
					"type": "array",
					"minItems": 3,
					"maxItems": 3,
					"description": "Rotation in Euler angles of the object [rz, ry, rx]",
					"items": {
						"type": "number"
					}
				}
			}
		},
		"link": {
			"type": "object",
			"properties": {
				"link": {
					"type": "string",
					"description": "The parameter path to subscribe to."
				},
				"channel": {
					"type": "number",
					"description": "The channel (or index) of the parameter value array (default=0). When reading arrays, this is the index of the first element."
				},
				"property": {
					"type": "string",
					"description": "The path to the property in the scenegraph of the object that will be affected. This is relative to the object."
				},
				"axis": {
					"type": "string",
					"description": "The axis or property the value is applied to.",
					"enum": [
						"x",
						"y",
						"z",
						"rx",
						"ry",
						"rz",
						"s",
						"sx",
						"sy",
						"sz",
						"visible",
						"opacity",
						"emissiveIntensity",
						"pose",
						"position",
						"rotationZYX",
						"scaleChildren"
					]
				},
				"gain": {
					"type": "number",
					"description": "The gain the value is multiplied by before it is applied to the axis."
				},
				"offset": {
					"type": "number",
					"description": "The offset that is added to the gained value by before it is applied to the axis."
				},
				"value": {
					"oneOf": [
						{
							"type": "boolean"
						},
						{
							"type": "number"
						},
						{
							"type": "array",
							"items": {
								"type": "number"
							}
						}
					],
					"description": "The initial value for parameter. Will be overwritten if a valid link is present."
				}
			}
		},
		"object": {
			"type": "object",
			"properties": {
				"name": {
					"type": "string",
					"description": "The name of the 3D object or scene that these settings apply to. Only the first object with a matching name will be found."
				},
				"receiveShadow": {
					"type": "boolean",
					"description": "Defines if the object (and all its children) receive shadows."
				},
				"castShadow": {
					"type": "boolean",
					"description": "Defines if the object (and all its children) cast shadows."
				},
				"addEnvironmentMap": {
					"type": "boolean",
					"description": "Defines if all the object (and all its children) materials use the environmentmap."
				},
				"environmentMapIntensity": {
					"type": "number",
					"description": "Intensity of the environmentmap being applied (default is 1)."
				},
				"links": {
					"type": "array",
					"description": "The list of links to apply to this object.",
					"items": {
						"$ref": "#/definitions/link"
					}
				}
			}
		}
	},
	"properties": {
		"files": {
			"type": "array",
			"description": "The list of 3D files to load.",
			"items": {
				"$ref": "#/definitions/file"
			}
		},
		"environmentmap": {
			"type": "object",
			"required": [
				"nx",
				"ny",
				"nz",
				"px",
				"py",
				"pz"
			],
			"description": "The environment (cubemap) images to load.",
			"properties": {
				"nx": {
					"type": "string"
				},
				"ny": {
					"type": "string"
				},
				"nz": {
					"type": "string"
				},
				"px": {
					"type": "string"
				},
				"py": {
					"type": "string"
				},
				"pz": {
					"type": "string"
				}
			}
		},
		"camera": {
			"description": "The name of the object to use as the camera.",
			"type": "string"
		},
		"cameraLookAt": {
			"type": "object",
			"required": [
				"x",
				"y",
				"z"
			],
			"description": "The 3D point that the camera will initially point towards.",
			"properties": {
				"x": {
					"type": "number"
				},
				"y": {
					"type": "number"
				},
				"z": {
					"type": "number"
				}
			}
		},
		"cameraPosition": {
			"type": "object",
			"required": [
				"x",
				"y",
				"z"
			],
			"description": "The 3D position of the Camera. This also will be applied to a camera that is loaded from a file.",
			"properties": {
				"x": {
					"type": "number"
				},
				"y": {
					"type": "number"
				},
				"z": {
					"type": "number"
				}
			}
		},
		"hemisphereLight": {
			"type": "object",
			"description": "Properties of the hemisphere light.",
			"properties": {
				"intensity": {
					"type": "number"
				}
			}
		},
		"spotLight": {
			"type": "object",
			"description": "Properties of the spotlight.",
			"properties": {
				"intensity": {
					"type": "number"
				},
				"penumbra": {
					"type": "number"
				},
				"angle": {
					"type": "number"
				},
				"castShadow": {
					"type": "boolean"
				},
				"x": {
					"type": "number"
				},
				"y": {
					"type": "number"
				},
				"z": {
					"type": "number"
				}
			}
		},
		"renderSettings": {
			"properties": {
				"fps": {
					"type": "number",
					"description": "Maximum number of Frames Per Second of the rendering."
				},
				"bloom": {
					"type": "object",
					"description": "Properties of the bloom effect.",
					"properties": {
						"enable": {
							"type": "boolean",
							"description": "Enables the blooming post effect."
						},
						"strength": {
							"type": "number",
							"description": "The overall strength of the blooming effect."
						},
						"radius": {
							"type": "number",
							"description": "The blur radius of the blooming effect."
						},
						"threshold": {
							"type": "number",
							"description": "The luminocity above which the blooming effect will be applied. Note: environmentmaps also add to the luminocity of a material."
						}
					}
				}
			}
		},
		"traceLine": {
			"type": "object",
			"description": "Draws a line in 3D space based on parameter links to axis x, y and z.",
			"properties": {
				"color": {
					"type": "string",
					"description": "A string defining a color as a CSS style string; examples: #ff0000, rgb(255, 0, 0), rgb(100%, 0%, 0%), red, hsl(0, 100%, 50%)"
				},
				"lineWidth": {
					"type": "number"
				},
				"tolerance": {
					"type": "number",
					"description": "The distance in either x, y or z direction that a new point needs to be away from the previous point before it is added to the line."
				},
				"numPoints": {
					"type": "number",
					"description": "The maximum number of points in a line. Points at the tail will be removed first."
				},
				"links": {
					"type": "array",
					"description": "The list of links to apply to this object.",
					"items": {
						"$ref": "#/definitions/link"
					}
				}
			}
		},
		"objects": {
			"type": "array",
			"description": "Object properties",
			"items": {
				"$ref": "#/definitions/object"
			}
		}
	}
}