react-cheminfo 0.135.0 → 0.137.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.
Files changed (311) hide show
  1. package/README.md +1 -1
  2. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  3. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  4. package/lib/crystal/core/cellAtoms.js +70 -0
  5. package/lib/crystal/core/cellAtoms.js.map +1 -0
  6. package/lib/crystal/core/index.d.ts +2 -0
  7. package/lib/crystal/core/index.d.ts.map +1 -1
  8. package/lib/crystal/core/index.js +1 -0
  9. package/lib/crystal/core/index.js.map +1 -1
  10. package/lib/crystal/core/molecules.d.ts.map +1 -1
  11. package/lib/crystal/core/molecules.js +6 -40
  12. package/lib/crystal/core/molecules.js.map +1 -1
  13. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  14. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  15. package/lib/crystal3d/core/cellClip.js +198 -0
  16. package/lib/crystal3d/core/cellClip.js.map +1 -0
  17. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  18. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  19. package/lib/crystal3d/core/cellGeometry.js +153 -0
  20. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  21. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  22. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  23. package/lib/crystal3d/core/cellStack.js +79 -0
  24. package/lib/crystal3d/core/cellStack.js.map +1 -0
  25. package/lib/crystal3d/core/crystalView.d.ts +81 -0
  26. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  27. package/lib/crystal3d/core/crystalView.js +55 -0
  28. package/lib/crystal3d/core/crystalView.js.map +1 -0
  29. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  30. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  31. package/lib/crystal3d/core/drawingSet.js +63 -0
  32. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  33. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  34. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  35. package/lib/crystal3d/core/elementDrawing.js +100 -0
  36. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  37. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  38. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  39. package/lib/crystal3d/core/elementExtent.js +56 -0
  40. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  41. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  42. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  43. package/lib/crystal3d/core/elementLabels.js +99 -0
  44. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  45. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  46. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  47. package/lib/crystal3d/core/elementShapes.js +115 -0
  48. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  49. package/lib/crystal3d/core/frame.d.ts +36 -0
  50. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  51. package/lib/crystal3d/core/frame.js +35 -0
  52. package/lib/crystal3d/core/frame.js.map +1 -0
  53. package/lib/crystal3d/core/framing.d.ts +41 -0
  54. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  55. package/lib/crystal3d/core/framing.js +79 -0
  56. package/lib/crystal3d/core/framing.js.map +1 -0
  57. package/lib/crystal3d/core/index.d.ts +42 -0
  58. package/lib/crystal3d/core/index.d.ts.map +1 -0
  59. package/lib/crystal3d/core/index.js +29 -0
  60. package/lib/crystal3d/core/index.js.map +1 -0
  61. package/lib/crystal3d/core/labelText.d.ts +19 -0
  62. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  63. package/lib/crystal3d/core/labelText.js +42 -0
  64. package/lib/crystal3d/core/labelText.js.map +1 -0
  65. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  66. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  67. package/lib/crystal3d/core/latticeBasis.js +89 -0
  68. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  69. package/lib/crystal3d/core/mat3.d.ts +68 -0
  70. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  71. package/lib/crystal3d/core/mat3.js +146 -0
  72. package/lib/crystal3d/core/mat3.js.map +1 -0
  73. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  74. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  75. package/lib/crystal3d/core/operationMatrix.js +172 -0
  76. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  77. package/lib/crystal3d/core/orientation.d.ts +62 -0
  78. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  79. package/lib/crystal3d/core/orientation.js +166 -0
  80. package/lib/crystal3d/core/orientation.js.map +1 -0
  81. package/lib/crystal3d/core/palette.d.ts +24 -0
  82. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  83. package/lib/crystal3d/core/palette.js +34 -0
  84. package/lib/crystal3d/core/palette.js.map +1 -0
  85. package/lib/crystal3d/core/primitives.d.ts +133 -0
  86. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  87. package/lib/crystal3d/core/primitives.js +80 -0
  88. package/lib/crystal3d/core/primitives.js.map +1 -0
  89. package/lib/crystal3d/core/structureText.d.ts +20 -0
  90. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  91. package/lib/crystal3d/core/structureText.js +37 -0
  92. package/lib/crystal3d/core/structureText.js.map +1 -0
  93. package/lib/crystal3d/core/supercell.d.ts +20 -0
  94. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  95. package/lib/crystal3d/core/supercell.js +35 -0
  96. package/lib/crystal3d/core/supercell.js.map +1 -0
  97. package/lib/crystal3d/core/types.d.ts +166 -0
  98. package/lib/crystal3d/core/types.d.ts.map +1 -0
  99. package/lib/crystal3d/core/types.js +10 -0
  100. package/lib/crystal3d/core/types.js.map +1 -0
  101. package/lib/crystal3d/core/vec3.d.ts +75 -0
  102. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  103. package/lib/crystal3d/core/vec3.js +119 -0
  104. package/lib/crystal3d/core/vec3.js.map +1 -0
  105. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  106. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  107. package/lib/crystal3d/ui/CrystalCanvas3D.js +250 -0
  108. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  109. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  110. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  111. package/lib/crystal3d/ui/CrystalStructureView.js +79 -0
  112. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  113. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  114. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  115. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  116. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  117. package/lib/crystal3d/ui/CrystalViewControls.d.ts +29 -0
  118. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  119. package/lib/crystal3d/ui/CrystalViewControls.js +24 -0
  120. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  121. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  122. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  123. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  124. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  125. package/lib/crystal3d/ui/crystalScene.d.ts +97 -0
  126. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  127. package/lib/crystal3d/ui/crystalScene.js +10 -0
  128. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  129. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  130. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  131. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  132. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  133. package/lib/crystal3d/ui/index.d.ts +16 -0
  134. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  135. package/lib/crystal3d/ui/index.js +12 -0
  136. package/lib/crystal3d/ui/index.js.map +1 -0
  137. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  138. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  139. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  140. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  141. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  142. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  143. package/lib/crystal3d/viewer/animate.js +83 -0
  144. package/lib/crystal3d/viewer/animate.js.map +1 -0
  145. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  146. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  147. package/lib/crystal3d/viewer/camera.js +103 -0
  148. package/lib/crystal3d/viewer/camera.js.map +1 -0
  149. package/lib/crystal3d/viewer/index.d.ts +13 -0
  150. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  151. package/lib/crystal3d/viewer/index.js +8 -0
  152. package/lib/crystal3d/viewer/index.js.map +1 -0
  153. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  154. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  155. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  156. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  157. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  158. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  159. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  160. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  161. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  162. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  163. package/lib/crystal3d/viewer/plugin.js +181 -0
  164. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  165. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  166. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  167. package/lib/crystal3d/viewer/renderCell.js +53 -0
  168. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  169. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  170. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  171. package/lib/crystal3d/viewer/renderElements.js +77 -0
  172. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  173. package/lib/crystal3d/viewer/renderStructure.d.ts +80 -0
  174. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  175. package/lib/crystal3d/viewer/renderStructure.js +143 -0
  176. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  177. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  178. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  179. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  180. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  181. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  182. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  183. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  184. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  185. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  186. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  187. package/lib/crystal3d/viewer/textLayer.js +59 -0
  188. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  189. package/lib/crystal3d/viewer/viewer.d.ts +119 -0
  190. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  191. package/lib/crystal3d/viewer/viewer.js +172 -0
  192. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  193. package/lib/crystal3d.d.ts +12 -0
  194. package/lib/crystal3d.d.ts.map +1 -0
  195. package/lib/crystal3d.js +12 -0
  196. package/lib/crystal3d.js.map +1 -0
  197. package/lib/download/core/croppedMarkup.d.ts.map +1 -1
  198. package/lib/download/core/croppedMarkup.js +16 -40
  199. package/lib/download/core/croppedMarkup.js.map +1 -1
  200. package/lib/download/core/dataUrl.d.ts +27 -0
  201. package/lib/download/core/dataUrl.d.ts.map +1 -0
  202. package/lib/download/core/dataUrl.js +54 -0
  203. package/lib/download/core/dataUrl.js.map +1 -0
  204. package/lib/download/core/index.d.ts +3 -0
  205. package/lib/download/core/index.d.ts.map +1 -1
  206. package/lib/download/core/index.js +2 -0
  207. package/lib/download/core/index.js.map +1 -1
  208. package/lib/download/core/svgMarkup.d.ts +39 -0
  209. package/lib/download/core/svgMarkup.d.ts.map +1 -0
  210. package/lib/download/core/svgMarkup.js +100 -0
  211. package/lib/download/core/svgMarkup.js.map +1 -0
  212. package/lib/drawing/ui/movingFigure.d.ts.map +1 -1
  213. package/lib/drawing/ui/movingFigure.js +4 -30
  214. package/lib/drawing/ui/movingFigure.js.map +1 -1
  215. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  216. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  217. package/lib/locales/de.json +26 -1
  218. package/lib/locales/en.json +26 -1
  219. package/lib/locales/es.json +26 -1
  220. package/lib/locales/fr.json +26 -1
  221. package/lib/locales/it.json +26 -1
  222. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  223. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  224. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  225. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  226. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  227. package/lib/molstar/bonds/bondRule.js +23 -0
  228. package/lib/molstar/bonds/bondRule.js.map +1 -0
  229. package/lib/molstar/bonds/index.d.ts +9 -0
  230. package/lib/molstar/bonds/index.d.ts.map +1 -0
  231. package/lib/molstar/bonds/index.js +9 -0
  232. package/lib/molstar/bonds/index.js.map +1 -0
  233. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  234. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  235. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  236. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  237. package/lib/molstar/ui/index.d.ts +10 -0
  238. package/lib/molstar/ui/index.d.ts.map +1 -0
  239. package/lib/molstar/ui/index.js +8 -0
  240. package/lib/molstar/ui/index.js.map +1 -0
  241. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  242. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  243. package/lib/molstar/ui/useMolstarTools.js +36 -0
  244. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  245. package/package.json +2 -1
  246. package/src/crystal/core/cellAtoms.ts +106 -0
  247. package/src/crystal/core/index.ts +2 -0
  248. package/src/crystal/core/molecules.ts +7 -44
  249. package/src/crystal3d/core/cellClip.ts +229 -0
  250. package/src/crystal3d/core/cellGeometry.ts +193 -0
  251. package/src/crystal3d/core/cellStack.ts +87 -0
  252. package/src/crystal3d/core/crystalView.ts +131 -0
  253. package/src/crystal3d/core/drawingSet.ts +71 -0
  254. package/src/crystal3d/core/elementDrawing.ts +147 -0
  255. package/src/crystal3d/core/elementExtent.ts +81 -0
  256. package/src/crystal3d/core/elementLabels.ts +130 -0
  257. package/src/crystal3d/core/elementShapes.ts +141 -0
  258. package/src/crystal3d/core/frame.ts +56 -0
  259. package/src/crystal3d/core/framing.ts +101 -0
  260. package/src/crystal3d/core/index.ts +134 -0
  261. package/src/crystal3d/core/labelText.ts +44 -0
  262. package/src/crystal3d/core/latticeBasis.ts +110 -0
  263. package/src/crystal3d/core/mat3.ts +163 -0
  264. package/src/crystal3d/core/operationMatrix.ts +255 -0
  265. package/src/crystal3d/core/orientation.ts +229 -0
  266. package/src/crystal3d/core/palette.ts +43 -0
  267. package/src/crystal3d/core/primitives.ts +183 -0
  268. package/src/crystal3d/core/structureText.ts +43 -0
  269. package/src/crystal3d/core/supercell.ts +40 -0
  270. package/src/crystal3d/core/types.ts +186 -0
  271. package/src/crystal3d/core/vec3.ts +127 -0
  272. package/src/crystal3d/ui/CrystalCanvas3D.tsx +393 -0
  273. package/src/crystal3d/ui/CrystalStructureView.tsx +153 -0
  274. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  275. package/src/crystal3d/ui/CrystalViewControls.tsx +129 -0
  276. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  277. package/src/crystal3d/ui/crystalScene.ts +106 -0
  278. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  279. package/src/crystal3d/ui/index.ts +20 -0
  280. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  281. package/src/crystal3d/viewer/animate.ts +113 -0
  282. package/src/crystal3d/viewer/camera.ts +139 -0
  283. package/src/crystal3d/viewer/index.ts +13 -0
  284. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  285. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  286. package/src/crystal3d/viewer/plugin.ts +258 -0
  287. package/src/crystal3d/viewer/renderCell.ts +98 -0
  288. package/src/crystal3d/viewer/renderElements.ts +121 -0
  289. package/src/crystal3d/viewer/renderStructure.ts +209 -0
  290. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  291. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  292. package/src/crystal3d/viewer/textLayer.ts +85 -0
  293. package/src/crystal3d/viewer/viewer.ts +223 -0
  294. package/src/crystal3d.ts +12 -0
  295. package/src/download/core/croppedMarkup.ts +16 -42
  296. package/src/download/core/dataUrl.ts +59 -0
  297. package/src/download/core/index.ts +3 -0
  298. package/src/download/core/svgMarkup.ts +113 -0
  299. package/src/drawing/ui/movingFigure.ts +4 -28
  300. package/src/locales/de.json +26 -1
  301. package/src/locales/en.json +26 -1
  302. package/src/locales/es.json +26 -1
  303. package/src/locales/fr.json +26 -1
  304. package/src/locales/it.json +26 -1
  305. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  306. package/src/molstar/bonds/bondRule.ts +34 -0
  307. package/src/molstar/bonds/index.ts +9 -0
  308. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  309. package/src/molstar/ui/index.ts +14 -0
  310. package/src/molstar/ui/useMolstarTools.ts +98 -0
  311. package/styles/chrome.css +90 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The unit cell, and the stack of cells around it.
3
+ *
4
+ * molstar's own unit-cell shape reads the space group off the model, and this
5
+ * site gives it none — it has applied its own operations already — so the box is
6
+ * drawn here, which also lets an n×n×n stack be drawn at all.
7
+ */
8
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
9
+ import type { CellRepeat, UnitCell } from '../core/types.ts';
10
+ /** How the box is drawn. */
11
+ export interface CellStyle {
12
+ /**
13
+ * Radius of an edge, ångström.
14
+ * @default 0.035
15
+ */
16
+ radius?: number;
17
+ /**
18
+ * Whether the a, b and c letters are drawn on the cell at the origin.
19
+ * @default true
20
+ */
21
+ labels?: boolean;
22
+ /**
23
+ * Height of those letters, ångström.
24
+ * @default 0.7
25
+ */
26
+ labelSize?: number;
27
+ }
28
+ /**
29
+ * Replace the drawn cell.
30
+ * @param plugin - The molstar context.
31
+ * @param cell - The six cell parameters, or `null` to draw none.
32
+ * @param repeat - Cells along a, b and c.
33
+ * @param style - See {@link CellStyle}.
34
+ * @throws {Error} When the canvas is not ready.
35
+ * @throws {RangeError} When the angles describe no cell.
36
+ */
37
+ export declare function renderUnitCell(plugin: PluginContext, cell: UnitCell | null, repeat?: CellRepeat, style?: CellStyle): Promise<void>;
38
+ /**
39
+ * Remove the cell and its letters.
40
+ * @param plugin - The molstar context.
41
+ */
42
+ export declare function clearUnitCell(plugin: PluginContext): void;
43
+ //# sourceMappingURL=renderCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderCell.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderCell.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKvE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAM7D,4BAA4B;AAC5B,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,MAAM,GAAE,UAAsB,EAC9B,KAAK,GAAE,SAAc,GACpB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAGzD"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The unit cell, and the stack of cells around it.
3
+ *
4
+ * molstar's own unit-cell shape reads the space group off the model, and this
5
+ * site gives it none — it has applied its own operations already — so the box is
6
+ * drawn here, which also lets an n×n×n stack be drawn at all.
7
+ */
8
+ import { cellAxisLabelPoints, cellEdges } from "../core/cellGeometry.js";
9
+ import { CELL_COLOUR, LABEL_COLOUR } from "../core/palette.js";
10
+ import { clearShapeLayer } from "./layerRegistry.js";
11
+ import { renderShapeLayer } from "./shapeLayer.js";
12
+ import { renderTextLayer } from "./textLayer.js";
13
+ /**
14
+ * Replace the drawn cell.
15
+ * @param plugin - The molstar context.
16
+ * @param cell - The six cell parameters, or `null` to draw none.
17
+ * @param repeat - Cells along a, b and c.
18
+ * @param style - See {@link CellStyle}.
19
+ * @throws {Error} When the canvas is not ready.
20
+ * @throws {RangeError} When the angles describe no cell.
21
+ */
22
+ export async function renderUnitCell(plugin, cell, repeat = [1, 1, 1], style = {}) {
23
+ if (cell === null) {
24
+ clearUnitCell(plugin);
25
+ return;
26
+ }
27
+ const radius = style.radius ?? 0.035;
28
+ const primitives = [];
29
+ for (const edge of cellEdges(cell, repeat)) {
30
+ primitives.push({ shape: 'rod', start: edge.start, end: edge.end, radius });
31
+ }
32
+ await renderShapeLayer(plugin, CELL_LAYER, 'Unit cell', [{ label: 'Unit cell', colour: CELL_COLOUR, primitives }], { alpha: 1 });
33
+ await renderTextLayer(plugin, CELL_LABEL_LAYER, 'Cell axes', style.labels === false ? [] : axisLabels(cell, style.labelSize ?? 0.7), LABEL_COLOUR);
34
+ }
35
+ /**
36
+ * Remove the cell and its letters.
37
+ * @param plugin - The molstar context.
38
+ */
39
+ export function clearUnitCell(plugin) {
40
+ clearShapeLayer(plugin, CELL_LAYER);
41
+ clearShapeLayer(plugin, CELL_LABEL_LAYER);
42
+ }
43
+ function axisLabels(cell, size) {
44
+ const points = cellAxisLabelPoints(cell);
45
+ return [
46
+ { text: 'a', position: points[0], size },
47
+ { text: 'b', position: points[1], size },
48
+ { text: 'c', position: points[2], size },
49
+ ];
50
+ }
51
+ const CELL_LAYER = 'crystal3d-unit-cell';
52
+ const CELL_LABEL_LAYER = 'crystal3d-unit-cell-labels';
53
+ //# sourceMappingURL=renderCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderCell.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderCell.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAA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ED,SAAS,UAAU,CAAC,IAAc,EAAE,IAAY;IAC9C,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO;QACL,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE;QACxC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE;QACxC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE;KACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The symmetry elements over the structure — the reason a symmetry page has a viewer
3
+ * of its own at all.
4
+ *
5
+ * The shapes come from `elementDrawing.ts`, which knows no molstar. This module
6
+ * hands them to **three** layers, which is what keeps a cell holding ten of
7
+ * them readable: the planes are drawn nearly transparent, the rods, rims and
8
+ * balls that outline them stay solid, and the names sit in a third layer so
9
+ * they can be switched off without rebuilding anything.
10
+ *
11
+ * Drawing the whole of an element at one opacity is what makes a stack of
12
+ * mirror planes a wash of colour with the structure lost somewhere inside it.
13
+ */
14
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
15
+ import type { ElementGroup } from '../core/elementDrawing.ts';
16
+ import type { ElementStyle } from '../core/primitives.ts';
17
+ import type { SymmetryDrawing } from '../core/types.ts';
18
+ /** How the elements are drawn. */
19
+ export interface ElementLayerStyle {
20
+ /** Sizes; the defaults of `primitives.ts` are used for anything left out. */
21
+ style?: ElementStyle;
22
+ /**
23
+ * Whether each element's name floats beside it.
24
+ * @default true
25
+ */
26
+ labels?: boolean;
27
+ /**
28
+ * Opacity of a plane's face. Low on purpose: the structure has to be read
29
+ * through however many planes cut the cell.
30
+ * @default 0.1
31
+ */
32
+ faceAlpha?: number;
33
+ /**
34
+ * Opacity of the rods, rims, arrows and balls.
35
+ * @default 0.9
36
+ */
37
+ lineAlpha?: number;
38
+ }
39
+ /**
40
+ * Replace the drawn symmetry elements.
41
+ * @param plugin - The molstar context.
42
+ * @param drawings - The elements; an empty list clears them.
43
+ * @param style - See {@link ElementLayerStyle}.
44
+ * @returns The groups that were drawn, so a caller can measure them without
45
+ * building them a second time.
46
+ * @throws {Error} When the canvas is not initialised yet.
47
+ */
48
+ export declare function renderSymmetryElements(plugin: PluginContext, drawings: readonly SymmetryDrawing[], style?: ElementLayerStyle): Promise<ElementGroup[]>;
49
+ /**
50
+ * Remove the symmetry elements and their labels.
51
+ * @param plugin - The molstar context.
52
+ */
53
+ export declare function clearSymmetryElements(plugin: PluginContext): void;
54
+ //# sourceMappingURL=renderElements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderElements.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderElements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOxD,kCAAkC;AAClC,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,KAAK,GAAE,iBAAsB,GAC5B,OAAO,CAAC,YAAY,EAAE,CAAC,CAwCzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAIjE"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The symmetry elements over the structure — the reason a symmetry page has a viewer
3
+ * of its own at all.
4
+ *
5
+ * The shapes come from `elementDrawing.ts`, which knows no molstar. This module
6
+ * hands them to **three** layers, which is what keeps a cell holding ten of
7
+ * them readable: the planes are drawn nearly transparent, the rods, rims and
8
+ * balls that outline them stay solid, and the names sit in a third layer so
9
+ * they can be switched off without rebuilding anything.
10
+ *
11
+ * Drawing the whole of an element at one opacity is what makes a stack of
12
+ * mirror planes a wash of colour with the structure lost somewhere inside it.
13
+ */
14
+ import { elementGroups } from "../core/elementDrawing.js";
15
+ import { LABEL_COLOUR } from "../core/palette.js";
16
+ import { clearShapeLayer } from "./layerRegistry.js";
17
+ import { renderShapeLayer } from "./shapeLayer.js";
18
+ import { renderTextLayer } from "./textLayer.js";
19
+ /**
20
+ * Replace the drawn symmetry elements.
21
+ * @param plugin - The molstar context.
22
+ * @param drawings - The elements; an empty list clears them.
23
+ * @param style - See {@link ElementLayerStyle}.
24
+ * @returns The groups that were drawn, so a caller can measure them without
25
+ * building them a second time.
26
+ * @throws {Error} When the canvas is not initialised yet.
27
+ */
28
+ export async function renderSymmetryElements(plugin, drawings, style = {}) {
29
+ const groups = elementGroups(drawings, {
30
+ style: style.style,
31
+ labels: style.labels ?? true,
32
+ });
33
+ const faces = [];
34
+ const lines = [];
35
+ const labels = [];
36
+ for (const group of groups) {
37
+ const solid = [];
38
+ const flat = [];
39
+ for (const primitive of group.primitives) {
40
+ const target = primitive.shape === 'face' || primitive.shape === 'plate'
41
+ ? flat
42
+ : solid;
43
+ target.push(primitive);
44
+ }
45
+ const { label, colour } = group;
46
+ if (flat.length > 0)
47
+ faces.push({ label, colour, primitives: flat });
48
+ if (solid.length > 0)
49
+ lines.push({ label, colour, primitives: solid });
50
+ for (const item of group.labels)
51
+ labels.push({ ...item, colour });
52
+ }
53
+ await renderShapeLayer(plugin, FACE_LAYER, 'Symmetry planes', faces, {
54
+ alpha: style.faceAlpha ?? 0.1,
55
+ // A face seen edge-on would otherwise darken to nothing.
56
+ ignoreLight: true,
57
+ });
58
+ await renderShapeLayer(plugin, ELEMENT_LAYER, 'Symmetry elements', lines, {
59
+ alpha: style.lineAlpha ?? 0.9,
60
+ ignoreLight: true,
61
+ });
62
+ await renderTextLayer(plugin, ELEMENT_LABEL_LAYER, 'Symmetry element labels', labels, LABEL_COLOUR);
63
+ return groups;
64
+ }
65
+ /**
66
+ * Remove the symmetry elements and their labels.
67
+ * @param plugin - The molstar context.
68
+ */
69
+ export function clearSymmetryElements(plugin) {
70
+ clearShapeLayer(plugin, FACE_LAYER);
71
+ clearShapeLayer(plugin, ELEMENT_LAYER);
72
+ clearShapeLayer(plugin, ELEMENT_LABEL_LAYER);
73
+ }
74
+ const FACE_LAYER = 'symmetry-element-faces';
75
+ const ELEMENT_LAYER = 'symmetry-elements';
76
+ const ELEMENT_LABEL_LAYER = 'symmetry-element-labels';
77
+ //# sourceMappingURL=renderElements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderElements.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderElements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAwBjD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAqB,EACrB,QAAoC,EAC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K,EAAE,KAAK,CAAC,SAAS,IAAI,GAAG;QAC7B,yDAAyD;QACzD,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,MAAM,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE;QACxE,KAAK,EAAE,KAAK,CAAC,SAAS,IAAI,GAAG;QAC7B,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,MAAM,eAAe,CACnB,MAAM,EACN,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,EACN,YAAY,CACb,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpC,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACvC,eAAe,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,MAAM,mBAAmB,GAAG,yBAAyB,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The atoms on screen.
3
+ *
4
+ * They arrive already expanded and already repeated over the lattice, as
5
+ * Cartesian ångström, and go in as XYZ — the one format that carries elements
6
+ * and coordinates and invites molstar to apply nothing of its own.
7
+ */
8
+ import type { Structure } from 'molstar/lib/mol-model/structure.js';
9
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
10
+ import type { Representation } from 'molstar/lib/mol-repr/representation.js';
11
+ import type { BallAndStickParams } from 'molstar/lib/mol-repr/structure/representation/ball-and-stick.js';
12
+ import type { ParamDefinition } from 'molstar/lib/mol-util/param-definition.js';
13
+ import type { CrystalBonds } from '../core/crystalView.ts';
14
+ import type { ViewerAtom } from '../core/types.ts';
15
+ /** How the atoms are drawn. */
16
+ export interface StructureStyle {
17
+ /**
18
+ * Balls and sticks, or space-filling spheres.
19
+ * @default 'ball-and-stick'
20
+ */
21
+ representation?: 'ball-and-stick' | 'spacefill';
22
+ /**
23
+ * Ball and stick radius multiplier. A handful of atoms reads better slightly
24
+ * thinner than molstar's protein-oriented default.
25
+ * @default 0.25
26
+ */
27
+ sizeFactor?: number;
28
+ /**
29
+ * Which bonds the balls and sticks draw.
30
+ * @default 'all'
31
+ */
32
+ bonds?: CrystalBonds;
33
+ }
34
+ /**
35
+ * Replace the atoms on screen.
36
+ * @param plugin - The molstar context.
37
+ * @param atoms - The whole scene, Cartesian ångström; an empty list clears it.
38
+ * @param style - See {@link StructureStyle}.
39
+ * @throws {Error} When molstar parses the file to no atoms at all.
40
+ */
41
+ export declare function renderStructure(plugin: PluginContext, atoms: readonly ViewerAtom[], style?: StructureStyle): Promise<void>;
42
+ /**
43
+ * Draw other bonds between the atoms on screen, in place: the camera, the
44
+ * measurements and an operation half applied all stay where they are.
45
+ * @param plugin - The molstar context.
46
+ * @param bonds - Which bonds are drawn.
47
+ */
48
+ export declare function setStructureBonds(plugin: PluginContext, bonds: CrystalBonds): Promise<void>;
49
+ /**
50
+ * The ball-and-stick parameters that draw these bonds. A metal's bonds are
51
+ * molstar's metal coordination, which it draws dashed.
52
+ * @param bonds - Which bonds are drawn.
53
+ * @returns The parameters to merge into the representation's own.
54
+ */
55
+ export declare function bondParams(bonds: CrystalBonds): BondParams;
56
+ /**
57
+ * Remove the atoms, leaving every drawn layer in place.
58
+ * @param plugin - The molstar context.
59
+ */
60
+ export declare function clearStructure(plugin: PluginContext): Promise<void>;
61
+ /**
62
+ * The representation the atoms are drawn by, which is what an operation moves.
63
+ *
64
+ * It is resolved from the state tree rather than kept, because a rebuild
65
+ * replaces the object behind the same address.
66
+ * @param plugin - The molstar context.
67
+ * @returns The representation, or `undefined` when nothing is drawn.
68
+ */
69
+ export declare function structureRepresentation(plugin: PluginContext): Representation.Any | undefined;
70
+ /**
71
+ * The structure the atoms on screen were built into, which is what a
72
+ * measurement names its atoms in.
73
+ * @param plugin - The molstar context.
74
+ * @returns The structure, or `undefined` when nothing is drawn.
75
+ */
76
+ export declare function crystalStructure(plugin: PluginContext): Structure | undefined;
77
+ /** The ball-and-stick parameters that say which bonds are drawn. */
78
+ type BondParams = Pick<ParamDefinition.Values<BallAndStickParams>, 'visuals' | 'excludeTypes'>;
79
+ export {};
80
+ //# sourceMappingURL=renderStructure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderStructure.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderStructure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iEAAiE,CAAC;AAC1G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,cAAc,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC;IAChD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,KAAK,GAAE,cAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoDf;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,UAAU,CAQ1D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,GACpB,cAAc,CAAC,GAAG,GAAG,SAAS,CAQhC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS,CAM7E;AAED,oEAAoE;AACpE,KAAK,UAAU,GAAG,IAAI,CACpB,eAAe,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAC1C,SAAS,GAAG,cAAc,CAC3B,CAAC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * The atoms on screen.
3
+ *
4
+ * They arrive already expanded and already repeated over the lattice, as
5
+ * Cartesian ångström, and go in as XYZ — the one format that carries elements
6
+ * and coordinates and invites molstar to apply nothing of its own.
7
+ */
8
+ import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects.js';
9
+ import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms.js';
10
+ import { toXyzText } from "../core/structureText.js";
11
+ /**
12
+ * Replace the atoms on screen.
13
+ * @param plugin - The molstar context.
14
+ * @param atoms - The whole scene, Cartesian ångström; an empty list clears it.
15
+ * @param style - See {@link StructureStyle}.
16
+ * @throws {Error} When molstar parses the file to no atoms at all.
17
+ */
18
+ export async function renderStructure(plugin, atoms, style = {}) {
19
+ await clearStructure(plugin);
20
+ if (atoms.length === 0)
21
+ return;
22
+ const { representation = 'ball-and-stick', sizeFactor = 0.25, bonds = 'all', } = style;
23
+ const data = await plugin.builders.data.rawData({ data: toXyzText(atoms) }, { ref: STRUCTURE_DATA_REF, state: { isGhost: true } });
24
+ const trajectory = await plugin.builders.structure.parseTrajectory(data, 'xyz');
25
+ const model = await plugin.builders.structure.createModel(trajectory);
26
+ if ((model.data?.atomicHierarchy.atoms._rowCount ?? 0) !== atoms.length) {
27
+ await clearStructure(plugin);
28
+ throw new Error(`molstar read ${model.data?.atomicHierarchy.atoms._rowCount ?? 0} of the ${atoms.length} atoms it was given.`);
29
+ }
30
+ const structure = await plugin.builders.structure.createStructure(model);
31
+ structureRefs.set(plugin, structure.ref);
32
+ const drawn = await plugin.builders.structure.representation.addRepresentation(structure, representation === 'spacefill'
33
+ ? {
34
+ type: 'spacefill',
35
+ typeParams: { sizeFactor: 1 },
36
+ color: 'element-symbol',
37
+ }
38
+ : {
39
+ type: 'ball-and-stick',
40
+ // A benzene drawn with molstar's dashed aromatic bond already shows
41
+ // the π cloud, which is a different lesson from the one here.
42
+ typeParams: {
43
+ sizeFactor,
44
+ sizeAspectRatio: 2 / 3,
45
+ aromaticBonds: false,
46
+ ...bondParams(bonds),
47
+ },
48
+ color: 'element-symbol',
49
+ colorParams: {
50
+ carbonColor: { name: 'element-symbol', params: {} },
51
+ },
52
+ });
53
+ representationRefs.set(plugin, drawn.ref);
54
+ }
55
+ /**
56
+ * Draw other bonds between the atoms on screen, in place: the camera, the
57
+ * measurements and an operation half applied all stay where they are.
58
+ * @param plugin - The molstar context.
59
+ * @param bonds - Which bonds are drawn.
60
+ */
61
+ export async function setStructureBonds(plugin, bonds) {
62
+ const ref = representationRefs.get(plugin);
63
+ if (ref === undefined)
64
+ return;
65
+ await plugin
66
+ .build()
67
+ .to(ref)
68
+ .update(StateTransforms.Representation.StructureRepresentation3D, (old) => old.type.name === 'ball-and-stick'
69
+ ? {
70
+ ...old,
71
+ type: {
72
+ ...old.type,
73
+ params: { ...old.type.params, ...bondParams(bonds) },
74
+ },
75
+ }
76
+ : old)
77
+ .commit();
78
+ }
79
+ /**
80
+ * The ball-and-stick parameters that draw these bonds. A metal's bonds are
81
+ * molstar's metal coordination, which it draws dashed.
82
+ * @param bonds - Which bonds are drawn.
83
+ * @returns The parameters to merge into the representation's own.
84
+ */
85
+ export function bondParams(bonds) {
86
+ return {
87
+ visuals: bonds === 'none'
88
+ ? ['element-sphere']
89
+ : ['element-sphere', 'intra-bond', 'inter-bond'],
90
+ excludeTypes: bonds === 'noMetal' ? ['metal-coordination'] : [],
91
+ };
92
+ }
93
+ /**
94
+ * Remove the atoms, leaving every drawn layer in place.
95
+ * @param plugin - The molstar context.
96
+ */
97
+ export async function clearStructure(plugin) {
98
+ representationRefs.delete(plugin);
99
+ structureRefs.delete(plugin);
100
+ if (!plugin.state.data.cells.has(STRUCTURE_DATA_REF))
101
+ return;
102
+ await plugin.build().delete(STRUCTURE_DATA_REF).commit();
103
+ }
104
+ /**
105
+ * The representation the atoms are drawn by, which is what an operation moves.
106
+ *
107
+ * It is resolved from the state tree rather than kept, because a rebuild
108
+ * replaces the object behind the same address.
109
+ * @param plugin - The molstar context.
110
+ * @returns The representation, or `undefined` when nothing is drawn.
111
+ */
112
+ export function structureRepresentation(plugin) {
113
+ const ref = representationRefs.get(plugin);
114
+ if (ref === undefined)
115
+ return undefined;
116
+ const object = plugin.state.data.cells.get(ref)?.obj;
117
+ if (!PluginStateObject.Molecule.Structure.Representation3D.is(object)) {
118
+ return undefined;
119
+ }
120
+ return object.data.repr;
121
+ }
122
+ /**
123
+ * The structure the atoms on screen were built into, which is what a
124
+ * measurement names its atoms in.
125
+ * @param plugin - The molstar context.
126
+ * @returns The structure, or `undefined` when nothing is drawn.
127
+ */
128
+ export function crystalStructure(plugin) {
129
+ const ref = structureRefs.get(plugin);
130
+ if (ref === undefined)
131
+ return undefined;
132
+ const object = plugin.state.data.cells.get(ref)?.obj;
133
+ if (!PluginStateObject.Molecule.Structure.is(object))
134
+ return undefined;
135
+ return object.data;
136
+ }
137
+ /** Deleting this ref deletes the model and the representation under it. */
138
+ const STRUCTURE_DATA_REF = 'crystal3d-structure-data';
139
+ /** Where the structure the atoms were built into sits, per plugin. */
140
+ const structureRefs = new WeakMap();
141
+ /** Where the drawn representation sits in the state tree, per plugin. */
142
+ const representationRefs = new WeakMap();
143
+ //# sourceMappingURL=renderStructure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderStructure.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/renderStructure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAM7E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAuBrD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAqB,EACrB,KAA4B,EAC5B,QAAwB,EAAE;IAE1B,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC/B,MAAM,EACJ,cAAc,GAAG,gBAAgB,EACjC,UAAU,GAAG,IAAI,EACjB,KAAK,GAAG,KAAK,GACd,GAAG,KAAK,CAAC;IAEV,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAC7C,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,EAC1B,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CACtD,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,CAChE,IAAI,EACJ,KAAK,CACN,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,CAA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GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IACrD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;QACtE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB;IACpD,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IACrD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACvE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAQD,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD,sEAAsE;AACtE,MAAM,aAAa,GAAG,IAAI,OAAO,EAAyB,CAAC;AAE3D,yEAAyE;AACzE,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAyB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Drawing a part of the scene and telling the camera how far it reaches, in one
3
+ * call, so the two can never disagree.
4
+ */
5
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
6
+ import type { CellRepeat, SymmetryDrawing, UnitCell, ViewerAtom } from '../core/types.ts';
7
+ import type { CellStyle } from './renderCell.ts';
8
+ import type { ElementLayerStyle } from './renderElements.ts';
9
+ import type { StructureStyle } from './renderStructure.ts';
10
+ /**
11
+ * Replace the atoms, and record how far they reach.
12
+ * @param plugin - The molstar context.
13
+ * @param atoms - The whole scene, Cartesian ångström.
14
+ * @param style - See {@link StructureStyle}.
15
+ */
16
+ export declare function drawStructure(plugin: PluginContext, atoms: readonly ViewerAtom[], style?: StructureStyle): Promise<void>;
17
+ /**
18
+ * Replace the cell, and record how far it reaches.
19
+ * @param plugin - The molstar context.
20
+ * @param cell - The six cell parameters, or `null` to draw none.
21
+ * @param repeat - Cells along a, b and c.
22
+ * @param style - See {@link CellStyle}.
23
+ */
24
+ export declare function drawCell(plugin: PluginContext, cell: UnitCell | null, repeat?: CellRepeat, style?: CellStyle): Promise<void>;
25
+ /**
26
+ * Replace the symmetry elements, and record how far they reach.
27
+ * @param plugin - The molstar context.
28
+ * @param drawings - The elements.
29
+ * @param style - See {@link ElementLayerStyle}.
30
+ */
31
+ export declare function drawElements(plugin: PluginContext, drawings: readonly SymmetryDrawing[], style?: ElementLayerStyle): Promise<void>;
32
+ //# sourceMappingURL=sceneParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sceneParts.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/sceneParts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAUvE,OAAO,KAAK,EACV,UAAU,EAEV,eAAe,EACf,QAAQ,EACR,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,KAAK,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,MAAM,GAAE,UAAsB,EAC9B,KAAK,CAAC,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Drawing a part of the scene and telling the camera how far it reaches, in one
3
+ * call, so the two can never disagree.
4
+ */
5
+ import { cellEdges } from "../core/cellGeometry.js";
6
+ import { boundingSphereOf, primitivesExtent, unionSpheres, } from "../core/framing.js";
7
+ import { setSceneExtent } from "./camera.js";
8
+ import { renderUnitCell } from "./renderCell.js";
9
+ import { renderSymmetryElements } from "./renderElements.js";
10
+ import { renderStructure } from "./renderStructure.js";
11
+ /**
12
+ * Replace the atoms, and record how far they reach.
13
+ * @param plugin - The molstar context.
14
+ * @param atoms - The whole scene, Cartesian ångström.
15
+ * @param style - See {@link StructureStyle}.
16
+ */
17
+ export async function drawStructure(plugin, atoms, style) {
18
+ await renderStructure(plugin, atoms, style);
19
+ if (atoms.length === 0) {
20
+ setSceneExtent(plugin, 'atoms', null);
21
+ return;
22
+ }
23
+ const positions = [];
24
+ for (const atom of atoms)
25
+ positions.push(atom.position);
26
+ // The largest van der Waals radius an ordinary structure carries is about
27
+ // 2 Å, and the representation draws a ball of that times the size factor.
28
+ setSceneExtent(plugin, 'atoms', boundingSphereOf(positions, ATOM_PADDING));
29
+ }
30
+ /**
31
+ * Replace the cell, and record how far it reaches.
32
+ * @param plugin - The molstar context.
33
+ * @param cell - The six cell parameters, or `null` to draw none.
34
+ * @param repeat - Cells along a, b and c.
35
+ * @param style - See {@link CellStyle}.
36
+ */
37
+ export async function drawCell(plugin, cell, repeat = [1, 1, 1], style) {
38
+ await renderUnitCell(plugin, cell, repeat, style);
39
+ if (cell === null) {
40
+ setSceneExtent(plugin, 'cell', null);
41
+ return;
42
+ }
43
+ const corners = [];
44
+ for (const edge of cellEdges(cell, repeat)) {
45
+ corners.push(edge.start, edge.end);
46
+ }
47
+ setSceneExtent(plugin, 'cell', boundingSphereOf(corners));
48
+ }
49
+ /**
50
+ * Replace the symmetry elements, and record how far they reach.
51
+ * @param plugin - The molstar context.
52
+ * @param drawings - The elements.
53
+ * @param style - See {@link ElementLayerStyle}.
54
+ */
55
+ export async function drawElements(plugin, drawings, style) {
56
+ const groups = await renderSymmetryElements(plugin, drawings, style);
57
+ if (groups.length === 0) {
58
+ setSceneExtent(plugin, 'elements', null);
59
+ return;
60
+ }
61
+ const primitives = [];
62
+ // A name sits past the end of the element it names, so the elements reach
63
+ // further than their shapes do and framing the shapes alone cuts the names
64
+ // off at the edge of the canvas.
65
+ const names = [];
66
+ for (const group of groups) {
67
+ primitives.push(...group.primitives);
68
+ for (const item of group.labels)
69
+ names.push(item.position);
70
+ }
71
+ const shapes = primitivesExtent(primitives);
72
+ setSceneExtent(plugin, 'elements', names.length === 0
73
+ ? shapes
74
+ : unionSpheres([shapes, boundingSphereOf(names)]));
75
+ }
76
+ const ATOM_PADDING = 0.5;
77
+ //# sourceMappingURL=sceneParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sceneParts.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/sceneParts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,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esh with one group per item, so every item picks up
3
+ * its own colour and its own hover label while the whole layer is added and
4
+ * removed in one call.
5
+ */
6
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
7
+ import type { MeshPrimitive } from '../core/primitives.ts';
8
+ /** One pickable, labelled item of a layer. */
9
+ export interface ShapeGroup {
10
+ /** What the pointer reads. */
11
+ readonly label: string;
12
+ /** `#rrggbb`. */
13
+ readonly colour: string;
14
+ /** Its shapes. */
15
+ readonly primitives: readonly MeshPrimitive[];
16
+ }
17
+ /** How solid a layer looks. */
18
+ export interface ShapeLayerStyle {
19
+ /**
20
+ * Opacity.
21
+ * @default 1
22
+ */
23
+ alpha?: number;
24
+ /**
25
+ * Draw it flat, so a square reads as one even surface whatever angle it is
26
+ * seen from.
27
+ * @default false
28
+ */
29
+ ignoreLight?: boolean;
30
+ }
31
+ /**
32
+ * Replace a layer of shapes.
33
+ * @param plugin - The molstar context.
34
+ * @param key - Which layer; a second call with the same key replaces it.
35
+ * @param name - What the layer is called in a picking label.
36
+ * @param groups - The items; an empty list clears the layer.
37
+ * @param style - See {@link ShapeLayerStyle}.
38
+ * @throws {Error} When the canvas is not initialised yet.
39
+ */
40
+ export declare function renderShapeLayer(plugin: PluginContext, key: string, name: string, groups: readonly ShapeGroup[], style?: ShapeLayerStyle): Promise<void>;
41
+ //# sourceMappingURL=shapeLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapeLayer.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/shapeLayer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kBAAkB;IAClB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAED,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,KAAK,GAAE,eAAoB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Cf"}