re_types/archetypes/
ellipsoids3d.rs

1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/ellipsoids3d.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22/// **Archetype**: 3D ellipsoids or spheres.
23///
24/// This archetype is for ellipsoids or spheres whose size is a key part of the data
25/// (e.g. a bounding sphere).
26/// For points whose radii are for the sake of visualization, use [`archetypes::Points3D`][crate::archetypes::Points3D] instead.
27///
28/// If there's more instance poses than half sizes, the last ellipsoid/sphere's orientation will be repeated for the remaining poses.
29/// Orienting and placing ellipsoids/spheres forms a separate transform that is applied prior to [`archetypes::InstancePoses3D`][crate::archetypes::InstancePoses3D] and [`archetypes::Transform3D`][crate::archetypes::Transform3D].
30///
31/// ## Example
32///
33/// ### Covariance ellipsoid
34/// ```ignore
35/// use rand::prelude::*;
36///
37/// fn main() -> Result<(), Box<dyn std::error::Error>> {
38///     let rec = rerun::RecordingStreamBuilder::new("rerun_example_ellipsoid_simple").spawn()?;
39///
40///     let sigmas: [f32; 3] = [5., 3., 1.];
41///
42///     let mut rng = rand::rngs::SmallRng::seed_from_u64(42);
43///     let normal = rand_distr::Normal::new(0.0, 1.0)?;
44///
45///     rec.log(
46///         "points",
47///         &rerun::Points3D::new((0..50_000).map(|_| {
48///             (
49///                 sigmas[0] * normal.sample(&mut rng),
50///                 sigmas[1] * normal.sample(&mut rng),
51///                 sigmas[2] * normal.sample(&mut rng),
52///             )
53///         }))
54///         .with_radii([0.02])
55///         .with_colors([rerun::Color::from_rgb(188, 77, 185)]),
56///     )?;
57///
58///     rec.log(
59///         "ellipsoid",
60///         &rerun::Ellipsoids3D::from_centers_and_half_sizes(
61///             [(0.0, 0.0, 0.0), (0.0, 0.0, 0.0)],
62///             [sigmas, [sigmas[0] * 3., sigmas[1] * 3., sigmas[2] * 3.]],
63///         )
64///         .with_colors([
65///             rerun::Color::from_rgb(255, 255, 0),
66///             rerun::Color::from_rgb(64, 64, 0),
67///         ]),
68///     )?;
69///
70///     Ok(())
71/// }
72/// ```
73/// <center>
74/// <picture>
75///   <source media="(max-width: 480px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/480w.png">
76///   <source media="(max-width: 768px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/768w.png">
77///   <source media="(max-width: 1024px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/1024w.png">
78///   <source media="(max-width: 1200px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/1200w.png">
79///   <img src="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/full.png" width="640">
80/// </picture>
81/// </center>
82#[derive(Clone, Debug, PartialEq, Default)]
83pub struct Ellipsoids3D {
84    /// For each ellipsoid, half of its size on its three axes.
85    ///
86    /// If all components are equal, then it is a sphere with that radius.
87    pub half_sizes: Option<SerializedComponentBatch>,
88
89    /// Optional center positions of the ellipsoids.
90    ///
91    /// If not specified, the centers will be at (0, 0, 0).
92    pub centers: Option<SerializedComponentBatch>,
93
94    /// Rotations via axis + angle.
95    ///
96    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
97    pub rotation_axis_angles: Option<SerializedComponentBatch>,
98
99    /// Rotations via quaternion.
100    ///
101    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
102    pub quaternions: Option<SerializedComponentBatch>,
103
104    /// Optional colors for the ellipsoids.
105    pub colors: Option<SerializedComponentBatch>,
106
107    /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
108    pub line_radii: Option<SerializedComponentBatch>,
109
110    /// Optionally choose whether the ellipsoids are drawn with lines or solid.
111    pub fill_mode: Option<SerializedComponentBatch>,
112
113    /// Optional text labels for the ellipsoids.
114    pub labels: Option<SerializedComponentBatch>,
115
116    /// Whether the text labels should be shown.
117    ///
118    /// If not set, labels will automatically appear when there is exactly one label for this entity
119    /// or the number of instances on this entity is under a certain threshold.
120    pub show_labels: Option<SerializedComponentBatch>,
121
122    /// Optional class ID for the ellipsoids.
123    ///
124    /// The class ID provides colors and labels if not specified explicitly.
125    pub class_ids: Option<SerializedComponentBatch>,
126}
127
128impl Ellipsoids3D {
129    /// Returns the [`ComponentDescriptor`] for [`Self::half_sizes`].
130    ///
131    /// The corresponding component is [`crate::components::HalfSize3D`].
132    #[inline]
133    pub fn descriptor_half_sizes() -> ComponentDescriptor {
134        ComponentDescriptor {
135            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
136            component: "Ellipsoids3D:half_sizes".into(),
137            component_type: Some("rerun.components.HalfSize3D".into()),
138        }
139    }
140
141    /// Returns the [`ComponentDescriptor`] for [`Self::centers`].
142    ///
143    /// The corresponding component is [`crate::components::PoseTranslation3D`].
144    #[inline]
145    pub fn descriptor_centers() -> ComponentDescriptor {
146        ComponentDescriptor {
147            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
148            component: "Ellipsoids3D:centers".into(),
149            component_type: Some("rerun.components.PoseTranslation3D".into()),
150        }
151    }
152
153    /// Returns the [`ComponentDescriptor`] for [`Self::rotation_axis_angles`].
154    ///
155    /// The corresponding component is [`crate::components::PoseRotationAxisAngle`].
156    #[inline]
157    pub fn descriptor_rotation_axis_angles() -> ComponentDescriptor {
158        ComponentDescriptor {
159            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
160            component: "Ellipsoids3D:rotation_axis_angles".into(),
161            component_type: Some("rerun.components.PoseRotationAxisAngle".into()),
162        }
163    }
164
165    /// Returns the [`ComponentDescriptor`] for [`Self::quaternions`].
166    ///
167    /// The corresponding component is [`crate::components::PoseRotationQuat`].
168    #[inline]
169    pub fn descriptor_quaternions() -> ComponentDescriptor {
170        ComponentDescriptor {
171            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
172            component: "Ellipsoids3D:quaternions".into(),
173            component_type: Some("rerun.components.PoseRotationQuat".into()),
174        }
175    }
176
177    /// Returns the [`ComponentDescriptor`] for [`Self::colors`].
178    ///
179    /// The corresponding component is [`crate::components::Color`].
180    #[inline]
181    pub fn descriptor_colors() -> ComponentDescriptor {
182        ComponentDescriptor {
183            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
184            component: "Ellipsoids3D:colors".into(),
185            component_type: Some("rerun.components.Color".into()),
186        }
187    }
188
189    /// Returns the [`ComponentDescriptor`] for [`Self::line_radii`].
190    ///
191    /// The corresponding component is [`crate::components::Radius`].
192    #[inline]
193    pub fn descriptor_line_radii() -> ComponentDescriptor {
194        ComponentDescriptor {
195            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
196            component: "Ellipsoids3D:line_radii".into(),
197            component_type: Some("rerun.components.Radius".into()),
198        }
199    }
200
201    /// Returns the [`ComponentDescriptor`] for [`Self::fill_mode`].
202    ///
203    /// The corresponding component is [`crate::components::FillMode`].
204    #[inline]
205    pub fn descriptor_fill_mode() -> ComponentDescriptor {
206        ComponentDescriptor {
207            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
208            component: "Ellipsoids3D:fill_mode".into(),
209            component_type: Some("rerun.components.FillMode".into()),
210        }
211    }
212
213    /// Returns the [`ComponentDescriptor`] for [`Self::labels`].
214    ///
215    /// The corresponding component is [`crate::components::Text`].
216    #[inline]
217    pub fn descriptor_labels() -> ComponentDescriptor {
218        ComponentDescriptor {
219            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
220            component: "Ellipsoids3D:labels".into(),
221            component_type: Some("rerun.components.Text".into()),
222        }
223    }
224
225    /// Returns the [`ComponentDescriptor`] for [`Self::show_labels`].
226    ///
227    /// The corresponding component is [`crate::components::ShowLabels`].
228    #[inline]
229    pub fn descriptor_show_labels() -> ComponentDescriptor {
230        ComponentDescriptor {
231            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
232            component: "Ellipsoids3D:show_labels".into(),
233            component_type: Some("rerun.components.ShowLabels".into()),
234        }
235    }
236
237    /// Returns the [`ComponentDescriptor`] for [`Self::class_ids`].
238    ///
239    /// The corresponding component is [`crate::components::ClassId`].
240    #[inline]
241    pub fn descriptor_class_ids() -> ComponentDescriptor {
242        ComponentDescriptor {
243            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
244            component: "Ellipsoids3D:class_ids".into(),
245            component_type: Some("rerun.components.ClassId".into()),
246        }
247    }
248}
249
250static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
251    once_cell::sync::Lazy::new(|| [Ellipsoids3D::descriptor_half_sizes()]);
252
253static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
254    once_cell::sync::Lazy::new(|| {
255        [
256            Ellipsoids3D::descriptor_centers(),
257            Ellipsoids3D::descriptor_colors(),
258        ]
259    });
260
261static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 7usize]> =
262    once_cell::sync::Lazy::new(|| {
263        [
264            Ellipsoids3D::descriptor_rotation_axis_angles(),
265            Ellipsoids3D::descriptor_quaternions(),
266            Ellipsoids3D::descriptor_line_radii(),
267            Ellipsoids3D::descriptor_fill_mode(),
268            Ellipsoids3D::descriptor_labels(),
269            Ellipsoids3D::descriptor_show_labels(),
270            Ellipsoids3D::descriptor_class_ids(),
271        ]
272    });
273
274static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 10usize]> =
275    once_cell::sync::Lazy::new(|| {
276        [
277            Ellipsoids3D::descriptor_half_sizes(),
278            Ellipsoids3D::descriptor_centers(),
279            Ellipsoids3D::descriptor_colors(),
280            Ellipsoids3D::descriptor_rotation_axis_angles(),
281            Ellipsoids3D::descriptor_quaternions(),
282            Ellipsoids3D::descriptor_line_radii(),
283            Ellipsoids3D::descriptor_fill_mode(),
284            Ellipsoids3D::descriptor_labels(),
285            Ellipsoids3D::descriptor_show_labels(),
286            Ellipsoids3D::descriptor_class_ids(),
287        ]
288    });
289
290impl Ellipsoids3D {
291    /// The total number of components in the archetype: 1 required, 2 recommended, 7 optional
292    pub const NUM_COMPONENTS: usize = 10usize;
293}
294
295impl ::re_types_core::Archetype for Ellipsoids3D {
296    #[inline]
297    fn name() -> ::re_types_core::ArchetypeName {
298        "rerun.archetypes.Ellipsoids3D".into()
299    }
300
301    #[inline]
302    fn display_name() -> &'static str {
303        "Ellipsoids 3D"
304    }
305
306    #[inline]
307    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
308        REQUIRED_COMPONENTS.as_slice().into()
309    }
310
311    #[inline]
312    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
313        RECOMMENDED_COMPONENTS.as_slice().into()
314    }
315
316    #[inline]
317    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
318        OPTIONAL_COMPONENTS.as_slice().into()
319    }
320
321    #[inline]
322    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
323        ALL_COMPONENTS.as_slice().into()
324    }
325
326    #[inline]
327    fn from_arrow_components(
328        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
329    ) -> DeserializationResult<Self> {
330        re_tracing::profile_function!();
331        use ::re_types_core::{Loggable as _, ResultExt as _};
332        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
333        let half_sizes = arrays_by_descr
334            .get(&Self::descriptor_half_sizes())
335            .map(|array| {
336                SerializedComponentBatch::new(array.clone(), Self::descriptor_half_sizes())
337            });
338        let centers = arrays_by_descr
339            .get(&Self::descriptor_centers())
340            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_centers()));
341        let rotation_axis_angles = arrays_by_descr
342            .get(&Self::descriptor_rotation_axis_angles())
343            .map(|array| {
344                SerializedComponentBatch::new(
345                    array.clone(),
346                    Self::descriptor_rotation_axis_angles(),
347                )
348            });
349        let quaternions = arrays_by_descr
350            .get(&Self::descriptor_quaternions())
351            .map(|array| {
352                SerializedComponentBatch::new(array.clone(), Self::descriptor_quaternions())
353            });
354        let colors = arrays_by_descr
355            .get(&Self::descriptor_colors())
356            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
357        let line_radii = arrays_by_descr
358            .get(&Self::descriptor_line_radii())
359            .map(|array| {
360                SerializedComponentBatch::new(array.clone(), Self::descriptor_line_radii())
361            });
362        let fill_mode = arrays_by_descr
363            .get(&Self::descriptor_fill_mode())
364            .map(|array| {
365                SerializedComponentBatch::new(array.clone(), Self::descriptor_fill_mode())
366            });
367        let labels = arrays_by_descr
368            .get(&Self::descriptor_labels())
369            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
370        let show_labels = arrays_by_descr
371            .get(&Self::descriptor_show_labels())
372            .map(|array| {
373                SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
374            });
375        let class_ids = arrays_by_descr
376            .get(&Self::descriptor_class_ids())
377            .map(|array| {
378                SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
379            });
380        Ok(Self {
381            half_sizes,
382            centers,
383            rotation_axis_angles,
384            quaternions,
385            colors,
386            line_radii,
387            fill_mode,
388            labels,
389            show_labels,
390            class_ids,
391        })
392    }
393}
394
395impl ::re_types_core::AsComponents for Ellipsoids3D {
396    #[inline]
397    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
398        use ::re_types_core::Archetype as _;
399        [
400            self.half_sizes.clone(),
401            self.centers.clone(),
402            self.rotation_axis_angles.clone(),
403            self.quaternions.clone(),
404            self.colors.clone(),
405            self.line_radii.clone(),
406            self.fill_mode.clone(),
407            self.labels.clone(),
408            self.show_labels.clone(),
409            self.class_ids.clone(),
410        ]
411        .into_iter()
412        .flatten()
413        .collect()
414    }
415}
416
417impl ::re_types_core::ArchetypeReflectionMarker for Ellipsoids3D {}
418
419impl Ellipsoids3D {
420    /// Create a new `Ellipsoids3D`.
421    #[inline]
422    pub(crate) fn new(
423        half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
424    ) -> Self {
425        Self {
426            half_sizes: try_serialize_field(Self::descriptor_half_sizes(), half_sizes),
427            centers: None,
428            rotation_axis_angles: None,
429            quaternions: None,
430            colors: None,
431            line_radii: None,
432            fill_mode: None,
433            labels: None,
434            show_labels: None,
435            class_ids: None,
436        }
437    }
438
439    /// Update only some specific fields of a `Ellipsoids3D`.
440    #[inline]
441    pub fn update_fields() -> Self {
442        Self::default()
443    }
444
445    /// Clear all the fields of a `Ellipsoids3D`.
446    #[inline]
447    pub fn clear_fields() -> Self {
448        use ::re_types_core::Loggable as _;
449        Self {
450            half_sizes: Some(SerializedComponentBatch::new(
451                crate::components::HalfSize3D::arrow_empty(),
452                Self::descriptor_half_sizes(),
453            )),
454            centers: Some(SerializedComponentBatch::new(
455                crate::components::PoseTranslation3D::arrow_empty(),
456                Self::descriptor_centers(),
457            )),
458            rotation_axis_angles: Some(SerializedComponentBatch::new(
459                crate::components::PoseRotationAxisAngle::arrow_empty(),
460                Self::descriptor_rotation_axis_angles(),
461            )),
462            quaternions: Some(SerializedComponentBatch::new(
463                crate::components::PoseRotationQuat::arrow_empty(),
464                Self::descriptor_quaternions(),
465            )),
466            colors: Some(SerializedComponentBatch::new(
467                crate::components::Color::arrow_empty(),
468                Self::descriptor_colors(),
469            )),
470            line_radii: Some(SerializedComponentBatch::new(
471                crate::components::Radius::arrow_empty(),
472                Self::descriptor_line_radii(),
473            )),
474            fill_mode: Some(SerializedComponentBatch::new(
475                crate::components::FillMode::arrow_empty(),
476                Self::descriptor_fill_mode(),
477            )),
478            labels: Some(SerializedComponentBatch::new(
479                crate::components::Text::arrow_empty(),
480                Self::descriptor_labels(),
481            )),
482            show_labels: Some(SerializedComponentBatch::new(
483                crate::components::ShowLabels::arrow_empty(),
484                Self::descriptor_show_labels(),
485            )),
486            class_ids: Some(SerializedComponentBatch::new(
487                crate::components::ClassId::arrow_empty(),
488                Self::descriptor_class_ids(),
489            )),
490        }
491    }
492
493    /// Partitions the component data into multiple sub-batches.
494    ///
495    /// Specifically, this transforms the existing [`SerializedComponentBatch`]es data into [`SerializedComponentColumn`]s
496    /// instead, via [`SerializedComponentBatch::partitioned`].
497    ///
498    /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
499    ///
500    /// The specified `lengths` must sum to the total length of the component batch.
501    ///
502    /// [`SerializedComponentColumn`]: [::re_types_core::SerializedComponentColumn]
503    #[inline]
504    pub fn columns<I>(
505        self,
506        _lengths: I,
507    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
508    where
509        I: IntoIterator<Item = usize> + Clone,
510    {
511        let columns = [
512            self.half_sizes
513                .map(|half_sizes| half_sizes.partitioned(_lengths.clone()))
514                .transpose()?,
515            self.centers
516                .map(|centers| centers.partitioned(_lengths.clone()))
517                .transpose()?,
518            self.rotation_axis_angles
519                .map(|rotation_axis_angles| rotation_axis_angles.partitioned(_lengths.clone()))
520                .transpose()?,
521            self.quaternions
522                .map(|quaternions| quaternions.partitioned(_lengths.clone()))
523                .transpose()?,
524            self.colors
525                .map(|colors| colors.partitioned(_lengths.clone()))
526                .transpose()?,
527            self.line_radii
528                .map(|line_radii| line_radii.partitioned(_lengths.clone()))
529                .transpose()?,
530            self.fill_mode
531                .map(|fill_mode| fill_mode.partitioned(_lengths.clone()))
532                .transpose()?,
533            self.labels
534                .map(|labels| labels.partitioned(_lengths.clone()))
535                .transpose()?,
536            self.show_labels
537                .map(|show_labels| show_labels.partitioned(_lengths.clone()))
538                .transpose()?,
539            self.class_ids
540                .map(|class_ids| class_ids.partitioned(_lengths.clone()))
541                .transpose()?,
542        ];
543        Ok(columns.into_iter().flatten())
544    }
545
546    /// Helper to partition the component data into unit-length sub-batches.
547    ///
548    /// This is semantically similar to calling [`Self::columns`] with `std::iter::take(1).repeat(n)`,
549    /// where `n` is automatically guessed.
550    #[inline]
551    pub fn columns_of_unit_batches(
552        self,
553    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
554        let len_half_sizes = self.half_sizes.as_ref().map(|b| b.array.len());
555        let len_centers = self.centers.as_ref().map(|b| b.array.len());
556        let len_rotation_axis_angles = self.rotation_axis_angles.as_ref().map(|b| b.array.len());
557        let len_quaternions = self.quaternions.as_ref().map(|b| b.array.len());
558        let len_colors = self.colors.as_ref().map(|b| b.array.len());
559        let len_line_radii = self.line_radii.as_ref().map(|b| b.array.len());
560        let len_fill_mode = self.fill_mode.as_ref().map(|b| b.array.len());
561        let len_labels = self.labels.as_ref().map(|b| b.array.len());
562        let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
563        let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
564        let len = None
565            .or(len_half_sizes)
566            .or(len_centers)
567            .or(len_rotation_axis_angles)
568            .or(len_quaternions)
569            .or(len_colors)
570            .or(len_line_radii)
571            .or(len_fill_mode)
572            .or(len_labels)
573            .or(len_show_labels)
574            .or(len_class_ids)
575            .unwrap_or(0);
576        self.columns(std::iter::repeat(1).take(len))
577    }
578
579    /// For each ellipsoid, half of its size on its three axes.
580    ///
581    /// If all components are equal, then it is a sphere with that radius.
582    #[inline]
583    pub fn with_half_sizes(
584        mut self,
585        half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
586    ) -> Self {
587        self.half_sizes = try_serialize_field(Self::descriptor_half_sizes(), half_sizes);
588        self
589    }
590
591    /// Optional center positions of the ellipsoids.
592    ///
593    /// If not specified, the centers will be at (0, 0, 0).
594    #[inline]
595    pub fn with_centers(
596        mut self,
597        centers: impl IntoIterator<Item = impl Into<crate::components::PoseTranslation3D>>,
598    ) -> Self {
599        self.centers = try_serialize_field(Self::descriptor_centers(), centers);
600        self
601    }
602
603    /// Rotations via axis + angle.
604    ///
605    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
606    #[inline]
607    pub fn with_rotation_axis_angles(
608        mut self,
609        rotation_axis_angles: impl IntoIterator<
610            Item = impl Into<crate::components::PoseRotationAxisAngle>,
611        >,
612    ) -> Self {
613        self.rotation_axis_angles = try_serialize_field(
614            Self::descriptor_rotation_axis_angles(),
615            rotation_axis_angles,
616        );
617        self
618    }
619
620    /// Rotations via quaternion.
621    ///
622    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
623    #[inline]
624    pub fn with_quaternions(
625        mut self,
626        quaternions: impl IntoIterator<Item = impl Into<crate::components::PoseRotationQuat>>,
627    ) -> Self {
628        self.quaternions = try_serialize_field(Self::descriptor_quaternions(), quaternions);
629        self
630    }
631
632    /// Optional colors for the ellipsoids.
633    #[inline]
634    pub fn with_colors(
635        mut self,
636        colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
637    ) -> Self {
638        self.colors = try_serialize_field(Self::descriptor_colors(), colors);
639        self
640    }
641
642    /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
643    #[inline]
644    pub fn with_line_radii(
645        mut self,
646        line_radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
647    ) -> Self {
648        self.line_radii = try_serialize_field(Self::descriptor_line_radii(), line_radii);
649        self
650    }
651
652    /// Optionally choose whether the ellipsoids are drawn with lines or solid.
653    #[inline]
654    pub fn with_fill_mode(mut self, fill_mode: impl Into<crate::components::FillMode>) -> Self {
655        self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), [fill_mode]);
656        self
657    }
658
659    /// This method makes it possible to pack multiple [`crate::components::FillMode`] in a single component batch.
660    ///
661    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_fill_mode`] should
662    /// be used when logging a single row's worth of data.
663    #[inline]
664    pub fn with_many_fill_mode(
665        mut self,
666        fill_mode: impl IntoIterator<Item = impl Into<crate::components::FillMode>>,
667    ) -> Self {
668        self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), fill_mode);
669        self
670    }
671
672    /// Optional text labels for the ellipsoids.
673    #[inline]
674    pub fn with_labels(
675        mut self,
676        labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
677    ) -> Self {
678        self.labels = try_serialize_field(Self::descriptor_labels(), labels);
679        self
680    }
681
682    /// Whether the text labels should be shown.
683    ///
684    /// If not set, labels will automatically appear when there is exactly one label for this entity
685    /// or the number of instances on this entity is under a certain threshold.
686    #[inline]
687    pub fn with_show_labels(
688        mut self,
689        show_labels: impl Into<crate::components::ShowLabels>,
690    ) -> Self {
691        self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
692        self
693    }
694
695    /// This method makes it possible to pack multiple [`crate::components::ShowLabels`] in a single component batch.
696    ///
697    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_show_labels`] should
698    /// be used when logging a single row's worth of data.
699    #[inline]
700    pub fn with_many_show_labels(
701        mut self,
702        show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
703    ) -> Self {
704        self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
705        self
706    }
707
708    /// Optional class ID for the ellipsoids.
709    ///
710    /// The class ID provides colors and labels if not specified explicitly.
711    #[inline]
712    pub fn with_class_ids(
713        mut self,
714        class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
715    ) -> Self {
716        self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
717        self
718    }
719}
720
721impl ::re_byte_size::SizeBytes for Ellipsoids3D {
722    #[inline]
723    fn heap_size_bytes(&self) -> u64 {
724        self.half_sizes.heap_size_bytes()
725            + self.centers.heap_size_bytes()
726            + self.rotation_axis_angles.heap_size_bytes()
727            + self.quaternions.heap_size_bytes()
728            + self.colors.heap_size_bytes()
729            + self.line_radii.heap_size_bytes()
730            + self.fill_mode.heap_size_bytes()
731            + self.labels.heap_size_bytes()
732            + self.show_labels.heap_size_bytes()
733            + self.class_ids.heap_size_bytes()
734    }
735}