-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
### Related * Follow-up of part 1: #8230 * Fixes #872 ### What Adds new line grid property to the 3D view and enables it by default. Furthermore... * improves the grid shader with infinite cardinal lines while showing only two types of "cardinalitities" * this is simply based on log10(camera distance from plane) and then blends between two levels of grid * improve grid's handling of extreme zoom levels. Still some instability on WebGL, but overall much more robust (less flickering/cutoff) * Introduce a general `Plane3D` component which is meant for later reuse in other contexts The new view property is best described its fbs: ```rust /// Configuration for the 3D line grid. table LineGrid3D ( "attr.rerun.scope": "blueprint" ) { /// Whether the grid is visible. /// /// Defaults to true. visible: rerun.blueprint.components.Visible ("attr.rerun.component_optional", nullable, order: 1000); /// Space between grid lines spacing of one line to the next in scene units. /// /// As you zoom out, successively only every tenth line is shown. /// This controls the closest zoom level. spacing: rerun.blueprint.components.GridSpacing ("attr.rerun.component_optional", nullable, order: 2000); /// In what plane the grid is drawn. /// /// Defaults to whatever plane is determined as the plane at zero units up/down as defined by [components.ViewCoordinates] if present. plane: rerun.components.Plane3D ("attr.rerun.component_optional", nullable, order: 3000); /// How thick the lines should be in ui units. /// /// Default is 1.0 ui unit. stroke_width: rerun.components.StrokeWidth ("attr.rerun.component_optional", nullable, order: 5000); /// Color used for the grid. /// /// Transparency via alpha channel is supported. /// Defaults to a slightly transparent light gray. color: rerun.components.Color ("attr.rerun.component_optional", nullable, order: 6000); } ``` Properties in the viewer in default selection panel width <img width="291" alt="image" src="https://github.com/user-attachments/assets/8292f7bb-e2a4-42b4-9147-7bbd72fc38c7"> New plane controls expanded: <img width="281" alt="image" src="https://github.com/user-attachments/assets/0cc19ce7-1031-4b58-bc24-7c2699d5e25b"> Examples of the grid in action (in default settings): <img width="1326" alt="image" src="https://github.com/user-attachments/assets/fe167eef-29e4-478f-a6e2-d2fb82f30a91"> <img width="1563" alt="image" src="https://github.com/user-attachments/assets/d1a878be-16b0-4c9b-873c-fcf1abcd67fd"> Bad case - grid is not fine enough and through the scene: <img width="1154" alt="image" src="https://github.com/user-attachments/assets/cb76355a-778d-4bd9-a724-b4d9b1dffd84"> Bad case - grid is above the scene. <img width="1464" alt="image" src="https://github.com/user-attachments/assets/0a150db3-f344-444a-a4a0-33c877ea38ae"> ## Testing * [x] Metal * [x] Vulkan * [x] WebGPU * [x] WebGL ## Future work * tweak some examples to disable the grid or change its spacing * Extend grid to 2d scenes
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace rerun.blueprint.archetypes; | ||
|
||
/// Configuration for the 3D line grid. | ||
table LineGrid3D ( | ||
"attr.rerun.scope": "blueprint" | ||
) { | ||
/// Whether the grid is visible. | ||
/// | ||
/// Defaults to true. | ||
visible: rerun.blueprint.components.Visible ("attr.rerun.component_optional", nullable, order: 1000); | ||
|
||
/// Space between grid lines spacing of one line to the next in scene units. | ||
/// | ||
/// As you zoom out, successively only every tenth line is shown. | ||
/// This controls the closest zoom level. | ||
spacing: rerun.blueprint.components.GridSpacing ("attr.rerun.component_optional", nullable, order: 2000); | ||
|
||
/// In what plane the grid is drawn. | ||
/// | ||
/// Defaults to whatever plane is determined as the plane at zero units up/down as defined by [components.ViewCoordinates] if present. | ||
plane: rerun.components.Plane3D ("attr.rerun.component_optional", nullable, order: 3000); | ||
|
||
/// How thick the lines should be in ui units. | ||
/// | ||
/// Default is 1.0 ui unit. | ||
stroke_width: rerun.components.StrokeWidth ("attr.rerun.component_optional", nullable, order: 5000); | ||
|
||
/// Color used for the grid. | ||
/// | ||
/// Transparency via alpha channel is supported. | ||
/// Defaults to a slightly transparent light gray. | ||
color: rerun.components.Color ("attr.rerun.component_optional", nullable, order: 6000); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace rerun.blueprint.components; | ||
|
||
/// Space between grid lines of one line to the next in scene units. | ||
table GridSpacing ( | ||
"attr.python.aliases": "float", | ||
"attr.python.array_aliases": "npt.ArrayLike", | ||
"attr.rerun.scope": "blueprint" | ||
) { | ||
/// Space between grid lines of one line to the next in scene units. | ||
distance: rerun.datatypes.Float32 (order: 100); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace rerun.components; | ||
|
||
/// An infinite 3D plane represented by a unit normal vector and a distance. | ||
/// | ||
/// Any point P on the plane fulfills the equation `dot(xyz, P) - d = 0`, | ||
/// where `xyz` is the plane's normal and `d` the distance of the plane from the origin. | ||
/// This representation is also known as the Hesse normal form. | ||
/// | ||
/// Note: although the normal will be passed through to the | ||
/// datastore as provided, when used in the Viewer, planes will always be normalized. | ||
/// I.e. the plane with xyz = (2, 0, 0), d = 1 is equivalent to xyz = (1, 0, 0), d = 0.5 | ||
struct Plane3D ( | ||
"attr.docs.unreleased", | ||
"attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable", | ||
"attr.rust.repr": "transparent" | ||
) { | ||
xyzd: rerun.datatypes.Plane3D (order: 100); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace rerun.datatypes; | ||
|
||
/// An infinite 3D plane represented by a unit normal vector and a distance. | ||
/// | ||
/// Any point P on the plane fulfills the equation `dot(xyz, P) - d = 0`, | ||
/// where `xyz` is the plane's normal and `d` the distance of the plane from the origin. | ||
/// This representation is also known as the Hesse normal form. | ||
/// | ||
/// Note: although the normal will be passed through to the | ||
/// datastore as provided, when used in the Viewer, planes will always be normalized. | ||
/// I.e. the plane with xyz = (2, 0, 0), d = 1 is equivalent to xyz = (1, 0, 0), d = 0.5 | ||
struct Plane3D ( | ||
"attr.docs.unreleased", | ||
"attr.arrow.transparent", | ||
"attr.python.array_aliases": "npt.NDArray[Any], npt.ArrayLike, Sequence[Sequence[float]]", | ||
"attr.rust.derive": "Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable", | ||
"attr.rust.tuple_struct", | ||
"attr.rust.repr": "C", | ||
"attr.cpp.no_field_ctors" // Always be explicit about the values of the fields. | ||
) { | ||
xyzd: [float: 4] (order: 100); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.