Skip to content

Commit

Permalink
Introduce roundtrip-able Points3D archetype (py + rs) (#2774)
Browse files Browse the repository at this point in the history
**Commit by commit!**

What the title says.

This is a pre-requisite to push `Points{2|3}D` all the way, because we
don't really have any sort of tests in place for the legacy Point2D
stuff, on the other hand nearly everything makes use of the old
`Point3D`.

### What

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2774) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2774)
- [Docs preview](https://rerun.io/preview/pr%3Acmc%2Fpoints3d_arch/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Acmc%2Fpoints3d_arch/examples)
  • Loading branch information
teh-cmc authored Jul 21, 2023
1 parent f78af94 commit 684c494
Show file tree
Hide file tree
Showing 52 changed files with 2,298 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/archetypes.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include "./archetypes/points2d.fbs";
include "./archetypes/points3d.fbs";
include "./archetypes/transform3d.fbs";

include "./testing/archetypes/fuzzy.fbs";
Expand Down
72 changes: 72 additions & 0 deletions crates/re_types/definitions/rerun/archetypes/points3d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
include "fbs/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/components.fbs";

namespace rerun.archetypes;

// ---

/// A 3D point cloud with positions and optional colors, radii, labels, etc.
///
/// \py Example
/// \py -------
/// \py
/// \py ```python
/// \py \include:../../../../../docs/code-examples/point3d_simple_v2.py
/// \py ```
///
/// \rs ## Example
/// \rs
/// \rs ```ignore
/// \rs \include:../../../../../docs/code-examples/point3d_simple_v2.rs
/// \rs ```
table Points3D (
"attr.rust.derive": "PartialEq",
order: 100
) {
// --- Required ---

/// All the actual 3D points that make up the point cloud.
points: [rerun.components.Point3D] ("attr.rerun.component_required", order: 1000);

// --- Recommended ---

/// Optional radii for the points, effectively turning them into circles.
radii: [rerun.components.Radius] ("attr.rerun.component_recommended", nullable, order: 2000);

/// Optional colors for the points.
///
/// \python The colors are interpreted as RGB or RGBA in sRGB gamma-space,
/// \python As either 0-1 floats or 0-255 integers, with separate alpha.
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2100);

// --- Optional ---

/// Optional text labels for the points.
labels: [rerun.components.Label] ("attr.rerun.component_optional", nullable, order: 3000);

/// An optional floating point value that specifies the 3D drawing order.
/// Objects with higher values are drawn on top of those with lower values.
///
/// The default for 3D points is 30.0.
draw_order: rerun.components.DrawOrder ("attr.rerun.component_optional", nullable, order: 3100);

/// Optional class Ids for the points.
///
/// The class ID provides colors and labels if not specified explicitly.
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional keypoint IDs for the points, identifying them within a class.
///
/// If keypoint IDs are passed in but no class IDs were specified, the class ID will
/// default to 0.
/// This is useful to identify points within a single classification (which is identified
/// with `class_id`).
/// E.g. the classification might be 'Person' and the keypoints refer to joints on a
/// detected skeleton.
keypoint_ids: [rerun.components.KeypointId] ("attr.rerun.component_optional", nullable, order: 3300);

/// Unique identifiers for each individual point in the batch.
instance_keys: [rerun.components.InstanceKey] ("attr.rerun.component_optional", nullable, order: 3400);
}
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ include "./components/instance_key.fbs";
include "./components/keypoint_id.fbs";
include "./components/label.fbs";
include "./components/point2d.fbs";
include "./components/point3d.fbs";
include "./components/radius.fbs";
include "./components/transform3d.fbs";
21 changes: 21 additions & 0 deletions crates/re_types/definitions/rerun/components/point3d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "rust/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/attributes.fbs";

namespace rerun.components;

// ---

/// A point in 3D space.
struct Point3D (
"attr.python.aliases": "npt.NDArray[np.float32], Sequence[float], Tuple[float, float, float]",
"attr.python.array_aliases": "npt.NDArray[np.float32], Sequence[float]",
"attr.rerun.legacy_fqname": "rerun.point3d",
"attr.rust.derive": "Default, Copy, PartialEq, PartialOrd",
order: 100
) {
xy: rerun.datatypes.Point3D (order: 100);
}
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/datatypes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include "./datatypes/angle.fbs";
include "./datatypes/mat3x3.fbs";
include "./datatypes/mat4x4.fbs";
include "./datatypes/point2d.fbs";
include "./datatypes/point3d.fbs";
include "./datatypes/quaternion.fbs";
include "./datatypes/rotation3d.fbs";
include "./datatypes/rotation_axis_angle.fbs";
Expand Down
20 changes: 20 additions & 0 deletions crates/re_types/definitions/rerun/datatypes/point3d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "fbs/attributes.fbs";
include "rust/attributes.fbs";

namespace rerun.datatypes;

// ---

/// A point in 3D space.
struct Point3D (
"attr.python.aliases": "Sequence[float]",
"attr.python.array_aliases": "npt.NDArray[Any], Sequence[npt.NDArray[Any]], Sequence[Tuple[float, float]], Sequence[float]",
"attr.rust.derive": "Default, Copy, PartialEq, PartialOrd",
order: 100
) {
x: float (order: 100);
y: float (order: 200);
z: float (order: 300);
}
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script.
# It can be safely removed at anytime to force the build script to run again.
# Check out build.rs to see how it's computed.
94f7feacba1a7d75fee69d10294c77e2f4539106e4906f3d58a5db776e11c4be
173356986894caad5a2b01f9b985726839309968b8466a9f1e19401efe546b87
2 changes: 2 additions & 0 deletions crates/re_types/src/archetypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

mod fuzzy;
mod points2d;
mod points3d;
mod transform3d;

pub use self::fuzzy::AffixFuzzer1;
pub use self::points2d::Points2D;
pub use self::points3d::Points3D;
pub use self::transform3d::Transform3D;
Loading

0 comments on commit 684c494

Please sign in to comment.