Skip to content

Getting started with the library

CifVis is available on npm; installing it into a project is as simple as:

bash
npm install cifvis

Three.js is the only runtime dependency. Two entry points are exposed:

EntryPurpose
cifvisBrowser entry. Exports everything, and registers <cifview-widget> as a custom element.
cifvis/nobrowserSame core exports (CIF/structure APIs, Filters, density calculation, IAM, reflection readers), but CrystalViewer/CifViewWidget are stubs that throw — safe to import in Node/SSR/test environments with no window.

A minimal viewer

html
<div id="viewer"></div>
<script type="module">
  import { CrystalViewer } from 'cifvis';

  const viewer = new CrystalViewer(document.getElementById('viewer'));
  await viewer.loadCIF(cifContent);
</script>

That gives you the full interactive scene: orthographic camera, orbit/selection controls, lighting, and the filter pipeline. From here:

Parsing CIF files and the structure model are covered in the General section: CIF files and The structure model.