1use gltf_v1_derive::Validate;
2use serde_derive::{Deserialize, Serialize};
3
4use super::common::StringIndex;
5use super::node::Node;
6
7#[derive(Clone, Debug, Deserialize, Serialize, Validate, Default)]
8pub struct Scene {
9 #[serde(default)]
10 #[serde(skip_serializing_if = "Vec::is_empty")]
11 pub nodes: Vec<StringIndex<Node>>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub name: Option<String>,
14}
15
16#[test]
17fn test_scene_deserialize() {
18 let data = r#"{
19 "name": "user-defined scene name",
20 "nodes": [
21 "mesh_node_id",
22 "camera_node_id"
23 ],
24 "extensions" : {
25 "extension_name" : {
26 "extension specific" : "value"
27 }
28 },
29 "extras" : {
30 "Application specific" : "The extra object can contain any properties."
31 }
32 }"#;
33 let scene: Result<Scene, _> = serde_json::from_str(data);
34 let scene_unwrap = scene.unwrap();
35 println!("{}", serde_json::to_string(&scene_unwrap).unwrap());
36 assert_eq!(
37 Some("user-defined scene name".to_string()),
38 scene_unwrap.name
39 );
40}