Skip to main content

three_rs/objects/
group.rs

1//! Port of `three.js/src/objects/Group.js`.
2
3use crate::core::object_ref::ObjectRef;
4use crate::core::Object3D;
5
6/// `Group` — an `Object3D` that exists only to hold children, with
7/// `type = 'Group'` and `isGroup = true`. three.js implements it as a subclass
8/// with no extra state, so here it is a constructor returning a [`ObjectRef`].
9pub struct Group;
10
11impl Group {
12    /// `new Group()`.
13    #[allow(clippy::new_ret_no_self)] // `new` mirrors three.js's constructor and returns a scene-graph `ObjectRef`, not `Self`; public API, not changing.
14    pub fn new() -> ObjectRef {
15        let object = Object3D {
16            object_type: "Group",
17            is_group: true,
18            ..Default::default()
19        };
20        object.into_node()
21    }
22}