pub struct Object {
pub name: String,
pub transform: Transform,
pub geometry: Option<Geometry>,
pub color: [f32; 4],
pub children: Vec<usize>,
pub parent: Option<usize>,
pub str_id: String,
pub texture_path: Option<String>,
}Expand description
A node in the scene graph.
Every visible or logical entity in a scene is represented by an Object.
Objects are stored in and managed by a crate::world::World; use
crate::world::World::spawn_object (or crate::scene::Scene::spawn) to
insert them.
§Hierarchy
Parent-child relationships are tracked via the Object::parent and
Object::children integer-ID lists. Do not mutate these directly:
use crate::world::World::reparent and crate::world::World::delete
to keep the hierarchy consistent.
§Identity
Each object has two identifiers:
- An integer
idassigned bycrate::world::Worldat spawn time, fast for per-frame lookups. - A stable
str_idstring chosen at construction, human-readable, resolved to an integer viacrate::world::World::get_id.
Fields§
§name: StringHuman-readable display name (does not need to be unique).
transform: TransformLocal-space transform (position, rotation, scale) relative to the parent, or to world origin if at the scene root.
geometry: Option<Geometry>Optional procedural geometry attached to this object. None means
the object is invisible (useful for empty pivot nodes).
color: [f32; 4]RGBA base color multiplied with the geometry during rendering.
Values outside [0.0, 1.0] are currently clamped by the shader.
children: Vec<usize>Integer IDs of direct children. Managed by crate::world::World;
do not mutate directly.
parent: Option<usize>Integer ID of the parent object, or None if this is a root object.
Managed by crate::world::World; do not mutate directly.
str_id: StringStable string identifier used as a human-friendly handle. Should be
unique within a world. Use
crate::world::World::rename_str_id to change it after spawn.
texture_path: Option<String>Path to a texture image applied to this object’s surface.
Implementations§
Source§impl Object
impl Object
Sourcepub fn new(config: ObjectConstructor) -> Self
pub fn new(config: ObjectConstructor) -> Self
Create a new object from an ObjectConstructor configuration.
None fields fall back to their defaults:
transform-> identitystr_id-> random UUIDcolor-> opaque whitegeometry->None(invisible)
Sourcepub fn from_geometry(
name: &str,
str_id: Option<String>,
geometry: Geometry,
transform: Transform,
color: [f32; 4],
) -> Self
pub fn from_geometry( name: &str, str_id: Option<String>, geometry: Geometry, transform: Transform, color: [f32; 4], ) -> Self
Convenience constructor for an object with a known geometry, transform, and color.
name- display name.str_id- stable string handle; a random UUID is used ifNone.geometry- shape attached to the object.transform- initial local transform.color- RGBA base color.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Object
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnsafeUnpin for Object
impl UnwindSafe for Object
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.