diff --git a/docs/snippets/INDEX.md b/docs/snippets/INDEX.md index aa559659970c..f77453ae1a2e 100644 --- a/docs/snippets/INDEX.md +++ b/docs/snippets/INDEX.md @@ -67,6 +67,7 @@ _All snippets, organized by the [`Archetype`](https://rerun.io/docs/reference/ty | **[`Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d)** | `archetypes/boxes3d_batch` | Log a batch of oriented bounding boxes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/boxes3d_batch.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/boxes3d_batch.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/boxes3d_batch.cpp) | | **[`Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d)** | `archetypes/instance_poses3d_combined` | Log a simple 3D box with a regular & instance pose transform | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.cpp) | | **[`Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d)** | `archetypes/mesh3d_instancing` | Log a simple 3D mesh with several instance pose transforms which instantiate the mesh several times and will not affect its children (known as mesh instancing) | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.cpp) | +| **[`Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d)** | `archetypes/transform3d_partial_updates` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp) | | **[`Boxes3D`](https://rerun.io/docs/reference/types/archetypes/boxes3d)** | `views/spatial3d` | Use a blueprint to customize a Spatial3DView | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/spatial3d.py) | | | | **[`Capsules3D`](https://rerun.io/docs/reference/types/archetypes/capsules3d)** | `archetypes/capsules3d_batch` | Log a batch of capsules | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.cpp) | | **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `archetypes/clear_simple` | Log and then clear data | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.cpp) | @@ -176,6 +177,7 @@ _All snippets, organized by the [`Archetype`](https://rerun.io/docs/reference/ty | **[`TextLog`](https://rerun.io/docs/reference/types/archetypes/text_log)** | `concepts/app-model/native-async` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-async.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-async.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-async.cpp) | | **[`TextLog`](https://rerun.io/docs/reference/types/archetypes/text_log)** | `concepts/app-model/native-sync` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-sync.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-sync.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/app-model/native-sync.cpp) | | **[`Transform3D`](https://rerun.io/docs/reference/types/archetypes/transform3d)** | `archetypes/transform3d_simple` | Log different transforms between three arrows | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.cpp) | +| **[`Transform3D`](https://rerun.io/docs/reference/types/archetypes/transform3d)** | `archetypes/transform3d_partial_updates` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp) | | **[`Transform3D`](https://rerun.io/docs/reference/types/archetypes/transform3d)** | `archetypes/transform3d_hierarchy` | Logs a transforms transform hierarchy | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.cpp) | | **[`Transform3D`](https://rerun.io/docs/reference/types/archetypes/transform3d)** | `archetypes/transform3d_axes` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.cpp) | | **[`Transform3D`](https://rerun.io/docs/reference/types/archetypes/transform3d)** | `archetypes/instance_poses3d_combined` | Log a simple 3D box with a regular & instance pose transform | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.cpp) | @@ -210,6 +212,7 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `concepts/viscomp-visualizer-override-multiple` | Override a visualizer | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/viscomp-visualizer-override-multiple.py) | | | | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `descriptors/descr_custom_archetype` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.cpp) | | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `views/spatial3d` | Use a blueprint to customize a Spatial3DView | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/spatial3d.py) | | | +| **[`FillMode`](https://rerun.io/docs/reference/types/components/fill_mode)** | `archetypes/transform3d_partial_updates` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp) | | **[`GeoLineString`](https://rerun.io/docs/reference/types/components/geo_line_string)** | `archetypes/geo_line_strings_simple` | Log a simple geospatial line string | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.cpp) | | **[`GraphEdge`](https://rerun.io/docs/reference/types/components/graph_edge)** | `archetypes/graph_directed` | Log a simple directed graph | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_directed.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_directed.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_directed.cpp) | | **[`GraphEdge`](https://rerun.io/docs/reference/types/components/graph_edge)** | `archetypes/graph_undirected` | Log a simple undirected graph | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_undirected.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_undirected.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/graph_undirected.cpp) | @@ -245,6 +248,7 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/mesh3d_instancing` | Log a simple 3D mesh with several instance pose transforms which instantiate the mesh several times and will not affect its children (known as mesh instancing) | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_instancing.cpp) | | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_axes` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_axes.cpp) | | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_hierarchy` | Logs a transforms transform hierarchy | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_hierarchy.cpp) | +| **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_partial_updates` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp) | | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_simple` | Log different transforms between three arrows | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_simple` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_send_columns` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.cpp) | diff --git a/docs/snippets/all/archetypes/transform3d_partial_updates.cpp b/docs/snippets/all/archetypes/transform3d_partial_updates.cpp new file mode 100644 index 000000000000..9baeb0c9586e --- /dev/null +++ b/docs/snippets/all/archetypes/transform3d_partial_updates.cpp @@ -0,0 +1,64 @@ +// Log different transforms with visualized coordinates axes. + +#include +#include + +float truncated_radians(float deg) { + return static_cast(static_cast(deg * M_PI / 180.0f * 1000.0f)) / 1000.0f; +} + +int main() { + const auto rec = rerun::RecordingStream("rerun_example_transform3d_axes"); + rec.spawn().exit_on_failure(); + + auto step = 0; + + rec.set_time_sequence("step", step); + rec.log( + "box", + rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}}).with_fill_mode(rerun::FillMode::Solid), + rerun::Transform3D().with_axis_length(10.0) + ); + + for (int deg = 0; deg <= 45; deg++) { + step++; + rec.set_time_sequence("step", step); + + auto rad = truncated_radians(deg * 4); + // TODO(cmc): update_fields + rec.log( + "box", + rerun::Transform3D().with_rotation_axis_angle( + rerun::RotationAxisAngle({0.0f, 1.0f, 0.0f}, rerun::Angle::radians(rad)) + ) + ); + } + + for (int t = 0; t <= 45; t++) { + step++; + rec.set_time_sequence("step", step); + rec.log( + "box", + rerun::Transform3D().with_translation({0.0f, 0.0f, static_cast(t) / 10.0f}) + ); + } + + for (int deg = 0; deg <= 45; deg++) { + step++; + rec.set_time_sequence("step", step); + + auto rad = truncated_radians((deg + 45) * 4); + // TODO(cmc): update_fields + rec.log( + "box", + rerun::Transform3D().with_rotation_axis_angle( + rerun::RotationAxisAngle({0.0f, 1.0f, 0.0f}, rerun::Angle::radians(rad)) + ) + ); + } + + step++; + rec.set_time_sequence("step", step); + // TODO(cmc): clear_fields + rec.log("box", rerun::Transform3D().with_axis_length(15.0)); +} diff --git a/docs/snippets/all/archetypes/transform3d_partial_updates.py b/docs/snippets/all/archetypes/transform3d_partial_updates.py new file mode 100644 index 000000000000..531f04255020 --- /dev/null +++ b/docs/snippets/all/archetypes/transform3d_partial_updates.py @@ -0,0 +1,66 @@ +"""Log different transforms with visualized coordinates axes.""" + +import math + +import rerun as rr + + +def truncated_radians(deg: float) -> float: + return float(int(math.radians(deg) * 1000.0)) / 1000.0 + + +rr.init("rerun_example_transform3d_axes", spawn=True) + +step = 0 +rr.set_time_sequence("step", step) + +rr.log( + "box", + rr.Boxes3D(half_sizes=[4.0, 2.0, 1.0], fill_mode=rr.components.FillMode.Solid), + rr.Transform3D(axis_length=10), +) + +for deg in range(46): + step += 1 + rr.set_time_sequence("step", step) + + rad = truncated_radians(deg * 4) + # TODO(cmc): update_fields + rr.log( + "box", + rr.Transform3D( + # TODO(cmc): we should have access to all the fields of the extended constructor too. + rotation_axis_angle=rr.RotationAxisAngle(axis=[0.0, 1.0, 0.0], radians=rad), + ), + ) + +for t in range(51): + step += 1 + rr.set_time_sequence("step", step) + # TODO(cmc): update_fields + rr.log( + "box", + rr.Transform3D(translation=[0, 0, t / 10.0]), + ) + +for deg in range(46): + step += 1 + rr.set_time_sequence("step", step) + + rad = truncated_radians((deg + 45) * 4) + # TODO(cmc): update_fields + rr.log( + "box", + rr.Transform3D( + # TODO(cmc): we should have access to all the fields of the extended constructor too. + rotation_axis_angle=rr.RotationAxisAngle(axis=[0.0, 1.0, 0.0], radians=rad), + ), + ) + +step += 1 +rr.set_time_sequence("step", step) +# TODO(cmc): update_fields(clear=True) +rr.log( + "box", + rr.Transform3D(axis_length=15), +) diff --git a/docs/snippets/all/archetypes/transform3d_partial_updates.rs b/docs/snippets/all/archetypes/transform3d_partial_updates.rs new file mode 100644 index 000000000000..ca1754e59a24 --- /dev/null +++ b/docs/snippets/all/archetypes/transform3d_partial_updates.rs @@ -0,0 +1,67 @@ +//! Log different transforms with visualized coordinates axes. + +fn main() -> Result<(), Box> { + let rec = rerun::RecordingStreamBuilder::new("rerun_example_transform3d_axes").spawn()?; + + let mut step = 0; + + rec.set_time_sequence("step", step); + rec.log( + "box", + &[ + &rerun::Boxes3D::from_half_sizes([(4.0, 2.0, 1.0)]) + .with_fill_mode(rerun::FillMode::Solid) as &dyn rerun::AsComponents, + &rerun::Transform3D::default().with_axis_length(10.0), + ], + )?; + + for deg in 0..=45 { + step += 1; + rec.set_time_sequence("step", step); + + let rad = truncated_radians((deg * 4) as f32); + rec.log( + "box", + &rerun::Transform3D::update_fields().with_rotation(rerun::RotationAxisAngle::new( + [0.0, 1.0, 0.0], + rerun::Angle::from_radians(rad), + )), + )?; + } + + for t in 0..=50 { + step += 1; + rec.set_time_sequence("step", step); + rec.log( + "box", + &rerun::Transform3D::update_fields().with_translation([0.0, 0.0, t as f32 / 10.0]), + )?; + } + + for deg in 0..=45 { + step += 1; + rec.set_time_sequence("step", step); + + let rad = truncated_radians(((deg + 45) * 4) as f32); + rec.log( + "box", + &rerun::Transform3D::update_fields().with_rotation(rerun::RotationAxisAngle::new( + [0.0, 1.0, 0.0], + rerun::Angle::from_radians(rad), + )), + )?; + } + + step += 1; + rec.set_time_sequence("step", step); + rec.log( + "box", + &rerun::Transform3D::clear_fields().with_axis_length(15.0), + )?; + + Ok(()) +} + +fn truncated_radians(deg: f32) -> f32 { + ((deg.to_radians() * 1000.0) as i32) as f32 / 1000.0 +} diff --git a/docs/snippets/snippets.toml b/docs/snippets/snippets.toml index d911b5f21f6c..35cb04b3802c 100644 --- a/docs/snippets/snippets.toml +++ b/docs/snippets/snippets.toml @@ -271,6 +271,10 @@ quick_start = [ # These examples don't have exactly the same implementation. "archetypes/transform3d_hierarchy" = [ # Uses a lot of trigonometry which is surprisingly easy to get the same on Rust & C++, but not on Python/Numpy "py", ] +"archetypes/transform3d_partial_updates" = [ + "cpp", # TODO(cmc): remove once C++ partial updates APIs have shipped + "py", # TODO(cmc): remove once Python partial updates APIs have shipped +] "archetypes/instance_poses3d_combined" = [ # TODO(#3235): Slight floating point differences in point grid. "cpp", "py", diff --git a/lychee.toml b/lychee.toml index 7342caee577e..dbe1ae32f097 100644 --- a/lychee.toml +++ b/lychee.toml @@ -160,4 +160,7 @@ exclude = [ 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp', 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs', 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs', ]