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,具体的参数可以根据具体情况进行调整
});
相关推荐
lichenyang45311 小时前
Docker 学习笔记(一):为什么需要镜像、容器和仓库?
前端
kyriewen11 小时前
别再对着 TypeScript 报错发呆了:我把 10 个最常见的红色波浪线翻译成了人话
前端·javascript·typescript
IT_陈寒11 小时前
SpringBoot自动配置的坑,我的API突然就404了
前端·人工智能·后端
free3512 小时前
从 0 实现一个 Tiny JavaScript VM:项目架构拆解
javascript
奇奇怪怪的12 小时前
Embedding 模型 10+ 横向评测
前端
陈广亮12 小时前
Monorepo 从 0 到 1 实操指南 2026 版:pnpm catalogs + Turborepo 2.x + changesets 全链路
前端
子兮曰12 小时前
OpenMontage 深度解剖:你的 AI 编程助手,其实是个视频工作室
前端·后端·ai编程
敲代码的鱼12 小时前
PDF 预览与签名批注写回 支持安卓 iOS 鸿蒙 UTS插件
android·前端·ios
子兮曰13 小时前
前端工具链的「Rust 化」:一场没有赢家的军备竞赛?
前端·后端·rust