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,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applying an operation to the structure, so a student watches it land back on
|
|
3
|
+
* itself.
|
|
4
|
+
*
|
|
5
|
+
* The structure moves and the symmetry elements do not: an axis that turned with
|
|
6
|
+
* the molecule would prove nothing. Moving it costs one GPU uniform per frame —
|
|
7
|
+
* `Representation.State.transform` is written straight into the renderable — so
|
|
8
|
+
* nothing is rebuilt and nothing is re-uploaded while the animation runs.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Mat4 } from 'molstar/lib/mol-math/linear-algebra.js';
|
|
12
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
13
|
+
|
|
14
|
+
import type { Matrix4 } from '../core/operationMatrix.ts';
|
|
15
|
+
import { IDENTITY_MATRIX4, operationAt } from '../core/operationMatrix.ts';
|
|
16
|
+
import type { ViewerOperation } from '../core/types.ts';
|
|
17
|
+
|
|
18
|
+
import { structureRepresentation } from './renderStructure.ts';
|
|
19
|
+
|
|
20
|
+
/** How an operation is played. */
|
|
21
|
+
export interface PlayOptions {
|
|
22
|
+
/**
|
|
23
|
+
* How long one application takes, milliseconds.
|
|
24
|
+
* @default 900
|
|
25
|
+
*/
|
|
26
|
+
durationMs?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Called with the fraction played, 0 to 1, on every frame.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
onProgress?: (fraction: number) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Play one application of an operation, and leave the structure where it lands.
|
|
36
|
+
*
|
|
37
|
+
* A second call cancels the first, so a student hammering the button never sees
|
|
38
|
+
* two animations fight.
|
|
39
|
+
* @param plugin - The molstar context.
|
|
40
|
+
* @param operation - What to apply.
|
|
41
|
+
* @param options - See {@link PlayOptions}.
|
|
42
|
+
* @returns Resolves when the operation has been applied in full, or as soon as
|
|
43
|
+
* a later call has taken over.
|
|
44
|
+
*/
|
|
45
|
+
export function playOperation(
|
|
46
|
+
plugin: PluginContext,
|
|
47
|
+
operation: ViewerOperation,
|
|
48
|
+
options: PlayOptions = {},
|
|
49
|
+
): Promise<void> {
|
|
50
|
+
const { durationMs = 900, onProgress } = options;
|
|
51
|
+
const token = (tokens.get(plugin) ?? 0) + 1;
|
|
52
|
+
tokens.set(plugin, token);
|
|
53
|
+
if (durationMs <= 0) {
|
|
54
|
+
setOperationFraction(plugin, operation, 1);
|
|
55
|
+
onProgress?.(1);
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
const started = now();
|
|
59
|
+
return new Promise<void>((resolve) => {
|
|
60
|
+
const step = (): void => {
|
|
61
|
+
if (tokens.get(plugin) !== token) {
|
|
62
|
+
resolve();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const fraction = Math.min(1, (now() - started) / durationMs);
|
|
66
|
+
setOperationFraction(plugin, operation, fraction);
|
|
67
|
+
onProgress?.(fraction);
|
|
68
|
+
if (fraction < 1) globalThis.requestAnimationFrame(step);
|
|
69
|
+
else resolve();
|
|
70
|
+
};
|
|
71
|
+
globalThis.requestAnimationFrame(step);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Hold the structure part-way through an operation, for a slider.
|
|
77
|
+
* @param plugin - The molstar context.
|
|
78
|
+
* @param operation - What is being applied.
|
|
79
|
+
* @param fraction - How far through, 0 to 1.
|
|
80
|
+
*/
|
|
81
|
+
export function setOperationFraction(
|
|
82
|
+
plugin: PluginContext,
|
|
83
|
+
operation: ViewerOperation,
|
|
84
|
+
fraction: number,
|
|
85
|
+
): void {
|
|
86
|
+
applyTransform(plugin, operationAt(operation, fraction));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Put the structure back where it started, and stop any animation in flight.
|
|
91
|
+
* @param plugin - The molstar context.
|
|
92
|
+
*/
|
|
93
|
+
export function resetOperation(plugin: PluginContext): void {
|
|
94
|
+
tokens.set(plugin, (tokens.get(plugin) ?? 0) + 1);
|
|
95
|
+
applyTransform(plugin, IDENTITY_MATRIX4);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function applyTransform(plugin: PluginContext, matrix: Matrix4): void {
|
|
99
|
+
const representation = structureRepresentation(plugin);
|
|
100
|
+
if (representation === undefined) return;
|
|
101
|
+
representation.setState({
|
|
102
|
+
transform: Mat4.fromArray(Mat4.identity(), matrix as number[], 0),
|
|
103
|
+
});
|
|
104
|
+
plugin.canvas3d?.update(representation);
|
|
105
|
+
plugin.canvas3d?.requestDraw();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function now(): number {
|
|
109
|
+
return globalThis.performance.now();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The animation in flight per plugin; a new one invalidates the old. */
|
|
113
|
+
const tokens = new WeakMap<PluginContext, number>();
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framing the scene.
|
|
3
|
+
*
|
|
4
|
+
* What is on screen is measured here rather than read off molstar, for the
|
|
5
|
+
* reason `framing.ts` gives: a representation's own bounding sphere is padded by
|
|
6
|
+
* the largest ball it could ever draw. Each part of the scene registers its
|
|
7
|
+
* extent as it is drawn, and the camera frames the union — the framing itself,
|
|
8
|
+
* and the union, are `react-cheminfo`'s.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Sphere3D } from 'molstar/lib/mol-math/geometry.js';
|
|
12
|
+
import { Vec3 } from 'molstar/lib/mol-math/linear-algebra.js';
|
|
13
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
14
|
+
|
|
15
|
+
import type { Molecule3DCamera } from '../../molecule3d/core/camera.ts';
|
|
16
|
+
import type { CameraReference } from '../../molstar/core/index.ts';
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_CAMERA_DURATION,
|
|
19
|
+
cameraToPose,
|
|
20
|
+
framedRadius,
|
|
21
|
+
poseToCamera,
|
|
22
|
+
resetCamera as frameScene,
|
|
23
|
+
unionSphere,
|
|
24
|
+
} from '../../molstar/core/index.ts';
|
|
25
|
+
import type { SceneSphere } from '../core/framing.ts';
|
|
26
|
+
import type { ViewOrientation } from '../core/orientation.ts';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The scene is measured as the ball through its furthest corners, and a camera
|
|
30
|
+
* fitting that ball to the window leaves a cell filling barely half of it: a
|
|
31
|
+
* cube touches its own circumscribed sphere only at eight corners, and uses
|
|
32
|
+
* about 82% of its diameter even seen square-on. So the ball handed to the
|
|
33
|
+
* camera is **smaller** than the one measured, by about the slack that costs.
|
|
34
|
+
* Nothing is cut at the orientations a cell is read at, and the reader can
|
|
35
|
+
* always pull back.
|
|
36
|
+
*/
|
|
37
|
+
const SCENE_MARGIN = -0.12;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Record how far one part of the scene reaches.
|
|
41
|
+
* @param plugin - The molstar context.
|
|
42
|
+
* @param key - Which part: the atoms, the cell, the elements.
|
|
43
|
+
* @param sphere - Its extent, or `null` once it is no longer drawn.
|
|
44
|
+
*/
|
|
45
|
+
export function setSceneExtent(
|
|
46
|
+
plugin: PluginContext,
|
|
47
|
+
key: string,
|
|
48
|
+
sphere: SceneSphere | null,
|
|
49
|
+
): void {
|
|
50
|
+
let parts = extents.get(plugin);
|
|
51
|
+
if (parts === undefined) {
|
|
52
|
+
parts = new Map<string, Sphere3D>();
|
|
53
|
+
extents.set(plugin, parts);
|
|
54
|
+
}
|
|
55
|
+
if (sphere === null) {
|
|
56
|
+
parts.delete(key);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const [x, y, z] = sphere.centre;
|
|
60
|
+
parts.set(key, Sphere3D.create(Vec3.create(x, y, z), sphere.radius));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Frame everything on screen.
|
|
65
|
+
* @param plugin - The molstar context.
|
|
66
|
+
* @param durationMs - Transition length; 0 jumps.
|
|
67
|
+
* @param orientation - Where to look from, from `sceneOrientation`. Left out,
|
|
68
|
+
* the camera keeps the direction it is already pointing, which is what a
|
|
69
|
+
* reframe after a reader has turned the scene should do.
|
|
70
|
+
*/
|
|
71
|
+
export function resetCamera(
|
|
72
|
+
plugin: PluginContext,
|
|
73
|
+
durationMs = DEFAULT_CAMERA_DURATION,
|
|
74
|
+
orientation?: ViewOrientation,
|
|
75
|
+
): void {
|
|
76
|
+
frameScene(plugin, {
|
|
77
|
+
spheres: [...(extents.get(plugin)?.values() ?? [])],
|
|
78
|
+
margin: SCENE_MARGIN,
|
|
79
|
+
durationMs,
|
|
80
|
+
orientation,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Where the camera stands, measured against what is drawn rather than in
|
|
86
|
+
* ångström, so a figure opens on the same view in a frame of another size.
|
|
87
|
+
* @param plugin - The molstar context.
|
|
88
|
+
* @returns The camera, or `null` while nothing is drawn to measure it against.
|
|
89
|
+
*/
|
|
90
|
+
export function readCamera(plugin: PluginContext): Molecule3DCamera | null {
|
|
91
|
+
const canvas = plugin.canvas3d;
|
|
92
|
+
const reference = sceneReference(plugin);
|
|
93
|
+
if (canvas === undefined || reference === null) return null;
|
|
94
|
+
return poseToCamera(
|
|
95
|
+
canvas.camera.getSnapshot(),
|
|
96
|
+
reference,
|
|
97
|
+
canvas.camera.getTargetDistance(reference.radius),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Put the camera where {@link readCamera} found it, against what is drawn now.
|
|
103
|
+
* @param plugin - The molstar context.
|
|
104
|
+
* @param camera - Where to stand.
|
|
105
|
+
*/
|
|
106
|
+
export function applyCamera(
|
|
107
|
+
plugin: PluginContext,
|
|
108
|
+
camera: Molecule3DCamera,
|
|
109
|
+
): void {
|
|
110
|
+
const canvas = plugin.canvas3d;
|
|
111
|
+
if (canvas === undefined) return;
|
|
112
|
+
// Resolves a reframe molstar has queued, which would otherwise land after
|
|
113
|
+
// this move and undo it.
|
|
114
|
+
canvas.commit(true);
|
|
115
|
+
const reference = sceneReference(plugin);
|
|
116
|
+
if (reference === null) return;
|
|
117
|
+
const pose = cameraToPose(
|
|
118
|
+
camera,
|
|
119
|
+
reference,
|
|
120
|
+
canvas.camera.getTargetDistance(reference.radius),
|
|
121
|
+
);
|
|
122
|
+
canvas.camera.setState({ ...pose, radius: reference.radius }, 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The sphere a camera is measured against: every part drawn, framed.
|
|
127
|
+
* @param plugin - The molstar context whose scene is measured.
|
|
128
|
+
* @returns The centre and framed radius, or `null` while nothing is drawn.
|
|
129
|
+
*/
|
|
130
|
+
function sceneReference(plugin: PluginContext): CameraReference | null {
|
|
131
|
+
const union = unionSphere([...(extents.get(plugin)?.values() ?? [])]);
|
|
132
|
+
if (union === null || !(union.radius > 0)) return null;
|
|
133
|
+
return { center: union.center, radius: framedRadius(union.radius) };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** What each part of the scene reaches, per plugin. */
|
|
137
|
+
const extents = new WeakMap<PluginContext, Map<string, Sphere3D>>();
|
|
138
|
+
|
|
139
|
+
export { DEFAULT_CAMERA_DURATION } from '../../molstar/core/index.ts';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The molstar half of the crystal viewer: the canvas, and everything drawn on
|
|
3
|
+
* it. Reaching it pulls molstar in, so only the lazy canvas imports it.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type { PlayOptions } from './animate.ts';
|
|
7
|
+
export { DEFAULT_CAMERA_DURATION } from './camera.ts';
|
|
8
|
+
export type { CrystalViewerOptions } from './plugin.ts';
|
|
9
|
+
export { CrystalViewerPlugin } from './plugin.ts';
|
|
10
|
+
export type { CellStyle } from './renderCell.ts';
|
|
11
|
+
export type { ElementLayerStyle } from './renderElements.ts';
|
|
12
|
+
export type { StructureStyle } from './renderStructure.ts';
|
|
13
|
+
export { CrystalViewer, createCrystalViewer } from './viewer.ts';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which drawn layers a canvas is carrying.
|
|
3
|
+
*
|
|
4
|
+
* A layer lives outside the state tree, keyed by name on the plugin, the way
|
|
5
|
+
* `lcao`'s lobes and nodal surfaces do: it is rebuilt whole on every toggle, and
|
|
6
|
+
* the state tree has nothing to add to that. Keeping the register here lets the
|
|
7
|
+
* mesh layers and the text layers share one place to be removed from.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
11
|
+
import type { Representation } from 'molstar/lib/mol-repr/representation.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Remember a layer, so a later call can take it off again.
|
|
15
|
+
* @param plugin - The molstar context.
|
|
16
|
+
* @param key - Which layer.
|
|
17
|
+
* @param representation - What was added to the canvas.
|
|
18
|
+
*/
|
|
19
|
+
export function storeLayer(
|
|
20
|
+
plugin: PluginContext,
|
|
21
|
+
key: string,
|
|
22
|
+
representation: Representation.Any,
|
|
23
|
+
): void {
|
|
24
|
+
let layers = registry.get(plugin);
|
|
25
|
+
if (layers === undefined) {
|
|
26
|
+
layers = new Map<string, Representation.Any>();
|
|
27
|
+
registry.set(plugin, layers);
|
|
28
|
+
}
|
|
29
|
+
layers.set(key, representation);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Remove one layer, leaving every other in place.
|
|
34
|
+
* @param plugin - The molstar context.
|
|
35
|
+
* @param key - Which layer; an unknown one is ignored.
|
|
36
|
+
*/
|
|
37
|
+
export function clearShapeLayer(plugin: PluginContext, key: string): void {
|
|
38
|
+
const layers = registry.get(plugin);
|
|
39
|
+
const previous = layers?.get(key);
|
|
40
|
+
if (layers === undefined || previous === undefined) return;
|
|
41
|
+
layers.delete(key);
|
|
42
|
+
plugin.canvas3d?.remove(previous);
|
|
43
|
+
plugin.canvas3d?.commit();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Every layer drawn on a plugin, so each can be removed on its own. */
|
|
47
|
+
const registry = new WeakMap<PluginContext, Map<string, Representation.Any>>();
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a shape worked out in `primitives.ts` becomes molstar geometry.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
addFixedCountDashedCylinder,
|
|
7
|
+
addSimpleCylinder,
|
|
8
|
+
} from 'molstar/lib/mol-geo/geometry/mesh/builder/cylinder.js';
|
|
9
|
+
import { addPlane } from 'molstar/lib/mol-geo/geometry/mesh/builder/plane.js';
|
|
10
|
+
import { addSphere } from 'molstar/lib/mol-geo/geometry/mesh/builder/sphere.js';
|
|
11
|
+
import { MeshBuilder } from 'molstar/lib/mol-geo/geometry/mesh/mesh-builder.js';
|
|
12
|
+
import { Vec3 } from 'molstar/lib/mol-math/linear-algebra.js';
|
|
13
|
+
|
|
14
|
+
import type { MeshPrimitive } from '../core/primitives.ts';
|
|
15
|
+
import type { Point3 } from '../core/types.ts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add one shape to a mesh under construction.
|
|
19
|
+
* @param state - The builder; its `currentGroup` decides which item the
|
|
20
|
+
* triangles belong to, and so what colour and label they take.
|
|
21
|
+
* @param primitive - The shape.
|
|
22
|
+
*/
|
|
23
|
+
export function addMeshPrimitive(
|
|
24
|
+
state: MeshBuilder.State,
|
|
25
|
+
primitive: MeshPrimitive,
|
|
26
|
+
): void {
|
|
27
|
+
switch (primitive.shape) {
|
|
28
|
+
case 'rod': {
|
|
29
|
+
addSimpleCylinder(state, vec(primitive.start), vec(primitive.end), {
|
|
30
|
+
radiusTop: primitive.radius,
|
|
31
|
+
radiusBottom: primitive.radius,
|
|
32
|
+
radialSegments: ROD_SEGMENTS,
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
case 'dashes': {
|
|
37
|
+
addFixedCountDashedCylinder(
|
|
38
|
+
state,
|
|
39
|
+
vec(primitive.start),
|
|
40
|
+
vec(primitive.end),
|
|
41
|
+
1,
|
|
42
|
+
primitive.segments,
|
|
43
|
+
true,
|
|
44
|
+
{
|
|
45
|
+
radiusTop: primitive.radius,
|
|
46
|
+
radiusBottom: primitive.radius,
|
|
47
|
+
radialSegments: ROD_SEGMENTS,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
case 'cone': {
|
|
53
|
+
addSimpleCylinder(state, vec(primitive.base), vec(primitive.tip), {
|
|
54
|
+
radiusTop: 0,
|
|
55
|
+
radiusBottom: primitive.radius,
|
|
56
|
+
radialSegments: CONE_SEGMENTS,
|
|
57
|
+
bottomCap: true,
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
case 'sphere': {
|
|
62
|
+
addSphere(state, vec(primitive.centre), primitive.radius, SPHERE_DETAIL);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
case 'face': {
|
|
66
|
+
// A fan from the first corner; the corners come round the plane in
|
|
67
|
+
// order, so the face is convex and the fan covers it exactly.
|
|
68
|
+
const { points } = primitive;
|
|
69
|
+
const first = points[0];
|
|
70
|
+
if (first === undefined) return;
|
|
71
|
+
for (let index = 1; index + 1 < points.length; index++) {
|
|
72
|
+
const second = points[index];
|
|
73
|
+
const third = points[index + 1];
|
|
74
|
+
if (second === undefined || third === undefined) continue;
|
|
75
|
+
MeshBuilder.addTriangle(state, vec(first), vec(second), vec(third));
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
case 'plate': {
|
|
80
|
+
// The unit plane is ±0.5, so the scale is the side of the square; the
|
|
81
|
+
// third component is the (zero-thickness) normal direction.
|
|
82
|
+
addPlane(
|
|
83
|
+
state,
|
|
84
|
+
vec(primitive.centre),
|
|
85
|
+
vec(primitive.major),
|
|
86
|
+
vec(primitive.minor),
|
|
87
|
+
Vec3.create(primitive.size, primitive.size, 1),
|
|
88
|
+
1,
|
|
89
|
+
1,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
// no default
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function vec(point: Point3): Vec3 {
|
|
97
|
+
return Vec3.create(point[0], point[1], point[2]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ROD_SEGMENTS = 12;
|
|
101
|
+
const CONE_SEGMENTS = 16;
|
|
102
|
+
const SPHERE_DETAIL = 2;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle of one molstar canvas: created now, disposed whenever, every call
|
|
3
|
+
* queued behind initialisation.
|
|
4
|
+
*
|
|
5
|
+
* The constructor is **synchronous** on purpose. React 19 runs an effect, its
|
|
6
|
+
* cleanup and the effect again on every mount in development, so an `await`ed
|
|
7
|
+
* constructor hands the cleanup nothing to dispose and leaks a WebGL context per
|
|
8
|
+
* mount — browsers drop the oldest after about sixteen, and the viewer silently
|
|
9
|
+
* goes blank. Returning the handle immediately means `dispose()` can always be
|
|
10
|
+
* called, even before initialisation has finished.
|
|
11
|
+
*
|
|
12
|
+
* molstar's own UI is never mounted: every control is the page's.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
16
|
+
|
|
17
|
+
import type { Molecule3DCamera } from '../../molecule3d/core/camera.ts';
|
|
18
|
+
import type { ImageSize } from '../../molecule3d/core/exportImage.ts';
|
|
19
|
+
import type { RenderedFigure } from '../../molecule3d/core/figureFrame.ts';
|
|
20
|
+
import type {
|
|
21
|
+
Measurement,
|
|
22
|
+
MeasurementKind,
|
|
23
|
+
} from '../../molecule3d/core/measurement.ts';
|
|
24
|
+
import type { SceneCapture } from '../../molecule3d/ui/exportMoleculeImage.ts';
|
|
25
|
+
import {
|
|
26
|
+
MeasurementPicker,
|
|
27
|
+
MolstarPlugin,
|
|
28
|
+
captureFigure,
|
|
29
|
+
captureScene,
|
|
30
|
+
clearMeasurements,
|
|
31
|
+
focusPoint,
|
|
32
|
+
renderMeasurements,
|
|
33
|
+
setSpin,
|
|
34
|
+
subscribeHoverLabel,
|
|
35
|
+
} from '../../molstar/core/index.ts';
|
|
36
|
+
import type { ViewOrientation } from '../core/orientation.ts';
|
|
37
|
+
import type { Point3 } from '../core/types.ts';
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
DEFAULT_CAMERA_DURATION,
|
|
41
|
+
applyCamera,
|
|
42
|
+
readCamera,
|
|
43
|
+
resetCamera,
|
|
44
|
+
} from './camera.ts';
|
|
45
|
+
import { crystalStructure } from './renderStructure.ts';
|
|
46
|
+
|
|
47
|
+
/** Settings fixed for the life of a viewer. */
|
|
48
|
+
export interface CrystalViewerOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Scene background, as `#rrggbb`.
|
|
51
|
+
* @default '#ffffff'
|
|
52
|
+
*/
|
|
53
|
+
background?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Called with each measurement once its atoms are picked; measuring is off
|
|
56
|
+
* without it.
|
|
57
|
+
* @default undefined
|
|
58
|
+
*/
|
|
59
|
+
onMeasure?: (measurement: Measurement) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One molstar canvas, and the queue everything drawn on it goes through. */
|
|
63
|
+
export class CrystalViewerPlugin implements SceneCapture {
|
|
64
|
+
readonly #plugin: MolstarPlugin;
|
|
65
|
+
#picker: MeasurementPicker | undefined;
|
|
66
|
+
|
|
67
|
+
/** Resolves once the canvas exists; every call awaits it internally. */
|
|
68
|
+
readonly ready: Promise<void>;
|
|
69
|
+
|
|
70
|
+
constructor(container: HTMLElement, options: CrystalViewerOptions = {}) {
|
|
71
|
+
this.#plugin = new MolstarPlugin(container, {
|
|
72
|
+
background: options.background,
|
|
73
|
+
// Replacing a scene commits several times, and molstar's own default
|
|
74
|
+
// glides the camera on each, so the structure appears to drift into
|
|
75
|
+
// place. Reframing is right; animating it between two unrelated
|
|
76
|
+
// structures is not.
|
|
77
|
+
cameraResetDurationMilliseconds: 0,
|
|
78
|
+
});
|
|
79
|
+
this.ready = this.#plugin.ready;
|
|
80
|
+
const { onMeasure } = options;
|
|
81
|
+
if (onMeasure !== undefined) {
|
|
82
|
+
// A failed initialisation is reported by the next call the page makes.
|
|
83
|
+
void this.#plugin
|
|
84
|
+
.run((plugin) => {
|
|
85
|
+
this.#picker = new MeasurementPicker(
|
|
86
|
+
plugin,
|
|
87
|
+
onMeasure,
|
|
88
|
+
crystalStructure,
|
|
89
|
+
);
|
|
90
|
+
})
|
|
91
|
+
.catch(() => undefined);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether {@link dispose} has been called.
|
|
97
|
+
* @returns True once the viewer is disposed.
|
|
98
|
+
*/
|
|
99
|
+
get disposed(): boolean {
|
|
100
|
+
return this.#plugin.disposed;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Wait for initialisation, then run `action` on the plugin.
|
|
105
|
+
* @param action - What to do with the molstar context.
|
|
106
|
+
* @returns Nothing once the viewer has been disposed — before the call or
|
|
107
|
+
* while `action` was still running. An initialisation failure, and any
|
|
108
|
+
* error `action` throws while the viewer is alive, still reach the caller.
|
|
109
|
+
*/
|
|
110
|
+
run(action: (plugin: PluginContext) => void | Promise<void>): Promise<void> {
|
|
111
|
+
return this.#plugin.run(action).then(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Frame everything on screen.
|
|
116
|
+
* @param durationMs - Transition length; 0 jumps.
|
|
117
|
+
* @param orientation - Where to look from, from `sceneOrientation`. Left out,
|
|
118
|
+
* the camera keeps the direction it is already pointing.
|
|
119
|
+
* @returns Resolves once the camera has been told where to go.
|
|
120
|
+
*/
|
|
121
|
+
resetCamera(
|
|
122
|
+
durationMs = DEFAULT_CAMERA_DURATION,
|
|
123
|
+
orientation?: ViewOrientation,
|
|
124
|
+
): Promise<void> {
|
|
125
|
+
return this.run((plugin) => {
|
|
126
|
+
resetCamera(plugin, durationMs, orientation);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Where the camera stands, against what is drawn.
|
|
132
|
+
* @returns The camera, or `null` while nothing is drawn.
|
|
133
|
+
*/
|
|
134
|
+
async readCamera(): Promise<Molecule3DCamera | null> {
|
|
135
|
+
return (await this.#plugin.run(readCamera)) ?? null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Put the camera back where {@link readCamera} found it.
|
|
140
|
+
* @param camera - Where to stand.
|
|
141
|
+
* @returns Resolves once the camera stands there.
|
|
142
|
+
*/
|
|
143
|
+
applyCamera(camera: Molecule3DCamera): Promise<void> {
|
|
144
|
+
return this.run((plugin) => {
|
|
145
|
+
applyCamera(plugin, camera);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Render the scene off screen at a size of its own, for a picture to save.
|
|
151
|
+
* @param size - Pixel size of the picture.
|
|
152
|
+
* @returns The PNG as a data URI; `undefined` once the viewer is disposed.
|
|
153
|
+
*/
|
|
154
|
+
captureImage(size: ImageSize): Promise<string | undefined> {
|
|
155
|
+
return this.#plugin.run((plugin) => captureScene(plugin, size));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Render the part of the scene holding the crystal, for a figure handed on.
|
|
160
|
+
* @param size - Pixel size of the frame the crystal is cut from.
|
|
161
|
+
* @param longest - Longest side of the figure, in pixels.
|
|
162
|
+
* @returns The figure; `undefined` once the viewer is disposed.
|
|
163
|
+
*/
|
|
164
|
+
captureFigure(
|
|
165
|
+
size: ImageSize,
|
|
166
|
+
longest: number,
|
|
167
|
+
): Promise<RenderedFigure | undefined> {
|
|
168
|
+
return this.#plugin.run((plugin) => captureFigure(plugin, size, longest));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Zoom onto one point of the scene.
|
|
173
|
+
* @param centre - What to frame, Cartesian ångström.
|
|
174
|
+
* @param radius - Radius of the ball to fit, ångström.
|
|
175
|
+
* @param durationMs - Transition length; 0 jumps.
|
|
176
|
+
* @param orientation - Where to look from; the current direction when absent.
|
|
177
|
+
* @returns Resolves once the camera has been told where to go.
|
|
178
|
+
*/
|
|
179
|
+
focus(
|
|
180
|
+
centre: Point3,
|
|
181
|
+
radius: number,
|
|
182
|
+
durationMs = DEFAULT_CAMERA_DURATION,
|
|
183
|
+
orientation?: ViewOrientation,
|
|
184
|
+
): Promise<void> {
|
|
185
|
+
return this.run((plugin) => {
|
|
186
|
+
focusPoint(plugin, centre, radius, { durationMs, orientation });
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Turn the automatic spin on or off. It moves the camera, never the object:
|
|
192
|
+
* showing that a molecule maps onto itself is a different button.
|
|
193
|
+
* @param spinning - Whether the scene should keep turning.
|
|
194
|
+
* @param speed - molstar's own spin unit.
|
|
195
|
+
* @returns Resolves once the spin is set.
|
|
196
|
+
*/
|
|
197
|
+
setSpin(spinning: boolean, speed = 1): Promise<void> {
|
|
198
|
+
return this.run((plugin) => {
|
|
199
|
+
setSpin(plugin, spinning, speed);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Report what the pointer rests on, by the label its drawing carries. Every
|
|
205
|
+
* axis, plane and centre is drawn with a label already — `C3 along [111]`,
|
|
206
|
+
* `n glide at x = ¼` — and an atom is named `O 1`, never by the row molstar
|
|
207
|
+
* parsed it from.
|
|
208
|
+
* @param listener - Called with the label, or `null` over nothing.
|
|
209
|
+
* @returns A function that stops the reporting; safe to call at any time.
|
|
210
|
+
*/
|
|
211
|
+
onHover(listener: (label: string | null) => void): () => void {
|
|
212
|
+
return this.#plugin.subscribe((plugin) =>
|
|
213
|
+
subscribeHoverLabel(plugin, (hover) => {
|
|
214
|
+
listener(hover === null ? null : hover.label);
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Make clicks on atoms build a measurement, or give them back to the camera.
|
|
221
|
+
* @param kind - The measurement to build, or `null`.
|
|
222
|
+
* @returns Resolves once clicks build that measurement.
|
|
223
|
+
*/
|
|
224
|
+
setMeasureKind(kind: MeasurementKind | null): Promise<void> {
|
|
225
|
+
return this.run(() => {
|
|
226
|
+
this.#picker?.setKind(kind);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Draw exactly these measurements over the atoms on screen.
|
|
232
|
+
* @param measurements - Replaces whatever is drawn; empty clears them.
|
|
233
|
+
* @returns Resolves once they are drawn.
|
|
234
|
+
*/
|
|
235
|
+
showMeasurements(measurements: readonly Measurement[]): Promise<void> {
|
|
236
|
+
return this.run(async (plugin) => {
|
|
237
|
+
if (measurements.length === 0) {
|
|
238
|
+
await clearMeasurements(plugin);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
await renderMeasurements(plugin, measurements, crystalStructure);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Re-read the container's size. Call from a `ResizeObserver`. */
|
|
246
|
+
handleResize(): void {
|
|
247
|
+
this.#plugin.handleResize();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Tear the canvas down and release its WebGL context. Idempotent, and safe to
|
|
252
|
+
* call before initialisation has finished.
|
|
253
|
+
*/
|
|
254
|
+
dispose(): void {
|
|
255
|
+
this.#picker?.dispose();
|
|
256
|
+
this.#plugin.dispose();
|
|
257
|
+
}
|
|
258
|
+
}
|