react-cheminfo 0.134.1 → 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/README.md +13 -0
- package/lib/crystal/core/bondGrid.d.ts +26 -0
- package/lib/crystal/core/bondGrid.d.ts.map +1 -0
- package/lib/crystal/core/bondGrid.js +76 -0
- package/lib/crystal/core/bondGrid.js.map +1 -0
- 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/cellBonds.d.ts +21 -0
- package/lib/crystal/core/cellBonds.d.ts.map +1 -0
- package/lib/crystal/core/cellBonds.js +100 -0
- package/lib/crystal/core/cellBonds.js.map +1 -0
- package/lib/crystal/core/cif/element.d.ts +9 -0
- package/lib/crystal/core/cif/element.d.ts.map +1 -0
- package/lib/crystal/core/cif/element.js +41 -0
- package/lib/crystal/core/cif/element.js.map +1 -0
- package/lib/crystal/core/cif/index.d.ts +4 -0
- package/lib/crystal/core/cif/index.d.ts.map +1 -0
- package/lib/crystal/core/cif/index.js +3 -0
- package/lib/crystal/core/cif/index.js.map +1 -0
- package/lib/crystal/core/cif/number.d.ts +27 -0
- package/lib/crystal/core/cif/number.d.ts.map +1 -0
- package/lib/crystal/core/cif/number.js +57 -0
- package/lib/crystal/core/cif/number.js.map +1 -0
- package/lib/crystal/core/cif/read.d.ts +12 -0
- package/lib/crystal/core/cif/read.d.ts.map +1 -0
- package/lib/crystal/core/cif/read.js +183 -0
- package/lib/crystal/core/cif/read.js.map +1 -0
- package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
- package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
- package/lib/crystal/core/cif/readGeometry.js +93 -0
- package/lib/crystal/core/cif/readGeometry.js.map +1 -0
- package/lib/crystal/core/cif/tags.d.ts +62 -0
- package/lib/crystal/core/cif/tags.d.ts.map +1 -0
- package/lib/crystal/core/cif/tags.js +115 -0
- package/lib/crystal/core/cif/tags.js.map +1 -0
- package/lib/crystal/core/cif/types.d.ts +158 -0
- package/lib/crystal/core/cif/types.d.ts.map +1 -0
- package/lib/crystal/core/cif/types.js +2 -0
- package/lib/crystal/core/cif/types.js.map +1 -0
- package/lib/crystal/core/components.d.ts +56 -0
- package/lib/crystal/core/components.d.ts.map +1 -0
- package/lib/crystal/core/components.js +132 -0
- package/lib/crystal/core/components.js.map +1 -0
- package/lib/crystal/core/covalentRadii.d.ts +24 -0
- package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
- package/lib/crystal/core/covalentRadii.js +55 -0
- package/lib/crystal/core/covalentRadii.js.map +1 -0
- package/lib/crystal/core/disorder.d.ts +59 -0
- package/lib/crystal/core/disorder.d.ts.map +1 -0
- package/lib/crystal/core/disorder.js +168 -0
- package/lib/crystal/core/disorder.js.map +1 -0
- package/lib/crystal/core/expand.d.ts +62 -0
- package/lib/crystal/core/expand.d.ts.map +1 -0
- package/lib/crystal/core/expand.js +61 -0
- package/lib/crystal/core/expand.js.map +1 -0
- package/lib/crystal/core/index.d.ts +20 -0
- package/lib/crystal/core/index.d.ts.map +1 -0
- package/lib/crystal/core/index.js +13 -0
- package/lib/crystal/core/index.js.map +1 -0
- package/lib/crystal/core/moleculeOf.d.ts +31 -0
- package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
- package/lib/crystal/core/moleculeOf.js +128 -0
- package/lib/crystal/core/moleculeOf.js.map +1 -0
- package/lib/crystal/core/moleculeTypes.d.ts +80 -0
- package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
- package/lib/crystal/core/moleculeTypes.js +2 -0
- package/lib/crystal/core/moleculeTypes.js.map +1 -0
- package/lib/crystal/core/molecules.d.ts +39 -0
- package/lib/crystal/core/molecules.d.ts.map +1 -0
- package/lib/crystal/core/molecules.js +106 -0
- package/lib/crystal/core/molecules.js.map +1 -0
- package/lib/crystal/core/operations.d.ts +19 -0
- package/lib/crystal/core/operations.d.ts.map +1 -0
- package/lib/crystal/core/operations.js +68 -0
- package/lib/crystal/core/operations.js.map +1 -0
- package/lib/crystal/core/packing.d.ts +43 -0
- package/lib/crystal/core/packing.d.ts.map +1 -0
- package/lib/crystal/core/packing.js +89 -0
- package/lib/crystal/core/packing.js.map +1 -0
- package/lib/crystal/core/periodicBonds.d.ts +57 -0
- package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
- package/lib/crystal/core/periodicBonds.js +167 -0
- package/lib/crystal/core/periodicBonds.js.map +1 -0
- package/lib/crystal/core/resolve.d.ts +61 -0
- package/lib/crystal/core/resolve.d.ts.map +1 -0
- package/lib/crystal/core/resolve.js +149 -0
- package/lib/crystal/core/resolve.js.map +1 -0
- package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
- package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/index.js +4 -0
- package/lib/crystal/core/spaceGroups/index.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
- package/lib/crystal/core/symmetry/group.d.ts +15 -0
- package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/group.js +37 -0
- package/lib/crystal/core/symmetry/group.js.map +1 -0
- package/lib/crystal/core/symmetry/index.d.ts +8 -0
- package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/index.js +6 -0
- package/lib/crystal/core/symmetry/index.js.map +1 -0
- package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
- package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
- package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
- package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
- package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/lattice.js +113 -0
- package/lib/crystal/core/symmetry/lattice.js.map +1 -0
- package/lib/crystal/core/symmetry/operation.d.ts +91 -0
- package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/operation.js +184 -0
- package/lib/crystal/core/symmetry/operation.js.map +1 -0
- package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
- package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/parseOperation.js +145 -0
- package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
- package/lib/crystal/core/symmetry/types.d.ts +29 -0
- package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/types.js +5 -0
- package/lib/crystal/core/symmetry/types.js.map +1 -0
- package/lib/crystal/core/symmetryClasses.d.ts +28 -0
- package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
- package/lib/crystal/core/symmetryClasses.js +93 -0
- package/lib/crystal/core/symmetryClasses.js.map +1 -0
- package/lib/crystal.d.ts +12 -0
- package/lib/crystal.d.ts.map +1 -0
- package/lib/crystal.js +12 -0
- package/lib/crystal.js.map +1 -0
- 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 +4 -1
- package/src/crystal/core/bondGrid.ts +98 -0
- package/src/crystal/core/cellAtoms.ts +106 -0
- package/src/crystal/core/cellBonds.ts +121 -0
- package/src/crystal/core/cif/element.ts +40 -0
- package/src/crystal/core/cif/index.ts +12 -0
- package/src/crystal/core/cif/number.ts +62 -0
- package/src/crystal/core/cif/read.ts +218 -0
- package/src/crystal/core/cif/readGeometry.ts +104 -0
- package/src/crystal/core/cif/tags.ts +143 -0
- package/src/crystal/core/cif/types.ts +164 -0
- package/src/crystal/core/components.ts +183 -0
- package/src/crystal/core/covalentRadii.ts +56 -0
- package/src/crystal/core/disorder.ts +190 -0
- package/src/crystal/core/expand.ts +105 -0
- package/src/crystal/core/index.ts +46 -0
- package/src/crystal/core/moleculeOf.ts +169 -0
- package/src/crystal/core/moleculeTypes.ts +85 -0
- package/src/crystal/core/molecules.ts +128 -0
- package/src/crystal/core/operations.ts +79 -0
- package/src/crystal/core/packing.ts +116 -0
- package/src/crystal/core/periodicBonds.ts +234 -0
- package/src/crystal/core/resolve.ts +187 -0
- package/src/crystal/core/spaceGroups/index.ts +16 -0
- package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
- package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
- package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
- package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
- package/src/crystal/core/symmetry/group.ts +42 -0
- package/src/crystal/core/symmetry/index.ts +23 -0
- package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
- package/src/crystal/core/symmetry/lattice.ts +152 -0
- package/src/crystal/core/symmetry/operation.ts +223 -0
- package/src/crystal/core/symmetry/parseOperation.ts +180 -0
- package/src/crystal/core/symmetry/types.ts +32 -0
- package/src/crystal/core/symmetryClasses.ts +105 -0
- package/src/crystal.ts +12 -0
- 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,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page hands the crystal viewer, and nothing molstar knows about.
|
|
3
|
+
*
|
|
4
|
+
* Every coordinate here is **Cartesian ångström**. The page has already applied
|
|
5
|
+
* the space group's operations by the time it draws: molstar's own expansion
|
|
6
|
+
* silently falls back to `P 1` on several common settings, so nothing in
|
|
7
|
+
* `viewer/` ever asks it to expand anything.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { Vec3 } from './vec3.ts';
|
|
11
|
+
|
|
12
|
+
export type { UnitCell } from '../../crystal/core/symmetry/lattice.ts';
|
|
13
|
+
|
|
14
|
+
/** A point or a direction in Cartesian ångström. */
|
|
15
|
+
export type Point3 = Vec3;
|
|
16
|
+
|
|
17
|
+
/** How many cells to draw along a, b and c. */
|
|
18
|
+
export type CellRepeat = readonly [number, number, number];
|
|
19
|
+
|
|
20
|
+
/** One atom of the scene, already in its final place. */
|
|
21
|
+
export interface ViewerAtom {
|
|
22
|
+
/** Element symbol, as `Na`, `Cl`, `C`. */
|
|
23
|
+
readonly element: string;
|
|
24
|
+
/** Where it sits, Cartesian ångström. */
|
|
25
|
+
readonly position: Point3;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What every drawn symmetry element carries. */
|
|
29
|
+
export interface DrawingBase {
|
|
30
|
+
/** Stable across redraws, so one element can be removed on its own. */
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/** What the pointer reads: `C3`, `2₁ along [001]`, `σv`, `n glide`. */
|
|
33
|
+
readonly label: string;
|
|
34
|
+
/**
|
|
35
|
+
* The short form written on the element in the scene — `m`, `3`, `2₁`, `-1`.
|
|
36
|
+
* Forty rods each carrying their full name is a wall of text nobody reads,
|
|
37
|
+
* and the list beside the view says the rest.
|
|
38
|
+
* @default the label
|
|
39
|
+
*/
|
|
40
|
+
readonly badge?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Its colour, `#rrggbb`. The kind's own convention is used when absent.
|
|
43
|
+
* @default the convention in `palette.ts`
|
|
44
|
+
*/
|
|
45
|
+
readonly colour?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A proper rotation axis: a rod through `point` along `direction`. */
|
|
49
|
+
export interface RotationDrawing extends DrawingBase {
|
|
50
|
+
readonly kind: 'rotation';
|
|
51
|
+
/** A point the axis passes through. */
|
|
52
|
+
readonly point: Point3;
|
|
53
|
+
/** The axis direction; need not be normalised. */
|
|
54
|
+
readonly direction: Point3;
|
|
55
|
+
/** Total rod length, ångström, centred on `point`. */
|
|
56
|
+
readonly length: number;
|
|
57
|
+
/** n of the n-fold, which is what gets labelled. */
|
|
58
|
+
readonly order: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A screw axis: the rod, plus an arrow as long as the pitch beside it. */
|
|
62
|
+
export interface ScrewDrawing extends DrawingBase {
|
|
63
|
+
readonly kind: 'screw';
|
|
64
|
+
readonly point: Point3;
|
|
65
|
+
readonly direction: Point3;
|
|
66
|
+
readonly length: number;
|
|
67
|
+
readonly order: number;
|
|
68
|
+
/** The intrinsic translation of one turn, ångström along `direction`. */
|
|
69
|
+
readonly pitch: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A rotoinversion: a dashed rod, with a ball at the inversion point on it. */
|
|
73
|
+
export interface RotoinversionDrawing extends DrawingBase {
|
|
74
|
+
readonly kind: 'rotoinversion';
|
|
75
|
+
/** The inversion point, which is where the ball sits. */
|
|
76
|
+
readonly point: Point3;
|
|
77
|
+
readonly direction: Point3;
|
|
78
|
+
readonly length: number;
|
|
79
|
+
readonly order: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A mirror plane: a translucent face through `point`. */
|
|
83
|
+
export interface MirrorDrawing extends DrawingBase {
|
|
84
|
+
readonly kind: 'mirror';
|
|
85
|
+
readonly point: Point3;
|
|
86
|
+
/** The plane normal; need not be normalised. */
|
|
87
|
+
readonly normal: Point3;
|
|
88
|
+
/** Side of the drawn square, ångström, when there is no outline. */
|
|
89
|
+
readonly size: number;
|
|
90
|
+
/**
|
|
91
|
+
* The corners the plane is drawn between, in order around it. A crystal
|
|
92
|
+
* hands over the polygon where the plane cuts the cell, which says where it
|
|
93
|
+
* sits far better than a square floating in the middle of one does.
|
|
94
|
+
* @default a square of `size`, spanned by the frame of the normal
|
|
95
|
+
*/
|
|
96
|
+
readonly outline?: readonly Point3[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A glide plane: the face, plus an arrow in it along the glide vector. */
|
|
100
|
+
export interface GlideDrawing extends DrawingBase {
|
|
101
|
+
readonly kind: 'glide';
|
|
102
|
+
readonly point: Point3;
|
|
103
|
+
readonly normal: Point3;
|
|
104
|
+
readonly size: number;
|
|
105
|
+
/** The glide vector itself, ångström, lying in the plane. */
|
|
106
|
+
readonly glide: Point3;
|
|
107
|
+
/**
|
|
108
|
+
* The corners the plane is drawn between, in order around it.
|
|
109
|
+
* @default a square of `size`, spanned by the frame of the normal
|
|
110
|
+
*/
|
|
111
|
+
readonly outline?: readonly Point3[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** An inversion centre: a small ball. */
|
|
115
|
+
export interface InversionDrawing extends DrawingBase {
|
|
116
|
+
readonly kind: 'inversion';
|
|
117
|
+
readonly point: Point3;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** One symmetry element as the viewer draws it. */
|
|
121
|
+
export type SymmetryDrawing =
|
|
122
|
+
| RotationDrawing
|
|
123
|
+
| ScrewDrawing
|
|
124
|
+
| RotoinversionDrawing
|
|
125
|
+
| MirrorDrawing
|
|
126
|
+
| GlideDrawing
|
|
127
|
+
| InversionDrawing;
|
|
128
|
+
|
|
129
|
+
/** Which of the six kinds a drawing is. */
|
|
130
|
+
export type SymmetryDrawingKind = SymmetryDrawing['kind'];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* An operation to apply to the structure, so a student watches it map onto
|
|
134
|
+
* itself.
|
|
135
|
+
*
|
|
136
|
+
* A proper rotation and a screw have a rigid path from the identity and are
|
|
137
|
+
* turned through it. The improper three have none, and say so by passing
|
|
138
|
+
* through the plane or the centre rather than around it.
|
|
139
|
+
*/
|
|
140
|
+
export type ViewerOperation =
|
|
141
|
+
| {
|
|
142
|
+
readonly kind: 'rotation';
|
|
143
|
+
readonly axis: Point3;
|
|
144
|
+
readonly origin: Point3;
|
|
145
|
+
/** n of the n-fold. */
|
|
146
|
+
readonly order: number;
|
|
147
|
+
/**
|
|
148
|
+
* k of `Cₙᵏ`.
|
|
149
|
+
* @default 1
|
|
150
|
+
*/
|
|
151
|
+
readonly power?: number;
|
|
152
|
+
}
|
|
153
|
+
| {
|
|
154
|
+
readonly kind: 'screw';
|
|
155
|
+
readonly axis: Point3;
|
|
156
|
+
readonly origin: Point3;
|
|
157
|
+
readonly order: number;
|
|
158
|
+
/** @default 1 */
|
|
159
|
+
readonly power?: number;
|
|
160
|
+
/** The translation of one application, Cartesian ångström. */
|
|
161
|
+
readonly translation: Point3;
|
|
162
|
+
}
|
|
163
|
+
| {
|
|
164
|
+
readonly kind: 'improperRotation';
|
|
165
|
+
readonly axis: Point3;
|
|
166
|
+
readonly origin: Point3;
|
|
167
|
+
readonly order: number;
|
|
168
|
+
/** @default 1 */
|
|
169
|
+
readonly power?: number;
|
|
170
|
+
}
|
|
171
|
+
| { readonly kind: 'mirror'; readonly normal: Point3; readonly point: Point3 }
|
|
172
|
+
| {
|
|
173
|
+
readonly kind: 'glide';
|
|
174
|
+
readonly normal: Point3;
|
|
175
|
+
readonly point: Point3;
|
|
176
|
+
readonly translation: Point3;
|
|
177
|
+
}
|
|
178
|
+
| { readonly kind: 'inversion'; readonly centre: Point3 }
|
|
179
|
+
| {
|
|
180
|
+
readonly kind: 'rotoinversion';
|
|
181
|
+
readonly axis: Point3;
|
|
182
|
+
readonly origin: Point3;
|
|
183
|
+
readonly order: number;
|
|
184
|
+
/** @default 1 */
|
|
185
|
+
readonly power?: number;
|
|
186
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** A point or a direction in Cartesian space, in ångström. */
|
|
2
|
+
export type Vec3 = readonly [number, number, number];
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* a + b.
|
|
6
|
+
* @param a - The first vector.
|
|
7
|
+
* @param b - The vector added to it.
|
|
8
|
+
* @returns The sum.
|
|
9
|
+
*/
|
|
10
|
+
export function addVectors(a: Vec3, b: Vec3): Vec3 {
|
|
11
|
+
return [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* a − b.
|
|
16
|
+
* @param a - The vector subtracted from.
|
|
17
|
+
* @param b - The vector subtracted.
|
|
18
|
+
* @returns The difference.
|
|
19
|
+
*/
|
|
20
|
+
export function subtractVectors(a: Vec3, b: Vec3): Vec3 {
|
|
21
|
+
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* a · factor.
|
|
26
|
+
* @param a - The vector.
|
|
27
|
+
* @param factor - The scalar it is multiplied by.
|
|
28
|
+
* @returns The scaled vector.
|
|
29
|
+
*/
|
|
30
|
+
export function scaleVector(a: Vec3, factor: number): Vec3 {
|
|
31
|
+
return [a[0] * factor, a[1] * factor, a[2] * factor];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* a · b.
|
|
36
|
+
* @param a - The first vector.
|
|
37
|
+
* @param b - The second vector.
|
|
38
|
+
* @returns The dot product.
|
|
39
|
+
*/
|
|
40
|
+
export function dotProduct(a: Vec3, b: Vec3): number {
|
|
41
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* a × b.
|
|
46
|
+
* @param a - The first vector.
|
|
47
|
+
* @param b - The second vector.
|
|
48
|
+
* @returns The cross product, right-handed.
|
|
49
|
+
*/
|
|
50
|
+
export function crossProduct(a: Vec3, b: Vec3): Vec3 {
|
|
51
|
+
return [
|
|
52
|
+
a[1] * b[2] - a[2] * b[1],
|
|
53
|
+
a[2] * b[0] - a[0] * b[2],
|
|
54
|
+
a[0] * b[1] - a[1] * b[0],
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* |a|.
|
|
60
|
+
* @param a - The vector.
|
|
61
|
+
* @returns Its Euclidean length.
|
|
62
|
+
*/
|
|
63
|
+
export function vectorNorm(a: Vec3): number {
|
|
64
|
+
return Math.hypot(a[0], a[1], a[2]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* |a − b|.
|
|
69
|
+
* @param a - The first point.
|
|
70
|
+
* @param b - The second point.
|
|
71
|
+
* @returns The distance between them.
|
|
72
|
+
*/
|
|
73
|
+
export function vectorDistance(a: Vec3, b: Vec3): number {
|
|
74
|
+
const dx = a[0] - b[0];
|
|
75
|
+
const dy = a[1] - b[1];
|
|
76
|
+
const dz = a[2] - b[2];
|
|
77
|
+
return Math.hypot(dx, dy, dz);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* a / |a|.
|
|
82
|
+
* @param a - The vector.
|
|
83
|
+
* @param minimumNorm - The length under which `a` counts as zero.
|
|
84
|
+
* @returns The unit vector along `a`.
|
|
85
|
+
* @throws {RangeError} When `a` is shorter than `minimumNorm`, which has no direction.
|
|
86
|
+
*/
|
|
87
|
+
export function normalizeVector(a: Vec3, minimumNorm = 1e-9): Vec3 {
|
|
88
|
+
const norm = vectorNorm(a);
|
|
89
|
+
if (norm < minimumNorm) {
|
|
90
|
+
throw new RangeError('a vector of zero length has no direction');
|
|
91
|
+
}
|
|
92
|
+
return [a[0] / norm, a[1] / norm, a[2] / norm];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether two unit vectors describe the same **axis**, which is a direction
|
|
97
|
+
* without a sense: `û` and `−û` are one axis.
|
|
98
|
+
* @param a - The first unit vector.
|
|
99
|
+
* @param b - The second unit vector.
|
|
100
|
+
* @param parallel - `|û · v̂|` above which they are the same; `1 - 1e-4` by default.
|
|
101
|
+
* @returns Whether they lie on one axis.
|
|
102
|
+
*/
|
|
103
|
+
export function sameAxis(a: Vec3, b: Vec3, parallel = 1 - 1e-4): boolean {
|
|
104
|
+
return Math.abs(dotProduct(a, b)) >= parallel;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Whether every point lies on one straight line through the first two.
|
|
109
|
+
* @param points - The points, Cartesian ångström.
|
|
110
|
+
* @param tolerance - The distance, in ångström, a point may stray from the line.
|
|
111
|
+
* @returns Whether they are collinear; true for fewer than three points.
|
|
112
|
+
*/
|
|
113
|
+
export function collinear(points: readonly Vec3[], tolerance = 1e-6): boolean {
|
|
114
|
+
if (points.length < 3) return true;
|
|
115
|
+
const origin = points[0] as Vec3;
|
|
116
|
+
let direction: Vec3 | null = null;
|
|
117
|
+
for (let i = 1; i < points.length; i++) {
|
|
118
|
+
const offset = subtractVectors(points[i] as Vec3, origin);
|
|
119
|
+
if (vectorNorm(offset) < tolerance) continue;
|
|
120
|
+
if (direction === null) {
|
|
121
|
+
direction = normalizeVector(offset);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (vectorNorm(crossProduct(direction, offset)) > tolerance) return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The molstar canvas of the crystal view, with the family's toolbars over it,
|
|
3
|
+
* in a box that can fill the screen.
|
|
4
|
+
*
|
|
5
|
+
* `CrystalViewer3D` reaches this module through `React.lazy`, so a page that
|
|
6
|
+
* never shows a crystal never downloads molstar. Every effect below lists
|
|
7
|
+
* exactly what it reads, so a page that keeps its scene stable redraws only the
|
|
8
|
+
* part that changed: toggling one mirror does not rebuild the structure, and
|
|
9
|
+
* moving the pointer does not redraw anything.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
13
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
|
|
15
|
+
import type { Molecule3DCamera } from '../../molecule3d/core/camera.ts';
|
|
16
|
+
import type { Measurement } from '../../molecule3d/core/measurement.ts';
|
|
17
|
+
import type { Molecule3DTools } from '../../molecule3d/core/settings.ts';
|
|
18
|
+
import { Molecule3DStage } from '../../molecule3d/ui/Molecule3DStage.tsx';
|
|
19
|
+
import { useImageExport } from '../../molecule3d/ui/useImageExport.ts';
|
|
20
|
+
import { MolstarToolbar } from '../../molstar/ui/MolstarToolbar.tsx';
|
|
21
|
+
import { useMolstarTools } from '../../molstar/ui/useMolstarTools.ts';
|
|
22
|
+
import { TOKEN } from '../../tokens/core/familyTokens.ts';
|
|
23
|
+
import { sceneOrientation } from '../core/orientation.ts';
|
|
24
|
+
import type { ViewerAtom } from '../core/types.ts';
|
|
25
|
+
import type { CrystalViewer } from '../viewer/index.ts';
|
|
26
|
+
import {
|
|
27
|
+
DEFAULT_CAMERA_DURATION,
|
|
28
|
+
createCrystalViewer,
|
|
29
|
+
} from '../viewer/index.ts';
|
|
30
|
+
|
|
31
|
+
import type { CrystalScene, CrystalViewHandle } from './crystalScene.ts';
|
|
32
|
+
|
|
33
|
+
/** Props of {@link CrystalCanvas3D}. */
|
|
34
|
+
export interface CrystalCanvas3DProps {
|
|
35
|
+
/** What to show. */
|
|
36
|
+
scene: CrystalScene;
|
|
37
|
+
/**
|
|
38
|
+
* Scene background, `#rrggbb`.
|
|
39
|
+
* @default '#ffffff'
|
|
40
|
+
*/
|
|
41
|
+
background?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Which tools the toolbars offer; every one it does not name is on.
|
|
44
|
+
* @default every tool but the display options and the surface
|
|
45
|
+
*/
|
|
46
|
+
tools?: Partial<Molecule3DTools>;
|
|
47
|
+
/**
|
|
48
|
+
* Base name of a picture saved from the toolbar, extension excluded.
|
|
49
|
+
* @default 'crystal'
|
|
50
|
+
*/
|
|
51
|
+
fileName?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Called whenever drawing fails, with one sentence, or `null` once it works
|
|
54
|
+
* again.
|
|
55
|
+
* @default undefined
|
|
56
|
+
*/
|
|
57
|
+
onFailure?: (message: string | null) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Called with the means to picture the scene once the canvas exists, and with
|
|
60
|
+
* `null` once it is gone.
|
|
61
|
+
* @default undefined
|
|
62
|
+
*/
|
|
63
|
+
onHandle?: (handle: CrystalViewHandle | null) => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Draw the scene, say what the pointer rests on, and float the toolbars.
|
|
68
|
+
* @param props - See {@link CrystalCanvas3DProps}.
|
|
69
|
+
* @returns The stage holding the canvas, its toolbars and its readout.
|
|
70
|
+
*/
|
|
71
|
+
export function CrystalCanvas3D(props: CrystalCanvas3DProps): ReactElement {
|
|
72
|
+
const {
|
|
73
|
+
scene,
|
|
74
|
+
background,
|
|
75
|
+
tools,
|
|
76
|
+
fileName = 'crystal',
|
|
77
|
+
onFailure,
|
|
78
|
+
onHandle,
|
|
79
|
+
} = props;
|
|
80
|
+
const {
|
|
81
|
+
atoms,
|
|
82
|
+
camera = null,
|
|
83
|
+
cell = null,
|
|
84
|
+
repeat,
|
|
85
|
+
representation,
|
|
86
|
+
elements,
|
|
87
|
+
labels,
|
|
88
|
+
elementStyle,
|
|
89
|
+
play = null,
|
|
90
|
+
} = scene;
|
|
91
|
+
const [container, setContainer] = useState<HTMLDivElement | null>(null);
|
|
92
|
+
const [hovered, setHovered] = useState<string | null>(null);
|
|
93
|
+
|
|
94
|
+
// The viewer is not React state: it is an external resource the effects below
|
|
95
|
+
// reach through this handle. Putting it in state would set state inside an
|
|
96
|
+
// effect, and every draw would then cost an extra render.
|
|
97
|
+
const held = useRef<CrystalViewer | null>(null);
|
|
98
|
+
|
|
99
|
+
// Which way the scene is opened on: measured from its own principal axis, so
|
|
100
|
+
// a molecule built about z and one built about x both open on a view where a
|
|
101
|
+
// plane reads as a plane and an axis reads as a rod.
|
|
102
|
+
const orientation = useMemo(
|
|
103
|
+
() => sceneOrientation({ cell, elements }),
|
|
104
|
+
[cell, elements],
|
|
105
|
+
);
|
|
106
|
+
// Held in a ref rather than read as a dependency, because only a new
|
|
107
|
+
// structure reframes: switching a layer off changes which elements are drawn,
|
|
108
|
+
// and a camera that swung round at that moment would look like the chip had
|
|
109
|
+
// moved the molecule.
|
|
110
|
+
const framing = useRef(orientation);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
framing.current = orientation;
|
|
113
|
+
}, [orientation]);
|
|
114
|
+
|
|
115
|
+
// A camera a figure carried is put back once, on the structure it came
|
|
116
|
+
// with; every later redraw frames the scene as any other does.
|
|
117
|
+
const opening = useRef<Molecule3DCamera | null>(camera);
|
|
118
|
+
const applied = useRef<Molecule3DCamera | null>(null);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
opening.current = camera;
|
|
121
|
+
}, [camera]);
|
|
122
|
+
|
|
123
|
+
// Kept in a ref as well, so a page passing an inline callback does not redraw
|
|
124
|
+
// the whole scene on every render.
|
|
125
|
+
const failure = useRef(onFailure);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
failure.current = onFailure;
|
|
128
|
+
}, [onFailure]);
|
|
129
|
+
|
|
130
|
+
// The draw in flight, so a picture or a measurement asked for meanwhile
|
|
131
|
+
// waits for it.
|
|
132
|
+
const drawing = useRef<Promise<void> | null>(null);
|
|
133
|
+
|
|
134
|
+
const { measurements, addMeasurement, clearMeasurements } =
|
|
135
|
+
useMeasurementsOf(atoms);
|
|
136
|
+
|
|
137
|
+
const imageExport = useImageExport(container, held, fileName);
|
|
138
|
+
const { capture } = imageExport;
|
|
139
|
+
const handing = useRef(onHandle);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
handing.current = onHandle;
|
|
142
|
+
}, [onHandle]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const listener = handing.current;
|
|
145
|
+
if (listener === undefined || container === null) return;
|
|
146
|
+
listener({
|
|
147
|
+
capture,
|
|
148
|
+
readCamera: () => held.current?.readCamera() ?? Promise.resolve(null),
|
|
149
|
+
whenDrawn: () => drawing.current ?? Promise.resolve(),
|
|
150
|
+
});
|
|
151
|
+
return () => {
|
|
152
|
+
listener(null);
|
|
153
|
+
};
|
|
154
|
+
}, [capture, container]);
|
|
155
|
+
|
|
156
|
+
// A callback ref, so the viewer is created by the element arriving; the
|
|
157
|
+
// effects that draw are declared after this one and so run after it, and
|
|
158
|
+
// every one of them lists `container` so a remount redraws.
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (container === null) return;
|
|
161
|
+
const created = createCrystalViewer(container, {
|
|
162
|
+
background,
|
|
163
|
+
onMeasure: addMeasurement,
|
|
164
|
+
});
|
|
165
|
+
held.current = created;
|
|
166
|
+
const observer = new ResizeObserver(() => {
|
|
167
|
+
created.handleResize();
|
|
168
|
+
});
|
|
169
|
+
observer.observe(container);
|
|
170
|
+
return () => {
|
|
171
|
+
held.current = null;
|
|
172
|
+
observer.disconnect();
|
|
173
|
+
created.dispose();
|
|
174
|
+
};
|
|
175
|
+
}, [container, background, addMeasurement]);
|
|
176
|
+
|
|
177
|
+
const controls = useMolstarTools(held, container);
|
|
178
|
+
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
const viewer = held.current;
|
|
181
|
+
if (viewer === null) return;
|
|
182
|
+
return viewer.onHover(setHovered);
|
|
183
|
+
}, [container, background]);
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
const viewer = held.current;
|
|
187
|
+
if (viewer === null) return;
|
|
188
|
+
container?.setAttribute('data-drawn', 'false');
|
|
189
|
+
const work = (async () => {
|
|
190
|
+
await viewer.showStructure(atoms, { representation });
|
|
191
|
+
await viewer.showCell(cell, repeat);
|
|
192
|
+
const wanted = opening.current;
|
|
193
|
+
if (wanted !== null && wanted !== applied.current) {
|
|
194
|
+
applied.current = wanted;
|
|
195
|
+
await viewer.applyCamera(wanted);
|
|
196
|
+
} else {
|
|
197
|
+
await viewer.resetCamera(0, framing.current);
|
|
198
|
+
}
|
|
199
|
+
container?.setAttribute('data-drawn', 'true');
|
|
200
|
+
})();
|
|
201
|
+
drawing.current = work.catch(() => undefined);
|
|
202
|
+
void report(failure, work);
|
|
203
|
+
}, [container, background, atoms, cell, repeat, representation]);
|
|
204
|
+
|
|
205
|
+
// Once the structure above is on screen, so they are drawn on the atoms they
|
|
206
|
+
// name.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
const viewer = held.current;
|
|
209
|
+
if (viewer === null) return;
|
|
210
|
+
let cancelled = false;
|
|
211
|
+
void (drawing.current ?? Promise.resolve()).then(() => {
|
|
212
|
+
if (!cancelled) void viewer.showMeasurements(measurements);
|
|
213
|
+
});
|
|
214
|
+
return () => {
|
|
215
|
+
cancelled = true;
|
|
216
|
+
};
|
|
217
|
+
}, [container, background, measurements]);
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const viewer = held.current;
|
|
221
|
+
if (viewer === null) return;
|
|
222
|
+
void report(
|
|
223
|
+
failure,
|
|
224
|
+
viewer.showElements(elements ?? [], { labels, style: elementStyle }),
|
|
225
|
+
);
|
|
226
|
+
}, [container, background, elements, labels, elementStyle]);
|
|
227
|
+
|
|
228
|
+
// The nonce is the cue that replays the same operation; the operation itself
|
|
229
|
+
// is in the list so that changing it applies the new one.
|
|
230
|
+
const operation = play?.operation ?? null;
|
|
231
|
+
const duration = play?.durationMs;
|
|
232
|
+
const nonce = play?.nonce ?? null;
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
const viewer = held.current;
|
|
235
|
+
if (viewer === null) return;
|
|
236
|
+
if (operation === null || nonce === null) {
|
|
237
|
+
void report(failure, viewer.resetOperation());
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
void report(
|
|
241
|
+
failure,
|
|
242
|
+
viewer.playOperation(operation, { durationMs: duration }),
|
|
243
|
+
);
|
|
244
|
+
}, [container, background, operation, duration, nonce]);
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<Molecule3DStage style={STAGE_STYLE}>
|
|
248
|
+
{(fullscreen) => (
|
|
249
|
+
<>
|
|
250
|
+
<div
|
|
251
|
+
ref={setContainer}
|
|
252
|
+
style={CANVAS_STYLE}
|
|
253
|
+
data-testid="crystal-3d"
|
|
254
|
+
/>
|
|
255
|
+
{atoms.length > 0 && (
|
|
256
|
+
<MolstarToolbar
|
|
257
|
+
controls={controls}
|
|
258
|
+
tools={{ ...DEFAULT_TOOLS, ...tools }}
|
|
259
|
+
fullscreen={fullscreen}
|
|
260
|
+
measurementCount={measurements.length}
|
|
261
|
+
onClearMeasurements={clearMeasurements}
|
|
262
|
+
onResetView={() => {
|
|
263
|
+
void held.current?.resetCamera(
|
|
264
|
+
DEFAULT_CAMERA_DURATION,
|
|
265
|
+
framing.current,
|
|
266
|
+
);
|
|
267
|
+
}}
|
|
268
|
+
imageExport={imageExport}
|
|
269
|
+
fileName={fileName}
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
272
|
+
{hovered !== null && (
|
|
273
|
+
<div style={READOUT_STYLE} data-testid="crystal-3d-readout">
|
|
274
|
+
{hovered}
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
</>
|
|
278
|
+
)}
|
|
279
|
+
</Molecule3DStage>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** What was measured, and on which atoms. */
|
|
284
|
+
interface TakenMeasurements {
|
|
285
|
+
readonly atoms: readonly ViewerAtom[];
|
|
286
|
+
readonly list: readonly Measurement[];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The measurements taken on the atoms on screen. A new set of atoms is a new
|
|
291
|
+
* structure, whose atoms no measurement names, so the list starts empty again.
|
|
292
|
+
* @param atoms - The atoms on screen.
|
|
293
|
+
* @returns The list, and stable callbacks that change it.
|
|
294
|
+
*/
|
|
295
|
+
function useMeasurementsOf(atoms: readonly ViewerAtom[]): {
|
|
296
|
+
measurements: readonly Measurement[];
|
|
297
|
+
addMeasurement: (measurement: Measurement) => void;
|
|
298
|
+
clearMeasurements: () => void;
|
|
299
|
+
} {
|
|
300
|
+
const latest = useRef(atoms);
|
|
301
|
+
useEffect(() => {
|
|
302
|
+
latest.current = atoms;
|
|
303
|
+
}, [atoms]);
|
|
304
|
+
const [taken, setTaken] = useState<TakenMeasurements>(() => ({
|
|
305
|
+
atoms,
|
|
306
|
+
list: NO_MEASUREMENTS,
|
|
307
|
+
}));
|
|
308
|
+
const addMeasurement = useCallback((measurement: Measurement) => {
|
|
309
|
+
setTaken((previous) => ({
|
|
310
|
+
atoms: latest.current,
|
|
311
|
+
list:
|
|
312
|
+
previous.atoms === latest.current
|
|
313
|
+
? [...previous.list, measurement]
|
|
314
|
+
: [measurement],
|
|
315
|
+
}));
|
|
316
|
+
}, []);
|
|
317
|
+
const clearMeasurements = useCallback(() => {
|
|
318
|
+
setTaken({ atoms: latest.current, list: NO_MEASUREMENTS });
|
|
319
|
+
}, []);
|
|
320
|
+
const measurements = taken.atoms === atoms ? taken.list : NO_MEASUREMENTS;
|
|
321
|
+
return { measurements, addMeasurement, clearMeasurements };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Report a failure as one sentence, and clear it once the next draw works.
|
|
326
|
+
* @param listener - The ref holding the page's failure callback.
|
|
327
|
+
* @param listener.current - The callback, given the message or `null`.
|
|
328
|
+
* @param work - The draw whose outcome is reported.
|
|
329
|
+
*/
|
|
330
|
+
async function report(
|
|
331
|
+
listener: { current?: (message: string | null) => void },
|
|
332
|
+
work: Promise<void>,
|
|
333
|
+
): Promise<void> {
|
|
334
|
+
try {
|
|
335
|
+
await work;
|
|
336
|
+
listener.current?.(null);
|
|
337
|
+
} catch (error) {
|
|
338
|
+
listener.current?.(
|
|
339
|
+
error instanceof Error ? error.message : 'The scene could not be drawn.',
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const NO_MEASUREMENTS: readonly Measurement[] = [];
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* A crystal is not a molecule: its look is the page's to set — the elements,
|
|
348
|
+
* the labels, the representation — so the display options and the molecular
|
|
349
|
+
* surface are not offered.
|
|
350
|
+
*/
|
|
351
|
+
const DEFAULT_TOOLS: Partial<Molecule3DTools> = {
|
|
352
|
+
options: false,
|
|
353
|
+
surface: false,
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const STAGE_STYLE: CSSProperties = {
|
|
357
|
+
position: 'relative',
|
|
358
|
+
width: '100%',
|
|
359
|
+
height: '100%',
|
|
360
|
+
minHeight: 0,
|
|
361
|
+
background: TOKEN.surface,
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/** molstar inserts its canvas here, which therefore has a size of its own. */
|
|
365
|
+
const CANVAS_STYLE: CSSProperties = { position: 'absolute', inset: 0 };
|
|
366
|
+
|
|
367
|
+
/*
|
|
368
|
+
* The readout sits over the canvas rather than beside it, so naming an axis does
|
|
369
|
+
* not reflow the page while the pointer moves.
|
|
370
|
+
*/
|
|
371
|
+
const READOUT_STYLE: CSSProperties = {
|
|
372
|
+
position: 'absolute',
|
|
373
|
+
right: 8,
|
|
374
|
+
bottom: 8,
|
|
375
|
+
left: 8,
|
|
376
|
+
padding: '3px 8px',
|
|
377
|
+
borderRadius: 6,
|
|
378
|
+
background: TOKEN.surface,
|
|
379
|
+
color: TOKEN.text,
|
|
380
|
+
fontSize: 12,
|
|
381
|
+
opacity: 0.92,
|
|
382
|
+
pointerEvents: 'none',
|
|
383
|
+
textAlign: 'right',
|
|
384
|
+
};
|