JSON Scene File Format

December 16, 2025 ยท View on GitHub

This document describes the structure of scene files that can be loaded by Donut's Scene class.

The scene loader looks at the file extension, and if it's .gltf or .glb, loads that model directly, otherwise treats the input as the custom scene description documented here. So, when Donut-based applications take a scene path on the command line, usually that scene can be either a single glTF model or this scene description.

The loader implementation can be found in Scene.cpp inside the LoadWithThreadPool function and other functions called from there.

1. Top-Level Structure

A scene file is a JSON object with the following top-level properties:

PropertyTypeDescription
modelsarray of stringEach string is a path to a model file (e.g., .gltf, .glb), relative to the scene file location.
Currently, only glTF 2.0 models are supported.
grapharray of objectSee the section on scene graph node objects
animationsarray of objectSee the section on animation objects

2. Scene graph node objects

The graph section contains an array of node objects, where each node may contain child nodes inside its children property.

Every node object may have the following properties:

PropertyTypeDescription
namestringName of the node
parentstringPath of the custom parent node, as a sequence of names separated by / starting from the scene root.
Normally, graph nodes are attached to their parent node in the JSON structure, but this property allows attaching nodes to anything, including inside scene graphs of the model files.
modelintegerIndex into the models array. If specified, an instance of the model is created and attached at this node
translation3-vector (*)Translation vector
rotation4-vectorQuaternion rotation in XYZW format
euler3-vectorEuler angles in radians (used if rotation is not present)
scaling3-vectorScaling vector
childrenarray of node objectsChild nodes
typestringLeaf type for custom node content. The custom node types are defined by SceneTypeFactory::CreateLeaf, which user code may override to support more node types

Note (*): The "N-vector" notation means an array of N numbers, or a single number that is broadcasted to every element of the vector.

Additional properties may be specified for leaf nodes, depending on the node type. The default implementation of SceneTypeFactory supports the following node types and their properties:

DirectionalLight

Represents a basic directional light with or without area, shining along the light node's negative Z axis.

PropertyTypeDescription
color3-vectorColor of the light, default is white [1, 1, 1]
irradiancenumberLight intensity, defined as illuminance of surfaces lit by the light at normal direction, in lm/m^2
angularSizenumberAngular lsize of the light, in degrees, default is 0

PointLight

Represents a point or spherical light source emitting light in all directions from its position.

PropertyTypeDescription
color3-vectorColor of the light, default is white [1, 1, 1]
intensitynumberLight intensity in candela (lm/sr)
radiusnumberLight radius in world units, default is 0 (point light)
rangenumberMaximum effective range of the light, default is infinite

SpotLight

Represents a spotlight emitting a cone of light from its position with a smooth falloff between the inner and outer angles. The angles are measured from the light node's negative Z axis.

PropertyTypeDescription
color3-vectorColor of the light, default is white [1, 1, 1]
intensitynumberLight intensity in candela (lm/sr)
radiusnumberLight radius in world units, default is 0 (point light)
rangenumberMaximum effective range of the light, default is infinite
innerAnglenumberApex angle of the inner (full-bright) cone in degrees, default is 180
outerAnglenumberApex angle of the outer cone in degrees, default is 180

PerspectiveCamera

Represents a perspective camera with specific projection parameters.

PropertyTypeDescription
verticalFovnumberVertical field of view in radians, default is 1.0 (57.2 degrees)
aspectRationumberAspect ratio, default is unspecified (automatic)
zNearnumberNear clipping plane in world units, default is 1.0
zFarnumberFar clipping plane in world units, default is no far plane (reverse infinite projection)

3. Animation objects

The animations section contains an array of animation objects, where each object defines animation channels for scene nodes or materials.

For more information, see KeyframeAnimation.cpp

Animation object properties

PropertyTypeDescription
namestringName of the animation
channelsarrayAnimation channels

Animation channel properties

PropertyTypeDescription
targetstringName of a single target node or material:<name>
targetsarray of stringsMultiple targets
modestringInterpolation mode (step, linear, slerp, hermite, catmull-rom)
attributestringAnimated property (translation, rotation, scaling, or custom property)
dataarrayKeyframes

Keyframe properties

PropertyTypeDescription
timenumberKeyframe time in seconds
valuenumber or arrayValue at keyframe
inTangentnumber or arrayIncoming tangent value (Hermite spline interpolation only)
outTangentnumber or arrayOutgoing tangent value (Hermite spline interpolation only)

4. Example

{
	"models": [
		"glTF-Sample-Assets/Models/Sponza/glTF/Sponza.gltf",
		"glTF-Sample-Assets/Models/BrainStem/glTF/BrainStem.gltf"
	],
	"graph": [
		{
			"name": "Sponza",
			"model": 0
		},
		{
			"name": "DancingRobot1",
			"model": 1,
			"translation": [4, 0, -0.5],
			"scaling": 1.2,
			"rotation": [0, 0.7071068, 0, -0.7071068]
		},
		{
			"name": "DancingRobot2",
			"model": 1,
			"translation": [-5, 0, -0.5],
			"scaling": 1.2,
			"rotation": [0, 0.7071068, 0, 0.7071068]
		}
	]
}