react-cheminfo 0.135.0 → 0.136.0
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.
- package/lib/crystal/core/cellAtoms.d.ts +43 -0
- package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
- package/lib/crystal/core/cellAtoms.js +70 -0
- package/lib/crystal/core/cellAtoms.js.map +1 -0
- package/lib/crystal/core/index.d.ts +2 -0
- package/lib/crystal/core/index.d.ts.map +1 -1
- package/lib/crystal/core/index.js +1 -0
- package/lib/crystal/core/index.js.map +1 -1
- package/lib/crystal/core/molecules.d.ts.map +1 -1
- package/lib/crystal/core/molecules.js +6 -40
- package/lib/crystal/core/molecules.js.map +1 -1
- package/lib/crystal3d/core/cellClip.d.ts +46 -0
- package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
- package/lib/crystal3d/core/cellClip.js +198 -0
- package/lib/crystal3d/core/cellClip.js.map +1 -0
- package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
- package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
- package/lib/crystal3d/core/cellGeometry.js +153 -0
- package/lib/crystal3d/core/cellGeometry.js.map +1 -0
- package/lib/crystal3d/core/cellStack.d.ts +51 -0
- package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
- package/lib/crystal3d/core/cellStack.js +79 -0
- package/lib/crystal3d/core/cellStack.js.map +1 -0
- package/lib/crystal3d/core/crystalView.d.ts +71 -0
- package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
- package/lib/crystal3d/core/crystalView.js +48 -0
- package/lib/crystal3d/core/crystalView.js.map +1 -0
- package/lib/crystal3d/core/drawingSet.d.ts +31 -0
- package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
- package/lib/crystal3d/core/drawingSet.js +63 -0
- package/lib/crystal3d/core/drawingSet.js.map +1 -0
- package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
- package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
- package/lib/crystal3d/core/elementDrawing.js +100 -0
- package/lib/crystal3d/core/elementDrawing.js.map +1 -0
- package/lib/crystal3d/core/elementExtent.d.ts +42 -0
- package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
- package/lib/crystal3d/core/elementExtent.js +56 -0
- package/lib/crystal3d/core/elementExtent.js.map +1 -0
- package/lib/crystal3d/core/elementLabels.d.ts +31 -0
- package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
- package/lib/crystal3d/core/elementLabels.js +99 -0
- package/lib/crystal3d/core/elementLabels.js.map +1 -0
- package/lib/crystal3d/core/elementShapes.d.ts +43 -0
- package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
- package/lib/crystal3d/core/elementShapes.js +115 -0
- package/lib/crystal3d/core/elementShapes.js.map +1 -0
- package/lib/crystal3d/core/frame.d.ts +36 -0
- package/lib/crystal3d/core/frame.d.ts.map +1 -0
- package/lib/crystal3d/core/frame.js +35 -0
- package/lib/crystal3d/core/frame.js.map +1 -0
- package/lib/crystal3d/core/framing.d.ts +41 -0
- package/lib/crystal3d/core/framing.d.ts.map +1 -0
- package/lib/crystal3d/core/framing.js +79 -0
- package/lib/crystal3d/core/framing.js.map +1 -0
- package/lib/crystal3d/core/index.d.ts +42 -0
- package/lib/crystal3d/core/index.d.ts.map +1 -0
- package/lib/crystal3d/core/index.js +29 -0
- package/lib/crystal3d/core/index.js.map +1 -0
- package/lib/crystal3d/core/labelText.d.ts +19 -0
- package/lib/crystal3d/core/labelText.d.ts.map +1 -0
- package/lib/crystal3d/core/labelText.js +42 -0
- package/lib/crystal3d/core/labelText.js.map +1 -0
- package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
- package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
- package/lib/crystal3d/core/latticeBasis.js +89 -0
- package/lib/crystal3d/core/latticeBasis.js.map +1 -0
- package/lib/crystal3d/core/mat3.d.ts +68 -0
- package/lib/crystal3d/core/mat3.d.ts.map +1 -0
- package/lib/crystal3d/core/mat3.js +146 -0
- package/lib/crystal3d/core/mat3.js.map +1 -0
- package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
- package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
- package/lib/crystal3d/core/operationMatrix.js +172 -0
- package/lib/crystal3d/core/operationMatrix.js.map +1 -0
- package/lib/crystal3d/core/orientation.d.ts +62 -0
- package/lib/crystal3d/core/orientation.d.ts.map +1 -0
- package/lib/crystal3d/core/orientation.js +166 -0
- package/lib/crystal3d/core/orientation.js.map +1 -0
- package/lib/crystal3d/core/palette.d.ts +24 -0
- package/lib/crystal3d/core/palette.d.ts.map +1 -0
- package/lib/crystal3d/core/palette.js +34 -0
- package/lib/crystal3d/core/palette.js.map +1 -0
- package/lib/crystal3d/core/primitives.d.ts +133 -0
- package/lib/crystal3d/core/primitives.d.ts.map +1 -0
- package/lib/crystal3d/core/primitives.js +80 -0
- package/lib/crystal3d/core/primitives.js.map +1 -0
- package/lib/crystal3d/core/structureText.d.ts +20 -0
- package/lib/crystal3d/core/structureText.d.ts.map +1 -0
- package/lib/crystal3d/core/structureText.js +37 -0
- package/lib/crystal3d/core/structureText.js.map +1 -0
- package/lib/crystal3d/core/supercell.d.ts +20 -0
- package/lib/crystal3d/core/supercell.d.ts.map +1 -0
- package/lib/crystal3d/core/supercell.js +35 -0
- package/lib/crystal3d/core/supercell.js.map +1 -0
- package/lib/crystal3d/core/types.d.ts +166 -0
- package/lib/crystal3d/core/types.d.ts.map +1 -0
- package/lib/crystal3d/core/types.js +10 -0
- package/lib/crystal3d/core/types.js.map +1 -0
- package/lib/crystal3d/core/vec3.d.ts +75 -0
- package/lib/crystal3d/core/vec3.d.ts.map +1 -0
- package/lib/crystal3d/core/vec3.js +119 -0
- package/lib/crystal3d/core/vec3.js.map +1 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
- package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
- package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
- package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
- package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
- package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
- package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
- package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
- package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
- package/lib/crystal3d/ui/crystalScene.js +10 -0
- package/lib/crystal3d/ui/crystalScene.js.map +1 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
- package/lib/crystal3d/ui/index.d.ts +16 -0
- package/lib/crystal3d/ui/index.d.ts.map +1 -0
- package/lib/crystal3d/ui/index.js +12 -0
- package/lib/crystal3d/ui/index.js.map +1 -0
- package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
- package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
- package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
- package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
- package/lib/crystal3d/viewer/animate.d.ts +49 -0
- package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
- package/lib/crystal3d/viewer/animate.js +83 -0
- package/lib/crystal3d/viewer/animate.js.map +1 -0
- package/lib/crystal3d/viewer/camera.d.ts +44 -0
- package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
- package/lib/crystal3d/viewer/camera.js +103 -0
- package/lib/crystal3d/viewer/camera.js.map +1 -0
- package/lib/crystal3d/viewer/index.d.ts +13 -0
- package/lib/crystal3d/viewer/index.d.ts.map +1 -0
- package/lib/crystal3d/viewer/index.js +8 -0
- package/lib/crystal3d/viewer/index.js.map +1 -0
- package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
- package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
- package/lib/crystal3d/viewer/layerRegistry.js +39 -0
- package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
- package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
- package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
- package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
- package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
- package/lib/crystal3d/viewer/plugin.d.ts +133 -0
- package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
- package/lib/crystal3d/viewer/plugin.js +181 -0
- package/lib/crystal3d/viewer/plugin.js.map +1 -0
- package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
- package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderCell.js +53 -0
- package/lib/crystal3d/viewer/renderCell.js.map +1 -0
- package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
- package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderElements.js +77 -0
- package/lib/crystal3d/viewer/renderElements.js.map +1 -0
- package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
- package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderStructure.js +103 -0
- package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
- package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
- package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
- package/lib/crystal3d/viewer/sceneParts.js +77 -0
- package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
- package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
- package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/shapeLayer.js +57 -0
- package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
- package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
- package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/textLayer.js +59 -0
- package/lib/crystal3d/viewer/textLayer.js.map +1 -0
- package/lib/crystal3d/viewer/viewer.d.ts +110 -0
- package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/viewer.js +157 -0
- package/lib/crystal3d/viewer/viewer.js.map +1 -0
- package/lib/crystal3d.d.ts +12 -0
- package/lib/crystal3d.d.ts.map +1 -0
- package/lib/crystal3d.js +12 -0
- package/lib/crystal3d.js.map +1 -0
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +19 -1
- package/lib/locales/en.json +19 -1
- package/lib/locales/es.json +19 -1
- package/lib/locales/fr.json +19 -1
- package/lib/locales/it.json +19 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molstar/bonds/bondRule.d.ts +16 -0
- package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
- package/lib/molstar/bonds/bondRule.js +23 -0
- package/lib/molstar/bonds/bondRule.js.map +1 -0
- package/lib/molstar/bonds/index.d.ts +9 -0
- package/lib/molstar/bonds/index.d.ts.map +1 -0
- package/lib/molstar/bonds/index.js +9 -0
- package/lib/molstar/bonds/index.js.map +1 -0
- package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
- package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
- package/lib/molstar/ui/MolstarToolbar.js +28 -0
- package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
- package/lib/molstar/ui/index.d.ts +10 -0
- package/lib/molstar/ui/index.d.ts.map +1 -0
- package/lib/molstar/ui/index.js +8 -0
- package/lib/molstar/ui/index.js.map +1 -0
- package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
- package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
- package/lib/molstar/ui/useMolstarTools.js +36 -0
- package/lib/molstar/ui/useMolstarTools.js.map +1 -0
- package/package.json +2 -1
- package/src/crystal/core/cellAtoms.ts +106 -0
- package/src/crystal/core/index.ts +2 -0
- package/src/crystal/core/molecules.ts +7 -44
- package/src/crystal3d/core/cellClip.ts +229 -0
- package/src/crystal3d/core/cellGeometry.ts +193 -0
- package/src/crystal3d/core/cellStack.ts +87 -0
- package/src/crystal3d/core/crystalView.ts +114 -0
- package/src/crystal3d/core/drawingSet.ts +71 -0
- package/src/crystal3d/core/elementDrawing.ts +147 -0
- package/src/crystal3d/core/elementExtent.ts +81 -0
- package/src/crystal3d/core/elementLabels.ts +130 -0
- package/src/crystal3d/core/elementShapes.ts +141 -0
- package/src/crystal3d/core/frame.ts +56 -0
- package/src/crystal3d/core/framing.ts +101 -0
- package/src/crystal3d/core/index.ts +132 -0
- package/src/crystal3d/core/labelText.ts +44 -0
- package/src/crystal3d/core/latticeBasis.ts +110 -0
- package/src/crystal3d/core/mat3.ts +163 -0
- package/src/crystal3d/core/operationMatrix.ts +255 -0
- package/src/crystal3d/core/orientation.ts +229 -0
- package/src/crystal3d/core/palette.ts +43 -0
- package/src/crystal3d/core/primitives.ts +183 -0
- package/src/crystal3d/core/structureText.ts +43 -0
- package/src/crystal3d/core/supercell.ts +40 -0
- package/src/crystal3d/core/types.ts +186 -0
- package/src/crystal3d/core/vec3.ts +127 -0
- package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
- package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
- package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
- package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
- package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
- package/src/crystal3d/ui/crystalScene.ts +100 -0
- package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
- package/src/crystal3d/ui/index.ts +20 -0
- package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
- package/src/crystal3d/viewer/animate.ts +113 -0
- package/src/crystal3d/viewer/camera.ts +139 -0
- package/src/crystal3d/viewer/index.ts +13 -0
- package/src/crystal3d/viewer/layerRegistry.ts +47 -0
- package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
- package/src/crystal3d/viewer/plugin.ts +258 -0
- package/src/crystal3d/viewer/renderCell.ts +98 -0
- package/src/crystal3d/viewer/renderElements.ts +121 -0
- package/src/crystal3d/viewer/renderStructure.ts +144 -0
- package/src/crystal3d/viewer/sceneParts.ts +119 -0
- package/src/crystal3d/viewer/shapeLayer.ts +108 -0
- package/src/crystal3d/viewer/textLayer.ts +85 -0
- package/src/crystal3d/viewer/viewer.ts +207 -0
- package/src/crystal3d.ts +12 -0
- package/src/locales/de.json +19 -1
- package/src/locales/en.json +19 -1
- package/src/locales/es.json +19 -1
- package/src/locales/fr.json +19 -1
- package/src/locales/it.json +19 -1
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
- package/src/molstar/bonds/bondRule.ts +34 -0
- package/src/molstar/bonds/index.ts +9 -0
- package/src/molstar/ui/MolstarToolbar.tsx +103 -0
- package/src/molstar/ui/index.ts +14 -0
- package/src/molstar/ui/useMolstarTools.ts +98 -0
- package/styles/chrome.css +90 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operation as a matrix, and as the path the structure takes to get there.
|
|
3
|
+
*
|
|
4
|
+
* A proper rotation and a screw have a rigid path from the identity, so they
|
|
5
|
+
* are turned through it and the molecule visibly lands back on itself. The
|
|
6
|
+
* improper ones have none: no continuous rigid motion carries a body onto its
|
|
7
|
+
* mirror image. Pretending otherwise would teach the wrong thing, so instead the
|
|
8
|
+
* structure passes *through* the plane or the centre — flat at the halfway
|
|
9
|
+
* point, which is exactly where the operation's fixed set is.
|
|
10
|
+
*/
|
|
11
|
+
import type { ViewerOperation } from './types.ts';
|
|
12
|
+
/** A 4×4 affine matrix, sixteen numbers in **column-major** order. */
|
|
13
|
+
export type Matrix4 = readonly number[];
|
|
14
|
+
/** The matrix that moves nothing. */
|
|
15
|
+
export declare const IDENTITY_MATRIX4: Matrix4;
|
|
16
|
+
/**
|
|
17
|
+
* The operation itself, as one matrix.
|
|
18
|
+
* @param operation - What to apply.
|
|
19
|
+
* @returns The 4×4 matrix, column-major.
|
|
20
|
+
*/
|
|
21
|
+
export declare function operationMatrix(operation: ViewerOperation): Matrix4;
|
|
22
|
+
/**
|
|
23
|
+
* The operation part-way through, so a caller can drive it with a clock.
|
|
24
|
+
* @param operation - What to apply.
|
|
25
|
+
* @param fraction - How far through, from 0 (the identity) to 1 (the operation
|
|
26
|
+
* itself). Anything outside that is clamped.
|
|
27
|
+
* @returns The 4×4 matrix, column-major.
|
|
28
|
+
*/
|
|
29
|
+
export declare function operationAt(operation: ViewerOperation, fraction: number): Matrix4;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the path from the identity is a rigid motion all the way.
|
|
32
|
+
*
|
|
33
|
+
* A page says so in one line under the button: a proper rotation turns, and an
|
|
34
|
+
* improper one has to pass through its own mirror.
|
|
35
|
+
* @param operation - What is about to be applied.
|
|
36
|
+
* @returns Whether every frame of it is a rotation.
|
|
37
|
+
*/
|
|
38
|
+
export declare function operationIsRigid(operation: ViewerOperation): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The fraction of an improper animation spent turning, before the reflection or
|
|
41
|
+
* the inversion begins.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ROTATION_PHASE = 0.6;
|
|
44
|
+
//# sourceMappingURL=operationMatrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operationMatrix.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/operationMatrix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,YAAY,CAAC;AAS1D,sEAAsE;AACtE,MAAM,MAAM,OAAO,GAAG,SAAS,MAAM,EAAE,CAAC;AAExC,qCAAqC;AACrC,eAAO,MAAM,gBAAgB,EAAE,OAG9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CA0CT;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAEpE;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,MAAM,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operation as a matrix, and as the path the structure takes to get there.
|
|
3
|
+
*
|
|
4
|
+
* A proper rotation and a screw have a rigid path from the identity, so they
|
|
5
|
+
* are turned through it and the molecule visibly lands back on itself. The
|
|
6
|
+
* improper ones have none: no continuous rigid motion carries a body onto its
|
|
7
|
+
* mirror image. Pretending otherwise would teach the wrong thing, so instead the
|
|
8
|
+
* structure passes *through* the plane or the centre — flat at the halfway
|
|
9
|
+
* point, which is exactly where the operation's fixed set is.
|
|
10
|
+
*/
|
|
11
|
+
import { IDENTITY_MATRIX, INVERSION_MATRIX, applyMatrix, multiplyMatrices, reflectionMatrix, rotationMatrix, } from "./mat3.js";
|
|
12
|
+
import { addVectors, normalizeVector, scaleVector, subtractVectors, } from "./vec3.js";
|
|
13
|
+
/** The matrix that moves nothing. */
|
|
14
|
+
export const IDENTITY_MATRIX4 = affineMatrix(IDENTITY_MATRIX, [0, 0, 0]);
|
|
15
|
+
/**
|
|
16
|
+
* The operation itself, as one matrix.
|
|
17
|
+
* @param operation - What to apply.
|
|
18
|
+
* @returns The 4×4 matrix, column-major.
|
|
19
|
+
*/
|
|
20
|
+
export function operationMatrix(operation) {
|
|
21
|
+
return operationAt(operation, 1);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The operation part-way through, so a caller can drive it with a clock.
|
|
25
|
+
* @param operation - What to apply.
|
|
26
|
+
* @param fraction - How far through, from 0 (the identity) to 1 (the operation
|
|
27
|
+
* itself). Anything outside that is clamped.
|
|
28
|
+
* @returns The 4×4 matrix, column-major.
|
|
29
|
+
*/
|
|
30
|
+
export function operationAt(operation, fraction) {
|
|
31
|
+
const t = Math.min(1, Math.max(0, fraction));
|
|
32
|
+
switch (operation.kind) {
|
|
33
|
+
case 'rotation': {
|
|
34
|
+
return aboutPoint(turn(operation, t), operation.origin, [0, 0, 0]);
|
|
35
|
+
}
|
|
36
|
+
case 'screw': {
|
|
37
|
+
return aboutPoint(turn(operation, t), operation.origin, scaleVector(operation.translation, t));
|
|
38
|
+
}
|
|
39
|
+
case 'mirror': {
|
|
40
|
+
return aboutPoint(blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t), operation.point, [0, 0, 0]);
|
|
41
|
+
}
|
|
42
|
+
case 'glide': {
|
|
43
|
+
return aboutPoint(blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t), operation.point, scaleVector(operation.translation, t));
|
|
44
|
+
}
|
|
45
|
+
case 'inversion': {
|
|
46
|
+
return aboutPoint(blend(IDENTITY_MATRIX, INVERSION_MATRIX, t), operation.centre, [0, 0, 0]);
|
|
47
|
+
}
|
|
48
|
+
case 'improperRotation': {
|
|
49
|
+
return twoPhase(operation, t, mirrorOf(operation.axis));
|
|
50
|
+
}
|
|
51
|
+
case 'rotoinversion': {
|
|
52
|
+
return twoPhase(operation, t, INVERSION_MATRIX);
|
|
53
|
+
}
|
|
54
|
+
// no default
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether the path from the identity is a rigid motion all the way.
|
|
59
|
+
*
|
|
60
|
+
* A page says so in one line under the button: a proper rotation turns, and an
|
|
61
|
+
* improper one has to pass through its own mirror.
|
|
62
|
+
* @param operation - What is about to be applied.
|
|
63
|
+
* @returns Whether every frame of it is a rotation.
|
|
64
|
+
*/
|
|
65
|
+
export function operationIsRigid(operation) {
|
|
66
|
+
return operation.kind === 'rotation' || operation.kind === 'screw';
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The fraction of an improper animation spent turning, before the reflection or
|
|
70
|
+
* the inversion begins.
|
|
71
|
+
*/
|
|
72
|
+
export const ROTATION_PHASE = 0.6;
|
|
73
|
+
/**
|
|
74
|
+
* Rotate rigidly, then pass through the plane or the centre.
|
|
75
|
+
* @param operation - The improper rotation or rotoinversion.
|
|
76
|
+
* @param t - How far through, from 0 to 1.
|
|
77
|
+
* @param improper - The reflection or inversion that follows the turn.
|
|
78
|
+
* @returns The 4×4 matrix, column-major.
|
|
79
|
+
*/
|
|
80
|
+
function twoPhase(operation, t, improper) {
|
|
81
|
+
if (t <= ROTATION_PHASE) {
|
|
82
|
+
return aboutPoint(turn(operation, t / ROTATION_PHASE), operation.origin, [0, 0, 0]);
|
|
83
|
+
}
|
|
84
|
+
const second = (t - ROTATION_PHASE) / (1 - ROTATION_PHASE);
|
|
85
|
+
const rotated = rotationMatrix(normalizeVector(operation.axis), angleOf(operation));
|
|
86
|
+
return aboutPoint(multiplyMatrices(blend(IDENTITY_MATRIX, improper, second), rotated), operation.origin, [0, 0, 0]);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The rotation of `operation` carried `t` of the way round.
|
|
90
|
+
* @param operation - An operation with an axis.
|
|
91
|
+
* @param t - How far round, from 0 to 1.
|
|
92
|
+
* @returns The rotation matrix.
|
|
93
|
+
*/
|
|
94
|
+
function turn(operation, t) {
|
|
95
|
+
return rotationMatrix(normalizeVector(operation.axis), angleOf(operation) * t);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `2πk/n`, the angle one application turns through.
|
|
99
|
+
* @param operation - An operation with an axis.
|
|
100
|
+
* @param operation.order - n, the order of the axis.
|
|
101
|
+
* @param operation.power - k, how many times it is applied; 1 by default.
|
|
102
|
+
* @returns The angle, in radians.
|
|
103
|
+
*/
|
|
104
|
+
function angleOf(operation) {
|
|
105
|
+
return (2 * Math.PI * (operation.power ?? 1)) / operation.order;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `I − 2 n̂ n̂ᵀ`, from a normal the caller need not have normalised.
|
|
109
|
+
* @param normal - The mirror's normal, Cartesian.
|
|
110
|
+
* @returns The reflection matrix.
|
|
111
|
+
*/
|
|
112
|
+
function mirrorOf(normal) {
|
|
113
|
+
return reflectionMatrix(normalizeVector(normal));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `(1 − t) a + t b`, component by component.
|
|
117
|
+
* @param a - The matrix at t = 0.
|
|
118
|
+
* @param b - The matrix at t = 1.
|
|
119
|
+
* @param t - How far from a towards b.
|
|
120
|
+
* @returns The blended matrix.
|
|
121
|
+
*/
|
|
122
|
+
function blend(a, b, t) {
|
|
123
|
+
return [
|
|
124
|
+
blendRow(a[0], b[0], t),
|
|
125
|
+
blendRow(a[1], b[1], t),
|
|
126
|
+
blendRow(a[2], b[2], t),
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
function blendRow(a, b, t) {
|
|
130
|
+
return [
|
|
131
|
+
a[0] * (1 - t) + b[0] * t,
|
|
132
|
+
a[1] * (1 - t) + b[1] * t,
|
|
133
|
+
a[2] * (1 - t) + b[2] * t,
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* `x ↦ L(x − p) + p + w`, written as one affine matrix.
|
|
138
|
+
* @param linear - L, the linear part.
|
|
139
|
+
* @param fixed - p, the point L keeps in place.
|
|
140
|
+
* @param shift - w, the translation added after.
|
|
141
|
+
* @returns The 4×4 matrix, column-major.
|
|
142
|
+
*/
|
|
143
|
+
function aboutPoint(linear, fixed, shift) {
|
|
144
|
+
return affineMatrix(linear, addVectors(subtractVectors(fixed, applyMatrix(linear, fixed)), shift));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The 3×3 and the translation, laid out the way a GPU reads them.
|
|
148
|
+
* @param linear - The linear part.
|
|
149
|
+
* @param translation - The translation, ångström.
|
|
150
|
+
* @returns The 4×4 matrix, column-major.
|
|
151
|
+
*/
|
|
152
|
+
function affineMatrix(linear, translation) {
|
|
153
|
+
return [
|
|
154
|
+
linear[0][0],
|
|
155
|
+
linear[1][0],
|
|
156
|
+
linear[2][0],
|
|
157
|
+
0,
|
|
158
|
+
linear[0][1],
|
|
159
|
+
linear[1][1],
|
|
160
|
+
linear[2][1],
|
|
161
|
+
0,
|
|
162
|
+
linear[0][2],
|
|
163
|
+
linear[1][2],
|
|
164
|
+
linear[2][2],
|
|
165
|
+
0,
|
|
166
|
+
translation[0],
|
|
167
|
+
translation[1],
|
|
168
|
+
translation[2],
|
|
169
|
+
1,
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=operationMatrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operationMatrix.js","sourceRoot":"","sources":["../../../src/crystal3d/core/operationMatrix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,eAAe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AC,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,WAAW,CAAC,CAAC,CAAC;QACd,WAAW,CAAC,CAAC,CAAC;QACd,WAAW,CAAC,CAAC,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the camera opens on a scene.
|
|
3
|
+
*
|
|
4
|
+
* molstar starts every canvas looking down −z, and a molecule is built in its
|
|
5
|
+
* standard frame with the principal axis along z — so the site opened on the
|
|
6
|
+
* one view that shows no symmetry at all: water end-on, three balls in a
|
|
7
|
+
* column, both σv planes exactly edge-on and the C₂ a dot behind the oxygen. A
|
|
8
|
+
* page that says *hover an axis or a plane* had nothing to hover.
|
|
9
|
+
*
|
|
10
|
+
* The cure is not another world direction, which would merely move the blind
|
|
11
|
+
* spot onto the molecules whose axis is x. The view is measured **from the
|
|
12
|
+
* scene's own axis**: the highest-order axis it draws, or a crystal's c edge.
|
|
13
|
+
*/
|
|
14
|
+
import type { Point3, SymmetryDrawing, UnitCell } from './types.ts';
|
|
15
|
+
/** Where the camera sits and which way is up, as unit vectors. */
|
|
16
|
+
export interface ViewOrientation {
|
|
17
|
+
/** From the centre of the scene towards the camera. */
|
|
18
|
+
readonly eye: Point3;
|
|
19
|
+
/** Up on screen; at right angles to `eye`. */
|
|
20
|
+
readonly up: Point3;
|
|
21
|
+
}
|
|
22
|
+
/** The part of a scene the opening view is read off. */
|
|
23
|
+
export interface OrientedScene {
|
|
24
|
+
/**
|
|
25
|
+
* The cell, when the scene has one. A crystal is framed on its cell rather
|
|
26
|
+
* than on its elements: a box that reads as a box is what places the fifty
|
|
27
|
+
* axes inside it.
|
|
28
|
+
* @default null
|
|
29
|
+
*/
|
|
30
|
+
readonly cell?: UnitCell | null;
|
|
31
|
+
/**
|
|
32
|
+
* The symmetry elements drawn over the structure.
|
|
33
|
+
* @default []
|
|
34
|
+
*/
|
|
35
|
+
readonly elements?: readonly SymmetryDrawing[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The view a scene opens on.
|
|
39
|
+
* @param scene - What is drawn; see {@link OrientedScene}.
|
|
40
|
+
* @returns A three-quarter view of it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sceneOrientation(scene: OrientedScene): ViewOrientation;
|
|
43
|
+
/**
|
|
44
|
+
* The scene's own axis: the highest-order one it draws, or a plane normal when
|
|
45
|
+
* it draws no axis at all.
|
|
46
|
+
* @param drawings - The symmetry elements on screen.
|
|
47
|
+
* @returns Its direction, or `null` when nothing drawn has one — an inversion
|
|
48
|
+
* centre alone, or an empty scene.
|
|
49
|
+
*/
|
|
50
|
+
export declare function principalAxisOf(drawings: readonly SymmetryDrawing[]): Point3 | null;
|
|
51
|
+
/**
|
|
52
|
+
* A view three-quarters of the way round an axis and well off the end of it.
|
|
53
|
+
* @param axis - The direction the view is measured from; need not be
|
|
54
|
+
* normalised, and its sign does not matter.
|
|
55
|
+
* @param reference - Where the azimuth is measured from — a crystal passes its
|
|
56
|
+
* a edge, so the same cell always opens the same way round. Left out, one is
|
|
57
|
+
* chosen from the axis alone.
|
|
58
|
+
* @returns Where the camera sits, and which way is up.
|
|
59
|
+
* @throws {RangeError} When the axis is too short to have a direction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function threeQuarterView(axis: Point3, reference?: Point3): ViewOrientation;
|
|
62
|
+
//# sourceMappingURL=orientation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orientation.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/orientation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAWpE,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,eAAe,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,eAAe,EAAE,GACnC,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,eAAe,CAmBjB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the camera opens on a scene.
|
|
3
|
+
*
|
|
4
|
+
* molstar starts every canvas looking down −z, and a molecule is built in its
|
|
5
|
+
* standard frame with the principal axis along z — so the site opened on the
|
|
6
|
+
* one view that shows no symmetry at all: water end-on, three balls in a
|
|
7
|
+
* column, both σv planes exactly edge-on and the C₂ a dot behind the oxygen. A
|
|
8
|
+
* page that says *hover an axis or a plane* had nothing to hover.
|
|
9
|
+
*
|
|
10
|
+
* The cure is not another world direction, which would merely move the blind
|
|
11
|
+
* spot onto the molecules whose axis is x. The view is measured **from the
|
|
12
|
+
* scene's own axis**: the highest-order axis it draws, or a crystal's c edge.
|
|
13
|
+
*/
|
|
14
|
+
import { cellAxes } from "./cellGeometry.js";
|
|
15
|
+
import { perpendicularTo } from "./frame.js";
|
|
16
|
+
import { addVectors, crossProduct, dotProduct, normalizeVector, scaleVector, subtractVectors, vectorNorm, } from "./vec3.js";
|
|
17
|
+
/**
|
|
18
|
+
* The view a scene opens on.
|
|
19
|
+
* @param scene - What is drawn; see {@link OrientedScene}.
|
|
20
|
+
* @returns A three-quarter view of it.
|
|
21
|
+
*/
|
|
22
|
+
export function sceneOrientation(scene) {
|
|
23
|
+
const { cell = null, elements = [] } = scene;
|
|
24
|
+
if (cell !== null) {
|
|
25
|
+
const [a, , c] = cellAxes(cell);
|
|
26
|
+
return threeQuarterView(c, a);
|
|
27
|
+
}
|
|
28
|
+
return threeQuarterView(principalAxisOf(elements) ?? WORLD_AXIS);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The scene's own axis: the highest-order one it draws, or a plane normal when
|
|
32
|
+
* it draws no axis at all.
|
|
33
|
+
* @param drawings - The symmetry elements on screen.
|
|
34
|
+
* @returns Its direction, or `null` when nothing drawn has one — an inversion
|
|
35
|
+
* centre alone, or an empty scene.
|
|
36
|
+
*/
|
|
37
|
+
export function principalAxisOf(drawings) {
|
|
38
|
+
let axis = null;
|
|
39
|
+
let order = 0;
|
|
40
|
+
let normal = null;
|
|
41
|
+
for (const drawing of drawings) {
|
|
42
|
+
if (drawing.kind === 'mirror' || drawing.kind === 'glide') {
|
|
43
|
+
if (normal === null && hasDirection(drawing.normal)) {
|
|
44
|
+
normal = drawing.normal;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (drawing.kind === 'inversion')
|
|
49
|
+
continue;
|
|
50
|
+
if (drawing.order <= order || !hasDirection(drawing.direction))
|
|
51
|
+
continue;
|
|
52
|
+
axis = drawing.direction;
|
|
53
|
+
order = drawing.order;
|
|
54
|
+
}
|
|
55
|
+
return axis ?? normal;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A view three-quarters of the way round an axis and well off the end of it.
|
|
59
|
+
* @param axis - The direction the view is measured from; need not be
|
|
60
|
+
* normalised, and its sign does not matter.
|
|
61
|
+
* @param reference - Where the azimuth is measured from — a crystal passes its
|
|
62
|
+
* a edge, so the same cell always opens the same way round. Left out, one is
|
|
63
|
+
* chosen from the axis alone.
|
|
64
|
+
* @returns Where the camera sits, and which way is up.
|
|
65
|
+
* @throws {RangeError} When the axis is too short to have a direction.
|
|
66
|
+
*/
|
|
67
|
+
export function threeQuarterView(axis, reference) {
|
|
68
|
+
const up = upwards(normalizeVector(axis));
|
|
69
|
+
const major = azimuthFrom(up, reference);
|
|
70
|
+
const minor = crossProduct(up, major);
|
|
71
|
+
const polar = toRadians(POLAR_DEGREES);
|
|
72
|
+
const azimuth = toRadians(AZIMUTH_DEGREES);
|
|
73
|
+
const eye = normalizeVector(addVectors(addVectors(scaleVector(major, Math.sin(polar) * Math.cos(azimuth)), scaleVector(minor, Math.sin(polar) * Math.sin(azimuth))), scaleVector(up, Math.cos(polar))));
|
|
74
|
+
return {
|
|
75
|
+
eye,
|
|
76
|
+
up: rollAbout(rejectFrom(up, eye), eye, toRadians(ROLL_DEGREES)),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Whichever way up leaves the axis pointing towards the top of the screen.
|
|
81
|
+
* @param unit - The axis, normalised.
|
|
82
|
+
* @returns The axis or its opposite.
|
|
83
|
+
*/
|
|
84
|
+
function upwards(unit) {
|
|
85
|
+
const [x, y, z] = unit;
|
|
86
|
+
let leading = x;
|
|
87
|
+
if (Math.abs(z) > DIRECTION_FLOOR)
|
|
88
|
+
leading = z;
|
|
89
|
+
else if (Math.abs(y) > DIRECTION_FLOOR)
|
|
90
|
+
leading = y;
|
|
91
|
+
return leading < 0 ? scaleVector(unit, -1) : unit;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The direction the azimuth is measured from, at right angles to the axis.
|
|
95
|
+
* @param up - The axis, normalised and pointing up.
|
|
96
|
+
* @param reference - The direction to measure from, or `undefined` to pick one.
|
|
97
|
+
* @returns A unit vector at right angles to `up`.
|
|
98
|
+
*/
|
|
99
|
+
function azimuthFrom(up, reference) {
|
|
100
|
+
if (reference === undefined)
|
|
101
|
+
return perpendicularTo(up);
|
|
102
|
+
const flat = subtractVectors(reference, scaleVector(up, dotProduct(reference, up)));
|
|
103
|
+
return hasDirection(flat) ? normalizeVector(flat) : perpendicularTo(up);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The part of a vector at right angles to a unit direction.
|
|
107
|
+
* @param vector - The vector.
|
|
108
|
+
* @param unit - The direction projected out, normalised.
|
|
109
|
+
* @returns That part, normalised.
|
|
110
|
+
*/
|
|
111
|
+
function rejectFrom(vector, unit) {
|
|
112
|
+
return normalizeVector(subtractVectors(vector, scaleVector(unit, dotProduct(vector, unit))));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Turn a vector about a unit axis it is already at right angles to.
|
|
116
|
+
* @param vector - The vector turned.
|
|
117
|
+
* @param unit - The axis, normalised.
|
|
118
|
+
* @param angle - The angle, in radians, right-handed.
|
|
119
|
+
* @returns The turned vector.
|
|
120
|
+
*/
|
|
121
|
+
function rollAbout(vector, unit, angle) {
|
|
122
|
+
return addVectors(scaleVector(vector, Math.cos(angle)), scaleVector(crossProduct(unit, vector), Math.sin(angle)));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether a vector is long enough to say which way it points.
|
|
126
|
+
* @param vector - The vector.
|
|
127
|
+
* @returns Whether its length is above the floor.
|
|
128
|
+
*/
|
|
129
|
+
function hasDirection(vector) {
|
|
130
|
+
return vectorNorm(vector) > DIRECTION_FLOOR;
|
|
131
|
+
}
|
|
132
|
+
function toRadians(degrees) {
|
|
133
|
+
return (degrees * Math.PI) / 180;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* How far off the axis the camera sits, degrees.
|
|
137
|
+
*
|
|
138
|
+
* Not 0 — that is the end-on view this module exists to stop — and not 90,
|
|
139
|
+
* which lays the eye inside every plane that contains the axis. At 65° an axis
|
|
140
|
+
* still draws 91% of its length while a plane across it is seen at 42% of its
|
|
141
|
+
* face, so a rod reads as a rod and a σh reads as a disc.
|
|
142
|
+
*/
|
|
143
|
+
const POLAR_DEGREES = 65;
|
|
144
|
+
/**
|
|
145
|
+
* How far round the axis, degrees from the reference direction.
|
|
146
|
+
*
|
|
147
|
+
* Every round value is a special position of some group: 0 and 90 lay the eye
|
|
148
|
+
* in a plane of any two at right angles, 45 in the diagonal plane of a
|
|
149
|
+
* four-fold, 30 and 60 in a three- or six-fold's. At 40° two planes at right
|
|
150
|
+
* angles are seen at 77% and 64% of their face, and neither is edge-on.
|
|
151
|
+
*/
|
|
152
|
+
const AZIMUTH_DEGREES = 40;
|
|
153
|
+
/**
|
|
154
|
+
* How far the horizon is tilted, degrees.
|
|
155
|
+
*
|
|
156
|
+
* Without it the axis stands exactly upright and the scene reads as a flat
|
|
157
|
+
* diagram of itself; ten degrees is enough to say it is a solid seen in space,
|
|
158
|
+
* and little enough that the names floating beside each element stay level
|
|
159
|
+
* enough to read.
|
|
160
|
+
*/
|
|
161
|
+
const ROLL_DEGREES = 10;
|
|
162
|
+
/** Which way is up when nothing drawn says otherwise. */
|
|
163
|
+
const WORLD_AXIS = [0, 0, 1];
|
|
164
|
+
/** Below this length a vector is taken to have no direction at all. */
|
|
165
|
+
const DIRECTION_FLOOR = 1e-9;
|
|
166
|
+
//# sourceMappingURL=orientation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orientation.js","sourceRoot":"","sources":["../../../src/crystal3d/core/orientation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAC;AA0BnB;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB;IACnD,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IAC7C,IAA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,EAAE,CAAC;AAExB,yDAAyD;AACzD,MAAM,UAAU,GAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAErC,uEAAuE;AACvE,MAAM,eAAe,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each kind of symmetry element is drawn in.
|
|
3
|
+
*
|
|
4
|
+
* The family's tokens paint the page around the canvas; inside it a colour
|
|
5
|
+
* carries a meaning — proper or improper, axis or plane — so each kind owns
|
|
6
|
+
* one, and a drawing overrides it only when a page has a reason to.
|
|
7
|
+
*/
|
|
8
|
+
import type { SymmetryDrawingKind } from './types.ts';
|
|
9
|
+
/** The colour of each kind, `#rrggbb`. */
|
|
10
|
+
export declare const ELEMENT_COLOURS: Readonly<Record<SymmetryDrawingKind, string>>;
|
|
11
|
+
/** The unit cell box, and the lattice repeats drawn around it. */
|
|
12
|
+
export declare const CELL_COLOUR = "#475569";
|
|
13
|
+
/** An element's label, and the a/b/c letters on the cell. */
|
|
14
|
+
export declare const LABEL_COLOUR = "#1f2937";
|
|
15
|
+
/** The card a label is written on, so it reads over a structure or a plane. */
|
|
16
|
+
export declare const LABEL_CARD_COLOUR = "#ffffff";
|
|
17
|
+
/**
|
|
18
|
+
* The colour a drawing is painted in.
|
|
19
|
+
* @param kind - Which of the six it is.
|
|
20
|
+
* @param colour - What the drawing asked for, if anything.
|
|
21
|
+
* @returns The chosen colour, `#rrggbb`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function drawingColour(kind: SymmetryDrawingKind, colour?: string): string;
|
|
24
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/palette.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,0CAA0C;AAC1C,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAOzE,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,6DAA6D;AAC7D,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,mBAAmB,EACzB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAER"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// tokens-ok: file — these colours are subject matter: they tell a 3-fold axis
|
|
2
|
+
// from a glide plane in the scene, the way a crystallographic diagram does.
|
|
3
|
+
/**
|
|
4
|
+
* What each kind of symmetry element is drawn in.
|
|
5
|
+
*
|
|
6
|
+
* The family's tokens paint the page around the canvas; inside it a colour
|
|
7
|
+
* carries a meaning — proper or improper, axis or plane — so each kind owns
|
|
8
|
+
* one, and a drawing overrides it only when a page has a reason to.
|
|
9
|
+
*/
|
|
10
|
+
/** The colour of each kind, `#rrggbb`. */
|
|
11
|
+
export const ELEMENT_COLOURS = {
|
|
12
|
+
rotation: '#1d4ed8',
|
|
13
|
+
screw: '#0f766e',
|
|
14
|
+
rotoinversion: '#7c3aed',
|
|
15
|
+
mirror: '#0891b2',
|
|
16
|
+
glide: '#c2410c',
|
|
17
|
+
inversion: '#be123c',
|
|
18
|
+
};
|
|
19
|
+
/** The unit cell box, and the lattice repeats drawn around it. */
|
|
20
|
+
export const CELL_COLOUR = '#475569';
|
|
21
|
+
/** An element's label, and the a/b/c letters on the cell. */
|
|
22
|
+
export const LABEL_COLOUR = '#1f2937';
|
|
23
|
+
/** The card a label is written on, so it reads over a structure or a plane. */
|
|
24
|
+
export const LABEL_CARD_COLOUR = '#ffffff';
|
|
25
|
+
/**
|
|
26
|
+
* The colour a drawing is painted in.
|
|
27
|
+
* @param kind - Which of the six it is.
|
|
28
|
+
* @param colour - What the drawing asked for, if anything.
|
|
29
|
+
* @returns The chosen colour, `#rrggbb`.
|
|
30
|
+
*/
|
|
31
|
+
export function drawingColour(kind, colour) {
|
|
32
|
+
return colour ?? ELEMENT_COLOURS[kind];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../../src/crystal3d/core/palette.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E;;;;;;GAMG;AAIH,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAkD;IAC5E,QAAQ,EAAE,SAAS;IACnB,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,SAAS;IACxB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,kEAAkE;AAClE,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAEtC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAyB,EACzB,MAAe;IAEf,OAAO,MAAM,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes a symmetry element is made of, named once so the geometry that
|
|
3
|
+
* builds them never has to know molstar exists.
|
|
4
|
+
*
|
|
5
|
+
* Everything in this module is plain arithmetic: it is what the unit tests
|
|
6
|
+
* assert, and what `renderElements.ts` hands to a mesh builder.
|
|
7
|
+
*/
|
|
8
|
+
import type { Point3 } from './types.ts';
|
|
9
|
+
/** One drawable shape, Cartesian ångström. */
|
|
10
|
+
export type MeshPrimitive =
|
|
11
|
+
/** A solid rod, as a rotation axis or a cell edge. */
|
|
12
|
+
{
|
|
13
|
+
readonly shape: 'rod';
|
|
14
|
+
start: Point3;
|
|
15
|
+
end: Point3;
|
|
16
|
+
radius: number;
|
|
17
|
+
}
|
|
18
|
+
/** A broken rod, as the axis of a rotoinversion. */
|
|
19
|
+
| {
|
|
20
|
+
readonly shape: 'dashes';
|
|
21
|
+
start: Point3;
|
|
22
|
+
end: Point3;
|
|
23
|
+
radius: number;
|
|
24
|
+
segments: number;
|
|
25
|
+
}
|
|
26
|
+
/** A cone, as the head of an arrow. */
|
|
27
|
+
| {
|
|
28
|
+
readonly shape: 'cone';
|
|
29
|
+
base: Point3;
|
|
30
|
+
tip: Point3;
|
|
31
|
+
radius: number;
|
|
32
|
+
}
|
|
33
|
+
/** A ball, as an inversion centre. */
|
|
34
|
+
| {
|
|
35
|
+
readonly shape: 'sphere';
|
|
36
|
+
centre: Point3;
|
|
37
|
+
radius: number;
|
|
38
|
+
}
|
|
39
|
+
/** A flat square, as a mirror or a glide plane. */
|
|
40
|
+
| {
|
|
41
|
+
readonly shape: 'plate';
|
|
42
|
+
centre: Point3;
|
|
43
|
+
major: Point3;
|
|
44
|
+
minor: Point3;
|
|
45
|
+
size: number;
|
|
46
|
+
}
|
|
47
|
+
/** A flat convex face, as the slice a plane cuts out of a cell. */
|
|
48
|
+
| {
|
|
49
|
+
readonly shape: 'face';
|
|
50
|
+
points: readonly Point3[];
|
|
51
|
+
};
|
|
52
|
+
/** A line of text floating in the scene. */
|
|
53
|
+
export interface TextItem {
|
|
54
|
+
/** What it reads. */
|
|
55
|
+
readonly text: string;
|
|
56
|
+
/** Where it sits, Cartesian ångström. */
|
|
57
|
+
readonly position: Point3;
|
|
58
|
+
/** Its height, ångström. */
|
|
59
|
+
readonly size: number;
|
|
60
|
+
/**
|
|
61
|
+
* What it is written in, `#rrggbb`. A name in the colour of the thing it
|
|
62
|
+
* names is the only way a reader pairs the two when ten of them are on one
|
|
63
|
+
* cell.
|
|
64
|
+
* @default the layer's own colour
|
|
65
|
+
*/
|
|
66
|
+
readonly colour?: string;
|
|
67
|
+
}
|
|
68
|
+
/** How thick, how long and how big the drawn elements are. */
|
|
69
|
+
export interface ElementStyle {
|
|
70
|
+
/**
|
|
71
|
+
* Radius of an axis rod, ångström.
|
|
72
|
+
* @default 0.06
|
|
73
|
+
*/
|
|
74
|
+
axisRadius?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Radius of an arrowhead's base, ångström.
|
|
77
|
+
* @default 0.16
|
|
78
|
+
*/
|
|
79
|
+
arrowRadius?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Length of an arrowhead, ångström.
|
|
82
|
+
* @default 0.4
|
|
83
|
+
*/
|
|
84
|
+
arrowLength?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Radius of an inversion centre, ångström.
|
|
87
|
+
* @default 0.18
|
|
88
|
+
*/
|
|
89
|
+
centreRadius?: number;
|
|
90
|
+
/**
|
|
91
|
+
* How far a pitch arrow sits beside its axis, in rod radii.
|
|
92
|
+
* @default 4
|
|
93
|
+
*/
|
|
94
|
+
arrowOffset?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Dashes along a rotoinversion axis.
|
|
97
|
+
* @default 9
|
|
98
|
+
*/
|
|
99
|
+
dashSegments?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Radius of the rim drawn round a plane, ångström. A stack of translucent
|
|
102
|
+
* faces is a wash; the same stack with its edges drawn reads as planes.
|
|
103
|
+
* @default 0.03
|
|
104
|
+
*/
|
|
105
|
+
rimRadius?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Height of an element's label, ångström.
|
|
108
|
+
* @default 0.6
|
|
109
|
+
*/
|
|
110
|
+
labelSize?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Gap between the end of an element and its label, ångström.
|
|
113
|
+
* @default 0.35
|
|
114
|
+
*/
|
|
115
|
+
labelGap?: number;
|
|
116
|
+
}
|
|
117
|
+
/** {@link ElementStyle} with every default filled in. */
|
|
118
|
+
export type ResolvedElementStyle = Required<ElementStyle>;
|
|
119
|
+
/** The defaults, read once so a caller can override one field. */
|
|
120
|
+
export declare const DEFAULT_ELEMENT_STYLE: ResolvedElementStyle;
|
|
121
|
+
/**
|
|
122
|
+
* Fill in whatever the caller left out.
|
|
123
|
+
* @param style - The caller's overrides, if any.
|
|
124
|
+
* @returns Every field, with the defaults where none was given.
|
|
125
|
+
*/
|
|
126
|
+
export declare function resolveElementStyle(style?: ElementStyle): ResolvedElementStyle;
|
|
127
|
+
/**
|
|
128
|
+
* The corners a primitive reaches, so the camera can frame what is drawn.
|
|
129
|
+
* @param primitive - One shape.
|
|
130
|
+
* @returns Points that between them hold it, Cartesian ångström.
|
|
131
|
+
*/
|
|
132
|
+
export declare function primitivePoints(primitive: MeshPrimitive): Point3[];
|
|
133
|
+
//# sourceMappingURL=primitives.d.ts.map
|