react-cheminfo 0.134.1 → 0.136.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (454) hide show
  1. package/README.md +13 -0
  2. package/lib/crystal/core/bondGrid.d.ts +26 -0
  3. package/lib/crystal/core/bondGrid.d.ts.map +1 -0
  4. package/lib/crystal/core/bondGrid.js +76 -0
  5. package/lib/crystal/core/bondGrid.js.map +1 -0
  6. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  7. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  8. package/lib/crystal/core/cellAtoms.js +70 -0
  9. package/lib/crystal/core/cellAtoms.js.map +1 -0
  10. package/lib/crystal/core/cellBonds.d.ts +21 -0
  11. package/lib/crystal/core/cellBonds.d.ts.map +1 -0
  12. package/lib/crystal/core/cellBonds.js +100 -0
  13. package/lib/crystal/core/cellBonds.js.map +1 -0
  14. package/lib/crystal/core/cif/element.d.ts +9 -0
  15. package/lib/crystal/core/cif/element.d.ts.map +1 -0
  16. package/lib/crystal/core/cif/element.js +41 -0
  17. package/lib/crystal/core/cif/element.js.map +1 -0
  18. package/lib/crystal/core/cif/index.d.ts +4 -0
  19. package/lib/crystal/core/cif/index.d.ts.map +1 -0
  20. package/lib/crystal/core/cif/index.js +3 -0
  21. package/lib/crystal/core/cif/index.js.map +1 -0
  22. package/lib/crystal/core/cif/number.d.ts +27 -0
  23. package/lib/crystal/core/cif/number.d.ts.map +1 -0
  24. package/lib/crystal/core/cif/number.js +57 -0
  25. package/lib/crystal/core/cif/number.js.map +1 -0
  26. package/lib/crystal/core/cif/read.d.ts +12 -0
  27. package/lib/crystal/core/cif/read.d.ts.map +1 -0
  28. package/lib/crystal/core/cif/read.js +183 -0
  29. package/lib/crystal/core/cif/read.js.map +1 -0
  30. package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
  31. package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
  32. package/lib/crystal/core/cif/readGeometry.js +93 -0
  33. package/lib/crystal/core/cif/readGeometry.js.map +1 -0
  34. package/lib/crystal/core/cif/tags.d.ts +62 -0
  35. package/lib/crystal/core/cif/tags.d.ts.map +1 -0
  36. package/lib/crystal/core/cif/tags.js +115 -0
  37. package/lib/crystal/core/cif/tags.js.map +1 -0
  38. package/lib/crystal/core/cif/types.d.ts +158 -0
  39. package/lib/crystal/core/cif/types.d.ts.map +1 -0
  40. package/lib/crystal/core/cif/types.js +2 -0
  41. package/lib/crystal/core/cif/types.js.map +1 -0
  42. package/lib/crystal/core/components.d.ts +56 -0
  43. package/lib/crystal/core/components.d.ts.map +1 -0
  44. package/lib/crystal/core/components.js +132 -0
  45. package/lib/crystal/core/components.js.map +1 -0
  46. package/lib/crystal/core/covalentRadii.d.ts +24 -0
  47. package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
  48. package/lib/crystal/core/covalentRadii.js +55 -0
  49. package/lib/crystal/core/covalentRadii.js.map +1 -0
  50. package/lib/crystal/core/disorder.d.ts +59 -0
  51. package/lib/crystal/core/disorder.d.ts.map +1 -0
  52. package/lib/crystal/core/disorder.js +168 -0
  53. package/lib/crystal/core/disorder.js.map +1 -0
  54. package/lib/crystal/core/expand.d.ts +62 -0
  55. package/lib/crystal/core/expand.d.ts.map +1 -0
  56. package/lib/crystal/core/expand.js +61 -0
  57. package/lib/crystal/core/expand.js.map +1 -0
  58. package/lib/crystal/core/index.d.ts +20 -0
  59. package/lib/crystal/core/index.d.ts.map +1 -0
  60. package/lib/crystal/core/index.js +13 -0
  61. package/lib/crystal/core/index.js.map +1 -0
  62. package/lib/crystal/core/moleculeOf.d.ts +31 -0
  63. package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
  64. package/lib/crystal/core/moleculeOf.js +128 -0
  65. package/lib/crystal/core/moleculeOf.js.map +1 -0
  66. package/lib/crystal/core/moleculeTypes.d.ts +80 -0
  67. package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
  68. package/lib/crystal/core/moleculeTypes.js +2 -0
  69. package/lib/crystal/core/moleculeTypes.js.map +1 -0
  70. package/lib/crystal/core/molecules.d.ts +39 -0
  71. package/lib/crystal/core/molecules.d.ts.map +1 -0
  72. package/lib/crystal/core/molecules.js +106 -0
  73. package/lib/crystal/core/molecules.js.map +1 -0
  74. package/lib/crystal/core/operations.d.ts +19 -0
  75. package/lib/crystal/core/operations.d.ts.map +1 -0
  76. package/lib/crystal/core/operations.js +68 -0
  77. package/lib/crystal/core/operations.js.map +1 -0
  78. package/lib/crystal/core/packing.d.ts +43 -0
  79. package/lib/crystal/core/packing.d.ts.map +1 -0
  80. package/lib/crystal/core/packing.js +89 -0
  81. package/lib/crystal/core/packing.js.map +1 -0
  82. package/lib/crystal/core/periodicBonds.d.ts +57 -0
  83. package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
  84. package/lib/crystal/core/periodicBonds.js +167 -0
  85. package/lib/crystal/core/periodicBonds.js.map +1 -0
  86. package/lib/crystal/core/resolve.d.ts +61 -0
  87. package/lib/crystal/core/resolve.d.ts.map +1 -0
  88. package/lib/crystal/core/resolve.js +149 -0
  89. package/lib/crystal/core/resolve.js.map +1 -0
  90. package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
  91. package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
  92. package/lib/crystal/core/spaceGroups/index.js +4 -0
  93. package/lib/crystal/core/spaceGroups/index.js.map +1 -0
  94. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
  95. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
  96. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
  97. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
  98. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
  99. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
  100. package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
  101. package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
  102. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
  103. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
  104. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
  105. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
  106. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
  107. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
  108. package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
  109. package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
  110. package/lib/crystal/core/symmetry/group.d.ts +15 -0
  111. package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
  112. package/lib/crystal/core/symmetry/group.js +37 -0
  113. package/lib/crystal/core/symmetry/group.js.map +1 -0
  114. package/lib/crystal/core/symmetry/index.d.ts +8 -0
  115. package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
  116. package/lib/crystal/core/symmetry/index.js +6 -0
  117. package/lib/crystal/core/symmetry/index.js.map +1 -0
  118. package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
  119. package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
  120. package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
  121. package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
  122. package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
  123. package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
  124. package/lib/crystal/core/symmetry/lattice.js +113 -0
  125. package/lib/crystal/core/symmetry/lattice.js.map +1 -0
  126. package/lib/crystal/core/symmetry/operation.d.ts +91 -0
  127. package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
  128. package/lib/crystal/core/symmetry/operation.js +184 -0
  129. package/lib/crystal/core/symmetry/operation.js.map +1 -0
  130. package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
  131. package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
  132. package/lib/crystal/core/symmetry/parseOperation.js +145 -0
  133. package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
  134. package/lib/crystal/core/symmetry/types.d.ts +29 -0
  135. package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
  136. package/lib/crystal/core/symmetry/types.js +5 -0
  137. package/lib/crystal/core/symmetry/types.js.map +1 -0
  138. package/lib/crystal/core/symmetryClasses.d.ts +28 -0
  139. package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
  140. package/lib/crystal/core/symmetryClasses.js +93 -0
  141. package/lib/crystal/core/symmetryClasses.js.map +1 -0
  142. package/lib/crystal.d.ts +12 -0
  143. package/lib/crystal.d.ts.map +1 -0
  144. package/lib/crystal.js +12 -0
  145. package/lib/crystal.js.map +1 -0
  146. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  147. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  148. package/lib/crystal3d/core/cellClip.js +198 -0
  149. package/lib/crystal3d/core/cellClip.js.map +1 -0
  150. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  151. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  152. package/lib/crystal3d/core/cellGeometry.js +153 -0
  153. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  154. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  155. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  156. package/lib/crystal3d/core/cellStack.js +79 -0
  157. package/lib/crystal3d/core/cellStack.js.map +1 -0
  158. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  159. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  160. package/lib/crystal3d/core/crystalView.js +48 -0
  161. package/lib/crystal3d/core/crystalView.js.map +1 -0
  162. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  163. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  164. package/lib/crystal3d/core/drawingSet.js +63 -0
  165. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  166. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  167. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  168. package/lib/crystal3d/core/elementDrawing.js +100 -0
  169. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  170. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  171. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  172. package/lib/crystal3d/core/elementExtent.js +56 -0
  173. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  174. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  175. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  176. package/lib/crystal3d/core/elementLabels.js +99 -0
  177. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  178. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  179. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  180. package/lib/crystal3d/core/elementShapes.js +115 -0
  181. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  182. package/lib/crystal3d/core/frame.d.ts +36 -0
  183. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  184. package/lib/crystal3d/core/frame.js +35 -0
  185. package/lib/crystal3d/core/frame.js.map +1 -0
  186. package/lib/crystal3d/core/framing.d.ts +41 -0
  187. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  188. package/lib/crystal3d/core/framing.js +79 -0
  189. package/lib/crystal3d/core/framing.js.map +1 -0
  190. package/lib/crystal3d/core/index.d.ts +42 -0
  191. package/lib/crystal3d/core/index.d.ts.map +1 -0
  192. package/lib/crystal3d/core/index.js +29 -0
  193. package/lib/crystal3d/core/index.js.map +1 -0
  194. package/lib/crystal3d/core/labelText.d.ts +19 -0
  195. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  196. package/lib/crystal3d/core/labelText.js +42 -0
  197. package/lib/crystal3d/core/labelText.js.map +1 -0
  198. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  199. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  200. package/lib/crystal3d/core/latticeBasis.js +89 -0
  201. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  202. package/lib/crystal3d/core/mat3.d.ts +68 -0
  203. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  204. package/lib/crystal3d/core/mat3.js +146 -0
  205. package/lib/crystal3d/core/mat3.js.map +1 -0
  206. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  207. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  208. package/lib/crystal3d/core/operationMatrix.js +172 -0
  209. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  210. package/lib/crystal3d/core/orientation.d.ts +62 -0
  211. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  212. package/lib/crystal3d/core/orientation.js +166 -0
  213. package/lib/crystal3d/core/orientation.js.map +1 -0
  214. package/lib/crystal3d/core/palette.d.ts +24 -0
  215. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  216. package/lib/crystal3d/core/palette.js +34 -0
  217. package/lib/crystal3d/core/palette.js.map +1 -0
  218. package/lib/crystal3d/core/primitives.d.ts +133 -0
  219. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  220. package/lib/crystal3d/core/primitives.js +80 -0
  221. package/lib/crystal3d/core/primitives.js.map +1 -0
  222. package/lib/crystal3d/core/structureText.d.ts +20 -0
  223. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  224. package/lib/crystal3d/core/structureText.js +37 -0
  225. package/lib/crystal3d/core/structureText.js.map +1 -0
  226. package/lib/crystal3d/core/supercell.d.ts +20 -0
  227. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  228. package/lib/crystal3d/core/supercell.js +35 -0
  229. package/lib/crystal3d/core/supercell.js.map +1 -0
  230. package/lib/crystal3d/core/types.d.ts +166 -0
  231. package/lib/crystal3d/core/types.d.ts.map +1 -0
  232. package/lib/crystal3d/core/types.js +10 -0
  233. package/lib/crystal3d/core/types.js.map +1 -0
  234. package/lib/crystal3d/core/vec3.d.ts +75 -0
  235. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  236. package/lib/crystal3d/core/vec3.js +119 -0
  237. package/lib/crystal3d/core/vec3.js.map +1 -0
  238. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  239. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  240. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  241. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  242. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  243. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  244. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  245. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  246. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  247. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  248. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  249. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  250. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  251. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  252. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  253. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  254. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  255. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  256. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  257. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  258. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  259. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  260. package/lib/crystal3d/ui/crystalScene.js +10 -0
  261. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  262. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  263. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  264. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  265. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  266. package/lib/crystal3d/ui/index.d.ts +16 -0
  267. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  268. package/lib/crystal3d/ui/index.js +12 -0
  269. package/lib/crystal3d/ui/index.js.map +1 -0
  270. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  271. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  272. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  273. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  274. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  275. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  276. package/lib/crystal3d/viewer/animate.js +83 -0
  277. package/lib/crystal3d/viewer/animate.js.map +1 -0
  278. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  279. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  280. package/lib/crystal3d/viewer/camera.js +103 -0
  281. package/lib/crystal3d/viewer/camera.js.map +1 -0
  282. package/lib/crystal3d/viewer/index.d.ts +13 -0
  283. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  284. package/lib/crystal3d/viewer/index.js +8 -0
  285. package/lib/crystal3d/viewer/index.js.map +1 -0
  286. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  287. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  288. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  289. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  290. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  291. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  292. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  293. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  294. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  295. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  296. package/lib/crystal3d/viewer/plugin.js +181 -0
  297. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  298. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  299. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  300. package/lib/crystal3d/viewer/renderCell.js +53 -0
  301. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  302. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  303. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  304. package/lib/crystal3d/viewer/renderElements.js +77 -0
  305. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  306. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  307. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  308. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  309. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  310. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  311. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  312. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  313. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  314. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  315. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  316. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  317. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  318. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  319. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  320. package/lib/crystal3d/viewer/textLayer.js +59 -0
  321. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  322. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  323. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  324. package/lib/crystal3d/viewer/viewer.js +157 -0
  325. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  326. package/lib/crystal3d.d.ts +12 -0
  327. package/lib/crystal3d.d.ts.map +1 -0
  328. package/lib/crystal3d.js +12 -0
  329. package/lib/crystal3d.js.map +1 -0
  330. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  331. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  332. package/lib/locales/de.json +19 -1
  333. package/lib/locales/en.json +19 -1
  334. package/lib/locales/es.json +19 -1
  335. package/lib/locales/fr.json +19 -1
  336. package/lib/locales/it.json +19 -1
  337. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  338. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  339. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  340. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  341. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  342. package/lib/molstar/bonds/bondRule.js +23 -0
  343. package/lib/molstar/bonds/bondRule.js.map +1 -0
  344. package/lib/molstar/bonds/index.d.ts +9 -0
  345. package/lib/molstar/bonds/index.d.ts.map +1 -0
  346. package/lib/molstar/bonds/index.js +9 -0
  347. package/lib/molstar/bonds/index.js.map +1 -0
  348. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  349. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  350. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  351. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  352. package/lib/molstar/ui/index.d.ts +10 -0
  353. package/lib/molstar/ui/index.d.ts.map +1 -0
  354. package/lib/molstar/ui/index.js +8 -0
  355. package/lib/molstar/ui/index.js.map +1 -0
  356. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  357. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  358. package/lib/molstar/ui/useMolstarTools.js +36 -0
  359. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  360. package/package.json +4 -1
  361. package/src/crystal/core/bondGrid.ts +98 -0
  362. package/src/crystal/core/cellAtoms.ts +106 -0
  363. package/src/crystal/core/cellBonds.ts +121 -0
  364. package/src/crystal/core/cif/element.ts +40 -0
  365. package/src/crystal/core/cif/index.ts +12 -0
  366. package/src/crystal/core/cif/number.ts +62 -0
  367. package/src/crystal/core/cif/read.ts +218 -0
  368. package/src/crystal/core/cif/readGeometry.ts +104 -0
  369. package/src/crystal/core/cif/tags.ts +143 -0
  370. package/src/crystal/core/cif/types.ts +164 -0
  371. package/src/crystal/core/components.ts +183 -0
  372. package/src/crystal/core/covalentRadii.ts +56 -0
  373. package/src/crystal/core/disorder.ts +190 -0
  374. package/src/crystal/core/expand.ts +105 -0
  375. package/src/crystal/core/index.ts +46 -0
  376. package/src/crystal/core/moleculeOf.ts +169 -0
  377. package/src/crystal/core/moleculeTypes.ts +85 -0
  378. package/src/crystal/core/molecules.ts +128 -0
  379. package/src/crystal/core/operations.ts +79 -0
  380. package/src/crystal/core/packing.ts +116 -0
  381. package/src/crystal/core/periodicBonds.ts +234 -0
  382. package/src/crystal/core/resolve.ts +187 -0
  383. package/src/crystal/core/spaceGroups/index.ts +16 -0
  384. package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
  385. package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
  386. package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
  387. package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
  388. package/src/crystal/core/symmetry/group.ts +42 -0
  389. package/src/crystal/core/symmetry/index.ts +23 -0
  390. package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
  391. package/src/crystal/core/symmetry/lattice.ts +152 -0
  392. package/src/crystal/core/symmetry/operation.ts +223 -0
  393. package/src/crystal/core/symmetry/parseOperation.ts +180 -0
  394. package/src/crystal/core/symmetry/types.ts +32 -0
  395. package/src/crystal/core/symmetryClasses.ts +105 -0
  396. package/src/crystal.ts +12 -0
  397. package/src/crystal3d/core/cellClip.ts +229 -0
  398. package/src/crystal3d/core/cellGeometry.ts +193 -0
  399. package/src/crystal3d/core/cellStack.ts +87 -0
  400. package/src/crystal3d/core/crystalView.ts +114 -0
  401. package/src/crystal3d/core/drawingSet.ts +71 -0
  402. package/src/crystal3d/core/elementDrawing.ts +147 -0
  403. package/src/crystal3d/core/elementExtent.ts +81 -0
  404. package/src/crystal3d/core/elementLabels.ts +130 -0
  405. package/src/crystal3d/core/elementShapes.ts +141 -0
  406. package/src/crystal3d/core/frame.ts +56 -0
  407. package/src/crystal3d/core/framing.ts +101 -0
  408. package/src/crystal3d/core/index.ts +132 -0
  409. package/src/crystal3d/core/labelText.ts +44 -0
  410. package/src/crystal3d/core/latticeBasis.ts +110 -0
  411. package/src/crystal3d/core/mat3.ts +163 -0
  412. package/src/crystal3d/core/operationMatrix.ts +255 -0
  413. package/src/crystal3d/core/orientation.ts +229 -0
  414. package/src/crystal3d/core/palette.ts +43 -0
  415. package/src/crystal3d/core/primitives.ts +183 -0
  416. package/src/crystal3d/core/structureText.ts +43 -0
  417. package/src/crystal3d/core/supercell.ts +40 -0
  418. package/src/crystal3d/core/types.ts +186 -0
  419. package/src/crystal3d/core/vec3.ts +127 -0
  420. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  421. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  422. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  423. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  424. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  425. package/src/crystal3d/ui/crystalScene.ts +100 -0
  426. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  427. package/src/crystal3d/ui/index.ts +20 -0
  428. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  429. package/src/crystal3d/viewer/animate.ts +113 -0
  430. package/src/crystal3d/viewer/camera.ts +139 -0
  431. package/src/crystal3d/viewer/index.ts +13 -0
  432. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  433. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  434. package/src/crystal3d/viewer/plugin.ts +258 -0
  435. package/src/crystal3d/viewer/renderCell.ts +98 -0
  436. package/src/crystal3d/viewer/renderElements.ts +121 -0
  437. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  438. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  439. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  440. package/src/crystal3d/viewer/textLayer.ts +85 -0
  441. package/src/crystal3d/viewer/viewer.ts +207 -0
  442. package/src/crystal3d.ts +12 -0
  443. package/src/locales/de.json +19 -1
  444. package/src/locales/en.json +19 -1
  445. package/src/locales/es.json +19 -1
  446. package/src/locales/fr.json +19 -1
  447. package/src/locales/it.json +19 -1
  448. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  449. package/src/molstar/bonds/bondRule.ts +34 -0
  450. package/src/molstar/bonds/index.ts +9 -0
  451. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  452. package/src/molstar/ui/index.ts +14 -0
  453. package/src/molstar/ui/useMolstarTools.ts +98 -0
  454. package/styles/chrome.css +90 -0
package/src/crystal.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Crystal structures: a CIF read, its asymmetric unit expanded by the space
3
+ * group, and the cell turned into whole, symmetry-independent molecules with
4
+ * Cartesian coordinates — or into the network a salt, a mineral or a metal is.
5
+ *
6
+ * Its own door because it carries the 230 space groups and a CIF reader, which
7
+ * a page that never opens a crystal must not download. It loads neither React
8
+ * nor openchemlib nor molstar, so a Node batch reading a whole database imports
9
+ * it as it is.
10
+ */
11
+
12
+ export * from './crystal/core/index.ts';
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Where an element meets the cell it belongs to.
3
+ *
4
+ * A symmetry element is unbounded — an axis is a whole line, a plane a whole
5
+ * plane — so drawing one means choosing how much of it to show. A rod of some
6
+ * arbitrary length centred on whatever point the decomposition happened to
7
+ * report reads as a floating stick; the same axis cut off where it enters and
8
+ * leaves the box reads as a diagonal of the cell, which is what it is.
9
+ *
10
+ * Everything here works in fractional coordinates, where the cell is the unit
11
+ * cube however oblique it is in ångström, and hands the answer back in
12
+ * Cartesian ångström.
13
+ */
14
+
15
+ import type { Lattice } from '../../crystal/core/symmetry/lattice.ts';
16
+
17
+ import { planeFrame } from './frame.ts';
18
+ import {
19
+ normalToFractional,
20
+ toCartesian,
21
+ toFractional,
22
+ } from './latticeBasis.ts';
23
+ import type { Point3 } from './types.ts';
24
+ import type { Vec3 } from './vec3.ts';
25
+ import {
26
+ addVectors,
27
+ dotProduct,
28
+ scaleVector,
29
+ subtractVectors,
30
+ } from './vec3.ts';
31
+
32
+ /** The piece of a line that lies inside the cell. */
33
+ export interface CellSegment {
34
+ readonly start: Point3;
35
+ readonly end: Point3;
36
+ }
37
+
38
+ /**
39
+ * Where a line enters and leaves the cell.
40
+ * @param lattice - The cell it is cut against.
41
+ * @param point - A point of the line, Cartesian ångström.
42
+ * @param direction - Its direction, Cartesian; need not be normalised.
43
+ * @param cells - How many cells the box spans along each axis.
44
+ * @default 1
45
+ * @returns The two ends, or `null` when the line misses the box, and when the
46
+ * direction is too short to say which way the line runs.
47
+ */
48
+ export function clipLineToCell(
49
+ lattice: Lattice,
50
+ point: Point3,
51
+ direction: Point3,
52
+ cells = 1,
53
+ ): CellSegment | null {
54
+ const origin = toFractional(lattice, point);
55
+ const along = toFractional(lattice, direction);
56
+ let enter = Number.NEGATIVE_INFINITY;
57
+ let leave = Number.POSITIVE_INFINITY;
58
+ for (let axis = 0; axis < 3; axis++) {
59
+ const speed = along[axis] ?? 0;
60
+ const start = origin[axis] ?? 0;
61
+ if (Math.abs(speed) < PARALLEL) {
62
+ if (start < -SLACK || start > cells + SLACK) return null;
63
+ continue;
64
+ }
65
+ const first = (0 - start) / speed;
66
+ const second = (cells - start) / speed;
67
+ enter = Math.max(enter, Math.min(first, second));
68
+ leave = Math.min(leave, Math.max(first, second));
69
+ }
70
+ // Every axis was parallel, so there is no line to cut: the ends would come
71
+ // back as `0 · ∞`, which is `NaN` in every coordinate and poisons the scene.
72
+ if (!Number.isFinite(enter) || !Number.isFinite(leave)) return null;
73
+ if (!(leave > enter)) return null;
74
+ return {
75
+ start: toCartesian(lattice, stepAlong(origin, along, enter)),
76
+ end: toCartesian(lattice, stepAlong(origin, along, leave)),
77
+ };
78
+ }
79
+
80
+ /**
81
+ * The polygon a plane cuts out of the cell.
82
+ *
83
+ * The corners come back in order around the plane, so a triangle fan over them
84
+ * is the face itself and a rod between each neighbouring pair is its rim.
85
+ * @param lattice - The cell it is cut against.
86
+ * @param point - A point of the plane, Cartesian ångström.
87
+ * @param normal - Its normal, Cartesian; need not be normalised.
88
+ * @param cells - How many cells the box spans along each axis.
89
+ * @default 1
90
+ * @returns The corners, Cartesian ångström, or an empty list when the plane
91
+ * misses the box or only touches an edge or a corner of it.
92
+ */
93
+ export function cellSection(
94
+ lattice: Lattice,
95
+ point: Point3,
96
+ normal: Point3,
97
+ cells = 1,
98
+ ): Point3[] {
99
+ const origin = toFractional(lattice, point);
100
+ // A Cartesian normal n reads in fractional coordinates as Mᵀn, which is what
101
+ // keeps the plane in place in a cell that is not orthogonal.
102
+ const along = normalToFractional(lattice, normal);
103
+ const corners = cubeCorners(cells);
104
+ const heights: number[] = [];
105
+ for (const corner of corners) {
106
+ heights.push(dotProduct(along, subtractVectors(corner, origin)));
107
+ }
108
+ const hits: Vec3[] = [];
109
+ for (let index = 0; index < corners.length; index++) {
110
+ const corner = corners[index];
111
+ if (corner !== undefined && Math.abs(heights[index] ?? 0) < FLAT) {
112
+ hits.push(corner);
113
+ }
114
+ }
115
+ for (const [from, to] of CUBE_EDGES) {
116
+ const low = heights[from] ?? 0;
117
+ const high = heights[to] ?? 0;
118
+ if (Math.abs(low) < FLAT || Math.abs(high) < FLAT) continue;
119
+ if (low > 0 === high > 0) continue;
120
+ const start = corners[from];
121
+ const end = corners[to];
122
+ if (start === undefined || end === undefined) continue;
123
+ const fraction = low / (low - high);
124
+ hits.push(stepAlong(start, subtractVectors(end, start), fraction));
125
+ }
126
+ const points: Point3[] = [];
127
+ for (const hit of hits) points.push(toCartesian(lattice, hit));
128
+ const section = dedupe(points);
129
+ if (section.length < 3) return [];
130
+ return orderAroundPlane(section, normal);
131
+ }
132
+
133
+ function stepAlong(origin: Vec3, direction: Vec3, distance: number): Vec3 {
134
+ return addVectors(origin, scaleVector(direction, distance));
135
+ }
136
+
137
+ /**
138
+ * The eight corners of the box, in the order {@link CUBE_EDGES} indexes.
139
+ * @param cells - How many cells the box spans along each axis.
140
+ * @returns The corners, in cell fractions.
141
+ */
142
+ function cubeCorners(cells: number): Vec3[] {
143
+ const corners: Vec3[] = [];
144
+ for (let i = 0; i < 2; i++) {
145
+ for (let j = 0; j < 2; j++) {
146
+ for (let k = 0; k < 2; k++) {
147
+ corners.push([i * cells, j * cells, k * cells]);
148
+ }
149
+ }
150
+ }
151
+ return corners;
152
+ }
153
+
154
+ /** Corners that differ in exactly one coordinate are joined by an edge. */
155
+ const CUBE_EDGES: ReadonlyArray<readonly [number, number]> = [
156
+ [0, 1],
157
+ [0, 2],
158
+ [0, 4],
159
+ [1, 3],
160
+ [1, 5],
161
+ [2, 3],
162
+ [2, 6],
163
+ [3, 7],
164
+ [4, 5],
165
+ [4, 6],
166
+ [5, 7],
167
+ [6, 7],
168
+ ];
169
+
170
+ /**
171
+ * The same corners, walked round the plane rather than found in cube order.
172
+ * @param points - The corners, Cartesian ångström.
173
+ * @param normal - The plane's normal, Cartesian.
174
+ * @returns The corners, in order around the plane.
175
+ */
176
+ function orderAroundPlane(points: readonly Point3[], normal: Point3): Point3[] {
177
+ const { major, minor } = planeFrame(normal);
178
+ let centre: Point3 = [0, 0, 0];
179
+ for (const point of points) centre = addVectors(centre, point);
180
+ centre = scaleVector(centre, 1 / points.length);
181
+ const turned: Array<{ point: Point3; angle: number }> = [];
182
+ for (const point of points) {
183
+ const offset = subtractVectors(point, centre);
184
+ turned.push({
185
+ point,
186
+ angle: Math.atan2(dotProduct(offset, minor), dotProduct(offset, major)),
187
+ });
188
+ }
189
+ turned.sort((left, right) => left.angle - right.angle);
190
+ const ordered: Point3[] = [];
191
+ for (const entry of turned) ordered.push(entry.point);
192
+ return ordered;
193
+ }
194
+
195
+ /**
196
+ * A corner the plane passes through is found once per edge that meets it.
197
+ * @param points - The corners found, Cartesian ångström.
198
+ * @returns Each corner once.
199
+ */
200
+ function dedupe(points: readonly Point3[]): Point3[] {
201
+ const kept: Point3[] = [];
202
+ for (const point of points) {
203
+ let seen = false;
204
+ for (const other of kept) {
205
+ if (
206
+ Math.abs((point[0] ?? 0) - (other[0] ?? 0)) < SAME &&
207
+ Math.abs((point[1] ?? 0) - (other[1] ?? 0)) < SAME &&
208
+ Math.abs((point[2] ?? 0) - (other[2] ?? 0)) < SAME
209
+ ) {
210
+ seen = true;
211
+ break;
212
+ }
213
+ }
214
+ if (!seen) kept.push(point);
215
+ }
216
+ return kept;
217
+ }
218
+
219
+ /** Below this, a line runs along a face rather than through it. */
220
+ const PARALLEL = 1e-9;
221
+
222
+ /** How far outside the box a parallel line may still count as inside it. */
223
+ const SLACK = 1e-9;
224
+
225
+ /** Below this, in cell fractions, a corner lies on the plane. */
226
+ const FLAT = 1e-9;
227
+
228
+ /** Below this, in ångström, two corners are the same corner. */
229
+ const SAME = 1e-6;
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The unit cell as lines in space: its three edge vectors, the twelve edges of
3
+ * one box, and the boxes of a supercell.
4
+ *
5
+ * The cell is drawn here rather than by molstar's own unit-cell shape, because
6
+ * the site hands molstar no space group at all — it has already applied its own
7
+ * operations — and because an n×n×n stack of boxes is not something that shape
8
+ * can draw.
9
+ */
10
+
11
+ import { cartesianMatrix } from '../../crystal/core/symmetry/lattice.ts';
12
+
13
+ import type { CellRepeat, Point3, UnitCell } from './types.ts';
14
+ import type { Vec3 } from './vec3.ts';
15
+ import { addVectors, scaleVector } from './vec3.ts';
16
+
17
+ /** A segment of the drawn cell, Cartesian ångström. */
18
+ export interface CellEdge {
19
+ readonly start: Point3;
20
+ readonly end: Point3;
21
+ }
22
+
23
+ /**
24
+ * The Cartesian components of a, b and c.
25
+ *
26
+ * The convention is the PDB one — a along x, b in the xy plane — which is the
27
+ * one `src/symmetry/core` uses and the one every CIF consumer assumes.
28
+ * @param cell - The six cell parameters.
29
+ * @returns The three edge vectors, in ångström.
30
+ * @throws {RangeError} When the three angles describe no cell.
31
+ */
32
+ export function cellAxes(cell: UnitCell): [Vec3, Vec3, Vec3] {
33
+ const matrix = cartesianMatrix(cell);
34
+ return [columnOf(matrix, 0), columnOf(matrix, 1), columnOf(matrix, 2)];
35
+ }
36
+
37
+ /**
38
+ * Where one fractional point of one cell of the stack sits.
39
+ * @param axes - The cell's edge vectors.
40
+ * @param fractional - The point, in cell fractions.
41
+ * @returns Its Cartesian position, ångström.
42
+ */
43
+ export function cellPoint(
44
+ axes: readonly [Vec3, Vec3, Vec3],
45
+ fractional: readonly [number, number, number],
46
+ ): Point3 {
47
+ return addVectors(
48
+ addVectors(
49
+ scaleVector(axes[0], fractional[0]),
50
+ scaleVector(axes[1], fractional[1]),
51
+ ),
52
+ scaleVector(axes[2], fractional[2]),
53
+ );
54
+ }
55
+
56
+ /**
57
+ * The lattice translations of an n×n×n stack, one per cell, in reading order.
58
+ * @param axes - The cell's edge vectors.
59
+ * @param repeat - Cells along a, b and c; anything below 1 counts as 1.
60
+ * @returns One translation per cell, the first of them zero.
61
+ */
62
+ export function latticeShifts(
63
+ axes: readonly [Vec3, Vec3, Vec3],
64
+ repeat: CellRepeat,
65
+ ): Point3[] {
66
+ const counts = clampRepeat(repeat);
67
+ const shifts: Point3[] = [];
68
+ for (let i = 0; i < counts[0]; i++) {
69
+ for (let j = 0; j < counts[1]; j++) {
70
+ for (let k = 0; k < counts[2]; k++) {
71
+ shifts.push(cellPoint(axes, [i, j, k]));
72
+ }
73
+ }
74
+ }
75
+ return shifts;
76
+ }
77
+
78
+ /**
79
+ * Every edge of every cell of the stack.
80
+ * @param cell - The six cell parameters.
81
+ * @param repeat - Cells along a, b and c.
82
+ * @returns Twelve edges per cell.
83
+ * @throws {RangeError} When the three angles describe no cell.
84
+ */
85
+ export function cellEdges(
86
+ cell: UnitCell,
87
+ repeat: CellRepeat = [1, 1, 1],
88
+ ): CellEdge[] {
89
+ const axes = cellAxes(cell);
90
+ const edges: CellEdge[] = [];
91
+ for (const shift of latticeShifts(axes, repeat)) {
92
+ for (const [from, to] of BOX_EDGES) {
93
+ edges.push({
94
+ start: addVectors(shift, cellPoint(axes, from)),
95
+ end: addVectors(shift, cellPoint(axes, to)),
96
+ });
97
+ }
98
+ }
99
+ return edges;
100
+ }
101
+
102
+ /**
103
+ * Where the a, b and c letters sit on the box at the origin.
104
+ * @param cell - The six cell parameters.
105
+ * @param reach - How far along each edge, as a fraction of it.
106
+ * @returns Three points, for a, b and c in that order.
107
+ * @throws {RangeError} When the three angles describe no cell.
108
+ */
109
+ export function cellAxisLabelPoints(
110
+ cell: UnitCell,
111
+ reach = 0.55,
112
+ ): [Point3, Point3, Point3] {
113
+ const [a, b, c] = cellAxes(cell);
114
+ return [scaleVector(a, reach), scaleVector(b, reach), scaleVector(c, reach)];
115
+ }
116
+
117
+ /**
118
+ * Each count, rounded down and never below one.
119
+ * @param repeat - Cells along a, b and c.
120
+ * @returns The counts, whole and at least one.
121
+ */
122
+ export function clampRepeat(repeat: CellRepeat): CellRepeat {
123
+ return [
124
+ Math.max(1, Math.floor(repeat[0])),
125
+ Math.max(1, Math.floor(repeat[1])),
126
+ Math.max(1, Math.floor(repeat[2])),
127
+ ];
128
+ }
129
+
130
+ function columnOf(matrix: readonly number[][], column: number): Vec3 {
131
+ return [
132
+ matrix[0]?.[column] ?? 0,
133
+ matrix[1]?.[column] ?? 0,
134
+ matrix[2]?.[column] ?? 0,
135
+ ];
136
+ }
137
+
138
+ /** The twelve edges of a box, as pairs of its eight fractional corners. */
139
+ const BOX_EDGES: ReadonlyArray<
140
+ readonly [
141
+ readonly [number, number, number],
142
+ readonly [number, number, number],
143
+ ]
144
+ > = [
145
+ [
146
+ [0, 0, 0],
147
+ [1, 0, 0],
148
+ ],
149
+ [
150
+ [0, 1, 0],
151
+ [1, 1, 0],
152
+ ],
153
+ [
154
+ [0, 0, 1],
155
+ [1, 0, 1],
156
+ ],
157
+ [
158
+ [0, 1, 1],
159
+ [1, 1, 1],
160
+ ],
161
+ [
162
+ [0, 0, 0],
163
+ [0, 1, 0],
164
+ ],
165
+ [
166
+ [1, 0, 0],
167
+ [1, 1, 0],
168
+ ],
169
+ [
170
+ [0, 0, 1],
171
+ [0, 1, 1],
172
+ ],
173
+ [
174
+ [1, 0, 1],
175
+ [1, 1, 1],
176
+ ],
177
+ [
178
+ [0, 0, 0],
179
+ [0, 0, 1],
180
+ ],
181
+ [
182
+ [1, 0, 0],
183
+ [1, 0, 1],
184
+ ],
185
+ [
186
+ [0, 1, 0],
187
+ [0, 1, 1],
188
+ ],
189
+ [
190
+ [1, 1, 0],
191
+ [1, 1, 1],
192
+ ],
193
+ ];
@@ -0,0 +1,87 @@
1
+ /**
2
+ * More than one cell of it.
3
+ *
4
+ * The stack is n×n×n and starts every axis at cell 0. The atoms themselves are
5
+ * repeated by `supercellAtoms`, which works in Cartesian ångström and is what
6
+ * the scene wants. What is here is what that does not say: the six parameters
7
+ * of the stack, how many atoms it holds, and how large a stack this machine
8
+ * should be asked to draw.
9
+ */
10
+
11
+ import type { UnitCell } from '../../crystal/core/symmetry/lattice.ts';
12
+
13
+ /**
14
+ * How many atoms a page draws before it stops growing the stack.
15
+ *
16
+ * The whole stack is rebuilt on every change — a cell edge, an atom, a group —
17
+ * so the ceiling is what keeps a 4×4×4 of a 192-operation group from freezing
18
+ * the page rather than drawing it.
19
+ */
20
+ export const SUPERCELL_ATOM_CAP = 20000;
21
+
22
+ /**
23
+ * The six parameters of the stack itself: the edges multiply, the angles do not.
24
+ *
25
+ * Its operations are **not** those of the cell it was built from — half of
26
+ * `P2₁/c`'s stop being symmetry operations the moment `a` is doubled — so
27
+ * nothing here claims a space group for it.
28
+ * @param cell - The cell being repeated.
29
+ * @param cells - Cells along each axis; anything below 1 counts as 1.
30
+ * @returns The stack's own cell.
31
+ */
32
+ export function repeatCell(cell: UnitCell, cells: number): UnitCell {
33
+ const count = wholeCells(cells);
34
+ return {
35
+ a: cell.a * count,
36
+ b: cell.b * count,
37
+ c: cell.c * count,
38
+ alpha: cell.alpha,
39
+ beta: cell.beta,
40
+ gamma: cell.gamma,
41
+ };
42
+ }
43
+
44
+ /**
45
+ * How many atoms the stack holds, without building it.
46
+ * @param atomsPerCell - Atoms in one cell, after the symmetry has filled it.
47
+ * @param cells - Cells along each axis.
48
+ * @returns Atoms in the whole stack.
49
+ */
50
+ export function repeatedAtomCount(atomsPerCell: number, cells: number): number {
51
+ const count = wholeCells(cells);
52
+ return atomsPerCell * count * count * count;
53
+ }
54
+
55
+ /**
56
+ * The largest stack at or below the one asked for that stays under the ceiling.
57
+ *
58
+ * A cell of eight atoms reaches 4×4×4 and a cell of a thousand does not, so the
59
+ * answer depends on the structure rather than on a number in the interface. The
60
+ * page says which it drew when it is not the one asked for.
61
+ * @param atomsPerCell - Atoms in one cell.
62
+ * @param cells - Cells along each axis the reader asked for.
63
+ * @param cap - Atoms the page will draw.
64
+ * @default SUPERCELL_ATOM_CAP
65
+ * @returns Cells along each axis, never below 1 even when one cell is already
66
+ * over the ceiling: a structure is drawn whole or not at all.
67
+ */
68
+ export function largestRepeatThatFits(
69
+ atomsPerCell: number,
70
+ cells: number,
71
+ cap = SUPERCELL_ATOM_CAP,
72
+ ): number {
73
+ for (let count = wholeCells(cells); count > 1; count--) {
74
+ if (repeatedAtomCount(atomsPerCell, count) <= cap) return count;
75
+ }
76
+ return 1;
77
+ }
78
+
79
+ /**
80
+ * Whole cells, one at the least.
81
+ * @param cells - Cells along each axis, as asked for.
82
+ * @returns The count rounded to a whole number, 1 when it is not finite.
83
+ */
84
+ function wholeCells(cells: number): number {
85
+ if (!Number.isFinite(cells)) return 1;
86
+ return Math.max(1, Math.round(cells));
87
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * What a crystal view draws, from the atoms of one cell: its molecules whole
3
+ * or the atoms the cell walls cut, repeated over as many cells as fit.
4
+ */
5
+
6
+ import { packMolecules } from '../../crystal/core/packing.ts';
7
+ import type {
8
+ BondLimit,
9
+ PackedAtom,
10
+ } from '../../crystal/core/periodicBonds.ts';
11
+ import type { Lattice } from '../../crystal/core/symmetry/lattice.ts';
12
+ import { fractionalToCartesian } from '../../crystal/core/symmetry/lattice.ts';
13
+
14
+ import { largestRepeatThatFits } from './cellStack.ts';
15
+ import { supercellAtoms } from './supercell.ts';
16
+ import type { ViewerAtom } from './types.ts';
17
+
18
+ /**
19
+ * How the cell is drawn: each molecule whole, in the cell its centre falls in,
20
+ * or every atom inside the cell, cut where its walls cut it.
21
+ */
22
+ export type CrystalPacking = 'molecules' | 'cell';
23
+
24
+ /** Every packing, in the order a control offers them. */
25
+ export const CRYSTAL_PACKINGS: readonly CrystalPacking[] = [
26
+ 'molecules',
27
+ 'cell',
28
+ ];
29
+
30
+ /** The cells along each axis a control offers, and a link may ask for. */
31
+ export const CELL_COUNT_RANGE = { minimum: 1, maximum: 4 } as const;
32
+
33
+ /** Options of {@link crystalView}. */
34
+ export interface CrystalViewOptions {
35
+ /**
36
+ * How the cell is drawn.
37
+ * @default 'molecules'
38
+ */
39
+ packing?: CrystalPacking;
40
+ /**
41
+ * Cells along each axis asked for; fewer are drawn when they would hold too
42
+ * many atoms.
43
+ * @default 1
44
+ */
45
+ cells?: number;
46
+ /**
47
+ * When two atoms are bonded, which is what completes a molecule. Pass the
48
+ * rule the viewer draws bonds with, so what is completed is what is joined.
49
+ */
50
+ bondLimit: BondLimit;
51
+ }
52
+
53
+ /** What {@link crystalView} found. */
54
+ export interface CrystalView {
55
+ /** The atoms to draw, Cartesian ångström, repeated over the cells. */
56
+ readonly atoms: ViewerAtom[];
57
+ /** Cells drawn along each axis: what was asked, or fewer. */
58
+ readonly cells: number;
59
+ /** Atoms in one cell, as drawn. */
60
+ readonly atomsPerCell: number;
61
+ /** Molecules in one cell, 0 when the cell is drawn as it is cut. */
62
+ readonly molecules: number;
63
+ /** Whether some atoms belong to a network running through the crystal. */
64
+ readonly extended: boolean;
65
+ }
66
+
67
+ /**
68
+ * The atoms a crystal view draws.
69
+ * @param cellAtoms - Every atom of one cell, fractional, wrapped into [0, 1).
70
+ * @param lattice - The cell they sit in.
71
+ * @param options - See {@link CrystalViewOptions}.
72
+ * @returns The atoms and what they hold.
73
+ */
74
+ export function crystalView(
75
+ cellAtoms: readonly PackedAtom[],
76
+ lattice: Lattice,
77
+ options: CrystalViewOptions,
78
+ ): CrystalView {
79
+ const { packing = 'molecules', cells: asked = 1, bondLimit } = options;
80
+ const packed =
81
+ packing === 'molecules'
82
+ ? packMolecules(cellAtoms, lattice, bondLimit)
83
+ : { atoms: cellAtoms, molecules: 0, extended: false };
84
+ const cells = largestRepeatThatFits(packed.atoms.length, asked);
85
+ const oneCell: ViewerAtom[] = [];
86
+ for (const atom of packed.atoms) {
87
+ const [x = 0, y = 0, z = 0] = fractionalToCartesian(lattice, atom.position);
88
+ oneCell.push({ element: atom.element, position: [x, y, z] });
89
+ }
90
+ return {
91
+ atoms: supercellAtoms(oneCell, lattice.cell, [cells, cells, cells]),
92
+ cells,
93
+ atomsPerCell: packed.atoms.length,
94
+ molecules: packed.molecules,
95
+ extended: packed.extended,
96
+ };
97
+ }
98
+
99
+ /** How a crystal view is set: what a control changes and a link may carry. */
100
+ export interface CrystalViewSettings {
101
+ /** How the cell is drawn. */
102
+ readonly packing: CrystalPacking;
103
+ /** Cells along each axis. */
104
+ readonly cells: number;
105
+ /** Whether the box of the unit cell is drawn. */
106
+ readonly unitCell: boolean;
107
+ }
108
+
109
+ /** One cell, its molecules whole, inside its box. */
110
+ export const DEFAULT_CRYSTAL_VIEW_SETTINGS: CrystalViewSettings = {
111
+ packing: 'molecules',
112
+ cells: 1,
113
+ unitCell: true,
114
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The set of symmetry elements currently drawn, kept as a list so a page can
3
+ * add and remove one at a time without rebuilding its own bookkeeping.
4
+ *
5
+ * The mesh behind them is rebuilt whole on every change — a handful of rods and
6
+ * squares costs nothing — but the *set* is edited, which is what lets a chip bar
7
+ * turn the mirrors off and leave the axes alone.
8
+ */
9
+
10
+ import type { SymmetryDrawing } from './types.ts';
11
+
12
+ /**
13
+ * Add the drawings, replacing any that carry an id already present.
14
+ * @param current - What is drawn now.
15
+ * @param incoming - What to add or replace.
16
+ * @returns The new set: the current order kept, anything genuinely new appended.
17
+ */
18
+ export function mergeDrawings(
19
+ current: readonly SymmetryDrawing[],
20
+ incoming: readonly SymmetryDrawing[],
21
+ ): SymmetryDrawing[] {
22
+ const replacements = new Map<string, SymmetryDrawing>();
23
+ for (const drawing of incoming) replacements.set(drawing.id, drawing);
24
+ const merged: SymmetryDrawing[] = [];
25
+ for (const drawing of current) {
26
+ merged.push(replacements.get(drawing.id) ?? drawing);
27
+ replacements.delete(drawing.id);
28
+ }
29
+ for (const drawing of incoming) {
30
+ const pending = replacements.get(drawing.id);
31
+ if (pending === undefined) continue;
32
+ merged.push(pending);
33
+ replacements.delete(drawing.id);
34
+ }
35
+ return merged;
36
+ }
37
+
38
+ /**
39
+ * Drop the drawings with these ids.
40
+ * @param current - What is drawn now.
41
+ * @param ids - Which to remove; an id that is not drawn is ignored.
42
+ * @returns The rest, in the order they were in.
43
+ */
44
+ export function withoutDrawings(
45
+ current: readonly SymmetryDrawing[],
46
+ ids: readonly string[],
47
+ ): SymmetryDrawing[] {
48
+ const dropped = new Set(ids);
49
+ const kept: SymmetryDrawing[] = [];
50
+ for (const drawing of current) {
51
+ if (!dropped.has(drawing.id)) kept.push(drawing);
52
+ }
53
+ return kept;
54
+ }
55
+
56
+ /**
57
+ * Whether two sets would draw the same thing, so an unchanged render is skipped.
58
+ * @param a - One set.
59
+ * @param b - The other.
60
+ * @returns Whether they hold the same drawings, in the same order.
61
+ */
62
+ export function sameDrawings(
63
+ a: readonly SymmetryDrawing[],
64
+ b: readonly SymmetryDrawing[],
65
+ ): boolean {
66
+ if (a.length !== b.length) return false;
67
+ for (let index = 0; index < a.length; index++) {
68
+ if (a[index] !== b[index]) return false;
69
+ }
70
+ return true;
71
+ }