pub struct SceneNode {
pub id: NodeId,
pub name: Option<String>,
pub local: Transform,
pub visible: bool,
pub parent: Option<NodeId>,
pub children: Vec<NodeId>,
pub tag: Option<String>,
pub sort_key: i32,
pub user_data: u64,
/* private fields */
}Expand description
A scene graph node with parent-child transform hierarchy.
Fields§
§id: NodeId§name: Option<String>§local: Transform§visible: bool§parent: Option<NodeId>§children: Vec<NodeId>§tag: Option<String>Arbitrary tag for queries (e.g. “player”, “enemy”, “ui”).
sort_key: i32Draw order within the same layer (lower = drawn first).
user_data: u64User-defined metadata slot (e.g. entity index).
Implementations§
Source§impl SceneNode
impl SceneNode
pub fn new(id: NodeId, position: Vec3) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_tag(self, tag: impl Into<String>) -> Self
pub fn with_sort_key(self, key: i32) -> Self
Sourcepub fn set_position(&mut self, pos: Vec3)
pub fn set_position(&mut self, pos: Vec3)
Set local position and mark dirty.
Sourcepub fn set_rotation_z(&mut self, angle: f32)
pub fn set_rotation_z(&mut self, angle: f32)
Set local rotation (Z axis) and mark dirty.
Sourcepub fn set_transform(&mut self, t: Transform)
pub fn set_transform(&mut self, t: Transform)
Set the full local transform and mark dirty.
Sourcepub fn update_world_transform(&mut self, parent_world: &Mat4) -> bool
pub fn update_world_transform(&mut self, parent_world: &Mat4) -> bool
Compute and cache the world transform given the parent’s world matrix. Returns whether recomputation occurred.
Sourcepub fn world_matrix(&self) -> &Mat4
pub fn world_matrix(&self) -> &Mat4
Get the cached world transform matrix.
Sourcepub fn world_position(&self) -> Vec3
pub fn world_position(&self) -> Vec3
World-space position (column 3 of world matrix).
Sourcepub fn world_scale(&self) -> Vec3
pub fn world_scale(&self) -> Vec3
World-space scale (magnitude of columns 0, 1, 2).
Sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Mark this node (and implicitly its subtree) as needing world-transform update.
pub fn is_visible(&self) -> bool
pub fn set_visible(&mut self, v: bool)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SceneNode
impl RefUnwindSafe for SceneNode
impl Send for SceneNode
impl Sync for SceneNode
impl Unpin for SceneNode
impl UnsafeUnpin for SceneNode
impl UnwindSafe for SceneNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.