bravais 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,9 @@
1
+ /** The text is not CIF the tokenizer and parser accept. */
2
+ export declare class CifSyntaxError extends Error {
3
+ /** 1-based line of the problem. */
4
+ readonly line: number;
5
+ constructor(message: string, line: number);
6
+ }
1
7
  /** The CIF parses but does not describe a structure this package can use. */
2
8
  export declare class CifStructureError extends Error {
3
9
  constructor(message: string);
@@ -1,15 +1,13 @@
1
1
  import type { Lattice, Site, SpaceGroupInfo, SymmetryOperation } from "../structure/types.js";
2
2
  import { type CifBlock } from "./parser.js";
3
- import { CifStructureError } from "./errors.js";
4
- export { CifStructureError };
5
3
  export interface ParsedCifStructure {
6
4
  lattice: Lattice;
7
5
  sites: Site[];
8
- /** Null when the file lists no operators; see `spaceGroup` then. */
6
+ /** Null when the file lists no operations; see `spaceGroup` then. */
9
7
  operations: SymmetryOperation[] | null;
10
8
  spaceGroup: SpaceGroupInfo;
11
9
  }
12
10
  /** True when the block carries atom coordinates (the one a viewer wants). */
13
11
  export declare function isStructureBlock(block: CifBlock): boolean;
14
- /** Lattice, merged sites, operators and space-group tags of one data block. */
12
+ /** Lattice, merged sites, operations and space-group tags of one data block. */
15
13
  export declare function parseCifStructure(block: CifBlock): ParsedCifStructure;
@@ -3,4 +3,4 @@ import type { SymmetryOperation } from "../structure/types.js";
3
3
  * Parse a symmetry operation as CIF files write it, such as
4
4
  * `-x+1/2, y, -z+1/2`, into a rotation matrix and translation.
5
5
  */
6
- export declare function parseSymmetryOperator(text: string): SymmetryOperation;
6
+ export declare function parseSymmetryOperation(text: string): SymmetryOperation;
@@ -4,12 +4,6 @@ export interface CifToken {
4
4
  text: string;
5
5
  line: number;
6
6
  }
7
- /** The text is not CIF the tokenizer and parser accept. */
8
- export declare class CifSyntaxError extends Error {
9
- /** 1-based line of the problem. */
10
- readonly line: number;
11
- constructor(message: string, line: number);
12
- }
13
7
  /**
14
8
  * Split CIF 1.1 text into tokens. Comments are dropped; quoted strings and
15
9
  * semicolon text fields become single value tokens holding their content.
@@ -1,22 +1,20 @@
1
1
  import type { Structure } from "./structure/types.js";
2
+ export { CifStructureError, CifSyntaxError } from "./cif/errors.js";
2
3
  export { parseCif, type CifBlock, type CifDocument, type CifLoop, } from "./cif/parser.js";
3
- export { CifSyntaxError } from "./cif/tokenizer.js";
4
- export { CifStructureError, parseCifStructure, type ParsedCifStructure, } from "./cif/structure.js";
5
- export { parseSymmetryOperator } from "./cif/symmetry-operators.js";
4
+ export { parseCifStructure, type ParsedCifStructure } from "./cif/structure.js";
5
+ export { parseSymmetryOperation } from "./cif/symmetry-operations.js";
6
6
  export { SpaceGroupLookupError, ensureMoyo, operationsForSpaceGroup, } from "./symmetry/moyo.js";
7
7
  export { SymmetryAnalysisError, symmetryDataset, type SymmetryDataset, type SymmetryOptions, } from "./symmetry/dataset.js";
8
8
  export { typesetSymbol } from "./symmetry/symbol.js";
9
9
  export { expandStructure } from "./structure/expand.js";
10
10
  export { latticeFromParameters, latticeFromVectors, } from "./structure/lattice.js";
11
- export { buildScene, structureElements } from "./scene/build.js";
11
+ export type { Bond } from "./structure/bonds.js";
12
+ export type { Lattice, LatticeParameters, Mat3, Site, SpaceGroupInfo, Species, Structure, SymmetryOperation, Vec3, } from "./structure/types.js";
13
+ export { buildScene, structureElements, type BuildSceneOptions, type SceneAtom, type SceneLayer, type StructureScene, } from "./scene/build.js";
12
14
  export { createViewer, type Viewer, type ViewerOptions, } from "./render/viewer.js";
13
15
  export { createThumbnailRenderer, type ThumbnailRenderer, } from "./render/thumbnails.js";
14
- export type { SceneLayer } from "./scene/build.js";
15
16
  export type { ViewState } from "./render/view-state.js";
16
17
  export { elementColor, elementColorAssignments, ensureElementColors, resetElementColors, } from "./render/palette.js";
17
- export type { BuildSceneOptions, SceneAtom, StructureScene, } from "./scene/build.js";
18
- export type { Bond } from "./structure/bonds.js";
19
- export type { Lattice, LatticeParameters, Mat3, Site, SpaceGroupInfo, Species, Structure, SymmetryOperation, Vec3, } from "./structure/types.js";
20
18
  /**
21
19
  * Read the first structure in a CIF file. Its symmetry comes from the
22
20
  * file's list of symmetry operations or, without one, from its space-group
@@ -1,11 +1,6 @@
1
- import { Box3, OrthographicCamera, Quaternion, Vector3 } from "three";
1
+ import { Box3, OrthographicCamera, Quaternion } from "three";
2
2
  import type { Mat3 } from "../structure/types.js";
3
3
  import type { ViewState } from "./view-state.js";
4
- /** Camera outward direction and up vector of the standard view of a cell. */
5
- export declare function standardViewVectors(cell: Mat3): {
6
- outward: Vector3;
7
- up: Vector3;
8
- };
9
4
  /** Distance of the orthographic camera from its target; only the clipping depends on it. */
10
5
  export declare function cameraDistance(span: number): number;
11
6
  export declare function standardQuaternion(cell: Mat3): Quaternion;
@@ -15,11 +10,6 @@ export declare function standardView(cell: Mat3): ViewState;
15
10
  export declare function applyViewState(camera: OrthographicCamera, view: Pick<ViewState, "quaternion" | "target">, distance: number, span: number): void;
16
11
  /** The orientation of a camera as a view-state quaternion. */
17
12
  export declare function quaternionTuple(quaternion: Quaternion): [number, number, number, number];
18
- /** Size of `bounds` projected on the screen plane of `quaternion`. */
19
- export declare function projectedSize(bounds: Box3, quaternion: Quaternion): {
20
- width: number;
21
- height: number;
22
- };
23
13
  /** Orthographic zoom (pixels per ångström) that fits `bounds` in the viewport. */
24
14
  export declare function fitZoom(bounds: Box3, quaternion: Quaternion, width: number, height: number): number;
25
15
  /** Frustum of an orthographic camera in pixel units, so `zoom` is pixels per ångström. */
@@ -8,7 +8,6 @@ export declare class AxesGizmo {
8
8
  /** The a, b and c arrows, built once and turned to each new cell. */
9
9
  private readonly arrows;
10
10
  private readonly headlight;
11
- private readonly inverse;
12
11
  private readonly direction;
13
12
  /** `fontFamily` is the interface font the axis letters are drawn in. */
14
13
  constructor(fontFamily: string);
@@ -1,14 +1,10 @@
1
1
  import { DataTexture, LineBasicMaterial, MeshStandardMaterial } from "three";
2
- export declare const METALNESS = 0.1;
3
- export declare const ROUGHNESS = 0.6;
4
2
  export declare const AMBIENT_LIGHT_INTENSITY = 0.8;
5
3
  export declare const HEADLIGHT_INTENSITY = 2.2;
6
4
  export declare const HEADLIGHT_OFFSET: readonly [number, number, number];
7
5
  export declare const BACKGROUND_COLOR = "#fafafa";
8
- export declare const CELL_FRAME_COLOR = "#444444";
9
6
  /** The part of a partially occupied site nobody occupies: a faint, see-through tint. */
10
7
  export declare const VACANCY_COLOR = "#f2f2f2";
11
- export declare const VACANCY_OPACITY = 0.3;
12
8
  /** Added to a vacancy texel's start fraction so the shader can tell it apart. */
13
9
  export declare const VACANCY_FLAG = 2;
14
10
  /**
@@ -1,12 +1,10 @@
1
1
  import { Box3, Group } from "three";
2
2
  import type { SceneLayer } from "../scene/build.js";
3
- import type { Mat3, Vec3 } from "../structure/types.js";
3
+ import type { Mat3 } from "../structure/types.js";
4
4
  export interface SceneModel {
5
5
  group: Group;
6
- /** Cell row vectors of the first layer, the frame everything is centred on. */
6
+ /** Cell row vectors of the first layer; `group` moves its centre to the origin. */
7
7
  cell: Mat3;
8
- /** Centre of that cell, which `group` moves to the origin. */
9
- center: Vec3;
10
8
  /** Bounds of every atom and cell corner of every layer, in the centred frame. */
11
9
  bounds: Box3;
12
10
  /** Largest cell edge length of any layer. */
@@ -15,7 +13,6 @@ export interface SceneModel {
15
13
  elements: string[];
16
14
  dispose(): void;
17
15
  }
18
- export declare function cellCenter(cell: Mat3): Vec3;
19
16
  /**
20
17
  * Build the three.js objects for the layers, centred on the first cell. A
21
18
  * layer at opacity 0 is not drawn but still counts toward the centre, the
@@ -15,7 +15,6 @@ export interface Oklch {
15
15
  h: number;
16
16
  }
17
17
  export declare function hexToOklab(hex: string): Oklab;
18
- export declare function isInGamut(lab: Oklab): boolean;
19
18
  export declare function oklabToHex(lab: Oklab): string;
20
19
  export declare function oklabToOklch(lab: Oklab): Oklch;
21
20
  export declare function oklchToOklab(lch: Oklch): Oklab;
@@ -12,8 +12,6 @@ export interface Bond {
12
12
  /** Distance between them in ångström. */
13
13
  length: number;
14
14
  }
15
- /** VESTA's bond-search maximum for an element pair, or null when VESTA draws none. */
16
- export declare function bondCutoff(elementA: string, elementB: string): number | null;
17
15
  /**
18
16
  * Bonds between the given atoms by VESTA's cutoff table. Only pairs VESTA
19
17
  * lists get bonds, so no metal-metal or anion-anion sticks appear. The bonds
@@ -1,8 +1,5 @@
1
1
  /** Element symbols in atomic-number order. */
2
2
  export declare const ELEMENT_SYMBOLS: string[];
3
- /** Deuterium keeps its own symbol for display and counts as hydrogen. */
4
- export declare const DEUTERIUM = "D";
5
- export declare function isElementSymbol(symbol: string): boolean;
6
3
  /**
7
4
  * The element behind a CIF atom label or type symbol: `Fe3+`, `O2-`, `Co1`,
8
5
  * `OW`, `fe` and `Wat` all resolve. Null when no element symbol fits.
@@ -1,12 +1,10 @@
1
1
  import type { SymmetryOperation, Vec3 } from "./types.js";
2
2
  /** Generated equivalents this close in fractional coordinates are one atom. */
3
3
  export declare const EQUIVALENT_TOLERANCE = 0.001;
4
- /** Fold a coordinate into [0, 1); a value within `nearOne` below 1 becomes 0. */
5
- export declare function wrap(value: number, nearOne?: number): number;
4
+ /** Fold a coordinate into [0, 1); a value within `tolerance` below 1 becomes 0. */
5
+ export declare function wrap(value: number, tolerance?: number): number;
6
6
  /** Fold a fractional position into the cell. */
7
7
  export declare function wrapVector(fractional: Vec3): Vec3;
8
- /** Periodic distance of two fractional positions, per axis, below `tolerance`. */
9
- export declare function samePosition(p: Vec3, q: Vec3, tolerance: number): boolean;
10
8
  /**
11
9
  * Fractional positions bucketed by where they fall in the cell, so finding
12
10
  * those within a tolerance of a position, across the periodic boundaries,
@@ -1,4 +1,4 @@
1
- import { type ParsedCifStructure } from "../cif/structure.js";
1
+ import type { ParsedCifStructure } from "../cif/structure.js";
2
2
  import { type SymmetryOperation } from "../structure/types.js";
3
3
  /**
4
4
  * The operations a parsed CIF's atoms are expanded with: the file's own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bravais",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A minimal crystal structure viewer for the web: reads CIF files and draws them with three.js.",
5
5
  "license": "MIT",
6
6
  "author": "Jiacheng Wang",