react-cheminfo 0.135.0 → 0.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/crystal/core/cellAtoms.d.ts +43 -0
- package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
- package/lib/crystal/core/cellAtoms.js +70 -0
- package/lib/crystal/core/cellAtoms.js.map +1 -0
- package/lib/crystal/core/index.d.ts +2 -0
- package/lib/crystal/core/index.d.ts.map +1 -1
- package/lib/crystal/core/index.js +1 -0
- package/lib/crystal/core/index.js.map +1 -1
- package/lib/crystal/core/molecules.d.ts.map +1 -1
- package/lib/crystal/core/molecules.js +6 -40
- package/lib/crystal/core/molecules.js.map +1 -1
- package/lib/crystal3d/core/cellClip.d.ts +46 -0
- package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
- package/lib/crystal3d/core/cellClip.js +198 -0
- package/lib/crystal3d/core/cellClip.js.map +1 -0
- package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
- package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
- package/lib/crystal3d/core/cellGeometry.js +153 -0
- package/lib/crystal3d/core/cellGeometry.js.map +1 -0
- package/lib/crystal3d/core/cellStack.d.ts +51 -0
- package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
- package/lib/crystal3d/core/cellStack.js +79 -0
- package/lib/crystal3d/core/cellStack.js.map +1 -0
- package/lib/crystal3d/core/crystalView.d.ts +71 -0
- package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
- package/lib/crystal3d/core/crystalView.js +48 -0
- package/lib/crystal3d/core/crystalView.js.map +1 -0
- package/lib/crystal3d/core/drawingSet.d.ts +31 -0
- package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
- package/lib/crystal3d/core/drawingSet.js +63 -0
- package/lib/crystal3d/core/drawingSet.js.map +1 -0
- package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
- package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
- package/lib/crystal3d/core/elementDrawing.js +100 -0
- package/lib/crystal3d/core/elementDrawing.js.map +1 -0
- package/lib/crystal3d/core/elementExtent.d.ts +42 -0
- package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
- package/lib/crystal3d/core/elementExtent.js +56 -0
- package/lib/crystal3d/core/elementExtent.js.map +1 -0
- package/lib/crystal3d/core/elementLabels.d.ts +31 -0
- package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
- package/lib/crystal3d/core/elementLabels.js +99 -0
- package/lib/crystal3d/core/elementLabels.js.map +1 -0
- package/lib/crystal3d/core/elementShapes.d.ts +43 -0
- package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
- package/lib/crystal3d/core/elementShapes.js +115 -0
- package/lib/crystal3d/core/elementShapes.js.map +1 -0
- package/lib/crystal3d/core/frame.d.ts +36 -0
- package/lib/crystal3d/core/frame.d.ts.map +1 -0
- package/lib/crystal3d/core/frame.js +35 -0
- package/lib/crystal3d/core/frame.js.map +1 -0
- package/lib/crystal3d/core/framing.d.ts +41 -0
- package/lib/crystal3d/core/framing.d.ts.map +1 -0
- package/lib/crystal3d/core/framing.js +79 -0
- package/lib/crystal3d/core/framing.js.map +1 -0
- package/lib/crystal3d/core/index.d.ts +42 -0
- package/lib/crystal3d/core/index.d.ts.map +1 -0
- package/lib/crystal3d/core/index.js +29 -0
- package/lib/crystal3d/core/index.js.map +1 -0
- package/lib/crystal3d/core/labelText.d.ts +19 -0
- package/lib/crystal3d/core/labelText.d.ts.map +1 -0
- package/lib/crystal3d/core/labelText.js +42 -0
- package/lib/crystal3d/core/labelText.js.map +1 -0
- package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
- package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
- package/lib/crystal3d/core/latticeBasis.js +89 -0
- package/lib/crystal3d/core/latticeBasis.js.map +1 -0
- package/lib/crystal3d/core/mat3.d.ts +68 -0
- package/lib/crystal3d/core/mat3.d.ts.map +1 -0
- package/lib/crystal3d/core/mat3.js +146 -0
- package/lib/crystal3d/core/mat3.js.map +1 -0
- package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
- package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
- package/lib/crystal3d/core/operationMatrix.js +172 -0
- package/lib/crystal3d/core/operationMatrix.js.map +1 -0
- package/lib/crystal3d/core/orientation.d.ts +62 -0
- package/lib/crystal3d/core/orientation.d.ts.map +1 -0
- package/lib/crystal3d/core/orientation.js +166 -0
- package/lib/crystal3d/core/orientation.js.map +1 -0
- package/lib/crystal3d/core/palette.d.ts +24 -0
- package/lib/crystal3d/core/palette.d.ts.map +1 -0
- package/lib/crystal3d/core/palette.js +34 -0
- package/lib/crystal3d/core/palette.js.map +1 -0
- package/lib/crystal3d/core/primitives.d.ts +133 -0
- package/lib/crystal3d/core/primitives.d.ts.map +1 -0
- package/lib/crystal3d/core/primitives.js +80 -0
- package/lib/crystal3d/core/primitives.js.map +1 -0
- package/lib/crystal3d/core/structureText.d.ts +20 -0
- package/lib/crystal3d/core/structureText.d.ts.map +1 -0
- package/lib/crystal3d/core/structureText.js +37 -0
- package/lib/crystal3d/core/structureText.js.map +1 -0
- package/lib/crystal3d/core/supercell.d.ts +20 -0
- package/lib/crystal3d/core/supercell.d.ts.map +1 -0
- package/lib/crystal3d/core/supercell.js +35 -0
- package/lib/crystal3d/core/supercell.js.map +1 -0
- package/lib/crystal3d/core/types.d.ts +166 -0
- package/lib/crystal3d/core/types.d.ts.map +1 -0
- package/lib/crystal3d/core/types.js +10 -0
- package/lib/crystal3d/core/types.js.map +1 -0
- package/lib/crystal3d/core/vec3.d.ts +75 -0
- package/lib/crystal3d/core/vec3.d.ts.map +1 -0
- package/lib/crystal3d/core/vec3.js +119 -0
- package/lib/crystal3d/core/vec3.js.map +1 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
- package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
- package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
- package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
- package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
- package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
- package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
- package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
- package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
- package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
- package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
- package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
- package/lib/crystal3d/ui/crystalScene.js +10 -0
- package/lib/crystal3d/ui/crystalScene.js.map +1 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
- package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
- package/lib/crystal3d/ui/index.d.ts +16 -0
- package/lib/crystal3d/ui/index.d.ts.map +1 -0
- package/lib/crystal3d/ui/index.js +12 -0
- package/lib/crystal3d/ui/index.js.map +1 -0
- package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
- package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
- package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
- package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
- package/lib/crystal3d/viewer/animate.d.ts +49 -0
- package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
- package/lib/crystal3d/viewer/animate.js +83 -0
- package/lib/crystal3d/viewer/animate.js.map +1 -0
- package/lib/crystal3d/viewer/camera.d.ts +44 -0
- package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
- package/lib/crystal3d/viewer/camera.js +103 -0
- package/lib/crystal3d/viewer/camera.js.map +1 -0
- package/lib/crystal3d/viewer/index.d.ts +13 -0
- package/lib/crystal3d/viewer/index.d.ts.map +1 -0
- package/lib/crystal3d/viewer/index.js +8 -0
- package/lib/crystal3d/viewer/index.js.map +1 -0
- package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
- package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
- package/lib/crystal3d/viewer/layerRegistry.js +39 -0
- package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
- package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
- package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
- package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
- package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
- package/lib/crystal3d/viewer/plugin.d.ts +133 -0
- package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
- package/lib/crystal3d/viewer/plugin.js +181 -0
- package/lib/crystal3d/viewer/plugin.js.map +1 -0
- package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
- package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderCell.js +53 -0
- package/lib/crystal3d/viewer/renderCell.js.map +1 -0
- package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
- package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderElements.js +77 -0
- package/lib/crystal3d/viewer/renderElements.js.map +1 -0
- package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
- package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
- package/lib/crystal3d/viewer/renderStructure.js +103 -0
- package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
- package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
- package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
- package/lib/crystal3d/viewer/sceneParts.js +77 -0
- package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
- package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
- package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/shapeLayer.js +57 -0
- package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
- package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
- package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/textLayer.js +59 -0
- package/lib/crystal3d/viewer/textLayer.js.map +1 -0
- package/lib/crystal3d/viewer/viewer.d.ts +110 -0
- package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
- package/lib/crystal3d/viewer/viewer.js +157 -0
- package/lib/crystal3d/viewer/viewer.js.map +1 -0
- package/lib/crystal3d.d.ts +12 -0
- package/lib/crystal3d.d.ts.map +1 -0
- package/lib/crystal3d.js +12 -0
- package/lib/crystal3d.js.map +1 -0
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +19 -1
- package/lib/locales/en.json +19 -1
- package/lib/locales/es.json +19 -1
- package/lib/locales/fr.json +19 -1
- package/lib/locales/it.json +19 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molstar/bonds/bondRule.d.ts +16 -0
- package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
- package/lib/molstar/bonds/bondRule.js +23 -0
- package/lib/molstar/bonds/bondRule.js.map +1 -0
- package/lib/molstar/bonds/index.d.ts +9 -0
- package/lib/molstar/bonds/index.d.ts.map +1 -0
- package/lib/molstar/bonds/index.js +9 -0
- package/lib/molstar/bonds/index.js.map +1 -0
- package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
- package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
- package/lib/molstar/ui/MolstarToolbar.js +28 -0
- package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
- package/lib/molstar/ui/index.d.ts +10 -0
- package/lib/molstar/ui/index.d.ts.map +1 -0
- package/lib/molstar/ui/index.js +8 -0
- package/lib/molstar/ui/index.js.map +1 -0
- package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
- package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
- package/lib/molstar/ui/useMolstarTools.js +36 -0
- package/lib/molstar/ui/useMolstarTools.js.map +1 -0
- package/package.json +2 -1
- package/src/crystal/core/cellAtoms.ts +106 -0
- package/src/crystal/core/index.ts +2 -0
- package/src/crystal/core/molecules.ts +7 -44
- package/src/crystal3d/core/cellClip.ts +229 -0
- package/src/crystal3d/core/cellGeometry.ts +193 -0
- package/src/crystal3d/core/cellStack.ts +87 -0
- package/src/crystal3d/core/crystalView.ts +114 -0
- package/src/crystal3d/core/drawingSet.ts +71 -0
- package/src/crystal3d/core/elementDrawing.ts +147 -0
- package/src/crystal3d/core/elementExtent.ts +81 -0
- package/src/crystal3d/core/elementLabels.ts +130 -0
- package/src/crystal3d/core/elementShapes.ts +141 -0
- package/src/crystal3d/core/frame.ts +56 -0
- package/src/crystal3d/core/framing.ts +101 -0
- package/src/crystal3d/core/index.ts +132 -0
- package/src/crystal3d/core/labelText.ts +44 -0
- package/src/crystal3d/core/latticeBasis.ts +110 -0
- package/src/crystal3d/core/mat3.ts +163 -0
- package/src/crystal3d/core/operationMatrix.ts +255 -0
- package/src/crystal3d/core/orientation.ts +229 -0
- package/src/crystal3d/core/palette.ts +43 -0
- package/src/crystal3d/core/primitives.ts +183 -0
- package/src/crystal3d/core/structureText.ts +43 -0
- package/src/crystal3d/core/supercell.ts +40 -0
- package/src/crystal3d/core/types.ts +186 -0
- package/src/crystal3d/core/vec3.ts +127 -0
- package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
- package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
- package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
- package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
- package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
- package/src/crystal3d/ui/crystalScene.ts +100 -0
- package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
- package/src/crystal3d/ui/index.ts +20 -0
- package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
- package/src/crystal3d/viewer/animate.ts +113 -0
- package/src/crystal3d/viewer/camera.ts +139 -0
- package/src/crystal3d/viewer/index.ts +13 -0
- package/src/crystal3d/viewer/layerRegistry.ts +47 -0
- package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
- package/src/crystal3d/viewer/plugin.ts +258 -0
- package/src/crystal3d/viewer/renderCell.ts +98 -0
- package/src/crystal3d/viewer/renderElements.ts +121 -0
- package/src/crystal3d/viewer/renderStructure.ts +144 -0
- package/src/crystal3d/viewer/sceneParts.ts +119 -0
- package/src/crystal3d/viewer/shapeLayer.ts +108 -0
- package/src/crystal3d/viewer/textLayer.ts +85 -0
- package/src/crystal3d/viewer/viewer.ts +207 -0
- package/src/crystal3d.ts +12 -0
- package/src/locales/de.json +19 -1
- package/src/locales/en.json +19 -1
- package/src/locales/es.json +19 -1
- package/src/locales/fr.json +19 -1
- package/src/locales/it.json +19 -1
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
- package/src/molstar/bonds/bondRule.ts +34 -0
- package/src/molstar/bonds/index.ts +9 -0
- package/src/molstar/ui/MolstarToolbar.tsx +103 -0
- package/src/molstar/ui/index.ts +14 -0
- package/src/molstar/ui/useMolstarTools.ts +98 -0
- package/styles/chrome.css +90 -0
package/lib/locales/it.json
CHANGED
|
@@ -1085,5 +1085,23 @@
|
|
|
1085
1085
|
"send.label": "Invia a",
|
|
1086
1086
|
"send.heading": "Invia {what} a",
|
|
1087
1087
|
"send.none": "Nulla di questa pagina può ancora essere inviato a un altro strumento.",
|
|
1088
|
-
"send.blocked": "Il browser ha bloccato la nuova scheda: consenti i pop-up per questo sito, poi invia di nuovo."
|
|
1088
|
+
"send.blocked": "Il browser ha bloccato la nuova scheda: consenti i pop-up per questo sito, poi invia di nuovo.",
|
|
1089
|
+
"crystal3d.draw": "Disegna",
|
|
1090
|
+
"crystal3d.cells": "Celle",
|
|
1091
|
+
"crystal3d.packing.molecules": "Molecole intere",
|
|
1092
|
+
"crystal3d.packing.moleculesHelp": "Ogni molecola intera, nella cella in cui cade il suo centro.",
|
|
1093
|
+
"crystal3d.packing.cell": "Atomi della cella",
|
|
1094
|
+
"crystal3d.packing.cellHelp": "Ogni atomo dentro la cella, tagliato dove lo tagliano le sue pareti.",
|
|
1095
|
+
"crystal3d.unitCell": "Cella elementare",
|
|
1096
|
+
"crystal3d.unitCellHelp": "Il contorno della cella elementare.",
|
|
1097
|
+
"crystal3d.caption.molecules.one": "1 molecola per cella",
|
|
1098
|
+
"crystal3d.caption.molecules.other": "{count} molecole per cella",
|
|
1099
|
+
"crystal3d.caption.atoms.one": "1 atomo per cella",
|
|
1100
|
+
"crystal3d.caption.atoms.other": "{count} atomi per cella",
|
|
1101
|
+
"crystal3d.caption.cells.one": "1×1×1 cella",
|
|
1102
|
+
"crystal3d.caption.cells.other": "{count}×{count}×{count} celle",
|
|
1103
|
+
"crystal3d.caption.cellsCapped": "{count}×{count}×{count} celle, perché {asked}×{asked}×{asked} conterrebbero troppi atomi",
|
|
1104
|
+
"crystal3d.unreadable": "Non è stato possibile leggere quel file",
|
|
1105
|
+
"crystal3d.tooLarge": "Questa cella contiene {count} atomi, più di quanti il visualizzatore ne disegni.",
|
|
1106
|
+
"crystal3d.unsupported": "Niente 3D su questo computer"
|
|
1089
1107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeCanvas3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MoleculeCanvas3D.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAkBzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAYxE,yCAAyC;AACzC,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,qBAAqB,EACrB,UAAU,GAAG,mBAAmB,CACjC;IACC,2EAA2E;IAC3E,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAyJ3E"}
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
4
4
|
import { DEFAULT_SPIN_SPEED } from "../../molstar/core/index.js";
|
|
5
|
+
import { MolstarToolbar } from "../../molstar/ui/MolstarToolbar.js";
|
|
6
|
+
import { useMolstarTools } from "../../molstar/ui/useMolstarTools.js";
|
|
5
7
|
import { DEFAULT_FRAMES_PER_SECOND } from "../core/animatedPng.js";
|
|
6
8
|
import { normalizeMolecule3DSettings, resolveMolecule3DTools, } from "../core/settings.js";
|
|
7
|
-
import { Molecule3DExport } from "./Molecule3DExport.js";
|
|
8
9
|
import { Molecule3DOptions } from "./Molecule3DOptions.js";
|
|
9
10
|
import { Molecule3DStage } from "./Molecule3DStage.js";
|
|
10
|
-
import { Molecule3DToolbar } from "./Molecule3DToolbar.js";
|
|
11
11
|
import { highlightColorOf } from "./highlightColor.js";
|
|
12
12
|
import { moleculeFileAtoms } from "./moleculeFileFormats.js";
|
|
13
13
|
import { useAtomHover } from "./useAtomHover.js";
|
|
@@ -28,9 +28,7 @@ export function MoleculeCanvas3D(props) {
|
|
|
28
28
|
const tools = resolveMolecule3DTools(toolsProp);
|
|
29
29
|
const [initialSettings] = useState(() => normalizeMolecule3DSettings(defaultSettings));
|
|
30
30
|
const [settings, setSettings] = useControlledState(settingsProp, initialSettings, onSettingsChange);
|
|
31
|
-
const [spinning, setSpinning] = useControlledState(spinningProp, defaultSpinning, onSpinningChange);
|
|
32
31
|
const { measurements, add: addMeasurement, remove: removeMeasurement, clear: clearMeasurements, } = useMeasurementList(measurementsProp, onMeasurementsChange);
|
|
33
|
-
const [measureKind, setMeasureKind] = useState(null);
|
|
34
32
|
const [frameCount, setFrameCount] = useState(0);
|
|
35
33
|
const polarSurfaceArea = usePolarSurfaceArea(molfile, settings.surfaceColoring === 'polarity');
|
|
36
34
|
// A callback ref: the element arriving is what creates the viewer, and every
|
|
@@ -42,15 +40,16 @@ export function MoleculeCanvas3D(props) {
|
|
|
42
40
|
onFrameCountChange: setFrameCount,
|
|
43
41
|
});
|
|
44
42
|
useMeasurementRemoval(container, viewerRef, tools.measure && molfile !== null ? removeMeasurement : undefined);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const controls = useMolstarTools(viewerRef, container, {
|
|
44
|
+
spinning: spinningProp,
|
|
45
|
+
defaultSpinning,
|
|
46
|
+
onSpinningChange,
|
|
47
|
+
spinSpeed,
|
|
48
|
+
});
|
|
49
|
+
const { spinning } = controls;
|
|
48
50
|
useEffect(() => {
|
|
49
51
|
void viewerRef.current?.frames.play(playing, framesPerSecond);
|
|
50
52
|
}, [container, viewerRef, playing, framesPerSecond]);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
void viewerRef.current?.setMeasureKind(measureKind);
|
|
53
|
-
}, [container, viewerRef, measureKind]);
|
|
54
53
|
// Kept out of the scene: a new highlight repaints the model, never redraws it.
|
|
55
54
|
useEffect(() => {
|
|
56
55
|
void viewerRef.current?.setHighlights(highlights, highlightColorOf(container));
|
|
@@ -67,7 +66,8 @@ export function MoleculeCanvas3D(props) {
|
|
|
67
66
|
onFailureChange,
|
|
68
67
|
camera: props,
|
|
69
68
|
});
|
|
70
|
-
const
|
|
69
|
+
const imageExport = useImageExport(container, viewerRef, fileName, framesPerSecond);
|
|
70
|
+
const { capture } = imageExport;
|
|
71
71
|
useEffect(() => {
|
|
72
72
|
if (onCapture === undefined || container === null)
|
|
73
73
|
return;
|
|
@@ -76,11 +76,11 @@ export function MoleculeCanvas3D(props) {
|
|
|
76
76
|
onCapture(null);
|
|
77
77
|
};
|
|
78
78
|
}, [onCapture, container, capture]);
|
|
79
|
-
return (_jsx(Molecule3DStage, { style: { ...STAGE_STYLE, minHeight }, children: (fullscreen) => (_jsxs(_Fragment, { children: [_jsx("div", { ref: setContainer, style: CANVAS_STYLE, "data-testid": "molecule3d" }), molfile !== null && (_jsx(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
return (_jsx(Molecule3DStage, { style: { ...STAGE_STYLE, minHeight }, children: (fullscreen) => (_jsxs(_Fragment, { children: [_jsx("div", { ref: setContainer, style: CANVAS_STYLE, "data-testid": "molecule3d" }), molfile !== null && (_jsx(MolstarToolbar, { controls: controls, tools: tools, fullscreen: fullscreen, measurementCount: measurements.length, onClearMeasurements: clearMeasurements, showSurface: settings.showSurface, onShowSurfaceChange: (showSurface) => {
|
|
80
|
+
setSettings({ ...settings, showSurface });
|
|
81
|
+
}, onResetView: resetView, options: _jsx(Molecule3DOptions, { settings: settings, onChange: setSettings, polarSurfaceArea: polarSurfaceArea, defaults: initialSettings }), exportLabel: moleculeFileAtoms(molfile, frameCount) > 0
|
|
82
|
+
? t('molecule3d.exportImageOrMolfile')
|
|
83
|
+
: undefined, imageExport: imageExport, frameCount: frameCount, molfile: molfile, fileName: fileName }))] })) }));
|
|
84
84
|
}
|
|
85
85
|
const NO_HIGHLIGHTS = [];
|
|
86
86
|
const STAGE_STYLE = {
|
|
@@ -92,15 +92,4 @@ const STAGE_STYLE = {
|
|
|
92
92
|
};
|
|
93
93
|
/** molstar inserts its canvas here, which therefore has a size of its own. */
|
|
94
94
|
const CANVAS_STYLE = { position: 'absolute', inset: 0 };
|
|
95
|
-
const OVERLAY_STYLE = {
|
|
96
|
-
position: 'absolute',
|
|
97
|
-
top: 8,
|
|
98
|
-
bottom: 8,
|
|
99
|
-
left: 8,
|
|
100
|
-
zIndex: 2,
|
|
101
|
-
display: 'flex',
|
|
102
|
-
alignItems: 'flex-start',
|
|
103
|
-
gap: 8,
|
|
104
|
-
pointerEvents: 'none',
|
|
105
|
-
};
|
|
106
95
|
//# sourceMappingURL=MoleculeCanvas3D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoleculeCanvas3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MoleculeCanvas3D.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/MoleculeCanvas3D.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO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AAQ;CACnB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,YAAY,GAAkB,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest bond molstar draws between two elements.
|
|
3
|
+
*
|
|
4
|
+
* Molecules are completed across the cell walls by this rule, so what the
|
|
5
|
+
* viewer draws as one molecule is exactly what the packing kept together. It
|
|
6
|
+
* is one molstar module with no imports of its own, so a page reading it pays
|
|
7
|
+
* for a table of thresholds, not for the 2.8 MB viewer.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The longest distance at which molstar bonds two atoms.
|
|
11
|
+
* @param a - One element symbol, e.g. `C`.
|
|
12
|
+
* @param b - The other.
|
|
13
|
+
* @returns The distance in ångström, or 0 for a pair it never bonds (H–H).
|
|
14
|
+
*/
|
|
15
|
+
export declare function bondLimit(a: string, b: string): number;
|
|
16
|
+
//# sourceMappingURL=bondRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bondRule.d.ts","sourceRoot":"","sources":["../../../src/molstar/bonds/bondRule.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAUtD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest bond molstar draws between two elements.
|
|
3
|
+
*
|
|
4
|
+
* Molecules are completed across the cell walls by this rule, so what the
|
|
5
|
+
* viewer draws as one molecule is exactly what the packing kept together. It
|
|
6
|
+
* is one molstar module with no imports of its own, so a page reading it pays
|
|
7
|
+
* for a table of thresholds, not for the 2.8 MB viewer.
|
|
8
|
+
*/
|
|
9
|
+
import { getElementIdx, getElementThreshold, getPairingThreshold, isHydrogen, } from 'molstar/lib/mol-model/structure/structure/unit/bonds/common.js';
|
|
10
|
+
/**
|
|
11
|
+
* The longest distance at which molstar bonds two atoms.
|
|
12
|
+
* @param a - One element symbol, e.g. `C`.
|
|
13
|
+
* @param b - The other.
|
|
14
|
+
* @returns The distance in ångström, or 0 for a pair it never bonds (H–H).
|
|
15
|
+
*/
|
|
16
|
+
export function bondLimit(a, b) {
|
|
17
|
+
const first = getElementIdx(a);
|
|
18
|
+
const second = getElementIdx(b);
|
|
19
|
+
if (isHydrogen(first) && isHydrogen(second))
|
|
20
|
+
return 0;
|
|
21
|
+
return getPairingThreshold(first, second, getElementThreshold(first), getElementThreshold(second));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=bondRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bondRule.js","sourceRoot":"","sources":["../../../src/molstar/bonds/bondRule.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,GACX,MAAM,gEAAgE,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,CAAS;IAC5C,MAAM,KAAK,GAAG,aAAa,CAAC,CAAkB,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,aAAa,CAAC,CAAkB,CAAC,CAAC;IACjD,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAC;IACtD,OAAO,mBAAmB,CACxB,KAAK,EACL,MAAM,EACN,mBAAmB,CAAC,KAAK,CAAC,EAC1B,mBAAmB,CAAC,MAAM,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest bond molstar draws between two elements.
|
|
3
|
+
*
|
|
4
|
+
* Its own path because it is one small molstar module: a page that fills a
|
|
5
|
+
* crystal's cell before the viewer has loaded completes its molecules by the
|
|
6
|
+
* rule the viewer will join them by, without downloading the viewer.
|
|
7
|
+
*/
|
|
8
|
+
export { bondLimit } from './bondRule.ts';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molstar/bonds/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest bond molstar draws between two elements.
|
|
3
|
+
*
|
|
4
|
+
* Its own path because it is one small molstar module: a page that fills a
|
|
5
|
+
* crystal's cell before the viewer has loaded completes its molecules by the
|
|
6
|
+
* rule the viewer will join them by, without downloading the viewer.
|
|
7
|
+
*/
|
|
8
|
+
export { bondLimit } from "./bondRule.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molstar/bonds/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolbars every 3D view of the family floats over its canvas: reset,
|
|
3
|
+
* spin, export, full screen and help, then the measuring tools.
|
|
4
|
+
*
|
|
5
|
+
* It is `Molecule3DToolbar` placed in the top-left corner of the stage and fed
|
|
6
|
+
* from `useMolstarTools` and `useImageExport`, so a site drawing its own
|
|
7
|
+
* scene — orbitals, a crystal — gets the controls `<MoleculeViewer3D>` has
|
|
8
|
+
* without wiring them a second time.
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactElement } from 'react';
|
|
11
|
+
import type { Molecule3DFile } from '../../molecule3d/core/file.ts';
|
|
12
|
+
import type { Molecule3DToolbarProps } from '../../molecule3d/ui/Molecule3DToolbar.tsx';
|
|
13
|
+
import type { ImageExport } from '../../molecule3d/ui/useImageExport.ts';
|
|
14
|
+
import type { MolstarTools } from './useMolstarTools.ts';
|
|
15
|
+
/** Props of {@link MolstarToolbar}. */
|
|
16
|
+
export interface MolstarToolbarProps extends Omit<Molecule3DToolbarProps, 'measureKind' | 'onMeasureKindChange' | 'spinning' | 'onSpinningChange' | 'exportPanel'> {
|
|
17
|
+
/** The state `useMolstarTools` keeps. */
|
|
18
|
+
controls: MolstarTools;
|
|
19
|
+
/**
|
|
20
|
+
* The pictures the export tool saves and copies; the tool is left out
|
|
21
|
+
* without them.
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
imageExport?: ImageExport;
|
|
25
|
+
/**
|
|
26
|
+
* Base name of what the export tool saves, extension excluded.
|
|
27
|
+
* @default 'molecule'
|
|
28
|
+
*/
|
|
29
|
+
fileName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The file on screen, offered beside the pictures; say so in `exportLabel`.
|
|
32
|
+
* @default undefined — only pictures are offered
|
|
33
|
+
*/
|
|
34
|
+
molfile?: Molecule3DFile | null;
|
|
35
|
+
/**
|
|
36
|
+
* How many frames the scene holds. Above one, a PNG may hold them all.
|
|
37
|
+
* @default 1
|
|
38
|
+
*/
|
|
39
|
+
frameCount?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The toolbars, in the top-left corner of a positioned stage.
|
|
43
|
+
* @param props - See {@link MolstarToolbarProps}.
|
|
44
|
+
* @returns The toolbars.
|
|
45
|
+
*/
|
|
46
|
+
export declare function MolstarToolbar(props: MolstarToolbarProps): ReactElement;
|
|
47
|
+
//# sourceMappingURL=MolstarToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MolstarToolbar.d.ts","sourceRoot":"","sources":["../../../src/molstar/ui/MolstarToolbar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAExF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,uCAAuC;AACvC,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,sBAAsB,EACpB,aAAa,GACb,qBAAqB,GACrB,UAAU,GACV,kBAAkB,GAClB,aAAa,CAChB;IACC,yCAAyC;IACzC,QAAQ,EAAE,YAAY,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CA2BvE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Molecule3DExport } from "../../molecule3d/ui/Molecule3DExport.js";
|
|
3
|
+
import { Molecule3DToolbar } from "../../molecule3d/ui/Molecule3DToolbar.js";
|
|
4
|
+
/**
|
|
5
|
+
* The toolbars, in the top-left corner of a positioned stage.
|
|
6
|
+
* @param props - See {@link MolstarToolbarProps}.
|
|
7
|
+
* @returns The toolbars.
|
|
8
|
+
*/
|
|
9
|
+
export function MolstarToolbar(props) {
|
|
10
|
+
const { controls, imageExport, fileName, molfile, frameCount, ...toolbar } = props;
|
|
11
|
+
return (_jsx("div", { style: OVERLAY_STYLE, children: _jsx(Molecule3DToolbar, { ...toolbar, measureKind: controls.measureKind, onMeasureKindChange: controls.setMeasureKind, spinning: controls.spinning, onSpinningChange: controls.setSpinning, exportPanel: imageExport === undefined ? undefined : (_jsx(Molecule3DExport, { getSize: imageExport.canvasSize, onExport: imageExport.exportImage, onCopy: imageExport.copyImage, writeFile: imageExport.imageFile, frameCount: frameCount, molfile: molfile, fileName: fileName })) }) }));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `pointerEvents` is off here and back on inside the toolbars, so the empty
|
|
15
|
+
* column beside them does not swallow a drag of the scene.
|
|
16
|
+
*/
|
|
17
|
+
const OVERLAY_STYLE = {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
top: 8,
|
|
20
|
+
bottom: 8,
|
|
21
|
+
left: 8,
|
|
22
|
+
zIndex: 2,
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'flex-start',
|
|
25
|
+
gap: 8,
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=MolstarToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MolstarToolbar.js","sourceRoot":"","sources":["../../../src/molstar/ui/MolstarToolbar.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAA0C,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA2C,CAAC;AAuC9E;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,GACxE,KAAK,CAAC;IACR,OAAO,CACL,cAAK,KAAK,EAAE,aAAa,YACvB,KAAC,iBAAiB,OACZ,OAAO,EACX,WAAW,EAAE,QAAQ,CAAC,WAAW,EACjC,mBAAmB,EAAE,QAAQ,CAAC,cAAc,EAC5C,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EACtC,WAAW,EACT,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CACtC,KAAC,gBAAgB,IACf,OAAO,EAAE,WAAW,CAAC,UAAU,EAC/B,QAAQ,EAAE,WAAW,CAAC,WAAW,EACjC,MAAM,EAAE,WAAW,CAAC,SAAS,EAC7B,SAAS,EAAE,WAAW,CAAC,SAAS,EAChC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,GAClB,CACH,GAEH,GACE,CACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,aAAa,GAAkB;IACnC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,CAAC;IACN,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The controls of a molstar canvas, for a site drawing a scene of its own:
|
|
3
|
+
* the toolbars `<MoleculeViewer3D>` floats over its canvas, and the state they
|
|
4
|
+
* keep on the viewer.
|
|
5
|
+
*/
|
|
6
|
+
export type { MolstarToolbarProps } from './MolstarToolbar.tsx';
|
|
7
|
+
export { MolstarToolbar } from './MolstarToolbar.tsx';
|
|
8
|
+
export type { MolstarTools, MolstarToolsOptions, MolstarToolsViewer, } from './useMolstarTools.ts';
|
|
9
|
+
export { useMolstarTools } from './useMolstarTools.ts';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molstar/ui/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The controls of a molstar canvas, for a site drawing a scene of its own:
|
|
3
|
+
* the toolbars `<MoleculeViewer3D>` floats over its canvas, and the state they
|
|
4
|
+
* keep on the viewer.
|
|
5
|
+
*/
|
|
6
|
+
export { MolstarToolbar } from "./MolstarToolbar.js";
|
|
7
|
+
export { useMolstarTools } from "./useMolstarTools.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molstar/ui/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the toolbar over a molstar canvas changes on the viewer: whether the
|
|
3
|
+
* scene turns, and what a click on an atom measures.
|
|
4
|
+
*
|
|
5
|
+
* Every 3D view of the family keeps its own viewer class — a molecule, its
|
|
6
|
+
* orbitals, a crystal — but all of them turn and measure the same way, so the
|
|
7
|
+
* state and the two effects that hand it to the viewer are written once here.
|
|
8
|
+
*/
|
|
9
|
+
import type { RefObject } from 'react';
|
|
10
|
+
import type { MeasurementKind } from '../../molecule3d/core/measurement.ts';
|
|
11
|
+
/** What a viewer offers the toolbar; each method resolves once it is done. */
|
|
12
|
+
export interface MolstarToolsViewer {
|
|
13
|
+
/** Turn the automatic spin on or off, at `speed`. */
|
|
14
|
+
setSpin: (spinning: boolean, speed?: number) => Promise<void>;
|
|
15
|
+
/** Make clicks on atoms build this measurement, or give them back. */
|
|
16
|
+
setMeasureKind: (kind: MeasurementKind | null) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** Options of {@link useMolstarTools}. */
|
|
19
|
+
export interface MolstarToolsOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the scene turns, when the parent owns it.
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
spinning?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the scene turns at first, when the toolbar owns it.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
defaultSpinning?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Called with every change of the spin.
|
|
32
|
+
* @default undefined
|
|
33
|
+
*/
|
|
34
|
+
onSpinningChange?: (spinning: boolean) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Turn rate, in molstar's own spin unit.
|
|
37
|
+
* @default DEFAULT_SPIN_SPEED
|
|
38
|
+
*/
|
|
39
|
+
spinSpeed?: number;
|
|
40
|
+
}
|
|
41
|
+
/** The toolbar's state, and its setters. */
|
|
42
|
+
export interface MolstarTools {
|
|
43
|
+
/** The measurement a click on an atom builds, or `null`. */
|
|
44
|
+
measureKind: MeasurementKind | null;
|
|
45
|
+
setMeasureKind: (kind: MeasurementKind | null) => void;
|
|
46
|
+
/** Whether the scene turns. */
|
|
47
|
+
spinning: boolean;
|
|
48
|
+
setSpinning: (spinning: boolean) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Keep the viewer turning and measuring as the toolbar says.
|
|
52
|
+
*
|
|
53
|
+
* Call it after the viewer is created, in the same component: effects run in
|
|
54
|
+
* the order they are declared, so a viewer created by an earlier effect is
|
|
55
|
+
* there when these run.
|
|
56
|
+
* @param viewerRef - The viewer, `null` while there is none.
|
|
57
|
+
* @param container - The element the viewer draws in; a new one is a new
|
|
58
|
+
* viewer, which is handed the state again.
|
|
59
|
+
* @param options - See {@link MolstarToolsOptions}.
|
|
60
|
+
* @returns See {@link MolstarTools}.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useMolstarTools(viewerRef: RefObject<MolstarToolsViewer | null>, container: HTMLElement | null, options?: MolstarToolsOptions): MolstarTools;
|
|
63
|
+
//# sourceMappingURL=useMolstarTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMolstarTools.d.ts","sourceRoot":"","sources":["../../../src/molstar/ui/useMolstarTools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAI5E,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,sEAAsE;IACtE,cAAc,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,+BAA+B;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,SAAS,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAC/C,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAuBd"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the toolbar over a molstar canvas changes on the viewer: whether the
|
|
3
|
+
* scene turns, and what a click on an atom measures.
|
|
4
|
+
*
|
|
5
|
+
* Every 3D view of the family keeps its own viewer class — a molecule, its
|
|
6
|
+
* orbitals, a crystal — but all of them turn and measure the same way, so the
|
|
7
|
+
* state and the two effects that hand it to the viewer are written once here.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
import { useControlledState } from "../../molecule3d/ui/useControlledState.js";
|
|
11
|
+
import { DEFAULT_SPIN_SPEED } from "../core/camera.js";
|
|
12
|
+
/**
|
|
13
|
+
* Keep the viewer turning and measuring as the toolbar says.
|
|
14
|
+
*
|
|
15
|
+
* Call it after the viewer is created, in the same component: effects run in
|
|
16
|
+
* the order they are declared, so a viewer created by an earlier effect is
|
|
17
|
+
* there when these run.
|
|
18
|
+
* @param viewerRef - The viewer, `null` while there is none.
|
|
19
|
+
* @param container - The element the viewer draws in; a new one is a new
|
|
20
|
+
* viewer, which is handed the state again.
|
|
21
|
+
* @param options - See {@link MolstarToolsOptions}.
|
|
22
|
+
* @returns See {@link MolstarTools}.
|
|
23
|
+
*/
|
|
24
|
+
export function useMolstarTools(viewerRef, container, options = {}) {
|
|
25
|
+
const { spinning: spinningProp, defaultSpinning = false, onSpinningChange, spinSpeed = DEFAULT_SPIN_SPEED, } = options;
|
|
26
|
+
const [measureKind, setMeasureKind] = useState(null);
|
|
27
|
+
const [spinning, setSpinning] = useControlledState(spinningProp, defaultSpinning, onSpinningChange);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
void viewerRef.current?.setSpin(spinning, spinSpeed);
|
|
30
|
+
}, [viewerRef, container, spinning, spinSpeed]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
void viewerRef.current?.setMeasureKind(measureKind);
|
|
33
|
+
}, [viewerRef, container, measureKind]);
|
|
34
|
+
return { measureKind, setMeasureKind, spinning, setSpinning };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useMolstarTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMolstarTools.js","sourceRoot":"","sources":["../../../src/molstar/ui/useMolstarTools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AA4CvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA+C,EAC/C,SAA6B,EAC7B,UAA+B,EAAE;IAEjC,MAAM,EACJ,QAAQ,EAAE,YAAY,EACtB,eAAe,GAAG,KAAK,EACvB,gBAAgB,EAChB,SAAS,GAAG,kBAAkB,GAC/B,GAAG,OAAO,CAAC;IACZ,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAyB,IAAI,CAAC,CAAC;IAC7E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,kBAAkB,CAChD,YAAY,EACZ,eAAe,EACf,gBAAgB,CACjB,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.136.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
|
|
6
6
|
"author": "Luc Patiny",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"./conformers": "./lib/conformers.js",
|
|
22
22
|
"./core": "./lib/core.js",
|
|
23
23
|
"./crystal": "./lib/crystal.js",
|
|
24
|
+
"./crystal3d": "./lib/crystal3d.js",
|
|
24
25
|
"./demo": "./lib/demo.js",
|
|
25
26
|
"./drawing": "./lib/drawing.js",
|
|
26
27
|
"./formula": "./lib/formula.js",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { CrystalSite, CrystalStructure } from './cif/types.ts';
|
|
2
|
+
import { chooseDisorder, isDummy } from './disorder.ts';
|
|
3
|
+
import type { ExpandedAtom } from './expand.ts';
|
|
4
|
+
import { expandSite } from './expand.ts';
|
|
5
|
+
import { structureOperations } from './operations.ts';
|
|
6
|
+
import type { Lattice } from './symmetry/lattice.ts';
|
|
7
|
+
import { createLattice } from './symmetry/lattice.ts';
|
|
8
|
+
import type { CrystalOperation } from './symmetry/types.ts';
|
|
9
|
+
|
|
10
|
+
/** Options of {@link crystalCellAtoms}. */
|
|
11
|
+
export interface CellAtomsOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The most atoms one cell is expanded into; past it, none is returned.
|
|
14
|
+
* @default 100000
|
|
15
|
+
*/
|
|
16
|
+
maxAtoms?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What one cell of a crystal holds. */
|
|
20
|
+
export interface CellAtoms {
|
|
21
|
+
/** The cell. */
|
|
22
|
+
readonly lattice: Lattice;
|
|
23
|
+
/** The space group's operations, as the file states or implies them. */
|
|
24
|
+
readonly operations: ReadonlyArray<CrystalOperation<3>>;
|
|
25
|
+
/**
|
|
26
|
+
* Every atom of the cell, fractional and wrapped into [0, 1): each site that
|
|
27
|
+
* is not a dummy, expanded, with the major part of each disorder kept. Empty
|
|
28
|
+
* when the cell holds more than `maxAtoms`.
|
|
29
|
+
*/
|
|
30
|
+
readonly atoms: readonly ExpandedAtom[];
|
|
31
|
+
/** How many atoms the expansion made, disorder included, counted past the cap. */
|
|
32
|
+
readonly count: number;
|
|
33
|
+
/** Whether the cell holds more than `maxAtoms`. */
|
|
34
|
+
readonly tooLarge: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The atoms one cell of a crystal holds, which is what a page draws or bonds.
|
|
39
|
+
*
|
|
40
|
+
* Every site that is not a dummy is expanded by the space group, and the
|
|
41
|
+
* disorder is resolved as `chooseDisorder` does: the atoms in no disorder group,
|
|
42
|
+
* and the major part of each.
|
|
43
|
+
* @param structure - What `readCif` returned.
|
|
44
|
+
* @param options - See {@link CellAtomsOptions}.
|
|
45
|
+
* @returns The cell's atoms, its lattice and its operations.
|
|
46
|
+
* @throws {Error} When the file names no space group and lists no operation, or
|
|
47
|
+
* its cell has angles no cell can have.
|
|
48
|
+
*/
|
|
49
|
+
export function crystalCellAtoms(
|
|
50
|
+
structure: CrystalStructure,
|
|
51
|
+
options: CellAtomsOptions = {},
|
|
52
|
+
): CellAtoms {
|
|
53
|
+
const { maxAtoms = 100_000 } = options;
|
|
54
|
+
const operations = structureOperations(structure);
|
|
55
|
+
const lattice = createLattice(structure.cell);
|
|
56
|
+
const { sites } = structure;
|
|
57
|
+
const expanded = expandSites(sites, operations, maxAtoms);
|
|
58
|
+
if (expanded.count > maxAtoms) {
|
|
59
|
+
return {
|
|
60
|
+
lattice,
|
|
61
|
+
operations,
|
|
62
|
+
atoms: [],
|
|
63
|
+
count: expanded.count,
|
|
64
|
+
tooLarge: true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const kept = chooseDisorder(sites, expanded.atoms, lattice);
|
|
68
|
+
const atoms: ExpandedAtom[] = [];
|
|
69
|
+
for (const atom of expanded.atoms) {
|
|
70
|
+
if (kept[atom.siteIndex] === 1) atoms.push(atom);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
lattice,
|
|
74
|
+
operations,
|
|
75
|
+
atoms,
|
|
76
|
+
count: expanded.count,
|
|
77
|
+
tooLarge: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Every atom of the cell the sites that are not dummies make, counted past the cap.
|
|
83
|
+
* @param sites - The asymmetric unit.
|
|
84
|
+
* @param operations - The full coset list.
|
|
85
|
+
* @param maxAtoms - The most atoms kept.
|
|
86
|
+
* @returns The atoms, and how many the cell holds.
|
|
87
|
+
*/
|
|
88
|
+
function expandSites(
|
|
89
|
+
sites: readonly CrystalSite[],
|
|
90
|
+
operations: ReadonlyArray<CrystalOperation<3>>,
|
|
91
|
+
maxAtoms: number,
|
|
92
|
+
): { atoms: ExpandedAtom[]; count: number } {
|
|
93
|
+
const atoms: ExpandedAtom[] = [];
|
|
94
|
+
let count = 0;
|
|
95
|
+
for (let index = 0; index < sites.length; index++) {
|
|
96
|
+
const site = sites[index] as CrystalSite;
|
|
97
|
+
if (isDummy(site)) continue;
|
|
98
|
+
const images = expandSite(site, index, operations);
|
|
99
|
+
count += images.length;
|
|
100
|
+
if (count > maxAtoms) continue;
|
|
101
|
+
for (let image = 0; image < images.length; image++) {
|
|
102
|
+
atoms.push(images[image] as ExpandedAtom);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { atoms, count };
|
|
106
|
+
}
|