尚未收集儲存庫資訊。
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗A minimal crystal structure viewer for the web. Try the demo.
npm install bravais three
Add a container with a height:
<div id="viewer" style="height: 480px"></div>
Then read a CIF and visualize it:
import { buildScene, createViewer, expandStructure, readCif } from "bravais";
const response = await fetch("https://unpkg.com/bravais/examples/CoO.cif");
const scene = buildScene(expandStructure(await readCif(await response.text())));
createViewer(document.getElementById("viewer")).setLayers([{ scene }]);
A structure read elsewhere, such as by a CIF reader in another language, can be given as plain data instead, with its symmetry operations, its space group, or neither when the sites list every atom of the cell:
import { readStructure } from "bravais";
const structure = await readStructure({
lattice: { a: 4.26, b: 4.26, c: 4.26, alpha: 90, beta: 90, gamma: 90 },
sites: [
{ label: "Co", fractional: [0, 0, 0], species: [{ element: "Co" }] },
{ label: "O", fractional: [0.5, 0.5, 0.5], species: [{ element: "O" }] },
],
spaceGroup: { symbol: "F m -3 m" },
});
readStructure checks the data and throws StructureDataError for anything
missing or malformed; the result works everywhere a structure from readCif
does.
Thanks to Feitong Song's Pretty Lattice, whose look, controls and softened element colours this viewer follows.
The code was written by Claude Code, under the author's direction and review.