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,229 @@
1
+ /**
2
+ * Where the camera opens on a scene.
3
+ *
4
+ * molstar starts every canvas looking down −z, and a molecule is built in its
5
+ * standard frame with the principal axis along z — so the site opened on the
6
+ * one view that shows no symmetry at all: water end-on, three balls in a
7
+ * column, both σv planes exactly edge-on and the C₂ a dot behind the oxygen. A
8
+ * page that says *hover an axis or a plane* had nothing to hover.
9
+ *
10
+ * The cure is not another world direction, which would merely move the blind
11
+ * spot onto the molecules whose axis is x. The view is measured **from the
12
+ * scene's own axis**: the highest-order axis it draws, or a crystal's c edge.
13
+ */
14
+
15
+ import { cellAxes } from './cellGeometry.ts';
16
+ import { perpendicularTo } from './frame.ts';
17
+ import type { Point3, SymmetryDrawing, UnitCell } from './types.ts';
18
+ import {
19
+ addVectors,
20
+ crossProduct,
21
+ dotProduct,
22
+ normalizeVector,
23
+ scaleVector,
24
+ subtractVectors,
25
+ vectorNorm,
26
+ } from './vec3.ts';
27
+
28
+ /** Where the camera sits and which way is up, as unit vectors. */
29
+ export interface ViewOrientation {
30
+ /** From the centre of the scene towards the camera. */
31
+ readonly eye: Point3;
32
+ /** Up on screen; at right angles to `eye`. */
33
+ readonly up: Point3;
34
+ }
35
+
36
+ /** The part of a scene the opening view is read off. */
37
+ export interface OrientedScene {
38
+ /**
39
+ * The cell, when the scene has one. A crystal is framed on its cell rather
40
+ * than on its elements: a box that reads as a box is what places the fifty
41
+ * axes inside it.
42
+ * @default null
43
+ */
44
+ readonly cell?: UnitCell | null;
45
+ /**
46
+ * The symmetry elements drawn over the structure.
47
+ * @default []
48
+ */
49
+ readonly elements?: readonly SymmetryDrawing[];
50
+ }
51
+
52
+ /**
53
+ * The view a scene opens on.
54
+ * @param scene - What is drawn; see {@link OrientedScene}.
55
+ * @returns A three-quarter view of it.
56
+ */
57
+ export function sceneOrientation(scene: OrientedScene): ViewOrientation {
58
+ const { cell = null, elements = [] } = scene;
59
+ if (cell !== null) {
60
+ const [a, , c] = cellAxes(cell);
61
+ return threeQuarterView(c, a);
62
+ }
63
+ return threeQuarterView(principalAxisOf(elements) ?? WORLD_AXIS);
64
+ }
65
+
66
+ /**
67
+ * The scene's own axis: the highest-order one it draws, or a plane normal when
68
+ * it draws no axis at all.
69
+ * @param drawings - The symmetry elements on screen.
70
+ * @returns Its direction, or `null` when nothing drawn has one — an inversion
71
+ * centre alone, or an empty scene.
72
+ */
73
+ export function principalAxisOf(
74
+ drawings: readonly SymmetryDrawing[],
75
+ ): Point3 | null {
76
+ let axis: Point3 | null = null;
77
+ let order = 0;
78
+ let normal: Point3 | null = null;
79
+ for (const drawing of drawings) {
80
+ if (drawing.kind === 'mirror' || drawing.kind === 'glide') {
81
+ if (normal === null && hasDirection(drawing.normal)) {
82
+ normal = drawing.normal;
83
+ }
84
+ continue;
85
+ }
86
+ if (drawing.kind === 'inversion') continue;
87
+ if (drawing.order <= order || !hasDirection(drawing.direction)) continue;
88
+ axis = drawing.direction;
89
+ order = drawing.order;
90
+ }
91
+ return axis ?? normal;
92
+ }
93
+
94
+ /**
95
+ * A view three-quarters of the way round an axis and well off the end of it.
96
+ * @param axis - The direction the view is measured from; need not be
97
+ * normalised, and its sign does not matter.
98
+ * @param reference - Where the azimuth is measured from — a crystal passes its
99
+ * a edge, so the same cell always opens the same way round. Left out, one is
100
+ * chosen from the axis alone.
101
+ * @returns Where the camera sits, and which way is up.
102
+ * @throws {RangeError} When the axis is too short to have a direction.
103
+ */
104
+ export function threeQuarterView(
105
+ axis: Point3,
106
+ reference?: Point3,
107
+ ): ViewOrientation {
108
+ const up = upwards(normalizeVector(axis));
109
+ const major = azimuthFrom(up, reference);
110
+ const minor = crossProduct(up, major);
111
+ const polar = toRadians(POLAR_DEGREES);
112
+ const azimuth = toRadians(AZIMUTH_DEGREES);
113
+ const eye = normalizeVector(
114
+ addVectors(
115
+ addVectors(
116
+ scaleVector(major, Math.sin(polar) * Math.cos(azimuth)),
117
+ scaleVector(minor, Math.sin(polar) * Math.sin(azimuth)),
118
+ ),
119
+ scaleVector(up, Math.cos(polar)),
120
+ ),
121
+ );
122
+ return {
123
+ eye,
124
+ up: rollAbout(rejectFrom(up, eye), eye, toRadians(ROLL_DEGREES)),
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Whichever way up leaves the axis pointing towards the top of the screen.
130
+ * @param unit - The axis, normalised.
131
+ * @returns The axis or its opposite.
132
+ */
133
+ function upwards(unit: Point3): Point3 {
134
+ const [x, y, z] = unit;
135
+ let leading = x;
136
+ if (Math.abs(z) > DIRECTION_FLOOR) leading = z;
137
+ else if (Math.abs(y) > DIRECTION_FLOOR) leading = y;
138
+ return leading < 0 ? scaleVector(unit, -1) : unit;
139
+ }
140
+
141
+ /**
142
+ * The direction the azimuth is measured from, at right angles to the axis.
143
+ * @param up - The axis, normalised and pointing up.
144
+ * @param reference - The direction to measure from, or `undefined` to pick one.
145
+ * @returns A unit vector at right angles to `up`.
146
+ */
147
+ function azimuthFrom(up: Point3, reference: Point3 | undefined): Point3 {
148
+ if (reference === undefined) return perpendicularTo(up);
149
+ const flat = subtractVectors(
150
+ reference,
151
+ scaleVector(up, dotProduct(reference, up)),
152
+ );
153
+ return hasDirection(flat) ? normalizeVector(flat) : perpendicularTo(up);
154
+ }
155
+
156
+ /**
157
+ * The part of a vector at right angles to a unit direction.
158
+ * @param vector - The vector.
159
+ * @param unit - The direction projected out, normalised.
160
+ * @returns That part, normalised.
161
+ */
162
+ function rejectFrom(vector: Point3, unit: Point3): Point3 {
163
+ return normalizeVector(
164
+ subtractVectors(vector, scaleVector(unit, dotProduct(vector, unit))),
165
+ );
166
+ }
167
+
168
+ /**
169
+ * Turn a vector about a unit axis it is already at right angles to.
170
+ * @param vector - The vector turned.
171
+ * @param unit - The axis, normalised.
172
+ * @param angle - The angle, in radians, right-handed.
173
+ * @returns The turned vector.
174
+ */
175
+ function rollAbout(vector: Point3, unit: Point3, angle: number): Point3 {
176
+ return addVectors(
177
+ scaleVector(vector, Math.cos(angle)),
178
+ scaleVector(crossProduct(unit, vector), Math.sin(angle)),
179
+ );
180
+ }
181
+
182
+ /**
183
+ * Whether a vector is long enough to say which way it points.
184
+ * @param vector - The vector.
185
+ * @returns Whether its length is above the floor.
186
+ */
187
+ function hasDirection(vector: Point3): boolean {
188
+ return vectorNorm(vector) > DIRECTION_FLOOR;
189
+ }
190
+
191
+ function toRadians(degrees: number): number {
192
+ return (degrees * Math.PI) / 180;
193
+ }
194
+
195
+ /**
196
+ * How far off the axis the camera sits, degrees.
197
+ *
198
+ * Not 0 — that is the end-on view this module exists to stop — and not 90,
199
+ * which lays the eye inside every plane that contains the axis. At 65° an axis
200
+ * still draws 91% of its length while a plane across it is seen at 42% of its
201
+ * face, so a rod reads as a rod and a σh reads as a disc.
202
+ */
203
+ const POLAR_DEGREES = 65;
204
+
205
+ /**
206
+ * How far round the axis, degrees from the reference direction.
207
+ *
208
+ * Every round value is a special position of some group: 0 and 90 lay the eye
209
+ * in a plane of any two at right angles, 45 in the diagonal plane of a
210
+ * four-fold, 30 and 60 in a three- or six-fold's. At 40° two planes at right
211
+ * angles are seen at 77% and 64% of their face, and neither is edge-on.
212
+ */
213
+ const AZIMUTH_DEGREES = 40;
214
+
215
+ /**
216
+ * How far the horizon is tilted, degrees.
217
+ *
218
+ * Without it the axis stands exactly upright and the scene reads as a flat
219
+ * diagram of itself; ten degrees is enough to say it is a solid seen in space,
220
+ * and little enough that the names floating beside each element stay level
221
+ * enough to read.
222
+ */
223
+ const ROLL_DEGREES = 10;
224
+
225
+ /** Which way is up when nothing drawn says otherwise. */
226
+ const WORLD_AXIS: Point3 = [0, 0, 1];
227
+
228
+ /** Below this length a vector is taken to have no direction at all. */
229
+ const DIRECTION_FLOOR = 1e-9;
@@ -0,0 +1,43 @@
1
+ // tokens-ok: file — these colours are subject matter: they tell a 3-fold axis
2
+ // from a glide plane in the scene, the way a crystallographic diagram does.
3
+ /**
4
+ * What each kind of symmetry element is drawn in.
5
+ *
6
+ * The family's tokens paint the page around the canvas; inside it a colour
7
+ * carries a meaning — proper or improper, axis or plane — so each kind owns
8
+ * one, and a drawing overrides it only when a page has a reason to.
9
+ */
10
+
11
+ import type { SymmetryDrawingKind } from './types.ts';
12
+
13
+ /** The colour of each kind, `#rrggbb`. */
14
+ export const ELEMENT_COLOURS: Readonly<Record<SymmetryDrawingKind, string>> = {
15
+ rotation: '#1d4ed8',
16
+ screw: '#0f766e',
17
+ rotoinversion: '#7c3aed',
18
+ mirror: '#0891b2',
19
+ glide: '#c2410c',
20
+ inversion: '#be123c',
21
+ };
22
+
23
+ /** The unit cell box, and the lattice repeats drawn around it. */
24
+ export const CELL_COLOUR = '#475569';
25
+
26
+ /** An element's label, and the a/b/c letters on the cell. */
27
+ export const LABEL_COLOUR = '#1f2937';
28
+
29
+ /** The card a label is written on, so it reads over a structure or a plane. */
30
+ export const LABEL_CARD_COLOUR = '#ffffff';
31
+
32
+ /**
33
+ * The colour a drawing is painted in.
34
+ * @param kind - Which of the six it is.
35
+ * @param colour - What the drawing asked for, if anything.
36
+ * @returns The chosen colour, `#rrggbb`.
37
+ */
38
+ export function drawingColour(
39
+ kind: SymmetryDrawingKind,
40
+ colour?: string,
41
+ ): string {
42
+ return colour ?? ELEMENT_COLOURS[kind];
43
+ }
@@ -0,0 +1,183 @@
1
+ /**
2
+ * The shapes a symmetry element is made of, named once so the geometry that
3
+ * builds them never has to know molstar exists.
4
+ *
5
+ * Everything in this module is plain arithmetic: it is what the unit tests
6
+ * assert, and what `renderElements.ts` hands to a mesh builder.
7
+ */
8
+
9
+ import type { Point3 } from './types.ts';
10
+
11
+ /** One drawable shape, Cartesian ångström. */
12
+ export type MeshPrimitive =
13
+ /** A solid rod, as a rotation axis or a cell edge. */
14
+ | { readonly shape: 'rod'; start: Point3; end: Point3; radius: number }
15
+ /** A broken rod, as the axis of a rotoinversion. */
16
+ | {
17
+ readonly shape: 'dashes';
18
+ start: Point3;
19
+ end: Point3;
20
+ radius: number;
21
+ segments: number;
22
+ }
23
+ /** A cone, as the head of an arrow. */
24
+ | { readonly shape: 'cone'; base: Point3; tip: Point3; radius: number }
25
+ /** A ball, as an inversion centre. */
26
+ | { readonly shape: 'sphere'; centre: Point3; radius: number }
27
+ /** A flat square, as a mirror or a glide plane. */
28
+ | {
29
+ readonly shape: 'plate';
30
+ centre: Point3;
31
+ major: Point3;
32
+ minor: Point3;
33
+ size: number;
34
+ }
35
+ /** A flat convex face, as the slice a plane cuts out of a cell. */
36
+ | { readonly shape: 'face'; points: readonly Point3[] };
37
+
38
+ /** A line of text floating in the scene. */
39
+ export interface TextItem {
40
+ /** What it reads. */
41
+ readonly text: string;
42
+ /** Where it sits, Cartesian ångström. */
43
+ readonly position: Point3;
44
+ /** Its height, ångström. */
45
+ readonly size: number;
46
+ /**
47
+ * What it is written in, `#rrggbb`. A name in the colour of the thing it
48
+ * names is the only way a reader pairs the two when ten of them are on one
49
+ * cell.
50
+ * @default the layer's own colour
51
+ */
52
+ readonly colour?: string;
53
+ }
54
+
55
+ /** How thick, how long and how big the drawn elements are. */
56
+ export interface ElementStyle {
57
+ /**
58
+ * Radius of an axis rod, ångström.
59
+ * @default 0.06
60
+ */
61
+ axisRadius?: number;
62
+ /**
63
+ * Radius of an arrowhead's base, ångström.
64
+ * @default 0.16
65
+ */
66
+ arrowRadius?: number;
67
+ /**
68
+ * Length of an arrowhead, ångström.
69
+ * @default 0.4
70
+ */
71
+ arrowLength?: number;
72
+ /**
73
+ * Radius of an inversion centre, ångström.
74
+ * @default 0.18
75
+ */
76
+ centreRadius?: number;
77
+ /**
78
+ * How far a pitch arrow sits beside its axis, in rod radii.
79
+ * @default 4
80
+ */
81
+ arrowOffset?: number;
82
+ /**
83
+ * Dashes along a rotoinversion axis.
84
+ * @default 9
85
+ */
86
+ dashSegments?: number;
87
+ /**
88
+ * Radius of the rim drawn round a plane, ångström. A stack of translucent
89
+ * faces is a wash; the same stack with its edges drawn reads as planes.
90
+ * @default 0.03
91
+ */
92
+ rimRadius?: number;
93
+ /**
94
+ * Height of an element's label, ångström.
95
+ * @default 0.6
96
+ */
97
+ labelSize?: number;
98
+ /**
99
+ * Gap between the end of an element and its label, ångström.
100
+ * @default 0.35
101
+ */
102
+ labelGap?: number;
103
+ }
104
+
105
+ /** {@link ElementStyle} with every default filled in. */
106
+ export type ResolvedElementStyle = Required<ElementStyle>;
107
+
108
+ /** The defaults, read once so a caller can override one field. */
109
+ export const DEFAULT_ELEMENT_STYLE: ResolvedElementStyle = {
110
+ axisRadius: 0.06,
111
+ arrowRadius: 0.16,
112
+ arrowLength: 0.4,
113
+ centreRadius: 0.18,
114
+ arrowOffset: 4,
115
+ dashSegments: 9,
116
+ rimRadius: 0.03,
117
+ labelSize: 0.6,
118
+ labelGap: 0.35,
119
+ };
120
+
121
+ /**
122
+ * Fill in whatever the caller left out.
123
+ * @param style - The caller's overrides, if any.
124
+ * @returns Every field, with the defaults where none was given.
125
+ */
126
+ export function resolveElementStyle(
127
+ style: ElementStyle = {},
128
+ ): ResolvedElementStyle {
129
+ return { ...DEFAULT_ELEMENT_STYLE, ...style };
130
+ }
131
+
132
+ /**
133
+ * The corners a primitive reaches, so the camera can frame what is drawn.
134
+ * @param primitive - One shape.
135
+ * @returns Points that between them hold it, Cartesian ångström.
136
+ */
137
+ export function primitivePoints(primitive: MeshPrimitive): Point3[] {
138
+ switch (primitive.shape) {
139
+ case 'rod':
140
+ case 'dashes': {
141
+ return [primitive.start, primitive.end];
142
+ }
143
+ case 'cone': {
144
+ return [primitive.base, primitive.tip];
145
+ }
146
+ case 'sphere': {
147
+ const [x, y, z] = primitive.centre;
148
+ const r = primitive.radius;
149
+ return [
150
+ [x - r, y, z],
151
+ [x + r, y, z],
152
+ [x, y - r, z],
153
+ [x, y + r, z],
154
+ [x, y, z - r],
155
+ [x, y, z + r],
156
+ ];
157
+ }
158
+ case 'face': {
159
+ return [...primitive.points];
160
+ }
161
+ case 'plate': {
162
+ const half = primitive.size / 2;
163
+ const corners: Point3[] = [];
164
+ for (const along of [-half, half]) {
165
+ for (const across of [-half, half]) {
166
+ corners.push([
167
+ primitive.centre[0] +
168
+ primitive.major[0] * along +
169
+ primitive.minor[0] * across,
170
+ primitive.centre[1] +
171
+ primitive.major[1] * along +
172
+ primitive.minor[1] * across,
173
+ primitive.centre[2] +
174
+ primitive.major[2] * along +
175
+ primitive.minor[2] * across,
176
+ ]);
177
+ }
178
+ }
179
+ return corners;
180
+ }
181
+ // no default
182
+ }
183
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The atoms as a file molstar can read.
3
+ *
4
+ * XYZ, and only XYZ: the page has already applied every operation, so the
5
+ * viewer needs a format that carries elements and Cartesian coordinates and
6
+ * nothing else. Handing molstar a CIF would invite it to expand the symmetry a
7
+ * second time, which is the one thing a crystal view must not let it do.
8
+ */
9
+
10
+ import type { ViewerAtom } from './types.ts';
11
+
12
+ /**
13
+ * Write the atoms as XYZ.
14
+ * @param atoms - The whole scene, Cartesian ångström.
15
+ * @param comment - The second line of the file, which molstar keeps as the
16
+ * model's comment.
17
+ * @returns The file text, ending in a newline.
18
+ * @throws {Error} When there are no atoms: molstar reads a count of zero as the end of
19
+ * the file and returns a model with no atoms rather than an error.
20
+ */
21
+ export function toXyzText(
22
+ atoms: readonly ViewerAtom[],
23
+ comment = 'crystal',
24
+ ): string {
25
+ if (atoms.length === 0) {
26
+ throw new Error('an XYZ file needs at least one atom.');
27
+ }
28
+ const lines: string[] = [String(atoms.length), comment];
29
+ for (const atom of atoms) {
30
+ const [x, y, z] = atom.position;
31
+ lines.push(`${atom.element} ${format(x)} ${format(y)} ${format(z)}`);
32
+ }
33
+ return `${lines.join('\n')}\n`;
34
+ }
35
+
36
+ /**
37
+ * Six decimals is a thousandth of the shortest bond, and reads as a number.
38
+ * @param value - A coordinate, ångström.
39
+ * @returns It with six decimals, never `-0.000000`.
40
+ */
41
+ function format(value: number): string {
42
+ return (value === 0 ? 0 : value).toFixed(6);
43
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The bridge from an expanded cell to the atom list the scene draws.
3
+ *
4
+ * The site applies its own operations — molstar's space-group expansion is
5
+ * unusable here, since it neither wraps into the cell nor deduplicates a special
6
+ * position, and it falls back to `P 1` without warning on settings this site
7
+ * ships. So the atoms arrive already expanded, and all that is left is to repeat
8
+ * them over the lattice.
9
+ */
10
+
11
+ import { cellAxes, latticeShifts } from './cellGeometry.ts';
12
+ import type { CellRepeat, UnitCell, ViewerAtom } from './types.ts';
13
+ import { addVectors } from './vec3.ts';
14
+
15
+ /**
16
+ * One cell's atoms, repeated over an n×n×n stack.
17
+ * @param atoms - The contents of one cell, Cartesian ångström.
18
+ * @param cell - The six cell parameters.
19
+ * @param repeat - Cells along a, b and c; anything below 1 counts as 1.
20
+ * @returns The atoms of every cell, the original ones first.
21
+ * @throws {RangeError} When the three angles describe no cell.
22
+ */
23
+ export function supercellAtoms(
24
+ atoms: readonly ViewerAtom[],
25
+ cell: UnitCell,
26
+ repeat: CellRepeat = [1, 1, 1],
27
+ ): ViewerAtom[] {
28
+ const shifts = latticeShifts(cellAxes(cell), repeat);
29
+ if (shifts.length === 1) return [...atoms];
30
+ const expanded: ViewerAtom[] = [];
31
+ for (const shift of shifts) {
32
+ for (const atom of atoms) {
33
+ expanded.push({
34
+ element: atom.element,
35
+ position: addVectors(atom.position, shift),
36
+ });
37
+ }
38
+ }
39
+ return expanded;
40
+ }