3dmol

中文文档
2.5.5发布于 2026/05/23BSD-3-ClauseTypeScriptCommonJS近 30 天下载 35.3万

JavaScript/TypeScript molecular visualization library

原始使用文档
文档目录6 节
  1. Examples
  2. HTML
  3. Documentation
  4. Contact
  5. Citing
  6. Funding

3Dmol.js

CDNJS codecov Github CI

3Dmol.js is an object-oriented, WebGL accelerated JavaScript library for online molecular visualization.

Since 3Dmol.js is licensed under the permissive BSD open-source license, you are free to use it in any project, as long the code is properly acknowledged and cited.

With 3Dmol.js, you can add beautifully rendered molecular visualizations to your web applications. Features include:

  • support for pdb, sdf, mol2, xyz, cif, cdjson, mmtf, prmtop, gro, pqr, cube, and vasp formats
  • parallelized molecular surface computation
  • sphere, stick, line, cross, cartoon, and surface styles
  • atom property based selection and styling
  • labels
  • clickable interactivity with molecular data
  • geometric shapes including spheres and arrows

See the documentation to learn how to use 3Dmol.js as a hosted viewer, embeddable viewer, or as a component of a larger application.

Examples

HTML

<script src="https://3Dmol.org/build/3Dmol-min.js"></script>     
 
 <div style="width: 400px; height: 400px;" 
        class='viewer_3Dmoljs' data-pdb='4N8T' data-style='cartoon:color=spectrum'
        data-surface='opacity:.7;color:white'></div>

JavaScript

We support the use of both PDB queries as well as PDB files.

Alt Text

First you simply create the viewer with a div's id.

var viewer = $3Dmol.createViewer($("#div"));

Then you can download a protein data bank model (here pdb:1MO8) and display it with the styling of your choosing.

$3Dmol.download("pdb:1MO8",viewer,{multimodel:true, frames:true},function(){
    viewer.setStyle({}, {cartoon:{color:"spectrum"}});
    viewer.render();
});

Surfaces

We also support the use of surfaces that are asynchronously loaded and support different color schemes

Alt Text

viewer.addSurface($3Dmol.SurfaceType.VDW, {
    opacity:0.85,
    voldata: new $3Dmol.VolumeData(volumedata, "cube"),
    volscheme: new $3Dmol.Gradient.ROYGB(range[1],range[0])
},{});

Shapes

The use of different shapes and styles is supported.

Alt Text

viewer.addCylinder({start:{x:0.0,y:2.0,z:0.0},
    end:{x:0.0,y:10.0,z:0.0},
    radius:0.5,
    fromCap:false,
    toCap:true,
    color:'teal'});
viewer.addCylinder({start:{x:15.0,y:0.0,z:0.0},
    end:{x:20.0,y:0.0,z:0.0},
    radius:1.0,
    color:'black',
    fromCap:false,
    toCap:false});

Documentation

Please check out our documentation at 3dmol.js. We have tutorials, as well as the stable release of the platform.

Contact

Please address any questions or concerns to [email protected]. You may also submit an issue on github.

Citing

If you use 3Dmol.js, please cite our Bioinformatics paper.

Funding

3DMol.js is funded through R35GM140753 (and previously R01GM108340) from the National Institute of General Medical Sciences. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institute of General Medical Sciences or the National Institutes of Health.

版本与发布记录

3dmol 共发布 51 个版本,首次发布于 2016/12/12;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.5.5latest2026/05/235 个月前
2.5.42026/01/229 个月前
2.5.32025/09/281.1 年前
2.5.22025/07/311.3 年前
2.5.12025/06/261.4 年前
2.5.02025/06/031.4 年前

关于 3dmol 的常见问题

3dmol 是什么?

JavaScript/TypeScript molecular visualization library

如何安装 3dmol?

在项目目录运行 npm install 3dmol,或使用 pnpm add / yarn add / bun add。

3dmol 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

3dmol 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

3dmol 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.16.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

3dmol 可以商用吗?

3dmol 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

3dmol 的下载量有多少?

根据 npm 官方下载统计,3dmol 在 2026/10/04 – 2026/11/02 这 30 天内被下载 353,200 次,日均约 11,773 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

3dmol 还在维护吗?

最新版本 2.5.5 发布于 2026/05/23(5 个月前);至今共发布 51 个版本,其中过去 12 个月发布了 2 个;首次发布于 2016/12/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。