1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! the Node trait is the base trait for every node. the scene is made up of types the implement
//! this trait.
//!
//! Node are made up of some components that all Nodes need to have such as a transform, a scene to
//! store children, and an EventReceiver to handle events. you can create your own nodes that
//! implement the node trait and add them to the scene just like any other node.
//!
//! # Example
//! ```rust
//! use maple::{
//! Node,
//! components::NodeTransform,
//! };
//!
//! // every node needs to have a transform.
//! // children and events are managed by the Scene.
//! #[derive(Clone, Node)]
//! pub struct CustomNode {
//!
//! /// The transform of the node.
//! #[transform]
//! pub transform: NodeTransform,
//!
//! /* other fields */
//! }
//! ```
use crate::;
use Any;
/// The Node trait is used to define that a type is a node in the scene graph.
/// A node is a part of the scene tree that can be transformed and have children.
/// the node_manager only stores nodes that implement the Node trait.
// impl fmt::Debug for dyn Node {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// // Start at the root level (no indentation)
// self.fmt_with_indent(f, 0)
// }
// }
/// The Instanceable trait is used to define that a node can be efficiently instanced.
///
/// Instancing creates a new node that shares the underlying data (like buffers, materials)
/// but has its own transform and descriptor sets. This is much more efficient than cloning
/// the entire node with all its GPU resources.