Skip to content

JSON Object Scene format 4

Mr.doob edited this page Jun 15, 2017 · 5 revisions

Work in progress.

Example of Scene with a Box and a Light.

{
	"metadata": {
		"version": 4.3,
		"type": "Object",
		"generator": "ObjectExporter"
	},
	"geometries": [
		{
			"uuid": "C3BF1E70-0BE7-4E6D-B184-C9F1E84A3423",
			"type": "BufferGeometry",
			"data": {
				"attributes": {
					"position": {
						"itemSize": 3,
						"type": "Float32Array",
						"array": [50,50,50,...]
					},
					"normal": {
						"itemSize": 3,
						"type": "Float32Array",
						"array": [1,0,0,...]
					},
					"uv": {
						"itemSize": 2,
						"type": "Float32Array",
						"array": [0,1,...]
					}
				},
				"boundingSphere": {
					"center": [0,0,0],
					"radius": 86.60254037844386
				}
			}
		}
	],
	"materials": [
		{
			"uuid": "87D95D6C-6BB4-4B8F-8166-A3A6945BA5E3",
			"type": "MeshPhongMaterial",
			"color": 16777215,
			"ambient": 16777215,
			"emissive": 0,
			"specular": 1118481,
			"shininess": 30,
			"opacity": 1,
			"transparent": false,
			"wireframe": false
		}
	],
	"object": {
		"uuid": "89529CC6-CBAC-412F-AFD1-FEEAE785BA19",
		"type": "Scene",
		"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
		"children": [
			{
				"uuid": "33FA38D9-0AAC-4657-9BBE-5E5780DDFB2F",
				"name": "Box 1",
				"type": "Mesh",
				"geometry": "C3BF1E70-0BE7-4E6D-B184-C9F1E84A3423",
				"material": "87D95D6C-6BB4-4B8F-8166-A3A6945BA5E3",
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
			},
			{
				"uuid": "16F2E381-2B73-44C4-A7BB-38D7E1CD2381",
				"name": "PointLight 1",
				"type": "PointLight",
				"color": 16777215,
				"intensity": 1,
				"distance": 0,
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,100,200,150,1]
			}
		]
	}
}

Example of scene with a simple indexed BufferGeometry plane

{
	"metadata": {
		"version": 4.3,
		"type": "Object",
		"generator": "ObjectExporter"
	},
	"textures": [],
	"images": [],
	"geometries": [
		{
			"uuid": "0A8F2988-626F-411C-BD6A-AC656C4E6878",
			"type": "BufferGeometry",
			"data": {
				"attributes": {
					"position": {
						"itemSize": 3,
						"type": "Float32Array",
						"array": [1,1,0,1,-1,0,-1,-1,0,-1,1,0],
						"normalized": false
					},
					"normal": {
						"itemSize": 3,
						"type": "Float32Array",
						"array": [0,0,1,0,0,1,0,0,1,0,0,1],
						"normalized": false
					},
					"uv": {
						"itemSize": 2,
						"type": "Float32Array",
						"array": [1,1,1,0,0,0,0,1],
						"normalized": false
					}
				},
				// type of index must be Uint8Array or Uint16Array.
				// # vertices thus cannot exceed 255 or 65535 respectively.
				// The current parser is able to read the index array
				// if it is nested in the attributes object, but such
				// syntax is no longer encouraged.
				"index": {
					"type": "Uint16Array",
					"array": [0,1,2,0,2,3]
				},
				"boundingSphere": {
					"center": [0,0,0],
					"radius": 1
				}
			}
		}
	],
	"materials": [],
	"object": {
		"uuid": "378FAA8D-0888-4249-8701-92D1C1F37C51",
		"type": "Scene",
		"matrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
		"children": [
			{
				"uuid": "E7B44C44-DD75-4C29-B571-21AD6AEF0CA9",
				"name": "SharedVertexTest",
				"type": "Mesh",
				"geometry": "0A8F2988-626F-411C-BD6A-AC656C4E6878",
				"matrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
			}
		]
	}
}

Example of Scene with raw Geometry, Light and a Material with multiple-UV Texture assignment

Note the faces array in the Geometry data object follows the Model Format 3 format. When multiple sets of UVs are present and a UV type bitmask is used, UVs from each set must be provided in the proper order

{
	"metadata": {
		"version": 4.5,
		"type": "Object",
		"generator": "Object3D.toJSON"
	},
	"geometries": [
		{
			"uuid": "0A8F2988-626F-411C-BD6A-AC656C4E6878",
			"type": "Geometry",
			"data": {
				"vertices": [ 1, 1, 0, 1, -1, 0, -1, -1, 0, -1, 1, 0 ],
				"normals":  [ 0,0,1, 0,0,1, 0,0,1, 0,0,1 ],
				"uvs": [ [ 1, 1, 1, 0, 0, 0, 0, 1 ], [ 1, 1, 1, 0, 0, 0, 0, 1 ] ],
				"faces": [ 
					// triangle
					// 00 00 10 00 = 8
					// 8, 
					// [vertex_index, vertex_index, vertex_index],
					// [uv0_index, uv0_index, uv0_index],
					// [uv1_index, uv1_index, uv1_index]
					8, 
					2,1,0, 2,1,0, 2,1,0,
					8,
					3,2,0, 3,2,0, 3,2,0 
				]
			}
		}],
	"materials": [
		{
			"uuid": "1004175C-0998-4243-900E-1183CE95A692",
			"type": "MeshStandardMaterial",
			"color": 16777215,
			"roughness": 0.5,
			"metalness": 0.01,
			"emissive": 0,
			"map": "2B905060-08BC-4F9A-B459-B19426D879A8",
			"normalMap": "DBCBCBC9-9C93-4CB0-96F0-BE95B3EAE706",
			"normalScale": [1,1],
			// roughness map uses the green channel of this map
			"roughnessMap": "2CC1EE93-3FA2-4458-A022-85210D6A415A",
			// aoMap uses the red channel of this map and the 2nd set of UVs
			"aoMap": "2CC1EE93-3FA2-4458-A022-85210D6A415A",
			// explicit aoMapIntensity ensures clean import
			"aoMapIntensity": 0.5,
			"depthFunc": 3,
			"depthTest": true,
			"depthWrite": true,
			"skinning": false,
			"morphTargets": false,
			"dithering": false
		}],
	"textures": [
		{
			"uuid": "2B905060-08BC-4F9A-B459-B19426D879A8",
			"name": "",
			"mapping": 300,
			"repeat": [1,1],
			"offset": [0,0],
			"wrap": [1001,1001],
			"minFilter": 1008,
			"magFilter": 1006,
			"anisotropy": 1,
			"flipY": true,
			"image": "66BE77DC-B7CB-4C84-B685-DDCC506C4015"
		},
		{
			"uuid": "DBCBCBC9-9C93-4CB0-96F0-BE95B3EAE706",
			"name": "",
			"mapping": 300,
			"repeat": [1,1],
			"offset": [0,0],
			"wrap": [1001,1001],
			"minFilter": 1008,
			"magFilter": 1006,
			"anisotropy": 1,
			"flipY": true,
			"image": "CEB6F8FF-29C2-44D4-8C25-6998FF62CDE5"
		},
		{
			"uuid": "2CC1EE93-3FA2-4458-A022-85210D6A415A",
			"name": "",
			"mapping": 300,
			"repeat": [1,1],
			"offset": [0,0],
			"wrap": [1001,1001],
			"minFilter": 1008,
			"magFilter": 1006,
			"anisotropy": 1,
			"flipY": true,
			"image": "5D6FFCBC-2194-4A81-AC85-59D92F101A4C"
		}],
	"images": [
		{
			"uuid": "66BE77DC-B7CB-4C84-B685-DDCC506C4015",
			"url": "Floor_BaseColor.jpg"
		},
		{
			"uuid": "CEB6F8FF-29C2-44D4-8C25-6998FF62CDE5",
			"url": "Floor_Normal.jpg"
		},
		{
			"uuid": "5D6FFCBC-2194-4A81-AC85-59D92F101A4C",
			"url": "Floor_AO_Roughness.jpg"
		}],
	"object": {
		"uuid": "378FAA8D-0888-4249-8701-92D1C1F37C51",
		"type": "Scene",
		"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
		"children": [
			{
				"uuid": "E7B44C44-DD75-4C29-B571-21AD6AEF0CA9",
				"type": "Mesh",
				"name": "FaceIndexedGeom",
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
				"geometry": "0A8F2988-626F-411C-BD6A-AC656C4E6878",
				"material": "1004175C-0998-4243-900E-1183CE95A692"
			},
			{
				"uuid": "95EE0E37-CAA0-455D-8F12-7C4FDF6DF794",
				"type": "PointLight",
				"name": "PointLight 1",
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,4.837141,1],
				"color": 16777215,
				"intensity": 0.25,
				"distance": 0,
				"decay": 1,
				"shadow": {
					"camera": {
						"uuid": "34ED7BBB-6BFE-47F4-B69B-554EC468FE20",
						"type": "PerspectiveCamera",
						"fov": 90,
						"zoom": 1,
						"near": 0.5,
						"far": 500,
						"focus": 10,
						"aspect": 1,
						"filmGauge": 35,
						"filmOffset": 0
					}
				}
			},
			{
				"uuid": "0F2D0E48-F685-487E-8E04-99E0B76F9A19",
				"type": "AmbientLight",
				"name": "AmbientLight 1",
				"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
				"color": 16777215,
				"intensity": 1
			}],
		"background": 11184810
	}
}