re_types/archetypes/pinhole.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/pinhole.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::allow_attributes)]
8#![allow(clippy::clone_on_copy)]
9#![allow(clippy::cloned_instead_of_copied)]
10#![allow(clippy::map_flatten)]
11#![allow(clippy::needless_question_mark)]
12#![allow(clippy::new_without_default)]
13#![allow(clippy::redundant_closure)]
14#![allow(clippy::too_many_arguments)]
15#![allow(clippy::too_many_lines)]
16#![allow(clippy::wildcard_imports)]
17
18use ::re_types_core::SerializationResult;
19use ::re_types_core::try_serialize_field;
20use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
21use ::re_types_core::{ComponentDescriptor, ComponentType};
22use ::re_types_core::{DeserializationError, DeserializationResult};
23
24/// **Archetype**: Camera perspective projection (a.k.a. intrinsics).
25///
26/// ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
27///
28/// ## Examples
29///
30/// ### Simple pinhole camera
31/// ```ignore
32/// use ndarray::{Array, ShapeBuilder as _};
33/// use rand::prelude::*;
34///
35/// fn main() -> Result<(), Box<dyn std::error::Error>> {
36/// let rec = rerun::RecordingStreamBuilder::new("rerun_example_pinhole").spawn()?;
37///
38/// let mut image = Array::<u8, _>::default((3, 3, 3).f());
39/// let mut rng = rand::rngs::SmallRng::seed_from_u64(42);
40/// image.map_inplace(|x| *x = rng.random());
41///
42/// rec.log(
43/// "world/image",
44/// &rerun::Pinhole::from_focal_length_and_resolution([3., 3.], [3., 3.]),
45/// )?;
46/// rec.log(
47/// "world/image",
48/// &rerun::Image::from_color_model_and_tensor(rerun::ColorModel::RGB, image)?,
49/// )?;
50///
51/// Ok(())
52/// }
53/// ```
54/// <center>
55/// <picture>
56/// <source media="(max-width: 480px)" srcset="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/480w.png">
57/// <source media="(max-width: 768px)" srcset="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/768w.png">
58/// <source media="(max-width: 1024px)" srcset="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/1024w.png">
59/// <source media="(max-width: 1200px)" srcset="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/1200w.png">
60/// <img src="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/full.png" width="640">
61/// </picture>
62/// </center>
63///
64/// ### Perspective pinhole camera
65/// ```ignore
66/// fn main() -> Result<(), Box<dyn std::error::Error>> {
67/// let rec = rerun::RecordingStreamBuilder::new("rerun_example_pinhole_perspective").spawn()?;
68///
69/// let fov_y = std::f32::consts::FRAC_PI_4;
70/// let aspect_ratio = 1.7777778;
71/// rec.log(
72/// "world/cam",
73/// &rerun::Pinhole::from_fov_and_aspect_ratio(fov_y, aspect_ratio)
74/// .with_camera_xyz(rerun::components::ViewCoordinates::RUB)
75/// .with_image_plane_distance(0.1)
76/// .with_color(rerun::Color::from_rgb(255, 128, 0))
77/// .with_line_width(0.003),
78/// )?;
79///
80/// rec.log(
81/// "world/points",
82/// &rerun::Points3D::new([(0.0, 0.0, -0.5), (0.1, 0.1, -0.5), (-0.1, -0.1, -0.5)])
83/// .with_radii([0.025]),
84/// )?;
85///
86/// Ok(())
87/// }
88/// ```
89/// <center>
90/// <picture>
91/// <source media="(max-width: 480px)" srcset="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/480w.png">
92/// <source media="(max-width: 768px)" srcset="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/768w.png">
93/// <source media="(max-width: 1024px)" srcset="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/1024w.png">
94/// <source media="(max-width: 1200px)" srcset="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/1200w.png">
95/// <img src="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/full.png" width="640">
96/// </picture>
97/// </center>
98#[derive(Clone, Debug, PartialEq, Default)]
99pub struct Pinhole {
100 /// Camera projection, from image coordinates to view coordinates.
101 pub image_from_camera: Option<SerializedComponentBatch>,
102
103 /// Pixel resolution (usually integers) of child image space. Width and height.
104 ///
105 /// Example:
106 /// ```text
107 /// [1920.0, 1440.0]
108 /// ```
109 ///
110 /// `image_from_camera` project onto the space spanned by `(0,0)` and `resolution - 1`.
111 pub resolution: Option<SerializedComponentBatch>,
112
113 /// Sets the view coordinates for the camera.
114 ///
115 /// All common values are available as constants on the [`components::ViewCoordinates`][crate::components::ViewCoordinates] class.
116 ///
117 /// The default is `ViewCoordinates::RDF`, i.e. X=Right, Y=Down, Z=Forward, and this is also the recommended setting.
118 /// This means that the camera frustum will point along the positive Z axis of the parent space,
119 /// and the cameras "up" direction will be along the negative Y axis of the parent space.
120 ///
121 /// The camera frustum will point whichever axis is set to `F` (or the opposite of `B`).
122 /// When logging a depth image under this entity, this is the direction the point cloud will be projected.
123 /// With `RDF`, the default forward is +Z.
124 ///
125 /// The frustum's "up" direction will be whichever axis is set to `U` (or the opposite of `D`).
126 /// This will match the negative Y direction of pixel space (all images are assumed to have xyz=RDF).
127 /// With `RDF`, the default is up is -Y.
128 ///
129 /// The frustum's "right" direction will be whichever axis is set to `R` (or the opposite of `L`).
130 /// This will match the positive X direction of pixel space (all images are assumed to have xyz=RDF).
131 /// With `RDF`, the default right is +x.
132 ///
133 /// Other common formats are `RUB` (X=Right, Y=Up, Z=Back) and `FLU` (X=Forward, Y=Left, Z=Up).
134 ///
135 /// NOTE: setting this to something else than `RDF` (the default) will change the orientation of the camera frustum,
136 /// and make the pinhole matrix not match up with the coordinate system of the pinhole entity.
137 ///
138 /// The pinhole matrix (the `image_from_camera` argument) always project along the third (Z) axis,
139 /// but will be re-oriented to project along the forward axis of the `camera_xyz` argument.
140 pub camera_xyz: Option<SerializedComponentBatch>,
141
142 /// The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.
143 ///
144 /// This is only used for visualization purposes, and does not affect the projection itself.
145 pub image_plane_distance: Option<SerializedComponentBatch>,
146
147 /// Color of the camera wireframe.
148 pub color: Option<SerializedComponentBatch>,
149
150 /// Width of the camera wireframe lines.
151 pub line_width: Option<SerializedComponentBatch>,
152}
153
154impl Pinhole {
155 /// Returns the [`ComponentDescriptor`] for [`Self::image_from_camera`].
156 ///
157 /// The corresponding component is [`crate::components::PinholeProjection`].
158 #[inline]
159 pub fn descriptor_image_from_camera() -> ComponentDescriptor {
160 ComponentDescriptor {
161 archetype: Some("rerun.archetypes.Pinhole".into()),
162 component: "Pinhole:image_from_camera".into(),
163 component_type: Some("rerun.components.PinholeProjection".into()),
164 }
165 }
166
167 /// Returns the [`ComponentDescriptor`] for [`Self::resolution`].
168 ///
169 /// The corresponding component is [`crate::components::Resolution`].
170 #[inline]
171 pub fn descriptor_resolution() -> ComponentDescriptor {
172 ComponentDescriptor {
173 archetype: Some("rerun.archetypes.Pinhole".into()),
174 component: "Pinhole:resolution".into(),
175 component_type: Some("rerun.components.Resolution".into()),
176 }
177 }
178
179 /// Returns the [`ComponentDescriptor`] for [`Self::camera_xyz`].
180 ///
181 /// The corresponding component is [`crate::components::ViewCoordinates`].
182 #[inline]
183 pub fn descriptor_camera_xyz() -> ComponentDescriptor {
184 ComponentDescriptor {
185 archetype: Some("rerun.archetypes.Pinhole".into()),
186 component: "Pinhole:camera_xyz".into(),
187 component_type: Some("rerun.components.ViewCoordinates".into()),
188 }
189 }
190
191 /// Returns the [`ComponentDescriptor`] for [`Self::image_plane_distance`].
192 ///
193 /// The corresponding component is [`crate::components::ImagePlaneDistance`].
194 #[inline]
195 pub fn descriptor_image_plane_distance() -> ComponentDescriptor {
196 ComponentDescriptor {
197 archetype: Some("rerun.archetypes.Pinhole".into()),
198 component: "Pinhole:image_plane_distance".into(),
199 component_type: Some("rerun.components.ImagePlaneDistance".into()),
200 }
201 }
202
203 /// Returns the [`ComponentDescriptor`] for [`Self::color`].
204 ///
205 /// The corresponding component is [`crate::components::Color`].
206 #[inline]
207 pub fn descriptor_color() -> ComponentDescriptor {
208 ComponentDescriptor {
209 archetype: Some("rerun.archetypes.Pinhole".into()),
210 component: "Pinhole:color".into(),
211 component_type: Some("rerun.components.Color".into()),
212 }
213 }
214
215 /// Returns the [`ComponentDescriptor`] for [`Self::line_width`].
216 ///
217 /// The corresponding component is [`crate::components::Radius`].
218 #[inline]
219 pub fn descriptor_line_width() -> ComponentDescriptor {
220 ComponentDescriptor {
221 archetype: Some("rerun.archetypes.Pinhole".into()),
222 component: "Pinhole:line_width".into(),
223 component_type: Some("rerun.components.Radius".into()),
224 }
225 }
226}
227
228static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
229 std::sync::LazyLock::new(|| [Pinhole::descriptor_image_from_camera()]);
230
231static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
232 std::sync::LazyLock::new(|| [Pinhole::descriptor_resolution()]);
233
234static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 4usize]> =
235 std::sync::LazyLock::new(|| {
236 [
237 Pinhole::descriptor_camera_xyz(),
238 Pinhole::descriptor_image_plane_distance(),
239 Pinhole::descriptor_color(),
240 Pinhole::descriptor_line_width(),
241 ]
242 });
243
244static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 6usize]> =
245 std::sync::LazyLock::new(|| {
246 [
247 Pinhole::descriptor_image_from_camera(),
248 Pinhole::descriptor_resolution(),
249 Pinhole::descriptor_camera_xyz(),
250 Pinhole::descriptor_image_plane_distance(),
251 Pinhole::descriptor_color(),
252 Pinhole::descriptor_line_width(),
253 ]
254 });
255
256impl Pinhole {
257 /// The total number of components in the archetype: 1 required, 1 recommended, 4 optional
258 pub const NUM_COMPONENTS: usize = 6usize;
259}
260
261impl ::re_types_core::Archetype for Pinhole {
262 #[inline]
263 fn name() -> ::re_types_core::ArchetypeName {
264 "rerun.archetypes.Pinhole".into()
265 }
266
267 #[inline]
268 fn display_name() -> &'static str {
269 "Pinhole"
270 }
271
272 #[inline]
273 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
274 REQUIRED_COMPONENTS.as_slice().into()
275 }
276
277 #[inline]
278 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
279 RECOMMENDED_COMPONENTS.as_slice().into()
280 }
281
282 #[inline]
283 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
284 OPTIONAL_COMPONENTS.as_slice().into()
285 }
286
287 #[inline]
288 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
289 ALL_COMPONENTS.as_slice().into()
290 }
291
292 #[inline]
293 fn from_arrow_components(
294 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
295 ) -> DeserializationResult<Self> {
296 re_tracing::profile_function!();
297 use ::re_types_core::{Loggable as _, ResultExt as _};
298 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
299 let image_from_camera = arrays_by_descr
300 .get(&Self::descriptor_image_from_camera())
301 .map(|array| {
302 SerializedComponentBatch::new(array.clone(), Self::descriptor_image_from_camera())
303 });
304 let resolution = arrays_by_descr
305 .get(&Self::descriptor_resolution())
306 .map(|array| {
307 SerializedComponentBatch::new(array.clone(), Self::descriptor_resolution())
308 });
309 let camera_xyz = arrays_by_descr
310 .get(&Self::descriptor_camera_xyz())
311 .map(|array| {
312 SerializedComponentBatch::new(array.clone(), Self::descriptor_camera_xyz())
313 });
314 let image_plane_distance = arrays_by_descr
315 .get(&Self::descriptor_image_plane_distance())
316 .map(|array| {
317 SerializedComponentBatch::new(
318 array.clone(),
319 Self::descriptor_image_plane_distance(),
320 )
321 });
322 let color = arrays_by_descr
323 .get(&Self::descriptor_color())
324 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_color()));
325 let line_width = arrays_by_descr
326 .get(&Self::descriptor_line_width())
327 .map(|array| {
328 SerializedComponentBatch::new(array.clone(), Self::descriptor_line_width())
329 });
330 Ok(Self {
331 image_from_camera,
332 resolution,
333 camera_xyz,
334 image_plane_distance,
335 color,
336 line_width,
337 })
338 }
339}
340
341impl ::re_types_core::AsComponents for Pinhole {
342 #[inline]
343 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
344 use ::re_types_core::Archetype as _;
345 [
346 self.image_from_camera.clone(),
347 self.resolution.clone(),
348 self.camera_xyz.clone(),
349 self.image_plane_distance.clone(),
350 self.color.clone(),
351 self.line_width.clone(),
352 ]
353 .into_iter()
354 .flatten()
355 .collect()
356 }
357}
358
359impl ::re_types_core::ArchetypeReflectionMarker for Pinhole {}
360
361impl Pinhole {
362 /// Create a new `Pinhole`.
363 #[inline]
364 pub fn new(image_from_camera: impl Into<crate::components::PinholeProjection>) -> Self {
365 Self {
366 image_from_camera: try_serialize_field(
367 Self::descriptor_image_from_camera(),
368 [image_from_camera],
369 ),
370 resolution: None,
371 camera_xyz: None,
372 image_plane_distance: None,
373 color: None,
374 line_width: None,
375 }
376 }
377
378 /// Update only some specific fields of a `Pinhole`.
379 #[inline]
380 pub fn update_fields() -> Self {
381 Self::default()
382 }
383
384 /// Clear all the fields of a `Pinhole`.
385 #[inline]
386 pub fn clear_fields() -> Self {
387 use ::re_types_core::Loggable as _;
388 Self {
389 image_from_camera: Some(SerializedComponentBatch::new(
390 crate::components::PinholeProjection::arrow_empty(),
391 Self::descriptor_image_from_camera(),
392 )),
393 resolution: Some(SerializedComponentBatch::new(
394 crate::components::Resolution::arrow_empty(),
395 Self::descriptor_resolution(),
396 )),
397 camera_xyz: Some(SerializedComponentBatch::new(
398 crate::components::ViewCoordinates::arrow_empty(),
399 Self::descriptor_camera_xyz(),
400 )),
401 image_plane_distance: Some(SerializedComponentBatch::new(
402 crate::components::ImagePlaneDistance::arrow_empty(),
403 Self::descriptor_image_plane_distance(),
404 )),
405 color: Some(SerializedComponentBatch::new(
406 crate::components::Color::arrow_empty(),
407 Self::descriptor_color(),
408 )),
409 line_width: Some(SerializedComponentBatch::new(
410 crate::components::Radius::arrow_empty(),
411 Self::descriptor_line_width(),
412 )),
413 }
414 }
415
416 /// Partitions the component data into multiple sub-batches.
417 ///
418 /// Specifically, this transforms the existing [`SerializedComponentBatch`]es data into [`SerializedComponentColumn`]s
419 /// instead, via [`SerializedComponentBatch::partitioned`].
420 ///
421 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
422 ///
423 /// The specified `lengths` must sum to the total length of the component batch.
424 ///
425 /// [`SerializedComponentColumn`]: [::re_types_core::SerializedComponentColumn]
426 #[inline]
427 pub fn columns<I>(
428 self,
429 _lengths: I,
430 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
431 where
432 I: IntoIterator<Item = usize> + Clone,
433 {
434 let columns = [
435 self.image_from_camera
436 .map(|image_from_camera| image_from_camera.partitioned(_lengths.clone()))
437 .transpose()?,
438 self.resolution
439 .map(|resolution| resolution.partitioned(_lengths.clone()))
440 .transpose()?,
441 self.camera_xyz
442 .map(|camera_xyz| camera_xyz.partitioned(_lengths.clone()))
443 .transpose()?,
444 self.image_plane_distance
445 .map(|image_plane_distance| image_plane_distance.partitioned(_lengths.clone()))
446 .transpose()?,
447 self.color
448 .map(|color| color.partitioned(_lengths.clone()))
449 .transpose()?,
450 self.line_width
451 .map(|line_width| line_width.partitioned(_lengths.clone()))
452 .transpose()?,
453 ];
454 Ok(columns.into_iter().flatten())
455 }
456
457 /// Helper to partition the component data into unit-length sub-batches.
458 ///
459 /// This is semantically similar to calling [`Self::columns`] with `std::iter::take(1).repeat(n)`,
460 /// where `n` is automatically guessed.
461 #[inline]
462 pub fn columns_of_unit_batches(
463 self,
464 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
465 let len_image_from_camera = self.image_from_camera.as_ref().map(|b| b.array.len());
466 let len_resolution = self.resolution.as_ref().map(|b| b.array.len());
467 let len_camera_xyz = self.camera_xyz.as_ref().map(|b| b.array.len());
468 let len_image_plane_distance = self.image_plane_distance.as_ref().map(|b| b.array.len());
469 let len_color = self.color.as_ref().map(|b| b.array.len());
470 let len_line_width = self.line_width.as_ref().map(|b| b.array.len());
471 let len = None
472 .or(len_image_from_camera)
473 .or(len_resolution)
474 .or(len_camera_xyz)
475 .or(len_image_plane_distance)
476 .or(len_color)
477 .or(len_line_width)
478 .unwrap_or(0);
479 self.columns(std::iter::repeat_n(1, len))
480 }
481
482 /// Camera projection, from image coordinates to view coordinates.
483 #[inline]
484 pub fn with_image_from_camera(
485 mut self,
486 image_from_camera: impl Into<crate::components::PinholeProjection>,
487 ) -> Self {
488 self.image_from_camera =
489 try_serialize_field(Self::descriptor_image_from_camera(), [image_from_camera]);
490 self
491 }
492
493 /// This method makes it possible to pack multiple [`crate::components::PinholeProjection`] in a single component batch.
494 ///
495 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_image_from_camera`] should
496 /// be used when logging a single row's worth of data.
497 #[inline]
498 pub fn with_many_image_from_camera(
499 mut self,
500 image_from_camera: impl IntoIterator<Item = impl Into<crate::components::PinholeProjection>>,
501 ) -> Self {
502 self.image_from_camera =
503 try_serialize_field(Self::descriptor_image_from_camera(), image_from_camera);
504 self
505 }
506
507 /// Pixel resolution (usually integers) of child image space. Width and height.
508 ///
509 /// Example:
510 /// ```text
511 /// [1920.0, 1440.0]
512 /// ```
513 ///
514 /// `image_from_camera` project onto the space spanned by `(0,0)` and `resolution - 1`.
515 #[inline]
516 pub fn with_resolution(mut self, resolution: impl Into<crate::components::Resolution>) -> Self {
517 self.resolution = try_serialize_field(Self::descriptor_resolution(), [resolution]);
518 self
519 }
520
521 /// This method makes it possible to pack multiple [`crate::components::Resolution`] in a single component batch.
522 ///
523 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_resolution`] should
524 /// be used when logging a single row's worth of data.
525 #[inline]
526 pub fn with_many_resolution(
527 mut self,
528 resolution: impl IntoIterator<Item = impl Into<crate::components::Resolution>>,
529 ) -> Self {
530 self.resolution = try_serialize_field(Self::descriptor_resolution(), resolution);
531 self
532 }
533
534 /// Sets the view coordinates for the camera.
535 ///
536 /// All common values are available as constants on the [`components::ViewCoordinates`][crate::components::ViewCoordinates] class.
537 ///
538 /// The default is `ViewCoordinates::RDF`, i.e. X=Right, Y=Down, Z=Forward, and this is also the recommended setting.
539 /// This means that the camera frustum will point along the positive Z axis of the parent space,
540 /// and the cameras "up" direction will be along the negative Y axis of the parent space.
541 ///
542 /// The camera frustum will point whichever axis is set to `F` (or the opposite of `B`).
543 /// When logging a depth image under this entity, this is the direction the point cloud will be projected.
544 /// With `RDF`, the default forward is +Z.
545 ///
546 /// The frustum's "up" direction will be whichever axis is set to `U` (or the opposite of `D`).
547 /// This will match the negative Y direction of pixel space (all images are assumed to have xyz=RDF).
548 /// With `RDF`, the default is up is -Y.
549 ///
550 /// The frustum's "right" direction will be whichever axis is set to `R` (or the opposite of `L`).
551 /// This will match the positive X direction of pixel space (all images are assumed to have xyz=RDF).
552 /// With `RDF`, the default right is +x.
553 ///
554 /// Other common formats are `RUB` (X=Right, Y=Up, Z=Back) and `FLU` (X=Forward, Y=Left, Z=Up).
555 ///
556 /// NOTE: setting this to something else than `RDF` (the default) will change the orientation of the camera frustum,
557 /// and make the pinhole matrix not match up with the coordinate system of the pinhole entity.
558 ///
559 /// The pinhole matrix (the `image_from_camera` argument) always project along the third (Z) axis,
560 /// but will be re-oriented to project along the forward axis of the `camera_xyz` argument.
561 #[inline]
562 pub fn with_camera_xyz(
563 mut self,
564 camera_xyz: impl Into<crate::components::ViewCoordinates>,
565 ) -> Self {
566 self.camera_xyz = try_serialize_field(Self::descriptor_camera_xyz(), [camera_xyz]);
567 self
568 }
569
570 /// This method makes it possible to pack multiple [`crate::components::ViewCoordinates`] in a single component batch.
571 ///
572 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_camera_xyz`] should
573 /// be used when logging a single row's worth of data.
574 #[inline]
575 pub fn with_many_camera_xyz(
576 mut self,
577 camera_xyz: impl IntoIterator<Item = impl Into<crate::components::ViewCoordinates>>,
578 ) -> Self {
579 self.camera_xyz = try_serialize_field(Self::descriptor_camera_xyz(), camera_xyz);
580 self
581 }
582
583 /// The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.
584 ///
585 /// This is only used for visualization purposes, and does not affect the projection itself.
586 #[inline]
587 pub fn with_image_plane_distance(
588 mut self,
589 image_plane_distance: impl Into<crate::components::ImagePlaneDistance>,
590 ) -> Self {
591 self.image_plane_distance = try_serialize_field(
592 Self::descriptor_image_plane_distance(),
593 [image_plane_distance],
594 );
595 self
596 }
597
598 /// This method makes it possible to pack multiple [`crate::components::ImagePlaneDistance`] in a single component batch.
599 ///
600 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_image_plane_distance`] should
601 /// be used when logging a single row's worth of data.
602 #[inline]
603 pub fn with_many_image_plane_distance(
604 mut self,
605 image_plane_distance: impl IntoIterator<Item = impl Into<crate::components::ImagePlaneDistance>>,
606 ) -> Self {
607 self.image_plane_distance = try_serialize_field(
608 Self::descriptor_image_plane_distance(),
609 image_plane_distance,
610 );
611 self
612 }
613
614 /// Color of the camera wireframe.
615 #[inline]
616 pub fn with_color(mut self, color: impl Into<crate::components::Color>) -> Self {
617 self.color = try_serialize_field(Self::descriptor_color(), [color]);
618 self
619 }
620
621 /// This method makes it possible to pack multiple [`crate::components::Color`] in a single component batch.
622 ///
623 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_color`] should
624 /// be used when logging a single row's worth of data.
625 #[inline]
626 pub fn with_many_color(
627 mut self,
628 color: impl IntoIterator<Item = impl Into<crate::components::Color>>,
629 ) -> Self {
630 self.color = try_serialize_field(Self::descriptor_color(), color);
631 self
632 }
633
634 /// Width of the camera wireframe lines.
635 #[inline]
636 pub fn with_line_width(mut self, line_width: impl Into<crate::components::Radius>) -> Self {
637 self.line_width = try_serialize_field(Self::descriptor_line_width(), [line_width]);
638 self
639 }
640
641 /// This method makes it possible to pack multiple [`crate::components::Radius`] in a single component batch.
642 ///
643 /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_line_width`] should
644 /// be used when logging a single row's worth of data.
645 #[inline]
646 pub fn with_many_line_width(
647 mut self,
648 line_width: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
649 ) -> Self {
650 self.line_width = try_serialize_field(Self::descriptor_line_width(), line_width);
651 self
652 }
653}
654
655impl ::re_byte_size::SizeBytes for Pinhole {
656 #[inline]
657 fn heap_size_bytes(&self) -> u64 {
658 self.image_from_camera.heap_size_bytes()
659 + self.resolution.heap_size_bytes()
660 + self.camera_xyz.heap_size_bytes()
661 + self.image_plane_distance.heap_size_bytes()
662 + self.color.heap_size_bytes()
663 + self.line_width.heap_size_bytes()
664 }
665}