docs/content/howto/visualization/component-mappings.md
By default, each visualizer reads its input components from the - for example, the Points3D visualizer reads colors from Points3D:colors.
Component mappings let you override this, redirecting any visualizer input to a different component on the same entity. This makes it possible to store multiple variants of the same data and switch between them per view.
To learn more about how visualizers are set up in general, also have a look at the concept page on customizing Views.
This guide uses a point cloud with two color sets as a running example, but the same technique works for any component!
You can find the full example here:
<picture> <source media="(max-width: 480px)" srcset="https://static.rerun.io/component-mappings-viewer-overview/bb3c3d249b44f1ef7bd569f58481d146380b061d/480w.png"> <source media="(max-width: 768px)" srcset="https://static.rerun.io/component-mappings-viewer-overview/bb3c3d249b44f1ef7bd569f58481d146380b061d/768w.png"> <source media="(max-width: 1024px)" srcset="https://static.rerun.io/component-mappings-viewer-overview/bb3c3d249b44f1ef7bd569f58481d146380b061d/1024w.png"> <source media="(max-width: 1200px)" srcset="https://static.rerun.io/component-mappings-viewer-overview/bb3c3d249b44f1ef7bd569f58481d146380b061d/1200w.png"> </picture>A standard archetype like Points3D assigns a fixed column name, as well as component type & archetype metainformation, to every component it logs (Points3D:colors, Points3D:positions, etc.).
To store additional variants of a component on the same entity, log them as custom archetypes. The easiest way to do this is to use the DynamicArchetype utility.
snippet: howto/dual_color_point_cloud[log_custom_archetypes]
After this call, the entity's component list contains four components:
Points3D:positions, Points3D:radii — from the standard archetypeHeightColors:colors — the first custom variantSpinColors:colors — the second custom variantYou can inspect this in the viewer by selecting the entity in the streams panel:
<picture style="zoom: 0.5"> <source media="(max-width: 480px)" srcset="https://static.rerun.io/component-mappings-selection/92c625844b0ad513c5985e71b825ee7121134959/480w.png"> <source media="(max-width: 768px)" srcset="https://static.rerun.io/component-mappings-selection/92c625844b0ad513c5985e71b825ee7121134959/768w.png"> </picture>To make a visualizer read from an arbitrary source, we need to explicitly set the component mapping for a visualizer. The mapping specifies a target (the component the visualizer expects) and a source (the component to actually read from). Everything that isn't explicitly mapped keeps its default behavior.
snippet: howto/dual_color_point_cloud[blueprint]
In this example, each view overrides only the color source for the Points3D visualizer - positions, radii, and everything else are still read from their default sources automatically.
In the viewer you can access and this in the visualizer settings, presented when selecting an entity in a view:
<picture style="zoom: 0.5"> <source media="(max-width: 480px)" srcset="https://static.rerun.io/component-mappings-source-mapping/5718b252fca23f80f794bdd51a4eb391e0466fe6/480w.png"> <source media="(max-width: 768px)" srcset="https://static.rerun.io/component-mappings-source-mapping/5718b252fca23f80f794bdd51a4eb391e0466fe6/768w.png"> <source media="(max-width: 1024px)" srcset="https://static.rerun.io/component-mappings-source-mapping/5718b252fca23f80f794bdd51a4eb391e0466fe6/1024w.png"> <source media="(max-width: 1200px)" srcset="https://static.rerun.io/component-mappings-source-mapping/5718b252fca23f80f794bdd51a4eb391e0466fe6/1200w.png"> </picture>You can set up the same mappings interactively without writing any blueprint code:
HeightColors:colors).