Skip to content

Commit

Permalink
impl Default for gltf_json::Node.
Browse files Browse the repository at this point in the history
Since `Node`s are generally expected to have only a few non-absent
fields, providing this `Default` implementation will allow code that is
generating `Node`s to be much more concise.
  • Loading branch information
kpreid committed Dec 18, 2023
1 parent c17732e commit 804a507
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions examples/export/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,8 @@ fn export(output: Output) {
};

let node = json::Node {
camera: None,
children: None,
extensions: Default::default(),
extras: Default::default(),
matrix: None,
mesh: Some(json::Index::new(0)),
name: None,
rotation: None,
scale: None,
translation: None,
skin: None,
weights: None,
..Default::default()
};

let root = json::Root {
Expand Down
2 changes: 1 addition & 1 deletion gltf-json/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use serde_derive::{Deserialize, Serialize};
/// identity. When a node is targeted for animation (referenced by an
/// animation.channel.target), only TRS properties may be present; `matrix` will not
/// be present.
#[derive(Clone, Debug, Deserialize, Serialize, Validate)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Node {
/// The index of the camera referenced by this node.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit 804a507

Please sign in to comment.