资讯动态

Rerun Interactive 组件详解:控制视图中实体交互行为的核心开关

发布时间:2026/9/16 18:05:26 来源:尧图企业网站定制
Rerun Interactive 组件详解控制视图中实体交互行为的核心开关【免费下载链接】rerunVisualize, query, and stream to train on multimodal robotics data.项目地址: https://gitcode.com/GitHub_Trending/re/rerunInteractive是 Rerun 数据模型re_types / rerun log types中一个基础而关键的组件它决定某个实体在查看器中是否允许被鼠标交互。本指南以 interactive.md 参考文档为骨架结合仓库中的类型定义、蓝图blueprintarchetype 实现与查看器端处理逻辑完整讲解该组件的语义、编码方式、默认值、继承传播规则及在 Python / Rust 三种 SDK 中的实际用法帮助你精确控制视图中可见但不可交互的实体。组件语义可见但不一定可交互根据官方参考文档Interactive组件的语义只有一句话Whether the entity can be interacted with. Non interactive components are still visible, but mouse interactions in the view are disabled.即该组件声明实体是否可以被交互。当实体被标记为不可交互false时它仍然会在视图中正常渲染、保持可见但视图中的鼠标交互例如在 2D/3D 空间视图中对点的悬停高亮、拾取、选中等操作会被禁用。这种可见但不可交互的能力在多模态机器人数据可视化、复杂场景调试中非常实用——例如当某个子树中包含大量辅助几何体、包围盒或标注对象时可以关闭它们的交互以排除对主目标的误选中干扰同时保留其视觉呈现。Rerun 编码与 Arrow 数据类型Interactive是典型的单值布尔组件其编码链路非常简洁Rerun encodingBool即 Bool 编码A single boolean一个单一布尔值Arrow datatypeBooleanArrow 原生布尔数组类型。在 Bool 编码文档 中可以看到Interactive与ClearIsRecursive、IsKeyframe、ShowLabels、Visible等组件一样共享同一种Bool编码均映射为 Arrow 的Boolean数据类型。Rust 侧的透明包装类型在 Rust 实现中该组件被定义为一个对Bool编码的透明repr(transparent)包装结构体类型定义文件interactive.def.rs生成的实现文件interactive.rs其核心声明如下pub struct Interactive(pub crate::encodings::Bool);并注册为ComponentTypererun.components.Interactive见 interactive.rs。类型定义中标注了#[rerun(state stable)]说明该组件属于稳定 API#[rust(repr transparent)]保证它在内存布局上等价于内部的Bool零开销存取。Python 侧的组件类Python 绑定同样由代码生成器产出见 interactive.pyclass Interactive(encodings.Bool, ComponentMixin): **Component**: Whether the entity can be interacted with. Non interactive components are still visible, but mouse interactions in the view are disabled. class InteractiveBatch(encodings.BoolBatch, ComponentBatchMixin): _COMPONENT_TYPE: str rerun.components.InteractiveInteractive直接继承encodings.Bool并混入ComponentMixin因此 Python 端可以直接用布尔值True/False构造或转换该组件InteractiveBatch则是其批量batch形态用于在send_blueprint/ 覆盖override流程中作为批量组件数据被消费。说明Python、Rust 等语言的绑定均由re_types_builder从同一份.def.rs类型定义自动生成源码头部均有 DO NOT EDIT! This file was auto-generated 注释因此各语言下该组件的命名、字段与语义完全一致。默认值默认是可交互的从源码结构看Interactive的默认行为是true可交互Rust 侧为Interactive实现了Default返回Self(true.into())见 interactive_ext.rs查看器端在构建数据结果树DataResultTree时每个节点的初始interactive字段同样被置为true见 view_contents.rs。也就是说在不做任何额外设置的前提下所有实体默认都是可交互的只有当你在蓝图blueprint中显式将其覆盖为false时交互才会被关闭。在EntityBehavior蓝图 archetype 中的角色Interactive并不单独存在而是EntityBehavior蓝图 archetype 的两个可选字段之一。EntityBehavior的定位是实体的通用可视化行为General visualization behavior of an entity定义于类型定义entity_behavior.def.rsRust 实现entity_behavior.rs其结构为两个可选的单值组件字段对应组件语义interactivererun.components.Interactive实体是否可被交互visiblererun.components.Visible实体是否可见继承传播规则EntityBehavior的两个字段都具有沿实体层级向下传播的特性文档注释原话为This property is propagated down the entity hierarchy until another child entity setsinteractiveto a different value at which point propagation continues with that value instead. Defaults to parentsinteractivevalue or true if there is no parent.即父实体的interactive值会向所有子实体传播一旦某个子实体显式设置了不同的interactive值传播就从该值继续向下延伸没有任何父级时默认值为true。这与visible的传播规则完全对称二者共同构成了实体行为这一蓝图层的通用控制面。实际用法Python 端覆盖视图中的实体行为仓库在 entity_behavior.py 中给出了完整可运行的 Python 示例演示如何通过EntityBehavior在视图的overrides中同时控制可见性与交互性import rerun as rr import rerun.blueprint as rrb rr.init(rerun_example_entity_behavior, spawnTrue) # Use EntityBehavior to override visibility interactivity of entities # in the blueprint. rr.send_blueprint( rrb.Spatial2DView( overrides{ hidden_subtree: rrb.EntityBehavior(visibleFalse), hidden_subtree/not_hidden: rrb.EntityBehavior(visibleTrue), non_interactive_subtree: rrb.EntityBehavior(interactiveFalse), } ) ) rr.log(hidden_subtree, rr.Points2D(positions(0, 0), radii0.5)) rr.log(hidden_subtree/also_hidden, rr.LineStrips2D(strips[(-1, 1), (1, -1)])) rr.log(hidden_subtree/not_hidden, rr.LineStrips2D(strips[(1, 1), (-1, -1)])) rr.log(non_interactive_subtree, rr.Boxes2D(centers(0, 0), half_sizes(1, 1))) rr.log( non_interactive_subtree/also_non_interactive, rr.Boxes2D(centers(0, 0), half_sizes(0.5, 0.5)), )要点拆解rrb.EntityBehavior(interactiveFalse)作用于non_interactive_subtree实体路径该路径下的所有子实体包括non_interactive_subtree/also_non_interactive都会继承不可交互状态对应地hidden_subtree被整体隐藏但hidden_subtree/not_hidden通过visibleTrue覆盖回可见——这就是传播规则中子实体设置不同值后以该值继续传播的直观体现interactive与visible相互独立可以只设置其中一个字段另一个保持None即不产生覆盖通过rr.send_blueprint发送的蓝图覆盖是持久化到 blueprint store 的对查看器端后续每一帧的交互判定都生效。Python 的EntityBehavior.__init__签名见 entity_behavior.py为EntityBehavior(*, interactive: encodings.BoolLike | None None, visible: encodings.BoolLike | None None)BoolLike意味着你可以直接传True/False布尔值。Rust 端的 builder 风格Rust 侧EntityBehavior提供了链式构造方法with_interactive/with_visible见 entity_behavior.rs。查看器内部在写回交互覆盖时正是使用该模式blueprint_archetypes::EntityBehavior::update_fields().with_interactive(new_value)该调用出现在 view_query.rs 的save_interactive中是仓库内真实存在的用法范例。查看器端实现原理交互状态如何生效Interactive的值最终如何影响查看器的鼠标交互可以从查看器侧的DataResult与蓝图解析逻辑中得到验证。1.DataResult.interactive字段DataResult表示视图中一个实体的数据查询结果其interactive字段注释明确写道Whether the entity is interactive. This is propagated through the entity tree.见 view_query.rs。并提供了两个便捷方法is_interactive()读取当前实体的交互状态view_query.rssave_interactive(ctx, data_result_tree, new_value)将新的交互值写回蓝图若父级已经持有期望值则清除覆盖避免冗余覆盖否则通过EntityBehavior::update_fields().with_interactive(new_value)写入见 view_query.rs。注意DataResult的文档还专门列出EntityBehaviorvisible、interactive属于对整个实体全局生效的特殊覆盖与CoordinateFrame、VisibleTimeRanges并列view_query.rs说明交互状态是视图级、实体级而非某个可视化器visualizer级的属性。2. 蓝图中覆盖的读取与传播在 view_contents.rs 的update_overrides_recursive中交互状态按以下流程解析递归入口处父级传入parent_interactive当前节点先继承该值作为默认view_contents.rs随后在蓝图引擎中查找当前实体路径上的覆盖若找到EntityBehavior::descriptor_interactive()对应的布尔组件数据则取数组首个值覆盖节点的interactiveview_contents.rs最后将解析出的visible与interactive一并传给所有子节点递归处理view_contents.rs根节点的初始父值在update_overrides中设为parent_visible true; parent_interactive trueview_contents.rs。这段代码完整印证了文档中描述的传播语义父值向下继承 → 子实体覆盖后以新值继续传播 → 无父级时默认true。使用限制与注意事项需要特别说明的是EntityBehavior类型定义中带有已知限制注释TODO(#6541): Fields of this archetype currently only have an effect when logged in the blueprint store.该注释同时出现在 entity_behavior.def.rs 和 entity_behavior.rs 中view_query.rs的is_interactive()/is_visible()注释也做了相同提醒Note that this wont check if the datastore store has interactivity logged见 view_query.rs。因此当前版本下Interactive只应在blueprint store蓝图存储中记录才生效即通过rr.send_blueprint、视图overrides等方式使用若直接向普通的数据存储datastore记录Interactive组件从源码结构看其效果尚未接入对应 issue 为 #6541这一点在使用时需要留意后续版本可能放宽。延伸阅读组件参考文档interactive.md底层布尔编码bool.md组件类型定义与生成实现interactive.def.rs、interactive.rs、interactive_ext.rs蓝图 archetype 定义与实现entity_behavior.def.rs、entity_behavior.rsPython 绑定与示例interactive.py、entity_behavior.py查看器端交互状态解析view_contents.rs、view_query.rs【免费下载链接】rerunVisualize, query, and stream to train on multimodal robotics data.项目地址: https://gitcode.com/GitHub_Trending/re/rerun创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价