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
@@ -0,0 +1,145 @@
1
+ import { matrixDeterminant } from "./integerMatrix.js";
2
+ import { AXIS_NAMES, TWELFTHS_PER_CELL } from "./types.js";
3
+ /** How far a decimal translation may sit from a twelfth and still be snapped to it. */
4
+ const DECIMAL_TOLERANCE = 5e-3;
5
+ /**
6
+ * Parse one coordinate triplet — `x,y,z`, `-x+1/2,-y,z+1/2`, `-x+y+2/3,-x+1/3,z+1/3`
7
+ * — into an exact operation.
8
+ *
9
+ * Accepts what the International Tables print and what a CIF may carry: any
10
+ * ordering of the terms (`1/2-x` as well as `-x+1/2`), a leading `+`, upper or
11
+ * lower case, decimal translations (`0.5+x`, `0.33333+y`), a translation of a
12
+ * whole cell, and whitespace anywhere. A two-dimensional operation is `x,y`.
13
+ * @param xyz - The triplet, with or without surrounding whitespace.
14
+ * @param dimension - 2 for a plane group, 3 for a space group.
15
+ * @throws {SyntaxError | RangeError} When the triplet has the wrong number of components, carries a
16
+ * variable coefficient outside {−1, 0, +1}, names an axis the dimension does
17
+ * not have, has a translation that is not a multiple of 1/12, or is singular.
18
+ * @returns The exact operation.
19
+ */
20
+ export function parseOperation(xyz, dimension) {
21
+ const components = xyz.split(',');
22
+ if (components.length !== dimension) {
23
+ throw new SyntaxError(`expected ${dimension} components in "${xyz.trim()}", received ${components.length}`);
24
+ }
25
+ const rotation = [];
26
+ const translation = [];
27
+ for (let index = 0; index < dimension; index++) {
28
+ const component = parseComponent(components[index] ?? '', dimension, xyz);
29
+ rotation.push(component.row);
30
+ translation.push(component.translation);
31
+ }
32
+ const determinant = matrixDeterminant(rotation);
33
+ if (determinant !== 1 && determinant !== -1) {
34
+ throw new RangeError(`"${xyz.trim()}" is not a symmetry operation: its determinant is ${determinant}, not ±1`);
35
+ }
36
+ return { dimension, rotation, translation };
37
+ }
38
+ /**
39
+ * One component of the triplet: a row of the matrix and one translation.
40
+ * @param source - The component, e.g. `-x+1/2`.
41
+ * @param dimension - 2 or 3.
42
+ * @param xyz - The whole triplet, for the error message.
43
+ * @returns One row of the matrix and the translation.
44
+ */
45
+ function parseComponent(source, dimension, xyz) {
46
+ const text = source.replaceAll(/\s+/g, '').toLowerCase();
47
+ if (text.length === 0) {
48
+ throw new SyntaxError(`empty component in "${xyz.trim()}"`);
49
+ }
50
+ const row = new Array(dimension).fill(0);
51
+ let twelfths = 0;
52
+ let cursor = 0;
53
+ while (cursor < text.length) {
54
+ let sign = 1;
55
+ const character = text[cursor];
56
+ if (character === '+') {
57
+ cursor += 1;
58
+ }
59
+ else if (character === '-') {
60
+ sign = -1;
61
+ cursor += 1;
62
+ }
63
+ else if (cursor > 0) {
64
+ throw new SyntaxError(`missing a sign before "${text.slice(cursor)}" in "${xyz.trim()}"`);
65
+ }
66
+ const number = readNumber(text, cursor, xyz);
67
+ cursor = number.cursor;
68
+ if (text[cursor] === '*')
69
+ cursor += 1;
70
+ const axis = AXIS_NAMES.indexOf((text[cursor] ?? ''));
71
+ if (axis === -1) {
72
+ if (number.value === null) {
73
+ throw new SyntaxError(`"${text}" of "${xyz.trim()}" has a term with nothing in it`);
74
+ }
75
+ twelfths += sign * toTwelfths(number.value, xyz);
76
+ continue;
77
+ }
78
+ if (axis >= dimension) {
79
+ throw new SyntaxError(`"${xyz.trim()}" names the axis ${AXIS_NAMES[axis]} in ${dimension}D`);
80
+ }
81
+ const coefficient = number.value ?? 1;
82
+ if (coefficient !== 1) {
83
+ throw new RangeError(`"${xyz.trim()}" carries the coefficient ${sign * coefficient} on ${AXIS_NAMES[axis]}`);
84
+ }
85
+ const current = row[axis] ?? 0;
86
+ const updated = current + sign;
87
+ if (Math.abs(updated) > 1) {
88
+ throw new RangeError(`"${xyz.trim()}" carries the coefficient ${updated} on ${AXIS_NAMES[axis]}`);
89
+ }
90
+ row[axis] = updated;
91
+ cursor += 1;
92
+ }
93
+ return {
94
+ row,
95
+ translation: ((twelfths % TWELFTHS_PER_CELL) + TWELFTHS_PER_CELL) % TWELFTHS_PER_CELL,
96
+ };
97
+ }
98
+ /**
99
+ * A fraction, a decimal or an integer at `cursor`, or `null` when none is there.
100
+ * @param text - The component, whitespace removed.
101
+ * @param cursor - Where to read.
102
+ * @param xyz - The whole triplet, for the error message.
103
+ * @returns The number, or `null` when none is there, and where reading stopped.
104
+ */
105
+ function readNumber(text, cursor, xyz) {
106
+ let end = cursor;
107
+ while (end < text.length && (isDigit(text[end]) || text[end] === '.')) {
108
+ end += 1;
109
+ }
110
+ if (end === cursor)
111
+ return { value: null, cursor };
112
+ const numerator = Number(text.slice(cursor, end));
113
+ if (!Number.isFinite(numerator)) {
114
+ throw new SyntaxError(`"${text.slice(cursor, end)}" is not a number, in "${xyz.trim()}"`);
115
+ }
116
+ if (text[end] !== '/')
117
+ return { value: numerator, cursor: end };
118
+ let denominatorEnd = end + 1;
119
+ while (denominatorEnd < text.length && isDigit(text[denominatorEnd])) {
120
+ denominatorEnd += 1;
121
+ }
122
+ const denominator = Number(text.slice(end + 1, denominatorEnd));
123
+ if (denominatorEnd === end + 1 || denominator === 0) {
124
+ throw new SyntaxError(`"${text}" of "${xyz.trim()}" has an unusable denominator`);
125
+ }
126
+ return { value: numerator / denominator, cursor: denominatorEnd };
127
+ }
128
+ /**
129
+ * A translation in twelfths, snapping `0.33333` to 4 and refusing `0.4`.
130
+ * @param value - A translation, in cells.
131
+ * @param xyz - The whole triplet, for the error message.
132
+ * @returns The translation, in twelfths.
133
+ */
134
+ function toTwelfths(value, xyz) {
135
+ const scaled = value * TWELFTHS_PER_CELL;
136
+ const twelfths = Math.round(scaled);
137
+ if (Math.abs(scaled - twelfths) > DECIMAL_TOLERANCE) {
138
+ throw new RangeError(`the translation ${value} of "${xyz.trim()}" is not a multiple of 1/12`);
139
+ }
140
+ return twelfths;
141
+ }
142
+ function isDigit(character) {
143
+ return character !== undefined && character >= '0' && character <= '9';
144
+ }
145
+ //# sourceMappingURL=parseOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOperation.js","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/parseOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3D,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAY;IAEZ,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,WAAW,CACnB,YAAY,SAAS,mBAAmB,GAAG,CAAC,IAAI,EAAE,eAAe,UAAU,CAAC,MAAM,EAAE,CACrF,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ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Q,CAAC,GAAG,iBAAiB,EAAE,CAAC;QACpD,MAAM,IAAI,UAAU,CAClB,mBAAmB,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,6BAA6B,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,OAAO,CAAC,SAA6B;IAC5C,OAAO,SAAS,KAAK,SAAS,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;AACzE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The dimension of a crystallographic group: 2 for the plane groups, 3 for the
3
+ * space groups.
4
+ */
5
+ export type Dimension = 2 | 3;
6
+ /**
7
+ * A symmetry operation of a crystallographic group, in the crystal basis.
8
+ *
9
+ * The rotation part is an exact integer matrix and the translation part is an
10
+ * exact integer count of {@link TWELFTHS_PER_CELL}, so two operations compare
11
+ * with `===` on their `operationKey` and a group expansion terminates. Every
12
+ * translation occurring in the 230 space groups and the 17 wallpaper groups is a
13
+ * twelfth: the denominators that occur are 2, 3, 4 and 6.
14
+ */
15
+ export interface CrystalOperation<D extends Dimension = 3> {
16
+ /** How many axes the operation acts on. A `CrystalOperation<2>` is not a `CrystalOperation<3>`. */
17
+ readonly dimension: D;
18
+ /** Rows of the D×D integer matrix W, acting on the fractional column (x, y, z). */
19
+ readonly rotation: ReadonlyArray<readonly number[]>;
20
+ /** Translation w, in twelfths of a cell edge, reduced into [0, 12). */
21
+ readonly translation: readonly number[];
22
+ }
23
+ /** An exact integer matrix, row-major. */
24
+ export type IntegerMatrix = ReadonlyArray<readonly number[]>;
25
+ /** The unit a translation is counted in: `6` is 1/2, `4` is 1/3, `3` is 1/4. */
26
+ export declare const TWELFTHS_PER_CELL = 12;
27
+ /** Variable names of a fractional coordinate, in order. */
28
+ export declare const AXIS_NAMES: readonly ["x", "y", "z"];
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,CAAC;IACvD,mGAAmG;IACnG,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IACpD,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,0CAA0C;AAC1C,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;AAE7D,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,2DAA2D;AAC3D,eAAO,MAAM,UAAU,0BAA2B,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** The unit a translation is counted in: `6` is 1/2, `4` is 1/3, `3` is 1/4. */
2
+ export const TWELFTHS_PER_CELL = 12;
3
+ /** Variable names of a fractional coordinate, in order. */
4
+ export const AXIS_NAMES = ['x', 'y', 'z'];
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/types.ts"],"names":[],"mappings":"AA2BA,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { PeriodicComponent } from './components.ts';
2
+ import type { ExpandedAtom } from './expand.ts';
3
+ /**
4
+ * The connected sets grouped by the sites they are built from: sets sharing a
5
+ * site are symmetry copies of one another.
6
+ * @param components - The connected sets of the cell.
7
+ * @param atoms - The atoms of the cell.
8
+ * @param siteCount - How many sites the asymmetric unit holds.
9
+ * @returns The groups, ordered on their first site.
10
+ */
11
+ export declare function symmetryClasses(components: readonly PeriodicComponent[], atoms: readonly ExpandedAtom[], siteCount: number): PeriodicComponent[][];
12
+ /**
13
+ * The copy of a molecule closest to the file: the one holding the most atoms
14
+ * the identity made, the first on a tie.
15
+ * @param members - The copies.
16
+ * @param atoms - The atoms of the cell.
17
+ * @param identityIndex - Index of the identity in the operation list.
18
+ * @returns The copy.
19
+ */
20
+ export declare function representative(members: readonly PeriodicComponent[], atoms: readonly ExpandedAtom[], identityIndex: number): PeriodicComponent;
21
+ /**
22
+ * The sites a group of connected sets is built from.
23
+ * @param members - The sets.
24
+ * @param atoms - The atoms of the cell.
25
+ * @returns The site indices, ascending.
26
+ */
27
+ export declare function siteIndicesOf(members: readonly PeriodicComponent[], atoms: readonly ExpandedAtom[]): number[];
28
+ //# sourceMappingURL=symmetryClasses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symmetryClasses.d.ts","sourceRoot":"","sources":["../../../src/crystal/core/symmetryClasses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,iBAAiB,EAAE,EACxC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,SAAS,EAAE,MAAM,GAChB,iBAAiB,EAAE,EAAE,CAuBvB;AAmBD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,aAAa,EAAE,MAAM,GACpB,iBAAiB,CAgBnB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,KAAK,EAAE,SAAS,YAAY,EAAE,GAC7B,MAAM,EAAE,CAQV"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The connected sets grouped by the sites they are built from: sets sharing a
3
+ * site are symmetry copies of one another.
4
+ * @param components - The connected sets of the cell.
5
+ * @param atoms - The atoms of the cell.
6
+ * @param siteCount - How many sites the asymmetric unit holds.
7
+ * @returns The groups, ordered on their first site.
8
+ */
9
+ export function symmetryClasses(components, atoms, siteCount) {
10
+ const parent = new Int32Array(siteCount);
11
+ for (let site = 0; site < siteCount; site++)
12
+ parent[site] = site;
13
+ for (const component of components) {
14
+ const first = atoms[component.atoms[0] ?? 0].siteIndex;
15
+ for (const index of component.atoms) {
16
+ unite(parent, first, atoms[index].siteIndex);
17
+ }
18
+ }
19
+ const classes = new Map();
20
+ for (const component of components) {
21
+ const site = atoms[component.atoms[0] ?? 0].siteIndex;
22
+ const root = rootOf(parent, site);
23
+ const members = classes.get(root);
24
+ if (members === undefined)
25
+ classes.set(root, [component]);
26
+ else
27
+ members.push(component);
28
+ }
29
+ const roots = Int32Array.from(classes.keys()).toSorted();
30
+ const ordered = [];
31
+ for (let index = 0; index < roots.length; index++) {
32
+ ordered.push(classes.get(roots[index] ?? 0) ?? []);
33
+ }
34
+ return ordered;
35
+ }
36
+ function rootOf(parent, site) {
37
+ let current = site;
38
+ while (parent[current] !== current) {
39
+ const next = parent[current] ?? current;
40
+ parent[current] = parent[next] ?? next;
41
+ current = next;
42
+ }
43
+ return current;
44
+ }
45
+ function unite(parent, a, b) {
46
+ const rootA = rootOf(parent, a);
47
+ const rootB = rootOf(parent, b);
48
+ if (rootA < rootB)
49
+ parent[rootB] = rootA;
50
+ else if (rootB < rootA)
51
+ parent[rootA] = rootB;
52
+ }
53
+ /**
54
+ * The copy of a molecule closest to the file: the one holding the most atoms
55
+ * the identity made, the first on a tie.
56
+ * @param members - The copies.
57
+ * @param atoms - The atoms of the cell.
58
+ * @param identityIndex - Index of the identity in the operation list.
59
+ * @returns The copy.
60
+ */
61
+ export function representative(members, atoms, identityIndex) {
62
+ let best = members[0];
63
+ let bestCount = -1;
64
+ for (const component of members) {
65
+ let count = 0;
66
+ for (const index of component.atoms) {
67
+ if (atoms[index].operationIndex === identityIndex) {
68
+ count++;
69
+ }
70
+ }
71
+ if (count > bestCount) {
72
+ best = component;
73
+ bestCount = count;
74
+ }
75
+ }
76
+ return best;
77
+ }
78
+ /**
79
+ * The sites a group of connected sets is built from.
80
+ * @param members - The sets.
81
+ * @param atoms - The atoms of the cell.
82
+ * @returns The site indices, ascending.
83
+ */
84
+ export function siteIndicesOf(members, atoms) {
85
+ const seen = new Set();
86
+ for (const component of members) {
87
+ for (const index of component.atoms) {
88
+ seen.add(atoms[index].siteIndex);
89
+ }
90
+ }
91
+ return Array.from(Int32Array.from(seen).toSorted());
92
+ }
93
+ //# sourceMappingURL=symmetryClasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symmetryClasses.js","sourceRoot":"","sources":["../../../src/crystal/core/symmetryClasses.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAwC,EACxC,KAA8B,EAC9B,SAAiB;IAEjB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;IACzC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,KAAK,GAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAkB,CAAC,SAAS,CAAC;QACzE,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACpC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,C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AM,KAAK,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACpC,IAAI,CAAC,GAAG,CAAE,KAAK,CAAC,KAAK,CAAkB,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC"}
@@ -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
+ export * from './crystal/core/index.ts';
12
+ //# sourceMappingURL=crystal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crystal.d.ts","sourceRoot":"","sources":["../src/crystal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,yBAAyB,CAAC"}
package/lib/crystal.js 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
+ export * from "./crystal/core/index.js";
12
+ //# sourceMappingURL=crystal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crystal.js","sourceRoot":"","sources":["../src/crystal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,46 @@
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
+ import type { Lattice } from '../../crystal/core/symmetry/lattice.ts';
15
+ import type { Point3 } from './types.ts';
16
+ /** The piece of a line that lies inside the cell. */
17
+ export interface CellSegment {
18
+ readonly start: Point3;
19
+ readonly end: Point3;
20
+ }
21
+ /**
22
+ * Where a line enters and leaves the cell.
23
+ * @param lattice - The cell it is cut against.
24
+ * @param point - A point of the line, Cartesian ångström.
25
+ * @param direction - Its direction, Cartesian; need not be normalised.
26
+ * @param cells - How many cells the box spans along each axis.
27
+ * @default 1
28
+ * @returns The two ends, or `null` when the line misses the box, and when the
29
+ * direction is too short to say which way the line runs.
30
+ */
31
+ export declare function clipLineToCell(lattice: Lattice, point: Point3, direction: Point3, cells?: number): CellSegment | null;
32
+ /**
33
+ * The polygon a plane cuts out of the cell.
34
+ *
35
+ * The corners come back in order around the plane, so a triangle fan over them
36
+ * is the face itself and a rod between each neighbouring pair is its rim.
37
+ * @param lattice - The cell it is cut against.
38
+ * @param point - A point of the plane, Cartesian ångström.
39
+ * @param normal - Its normal, Cartesian; need not be normalised.
40
+ * @param cells - How many cells the box spans along each axis.
41
+ * @default 1
42
+ * @returns The corners, Cartesian ångström, or an empty list when the plane
43
+ * misses the box or only touches an edge or a corner of it.
44
+ */
45
+ export declare function cellSection(lattice: Lattice, point: Point3, normal: Point3, cells?: number): Point3[];
46
+ //# sourceMappingURL=cellClip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellClip.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/cellClip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAQtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AASzC,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,SAAI,GACR,WAAW,GAAG,IAAI,CAyBpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,SAAI,GACR,MAAM,EAAE,CAiCV"}
@@ -0,0 +1,198 @@
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
+ import { planeFrame } from "./frame.js";
15
+ import { normalToFractional, toCartesian, toFractional, } from "./latticeBasis.js";
16
+ import { addVectors, dotProduct, scaleVector, subtractVectors, } from "./vec3.js";
17
+ /**
18
+ * Where a line enters and leaves the cell.
19
+ * @param lattice - The cell it is cut against.
20
+ * @param point - A point of the line, Cartesian ångström.
21
+ * @param direction - Its direction, Cartesian; need not be normalised.
22
+ * @param cells - How many cells the box spans along each axis.
23
+ * @default 1
24
+ * @returns The two ends, or `null` when the line misses the box, and when the
25
+ * direction is too short to say which way the line runs.
26
+ */
27
+ export function clipLineToCell(lattice, point, direction, cells = 1) {
28
+ const origin = toFractional(lattice, point);
29
+ const along = toFractional(lattice, direction);
30
+ let enter = Number.NEGATIVE_INFINITY;
31
+ let leave = Number.POSITIVE_INFINITY;
32
+ for (let axis = 0; axis < 3; axis++) {
33
+ const speed = along[axis] ?? 0;
34
+ const start = origin[axis] ?? 0;
35
+ if (Math.abs(speed) < PARALLEL) {
36
+ if (start < -SLACK || start > cells + SLACK)
37
+ return null;
38
+ continue;
39
+ }
40
+ const first = (0 - start) / speed;
41
+ const second = (cells - start) / speed;
42
+ enter = Math.max(enter, Math.min(first, second));
43
+ leave = Math.min(leave, Math.max(first, second));
44
+ }
45
+ // Every axis was parallel, so there is no line to cut: the ends would come
46
+ // back as `0 · ∞`, which is `NaN` in every coordinate and poisons the scene.
47
+ if (!Number.isFinite(enter) || !Number.isFinite(leave))
48
+ return null;
49
+ if (!(leave > enter))
50
+ return null;
51
+ return {
52
+ start: toCartesian(lattice, stepAlong(origin, along, enter)),
53
+ end: toCartesian(lattice, stepAlong(origin, along, leave)),
54
+ };
55
+ }
56
+ /**
57
+ * The polygon a plane cuts out of the cell.
58
+ *
59
+ * The corners come back in order around the plane, so a triangle fan over them
60
+ * is the face itself and a rod between each neighbouring pair is its rim.
61
+ * @param lattice - The cell it is cut against.
62
+ * @param point - A point of the plane, Cartesian ångström.
63
+ * @param normal - Its normal, Cartesian; need not be normalised.
64
+ * @param cells - How many cells the box spans along each axis.
65
+ * @default 1
66
+ * @returns The corners, Cartesian ångström, or an empty list when the plane
67
+ * misses the box or only touches an edge or a corner of it.
68
+ */
69
+ export function cellSection(lattice, point, normal, cells = 1) {
70
+ const origin = toFractional(lattice, point);
71
+ // A Cartesian normal n reads in fractional coordinates as Mᵀn, which is what
72
+ // keeps the plane in place in a cell that is not orthogonal.
73
+ const along = normalToFractional(lattice, normal);
74
+ const corners = cubeCorners(cells);
75
+ const heights = [];
76
+ for (const corner of corners) {
77
+ heights.push(dotProduct(along, subtractVectors(corner, origin)));
78
+ }
79
+ const hits = [];
80
+ for (let index = 0; index < corners.length; index++) {
81
+ const corner = corners[index];
82
+ if (corner !== undefined && Math.abs(heights[index] ?? 0) < FLAT) {
83
+ hits.push(corner);
84
+ }
85
+ }
86
+ for (const [from, to] of CUBE_EDGES) {
87
+ const low = heights[from] ?? 0;
88
+ const high = heights[to] ?? 0;
89
+ if (Math.abs(low) < FLAT || Math.abs(high) < FLAT)
90
+ continue;
91
+ if (low > 0 === high > 0)
92
+ continue;
93
+ const start = corners[from];
94
+ const end = corners[to];
95
+ if (start === undefined || end === undefined)
96
+ continue;
97
+ const fraction = low / (low - high);
98
+ hits.push(stepAlong(start, subtractVectors(end, start), fraction));
99
+ }
100
+ const points = [];
101
+ for (const hit of hits)
102
+ points.push(toCartesian(lattice, hit));
103
+ const section = dedupe(points);
104
+ if (section.length < 3)
105
+ return [];
106
+ return orderAroundPlane(section, normal);
107
+ }
108
+ function stepAlong(origin, direction, distance) {
109
+ return addVectors(origin, scaleVector(direction, distance));
110
+ }
111
+ /**
112
+ * The eight corners of the box, in the order {@link CUBE_EDGES} indexes.
113
+ * @param cells - How many cells the box spans along each axis.
114
+ * @returns The corners, in cell fractions.
115
+ */
116
+ function cubeCorners(cells) {
117
+ const corners = [];
118
+ for (let i = 0; i < 2; i++) {
119
+ for (let j = 0; j < 2; j++) {
120
+ for (let k = 0; k < 2; k++) {
121
+ corners.push([i * cells, j * cells, k * cells]);
122
+ }
123
+ }
124
+ }
125
+ return corners;
126
+ }
127
+ /** Corners that differ in exactly one coordinate are joined by an edge. */
128
+ const CUBE_EDGES = [
129
+ [0, 1],
130
+ [0, 2],
131
+ [0, 4],
132
+ [1, 3],
133
+ [1, 5],
134
+ [2, 3],
135
+ [2, 6],
136
+ [3, 7],
137
+ [4, 5],
138
+ [4, 6],
139
+ [5, 7],
140
+ [6, 7],
141
+ ];
142
+ /**
143
+ * The same corners, walked round the plane rather than found in cube order.
144
+ * @param points - The corners, Cartesian ångström.
145
+ * @param normal - The plane's normal, Cartesian.
146
+ * @returns The corners, in order around the plane.
147
+ */
148
+ function orderAroundPlane(points, normal) {
149
+ const { major, minor } = planeFrame(normal);
150
+ let centre = [0, 0, 0];
151
+ for (const point of points)
152
+ centre = addVectors(centre, point);
153
+ centre = scaleVector(centre, 1 / points.length);
154
+ const turned = [];
155
+ for (const point of points) {
156
+ const offset = subtractVectors(point, centre);
157
+ turned.push({
158
+ point,
159
+ angle: Math.atan2(dotProduct(offset, minor), dotProduct(offset, major)),
160
+ });
161
+ }
162
+ turned.sort((left, right) => left.angle - right.angle);
163
+ const ordered = [];
164
+ for (const entry of turned)
165
+ ordered.push(entry.point);
166
+ return ordered;
167
+ }
168
+ /**
169
+ * A corner the plane passes through is found once per edge that meets it.
170
+ * @param points - The corners found, Cartesian ångström.
171
+ * @returns Each corner once.
172
+ */
173
+ function dedupe(points) {
174
+ const kept = [];
175
+ for (const point of points) {
176
+ let seen = false;
177
+ for (const other of kept) {
178
+ if (Math.abs((point[0] ?? 0) - (other[0] ?? 0)) < SAME &&
179
+ Math.abs((point[1] ?? 0) - (other[1] ?? 0)) < SAME &&
180
+ Math.abs((point[2] ?? 0) - (other[2] ?? 0)) < SAME) {
181
+ seen = true;
182
+ break;
183
+ }
184
+ }
185
+ if (!seen)
186
+ kept.push(point);
187
+ }
188
+ return kept;
189
+ }
190
+ /** Below this, a line runs along a face rather than through it. */
191
+ const PARALLEL = 1e-9;
192
+ /** How far outside the box a parallel line may still count as inside it. */
193
+ const SLACK = 1e-9;
194
+ /** Below this, in cell fractions, a corner lies on the plane. */
195
+ const FLAT = 1e-9;
196
+ /** Below this, in ångström, two corners are the same corner. */
197
+ const SAME = 1e-6;
198
+ //# sourceMappingURL=cellClip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellClip.js","sourceRoot":"","sources":["../../../src/crystal3d/core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