Molstar 更改 Focus representation 的 扩展半径

更多内容请查看

背景说明:

Focus representation 是指在结构可视化中,当用户选中某个结构元素(如原子、残基、链等)时,会在可视化界面中显示一个突出的表示,以便用户能够更清晰地看到选中的元素。 默认情况下,Focus representation 会扩展一定的半径,以确保选中的元素能够在可视化界面中被突出显示。 但在某些情况下,用户可能希望调整 Focus representation 的扩展半径,以满足特定的可视化需求。

TypeScript 复制代码
export const StructureFocusRepresentation = PluginBehavior.create({
  name: "create-structure-focus-representation",
  display: { name: "Structure Focus Representation" },
  category: "interaction",
  ctor: StructureFocusRepresentationBehavior,
  params: (_, plugin) => StructureFocusRepresentationParams(plugin),
});

方案 1:在初始化 Behavior 时传递参数

TypeScript 复制代码
behaviors: [
  // ...
  PluginSpec.Behavior(StructureFocusRepresentation, { expandRadius: 8 }), // 这里设置扩展半径为8,具体的参数可以根据具体情况进行调整
];

方案 2:在运行时动态修改参数

TypeScript 复制代码
this.plugin.state.updateBehavior(StructureFocusRepresentation, (p) => {
  p.expandRadius = 8; // 这里设置扩展半径为8,具体的参数可以根据具体情况进行调整
});
相关推荐
恋猫de小郭10 小时前
Flutter iOS Deep Link 为什么会突然失效:一系列难以言喻的问题
android·前端·flutter
Full Stack Developme10 小时前
跨站脚本攻击 (XSS) 是什么 设计及工作原理
前端·xss
进击的蛋蛋10 小时前
JS对象拷贝
前端
一心只读圣贤书10 小时前
AI 辅助前端组件文档治理:从 Props 说明到交互示例生成
前端
晴殇i10 小时前
最近在 Github 名字叫“马尾辫”,这个真的很有趣看到头像
前端·后端·开源
10mAh11 小时前
【PaddleOCR】扫描版 PDF 无法复制、RAG 检索为空怎么解决?——OCR 解析与版面还原实战
前端·pdf·ocr
IMPYLH11 小时前
HTML 的 <embed> 元素
前端·数据库·html
IT_陈寒11 小时前
Vite打包时静态资源404?加个斜杠就能解决
前端·人工智能·后端
沐土Arvin11 小时前
音频录制sdk开发
前端·微信
anyup11 小时前
【2026年8月】uView Pro 千星,还拿到了 GVP
前端·uni-app·github