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.
Files changed (287) hide show
  1. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  2. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  3. package/lib/crystal/core/cellAtoms.js +70 -0
  4. package/lib/crystal/core/cellAtoms.js.map +1 -0
  5. package/lib/crystal/core/index.d.ts +2 -0
  6. package/lib/crystal/core/index.d.ts.map +1 -1
  7. package/lib/crystal/core/index.js +1 -0
  8. package/lib/crystal/core/index.js.map +1 -1
  9. package/lib/crystal/core/molecules.d.ts.map +1 -1
  10. package/lib/crystal/core/molecules.js +6 -40
  11. package/lib/crystal/core/molecules.js.map +1 -1
  12. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  13. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  14. package/lib/crystal3d/core/cellClip.js +198 -0
  15. package/lib/crystal3d/core/cellClip.js.map +1 -0
  16. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  17. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  18. package/lib/crystal3d/core/cellGeometry.js +153 -0
  19. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  20. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  21. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  22. package/lib/crystal3d/core/cellStack.js +79 -0
  23. package/lib/crystal3d/core/cellStack.js.map +1 -0
  24. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  25. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  26. package/lib/crystal3d/core/crystalView.js +48 -0
  27. package/lib/crystal3d/core/crystalView.js.map +1 -0
  28. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  29. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  30. package/lib/crystal3d/core/drawingSet.js +63 -0
  31. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  32. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  33. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  34. package/lib/crystal3d/core/elementDrawing.js +100 -0
  35. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  36. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  37. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  38. package/lib/crystal3d/core/elementExtent.js +56 -0
  39. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  40. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  41. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  42. package/lib/crystal3d/core/elementLabels.js +99 -0
  43. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  44. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  45. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  46. package/lib/crystal3d/core/elementShapes.js +115 -0
  47. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  48. package/lib/crystal3d/core/frame.d.ts +36 -0
  49. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  50. package/lib/crystal3d/core/frame.js +35 -0
  51. package/lib/crystal3d/core/frame.js.map +1 -0
  52. package/lib/crystal3d/core/framing.d.ts +41 -0
  53. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  54. package/lib/crystal3d/core/framing.js +79 -0
  55. package/lib/crystal3d/core/framing.js.map +1 -0
  56. package/lib/crystal3d/core/index.d.ts +42 -0
  57. package/lib/crystal3d/core/index.d.ts.map +1 -0
  58. package/lib/crystal3d/core/index.js +29 -0
  59. package/lib/crystal3d/core/index.js.map +1 -0
  60. package/lib/crystal3d/core/labelText.d.ts +19 -0
  61. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  62. package/lib/crystal3d/core/labelText.js +42 -0
  63. package/lib/crystal3d/core/labelText.js.map +1 -0
  64. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  65. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  66. package/lib/crystal3d/core/latticeBasis.js +89 -0
  67. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  68. package/lib/crystal3d/core/mat3.d.ts +68 -0
  69. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  70. package/lib/crystal3d/core/mat3.js +146 -0
  71. package/lib/crystal3d/core/mat3.js.map +1 -0
  72. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  73. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  74. package/lib/crystal3d/core/operationMatrix.js +172 -0
  75. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  76. package/lib/crystal3d/core/orientation.d.ts +62 -0
  77. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  78. package/lib/crystal3d/core/orientation.js +166 -0
  79. package/lib/crystal3d/core/orientation.js.map +1 -0
  80. package/lib/crystal3d/core/palette.d.ts +24 -0
  81. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  82. package/lib/crystal3d/core/palette.js +34 -0
  83. package/lib/crystal3d/core/palette.js.map +1 -0
  84. package/lib/crystal3d/core/primitives.d.ts +133 -0
  85. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  86. package/lib/crystal3d/core/primitives.js +80 -0
  87. package/lib/crystal3d/core/primitives.js.map +1 -0
  88. package/lib/crystal3d/core/structureText.d.ts +20 -0
  89. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  90. package/lib/crystal3d/core/structureText.js +37 -0
  91. package/lib/crystal3d/core/structureText.js.map +1 -0
  92. package/lib/crystal3d/core/supercell.d.ts +20 -0
  93. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  94. package/lib/crystal3d/core/supercell.js +35 -0
  95. package/lib/crystal3d/core/supercell.js.map +1 -0
  96. package/lib/crystal3d/core/types.d.ts +166 -0
  97. package/lib/crystal3d/core/types.d.ts.map +1 -0
  98. package/lib/crystal3d/core/types.js +10 -0
  99. package/lib/crystal3d/core/types.js.map +1 -0
  100. package/lib/crystal3d/core/vec3.d.ts +75 -0
  101. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  102. package/lib/crystal3d/core/vec3.js +119 -0
  103. package/lib/crystal3d/core/vec3.js.map +1 -0
  104. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  105. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  106. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  107. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  108. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  109. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  110. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  111. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  112. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  113. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  114. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  115. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  116. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  117. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  118. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  119. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  120. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  121. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  122. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  123. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  124. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  125. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  126. package/lib/crystal3d/ui/crystalScene.js +10 -0
  127. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  128. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  129. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  130. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  131. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  132. package/lib/crystal3d/ui/index.d.ts +16 -0
  133. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  134. package/lib/crystal3d/ui/index.js +12 -0
  135. package/lib/crystal3d/ui/index.js.map +1 -0
  136. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  137. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  138. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  139. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  140. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  141. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  142. package/lib/crystal3d/viewer/animate.js +83 -0
  143. package/lib/crystal3d/viewer/animate.js.map +1 -0
  144. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  145. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  146. package/lib/crystal3d/viewer/camera.js +103 -0
  147. package/lib/crystal3d/viewer/camera.js.map +1 -0
  148. package/lib/crystal3d/viewer/index.d.ts +13 -0
  149. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  150. package/lib/crystal3d/viewer/index.js +8 -0
  151. package/lib/crystal3d/viewer/index.js.map +1 -0
  152. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  153. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  154. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  155. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  156. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  157. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  158. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  159. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  160. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  161. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  162. package/lib/crystal3d/viewer/plugin.js +181 -0
  163. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  164. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  165. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  166. package/lib/crystal3d/viewer/renderCell.js +53 -0
  167. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  168. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  169. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  170. package/lib/crystal3d/viewer/renderElements.js +77 -0
  171. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  172. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  173. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  174. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  175. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  176. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  177. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  178. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  179. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  180. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  181. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  182. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  183. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  184. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  185. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  186. package/lib/crystal3d/viewer/textLayer.js +59 -0
  187. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  188. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  189. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  190. package/lib/crystal3d/viewer/viewer.js +157 -0
  191. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  192. package/lib/crystal3d.d.ts +12 -0
  193. package/lib/crystal3d.d.ts.map +1 -0
  194. package/lib/crystal3d.js +12 -0
  195. package/lib/crystal3d.js.map +1 -0
  196. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  197. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  198. package/lib/locales/de.json +19 -1
  199. package/lib/locales/en.json +19 -1
  200. package/lib/locales/es.json +19 -1
  201. package/lib/locales/fr.json +19 -1
  202. package/lib/locales/it.json +19 -1
  203. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  204. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  205. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  206. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  207. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  208. package/lib/molstar/bonds/bondRule.js +23 -0
  209. package/lib/molstar/bonds/bondRule.js.map +1 -0
  210. package/lib/molstar/bonds/index.d.ts +9 -0
  211. package/lib/molstar/bonds/index.d.ts.map +1 -0
  212. package/lib/molstar/bonds/index.js +9 -0
  213. package/lib/molstar/bonds/index.js.map +1 -0
  214. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  215. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  216. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  217. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  218. package/lib/molstar/ui/index.d.ts +10 -0
  219. package/lib/molstar/ui/index.d.ts.map +1 -0
  220. package/lib/molstar/ui/index.js +8 -0
  221. package/lib/molstar/ui/index.js.map +1 -0
  222. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  223. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  224. package/lib/molstar/ui/useMolstarTools.js +36 -0
  225. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  226. package/package.json +2 -1
  227. package/src/crystal/core/cellAtoms.ts +106 -0
  228. package/src/crystal/core/index.ts +2 -0
  229. package/src/crystal/core/molecules.ts +7 -44
  230. package/src/crystal3d/core/cellClip.ts +229 -0
  231. package/src/crystal3d/core/cellGeometry.ts +193 -0
  232. package/src/crystal3d/core/cellStack.ts +87 -0
  233. package/src/crystal3d/core/crystalView.ts +114 -0
  234. package/src/crystal3d/core/drawingSet.ts +71 -0
  235. package/src/crystal3d/core/elementDrawing.ts +147 -0
  236. package/src/crystal3d/core/elementExtent.ts +81 -0
  237. package/src/crystal3d/core/elementLabels.ts +130 -0
  238. package/src/crystal3d/core/elementShapes.ts +141 -0
  239. package/src/crystal3d/core/frame.ts +56 -0
  240. package/src/crystal3d/core/framing.ts +101 -0
  241. package/src/crystal3d/core/index.ts +132 -0
  242. package/src/crystal3d/core/labelText.ts +44 -0
  243. package/src/crystal3d/core/latticeBasis.ts +110 -0
  244. package/src/crystal3d/core/mat3.ts +163 -0
  245. package/src/crystal3d/core/operationMatrix.ts +255 -0
  246. package/src/crystal3d/core/orientation.ts +229 -0
  247. package/src/crystal3d/core/palette.ts +43 -0
  248. package/src/crystal3d/core/primitives.ts +183 -0
  249. package/src/crystal3d/core/structureText.ts +43 -0
  250. package/src/crystal3d/core/supercell.ts +40 -0
  251. package/src/crystal3d/core/types.ts +186 -0
  252. package/src/crystal3d/core/vec3.ts +127 -0
  253. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  254. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  255. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  256. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  257. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  258. package/src/crystal3d/ui/crystalScene.ts +100 -0
  259. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  260. package/src/crystal3d/ui/index.ts +20 -0
  261. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  262. package/src/crystal3d/viewer/animate.ts +113 -0
  263. package/src/crystal3d/viewer/camera.ts +139 -0
  264. package/src/crystal3d/viewer/index.ts +13 -0
  265. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  266. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  267. package/src/crystal3d/viewer/plugin.ts +258 -0
  268. package/src/crystal3d/viewer/renderCell.ts +98 -0
  269. package/src/crystal3d/viewer/renderElements.ts +121 -0
  270. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  271. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  272. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  273. package/src/crystal3d/viewer/textLayer.ts +85 -0
  274. package/src/crystal3d/viewer/viewer.ts +207 -0
  275. package/src/crystal3d.ts +12 -0
  276. package/src/locales/de.json +19 -1
  277. package/src/locales/en.json +19 -1
  278. package/src/locales/es.json +19 -1
  279. package/src/locales/fr.json +19 -1
  280. package/src/locales/it.json +19 -1
  281. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  282. package/src/molstar/bonds/bondRule.ts +34 -0
  283. package/src/molstar/bonds/index.ts +9 -0
  284. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  285. package/src/molstar/ui/index.ts +14 -0
  286. package/src/molstar/ui/useMolstarTools.ts +98 -0
  287. package/styles/chrome.css +90 -0
@@ -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,2B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,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACvE,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE;QACnE,KAAK,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,55 @@
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 { ViewerAtom } from '../core/types.ts';
12
+ /** How the atoms are drawn. */
13
+ export interface StructureStyle {
14
+ /**
15
+ * Balls and sticks, or space-filling spheres.
16
+ * @default 'ball-and-stick'
17
+ */
18
+ representation?: 'ball-and-stick' | 'spacefill';
19
+ /**
20
+ * Ball and stick radius multiplier. A handful of atoms reads better slightly
21
+ * thinner than molstar's protein-oriented default.
22
+ * @default 0.25
23
+ */
24
+ sizeFactor?: number;
25
+ }
26
+ /**
27
+ * Replace the atoms on screen.
28
+ * @param plugin - The molstar context.
29
+ * @param atoms - The whole scene, Cartesian ångström; an empty list clears it.
30
+ * @param style - See {@link StructureStyle}.
31
+ * @throws {Error} When molstar parses the file to no atoms at all.
32
+ */
33
+ export declare function renderStructure(plugin: PluginContext, atoms: readonly ViewerAtom[], style?: StructureStyle): Promise<void>;
34
+ /**
35
+ * Remove the atoms, leaving every drawn layer in place.
36
+ * @param plugin - The molstar context.
37
+ */
38
+ export declare function clearStructure(plugin: PluginContext): Promise<void>;
39
+ /**
40
+ * The representation the atoms are drawn by, which is what an operation moves.
41
+ *
42
+ * It is resolved from the state tree rather than kept, because a rebuild
43
+ * replaces the object behind the same address.
44
+ * @param plugin - The molstar context.
45
+ * @returns The representation, or `undefined` when nothing is drawn.
46
+ */
47
+ export declare function structureRepresentation(plugin: PluginContext): Representation.Any | undefined;
48
+ /**
49
+ * The structure the atoms on screen were built into, which is what a
50
+ * measurement names its atoms in.
51
+ * @param plugin - The molstar context.
52
+ * @returns The structure, or `undefined` when nothing is drawn.
53
+ */
54
+ export declare function crystalStructure(plugin: PluginContext): Structure | undefined;
55
+ //# 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;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAG7E,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;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,KAAK,GAAE,cAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CA+Cf;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"}
@@ -0,0 +1,103 @@
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 { toXyzText } from "../core/structureText.js";
10
+ /**
11
+ * Replace the atoms on screen.
12
+ * @param plugin - The molstar context.
13
+ * @param atoms - The whole scene, Cartesian ångström; an empty list clears it.
14
+ * @param style - See {@link StructureStyle}.
15
+ * @throws {Error} When molstar parses the file to no atoms at all.
16
+ */
17
+ export async function renderStructure(plugin, atoms, style = {}) {
18
+ await clearStructure(plugin);
19
+ if (atoms.length === 0)
20
+ return;
21
+ const { representation = 'ball-and-stick', sizeFactor = 0.25 } = style;
22
+ const data = await plugin.builders.data.rawData({ data: toXyzText(atoms) }, { ref: STRUCTURE_DATA_REF, state: { isGhost: true } });
23
+ const trajectory = await plugin.builders.structure.parseTrajectory(data, 'xyz');
24
+ const model = await plugin.builders.structure.createModel(trajectory);
25
+ if ((model.data?.atomicHierarchy.atoms._rowCount ?? 0) !== atoms.length) {
26
+ await clearStructure(plugin);
27
+ throw new Error(`molstar read ${model.data?.atomicHierarchy.atoms._rowCount ?? 0} of the ${atoms.length} atoms it was given.`);
28
+ }
29
+ const structure = await plugin.builders.structure.createStructure(model);
30
+ structureRefs.set(plugin, structure.ref);
31
+ const drawn = await plugin.builders.structure.representation.addRepresentation(structure, representation === 'spacefill'
32
+ ? {
33
+ type: 'spacefill',
34
+ typeParams: { sizeFactor: 1 },
35
+ color: 'element-symbol',
36
+ }
37
+ : {
38
+ type: 'ball-and-stick',
39
+ // A benzene drawn with molstar's dashed aromatic bond already shows
40
+ // the π cloud, which is a different lesson from the one here.
41
+ typeParams: {
42
+ sizeFactor,
43
+ sizeAspectRatio: 2 / 3,
44
+ aromaticBonds: false,
45
+ },
46
+ color: 'element-symbol',
47
+ colorParams: {
48
+ carbonColor: { name: 'element-symbol', params: {} },
49
+ },
50
+ });
51
+ representationRefs.set(plugin, drawn.ref);
52
+ }
53
+ /**
54
+ * Remove the atoms, leaving every drawn layer in place.
55
+ * @param plugin - The molstar context.
56
+ */
57
+ export async function clearStructure(plugin) {
58
+ representationRefs.delete(plugin);
59
+ structureRefs.delete(plugin);
60
+ if (!plugin.state.data.cells.has(STRUCTURE_DATA_REF))
61
+ return;
62
+ await plugin.build().delete(STRUCTURE_DATA_REF).commit();
63
+ }
64
+ /**
65
+ * The representation the atoms are drawn by, which is what an operation moves.
66
+ *
67
+ * It is resolved from the state tree rather than kept, because a rebuild
68
+ * replaces the object behind the same address.
69
+ * @param plugin - The molstar context.
70
+ * @returns The representation, or `undefined` when nothing is drawn.
71
+ */
72
+ export function structureRepresentation(plugin) {
73
+ const ref = representationRefs.get(plugin);
74
+ if (ref === undefined)
75
+ return undefined;
76
+ const object = plugin.state.data.cells.get(ref)?.obj;
77
+ if (!PluginStateObject.Molecule.Structure.Representation3D.is(object)) {
78
+ return undefined;
79
+ }
80
+ return object.data.repr;
81
+ }
82
+ /**
83
+ * The structure the atoms on screen were built into, which is what a
84
+ * measurement names its atoms in.
85
+ * @param plugin - The molstar context.
86
+ * @returns The structure, or `undefined` when nothing is drawn.
87
+ */
88
+ export function crystalStructure(plugin) {
89
+ const ref = structureRefs.get(plugin);
90
+ if (ref === undefined)
91
+ return undefined;
92
+ const object = plugin.state.data.cells.get(ref)?.obj;
93
+ if (!PluginStateObject.Molecule.Structure.is(object))
94
+ return undefined;
95
+ return object.data;
96
+ }
97
+ /** Deleting this ref deletes the model and the representation under it. */
98
+ const STRUCTURE_DATA_REF = 'crystal3d-structure-data';
99
+ /** Where the structure the atoms were built into sits, per plugin. */
100
+ const structureRefs = new WeakMap();
101
+ /** Where the drawn representation sits in the state tree, per plugin. */
102
+ const representationRefs = new WeakMap();
103
+ //# 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;AAG5E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAkBrD;;;;;;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,C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AAO,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;AAED,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,oBAAoB,CAAC;AAU5B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAqB,EACrB,KAA4B,EAC5B,KAAsB;IAEtB,MAAM,eAAe,CAAC,MA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BAAsB,CACzD,MAAM,EACN,QAAQ,EACR,KAAK,CACN,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IACD,MAAM,UAAU,GAAoB,EAAE,CAAC;IACvC,0EAA0E;IAC1E,2EAA2E;IAC3E,iCAAiC;IACjC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACrC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5C,cAAc,CACZ,MAAM,EACN,UAAU,EACV,KAAK,CAAC,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CACpD,CAAC;AACJ,CAAC;AAED,MAAM,YAAY,GAAG,GAAG,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * A layer of shapes: one mesh 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"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A layer of shapes: one mesh 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 { MeshBuilder } from 'molstar/lib/mol-geo/geometry/mesh/mesh-builder.js';
7
+ import { Mesh } from 'molstar/lib/mol-geo/geometry/mesh/mesh.js';
8
+ import { Shape } from 'molstar/lib/mol-model/shape.js';
9
+ // Lowercased on import: it is a factory, not a constructor.
10
+ import { ShapeRepresentation as createShapeRepresentation } from 'molstar/lib/mol-repr/shape/representation.js';
11
+ import { Color } from 'molstar/lib/mol-util/color/color.js';
12
+ import { clearShapeLayer, storeLayer } from "./layerRegistry.js";
13
+ import { addMeshPrimitive } from "./meshPrimitives.js";
14
+ /**
15
+ * Replace a layer of shapes.
16
+ * @param plugin - The molstar context.
17
+ * @param key - Which layer; a second call with the same key replaces it.
18
+ * @param name - What the layer is called in a picking label.
19
+ * @param groups - The items; an empty list clears the layer.
20
+ * @param style - See {@link ShapeLayerStyle}.
21
+ * @throws {Error} When the canvas is not initialised yet.
22
+ */
23
+ export async function renderShapeLayer(plugin, key, name, groups, style = {}) {
24
+ const canvas3d = plugin.canvas3d;
25
+ if (canvas3d === undefined) {
26
+ throw new Error(`renderShapeLayer: the molstar canvas is not ready (${key}).`);
27
+ }
28
+ clearShapeLayer(plugin, key);
29
+ if (groups.length === 0)
30
+ return;
31
+ const state = MeshBuilder.createState(4096, 2048);
32
+ const colours = [];
33
+ const labels = [];
34
+ for (const group of groups) {
35
+ state.currentGroup = colours.length;
36
+ colours.push(Color.fromHexStyle(group.colour));
37
+ labels.push(group.label);
38
+ for (const primitive of group.primitives) {
39
+ addMeshPrimitive(state, primitive);
40
+ }
41
+ }
42
+ const mesh = MeshBuilder.getMesh(state);
43
+ Mesh.computeNormals(mesh);
44
+ const shape = Shape.create(name, {}, mesh, (group) => colours[group] ?? BLACK, () => 1, (group) => labels[group] ?? name);
45
+ const representation = createShapeRepresentation(() => shape, Mesh.Utils);
46
+ await plugin.runTask(representation.createOrUpdate({
47
+ alpha: style.alpha ?? 1,
48
+ doubleSided: true,
49
+ ignoreLight: style.ignoreLight ?? false,
50
+ }, shape));
51
+ storeLayer(plugin, key, representation);
52
+ canvas3d.add(representation);
53
+ // add() only queues; nothing appears until the queue is committed.
54
+ canvas3d.commit();
55
+ }
56
+ const BLACK = Color.fromHexStyle('#000000'); // tokens-ok: the fallback ink of a picking label.
57
+ //# sourceMappingURL=shapeLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapeLayer.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/shapeLayer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,2CAA2C,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,4DAA4D;AAC5D,OAAO,EAAE,mBAAmB,IAAI,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAChH,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAI5D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA2BvD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAqB,EACrB,GAAW,EACX,IAAY,EACZ,MAA6B,EAC7B,QAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,sDAAsD,GAAG,IAAI,CAC9D,CAAC;IACJ,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AC;QACvB,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK;KACxC,EACD,KAAK,CACN,CACF,CAAC;IACF,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;IACxC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,kDAAkD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A layer of text floating in the scene: an element's name, a cell's a, b and c.
3
+ *
4
+ * The text is written on a pale card rather than straight onto the scene: a
5
+ * name over a dark atom, or over three translucent planes, is otherwise read
6
+ * as part of them.
7
+ */
8
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
9
+ import type { TextItem } from '../core/primitives.ts';
10
+ /**
11
+ * Replace a layer of floating text.
12
+ * @param plugin - The molstar context.
13
+ * @param key - Which layer; a second call with the same key replaces it.
14
+ * @param name - What the layer is called in a picking label.
15
+ * @param items - The lines; an empty list clears the layer.
16
+ * @param colour - What a line with no colour of its own is written in,
17
+ * `#rrggbb`.
18
+ * @throws {Error} When the canvas is not initialised yet.
19
+ */
20
+ export declare function renderTextLayer(plugin: PluginContext, key: string, name: string, items: readonly TextItem[], colour: string): Promise<void>;
21
+ //# sourceMappingURL=textLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textLayer.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/viewer/textLayer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAMvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA+Cf"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * A layer of text floating in the scene: an element's name, a cell's a, b and c.
3
+ *
4
+ * The text is written on a pale card rather than straight onto the scene: a
5
+ * name over a dark atom, or over three translucent planes, is otherwise read
6
+ * as part of them.
7
+ */
8
+ import { TextBuilder } from 'molstar/lib/mol-geo/geometry/text/text-builder.js';
9
+ import { Text } from 'molstar/lib/mol-geo/geometry/text/text.js';
10
+ import { Shape } from 'molstar/lib/mol-model/shape.js';
11
+ // Lowercased on import: it is a factory, not a constructor.
12
+ import { ShapeRepresentation as createShapeRepresentation } from 'molstar/lib/mol-repr/shape/representation.js';
13
+ import { Color } from 'molstar/lib/mol-util/color/color.js';
14
+ import { LABEL_CARD_COLOUR } from "../core/palette.js";
15
+ import { clearShapeLayer, storeLayer } from "./layerRegistry.js";
16
+ /**
17
+ * Replace a layer of floating text.
18
+ * @param plugin - The molstar context.
19
+ * @param key - Which layer; a second call with the same key replaces it.
20
+ * @param name - What the layer is called in a picking label.
21
+ * @param items - The lines; an empty list clears the layer.
22
+ * @param colour - What a line with no colour of its own is written in,
23
+ * `#rrggbb`.
24
+ * @throws {Error} When the canvas is not initialised yet.
25
+ */
26
+ export async function renderTextLayer(plugin, key, name, items, colour) {
27
+ const canvas3d = plugin.canvas3d;
28
+ if (canvas3d === undefined) {
29
+ throw new Error(`renderTextLayer: the molstar canvas is not ready (${key}).`);
30
+ }
31
+ clearShapeLayer(plugin, key);
32
+ if (items.length === 0)
33
+ return;
34
+ const builder = TextBuilder.create({}, items.length * 4, items.length * 4);
35
+ const fallback = Color.fromHexStyle(colour);
36
+ const inks = [];
37
+ for (let index = 0; index < items.length; index++) {
38
+ const item = items[index];
39
+ if (item === undefined)
40
+ continue;
41
+ const [x, y, z] = item.position;
42
+ builder.add(item.text, x, y, z, item.size, item.size, index);
43
+ inks.push(item.colour === undefined ? fallback : Color.fromHexStyle(item.colour));
44
+ }
45
+ const shape = Shape.create(name, {}, builder.getText(), (group) => inks[group] ?? fallback, () => 1, (group) => items[group]?.text ?? name);
46
+ const representation = createShapeRepresentation(() => shape, Text.Utils);
47
+ await plugin.runTask(representation.createOrUpdate({
48
+ attachment: 'middle-center',
49
+ background: true,
50
+ backgroundMargin: 0.25,
51
+ backgroundColor: Color.fromHexStyle(LABEL_CARD_COLOUR),
52
+ backgroundOpacity: 0.85,
53
+ fontWeight: 'bold',
54
+ }, shape));
55
+ storeLayer(plugin, key, representation);
56
+ canvas3d.add(representation);
57
+ canvas3d.commit();
58
+ }
59
+ //# sourceMappingURL=textLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textLayer.js","sourceRoot":"","sources":["../../../src/crystal3d/viewer/textLayer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,2CAA2C,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,4DAA4D;AAC5D,OAAO,EAAE,mBAAmB,IAAI,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAChH,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAqB,EACrB,GAAW,EACX,IAAY,EACZ,KAA0B,EAC1B,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,I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