react-cheminfo 0.135.0 → 0.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/README.md +1 -1
  2. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  3. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  4. package/lib/crystal/core/cellAtoms.js +70 -0
  5. package/lib/crystal/core/cellAtoms.js.map +1 -0
  6. package/lib/crystal/core/index.d.ts +2 -0
  7. package/lib/crystal/core/index.d.ts.map +1 -1
  8. package/lib/crystal/core/index.js +1 -0
  9. package/lib/crystal/core/index.js.map +1 -1
  10. package/lib/crystal/core/molecules.d.ts.map +1 -1
  11. package/lib/crystal/core/molecules.js +6 -40
  12. package/lib/crystal/core/molecules.js.map +1 -1
  13. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  14. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  15. package/lib/crystal3d/core/cellClip.js +198 -0
  16. package/lib/crystal3d/core/cellClip.js.map +1 -0
  17. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  18. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  19. package/lib/crystal3d/core/cellGeometry.js +153 -0
  20. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  21. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  22. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  23. package/lib/crystal3d/core/cellStack.js +79 -0
  24. package/lib/crystal3d/core/cellStack.js.map +1 -0
  25. package/lib/crystal3d/core/crystalView.d.ts +81 -0
  26. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  27. package/lib/crystal3d/core/crystalView.js +55 -0
  28. package/lib/crystal3d/core/crystalView.js.map +1 -0
  29. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  30. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  31. package/lib/crystal3d/core/drawingSet.js +63 -0
  32. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  33. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  34. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  35. package/lib/crystal3d/core/elementDrawing.js +100 -0
  36. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  37. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  38. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  39. package/lib/crystal3d/core/elementExtent.js +56 -0
  40. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  41. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  42. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  43. package/lib/crystal3d/core/elementLabels.js +99 -0
  44. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  45. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  46. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  47. package/lib/crystal3d/core/elementShapes.js +115 -0
  48. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  49. package/lib/crystal3d/core/frame.d.ts +36 -0
  50. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  51. package/lib/crystal3d/core/frame.js +35 -0
  52. package/lib/crystal3d/core/frame.js.map +1 -0
  53. package/lib/crystal3d/core/framing.d.ts +41 -0
  54. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  55. package/lib/crystal3d/core/framing.js +79 -0
  56. package/lib/crystal3d/core/framing.js.map +1 -0
  57. package/lib/crystal3d/core/index.d.ts +42 -0
  58. package/lib/crystal3d/core/index.d.ts.map +1 -0
  59. package/lib/crystal3d/core/index.js +29 -0
  60. package/lib/crystal3d/core/index.js.map +1 -0
  61. package/lib/crystal3d/core/labelText.d.ts +19 -0
  62. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  63. package/lib/crystal3d/core/labelText.js +42 -0
  64. package/lib/crystal3d/core/labelText.js.map +1 -0
  65. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  66. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  67. package/lib/crystal3d/core/latticeBasis.js +89 -0
  68. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  69. package/lib/crystal3d/core/mat3.d.ts +68 -0
  70. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  71. package/lib/crystal3d/core/mat3.js +146 -0
  72. package/lib/crystal3d/core/mat3.js.map +1 -0
  73. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  74. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  75. package/lib/crystal3d/core/operationMatrix.js +172 -0
  76. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  77. package/lib/crystal3d/core/orientation.d.ts +62 -0
  78. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  79. package/lib/crystal3d/core/orientation.js +166 -0
  80. package/lib/crystal3d/core/orientation.js.map +1 -0
  81. package/lib/crystal3d/core/palette.d.ts +24 -0
  82. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  83. package/lib/crystal3d/core/palette.js +34 -0
  84. package/lib/crystal3d/core/palette.js.map +1 -0
  85. package/lib/crystal3d/core/primitives.d.ts +133 -0
  86. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  87. package/lib/crystal3d/core/primitives.js +80 -0
  88. package/lib/crystal3d/core/primitives.js.map +1 -0
  89. package/lib/crystal3d/core/structureText.d.ts +20 -0
  90. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  91. package/lib/crystal3d/core/structureText.js +37 -0
  92. package/lib/crystal3d/core/structureText.js.map +1 -0
  93. package/lib/crystal3d/core/supercell.d.ts +20 -0
  94. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  95. package/lib/crystal3d/core/supercell.js +35 -0
  96. package/lib/crystal3d/core/supercell.js.map +1 -0
  97. package/lib/crystal3d/core/types.d.ts +166 -0
  98. package/lib/crystal3d/core/types.d.ts.map +1 -0
  99. package/lib/crystal3d/core/types.js +10 -0
  100. package/lib/crystal3d/core/types.js.map +1 -0
  101. package/lib/crystal3d/core/vec3.d.ts +75 -0
  102. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  103. package/lib/crystal3d/core/vec3.js +119 -0
  104. package/lib/crystal3d/core/vec3.js.map +1 -0
  105. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  106. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  107. package/lib/crystal3d/ui/CrystalCanvas3D.js +250 -0
  108. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  109. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  110. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  111. package/lib/crystal3d/ui/CrystalStructureView.js +79 -0
  112. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  113. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  114. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  115. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  116. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  117. package/lib/crystal3d/ui/CrystalViewControls.d.ts +29 -0
  118. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  119. package/lib/crystal3d/ui/CrystalViewControls.js +24 -0
  120. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  121. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  122. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  123. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  124. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  125. package/lib/crystal3d/ui/crystalScene.d.ts +97 -0
  126. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  127. package/lib/crystal3d/ui/crystalScene.js +10 -0
  128. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  129. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  130. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  131. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  132. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  133. package/lib/crystal3d/ui/index.d.ts +16 -0
  134. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  135. package/lib/crystal3d/ui/index.js +12 -0
  136. package/lib/crystal3d/ui/index.js.map +1 -0
  137. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  138. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  139. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  140. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  141. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  142. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  143. package/lib/crystal3d/viewer/animate.js +83 -0
  144. package/lib/crystal3d/viewer/animate.js.map +1 -0
  145. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  146. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  147. package/lib/crystal3d/viewer/camera.js +103 -0
  148. package/lib/crystal3d/viewer/camera.js.map +1 -0
  149. package/lib/crystal3d/viewer/index.d.ts +13 -0
  150. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  151. package/lib/crystal3d/viewer/index.js +8 -0
  152. package/lib/crystal3d/viewer/index.js.map +1 -0
  153. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  154. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  155. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  156. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  157. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  158. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  159. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  160. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  161. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  162. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  163. package/lib/crystal3d/viewer/plugin.js +181 -0
  164. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  165. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  166. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  167. package/lib/crystal3d/viewer/renderCell.js +53 -0
  168. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  169. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  170. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  171. package/lib/crystal3d/viewer/renderElements.js +77 -0
  172. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  173. package/lib/crystal3d/viewer/renderStructure.d.ts +80 -0
  174. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  175. package/lib/crystal3d/viewer/renderStructure.js +143 -0
  176. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  177. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  178. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  179. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  180. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  181. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  182. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  183. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  184. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  185. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  186. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  187. package/lib/crystal3d/viewer/textLayer.js +59 -0
  188. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  189. package/lib/crystal3d/viewer/viewer.d.ts +119 -0
  190. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  191. package/lib/crystal3d/viewer/viewer.js +172 -0
  192. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  193. package/lib/crystal3d.d.ts +12 -0
  194. package/lib/crystal3d.d.ts.map +1 -0
  195. package/lib/crystal3d.js +12 -0
  196. package/lib/crystal3d.js.map +1 -0
  197. package/lib/download/core/croppedMarkup.d.ts.map +1 -1
  198. package/lib/download/core/croppedMarkup.js +16 -40
  199. package/lib/download/core/croppedMarkup.js.map +1 -1
  200. package/lib/download/core/dataUrl.d.ts +27 -0
  201. package/lib/download/core/dataUrl.d.ts.map +1 -0
  202. package/lib/download/core/dataUrl.js +54 -0
  203. package/lib/download/core/dataUrl.js.map +1 -0
  204. package/lib/download/core/index.d.ts +3 -0
  205. package/lib/download/core/index.d.ts.map +1 -1
  206. package/lib/download/core/index.js +2 -0
  207. package/lib/download/core/index.js.map +1 -1
  208. package/lib/download/core/svgMarkup.d.ts +39 -0
  209. package/lib/download/core/svgMarkup.d.ts.map +1 -0
  210. package/lib/download/core/svgMarkup.js +100 -0
  211. package/lib/download/core/svgMarkup.js.map +1 -0
  212. package/lib/drawing/ui/movingFigure.d.ts.map +1 -1
  213. package/lib/drawing/ui/movingFigure.js +4 -30
  214. package/lib/drawing/ui/movingFigure.js.map +1 -1
  215. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  216. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  217. package/lib/locales/de.json +26 -1
  218. package/lib/locales/en.json +26 -1
  219. package/lib/locales/es.json +26 -1
  220. package/lib/locales/fr.json +26 -1
  221. package/lib/locales/it.json +26 -1
  222. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  223. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  224. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  225. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  226. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  227. package/lib/molstar/bonds/bondRule.js +23 -0
  228. package/lib/molstar/bonds/bondRule.js.map +1 -0
  229. package/lib/molstar/bonds/index.d.ts +9 -0
  230. package/lib/molstar/bonds/index.d.ts.map +1 -0
  231. package/lib/molstar/bonds/index.js +9 -0
  232. package/lib/molstar/bonds/index.js.map +1 -0
  233. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  234. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  235. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  236. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  237. package/lib/molstar/ui/index.d.ts +10 -0
  238. package/lib/molstar/ui/index.d.ts.map +1 -0
  239. package/lib/molstar/ui/index.js +8 -0
  240. package/lib/molstar/ui/index.js.map +1 -0
  241. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  242. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  243. package/lib/molstar/ui/useMolstarTools.js +36 -0
  244. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  245. package/package.json +2 -1
  246. package/src/crystal/core/cellAtoms.ts +106 -0
  247. package/src/crystal/core/index.ts +2 -0
  248. package/src/crystal/core/molecules.ts +7 -44
  249. package/src/crystal3d/core/cellClip.ts +229 -0
  250. package/src/crystal3d/core/cellGeometry.ts +193 -0
  251. package/src/crystal3d/core/cellStack.ts +87 -0
  252. package/src/crystal3d/core/crystalView.ts +131 -0
  253. package/src/crystal3d/core/drawingSet.ts +71 -0
  254. package/src/crystal3d/core/elementDrawing.ts +147 -0
  255. package/src/crystal3d/core/elementExtent.ts +81 -0
  256. package/src/crystal3d/core/elementLabels.ts +130 -0
  257. package/src/crystal3d/core/elementShapes.ts +141 -0
  258. package/src/crystal3d/core/frame.ts +56 -0
  259. package/src/crystal3d/core/framing.ts +101 -0
  260. package/src/crystal3d/core/index.ts +134 -0
  261. package/src/crystal3d/core/labelText.ts +44 -0
  262. package/src/crystal3d/core/latticeBasis.ts +110 -0
  263. package/src/crystal3d/core/mat3.ts +163 -0
  264. package/src/crystal3d/core/operationMatrix.ts +255 -0
  265. package/src/crystal3d/core/orientation.ts +229 -0
  266. package/src/crystal3d/core/palette.ts +43 -0
  267. package/src/crystal3d/core/primitives.ts +183 -0
  268. package/src/crystal3d/core/structureText.ts +43 -0
  269. package/src/crystal3d/core/supercell.ts +40 -0
  270. package/src/crystal3d/core/types.ts +186 -0
  271. package/src/crystal3d/core/vec3.ts +127 -0
  272. package/src/crystal3d/ui/CrystalCanvas3D.tsx +393 -0
  273. package/src/crystal3d/ui/CrystalStructureView.tsx +153 -0
  274. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  275. package/src/crystal3d/ui/CrystalViewControls.tsx +129 -0
  276. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  277. package/src/crystal3d/ui/crystalScene.ts +106 -0
  278. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  279. package/src/crystal3d/ui/index.ts +20 -0
  280. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  281. package/src/crystal3d/viewer/animate.ts +113 -0
  282. package/src/crystal3d/viewer/camera.ts +139 -0
  283. package/src/crystal3d/viewer/index.ts +13 -0
  284. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  285. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  286. package/src/crystal3d/viewer/plugin.ts +258 -0
  287. package/src/crystal3d/viewer/renderCell.ts +98 -0
  288. package/src/crystal3d/viewer/renderElements.ts +121 -0
  289. package/src/crystal3d/viewer/renderStructure.ts +209 -0
  290. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  291. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  292. package/src/crystal3d/viewer/textLayer.ts +85 -0
  293. package/src/crystal3d/viewer/viewer.ts +223 -0
  294. package/src/crystal3d.ts +12 -0
  295. package/src/download/core/croppedMarkup.ts +16 -42
  296. package/src/download/core/dataUrl.ts +59 -0
  297. package/src/download/core/index.ts +3 -0
  298. package/src/download/core/svgMarkup.ts +113 -0
  299. package/src/drawing/ui/movingFigure.ts +4 -28
  300. package/src/locales/de.json +26 -1
  301. package/src/locales/en.json +26 -1
  302. package/src/locales/es.json +26 -1
  303. package/src/locales/fr.json +26 -1
  304. package/src/locales/it.json +26 -1
  305. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  306. package/src/molstar/bonds/bondRule.ts +34 -0
  307. package/src/molstar/bonds/index.ts +9 -0
  308. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  309. package/src/molstar/ui/index.ts +14 -0
  310. package/src/molstar/ui/useMolstarTools.ts +98 -0
  311. package/styles/chrome.css +90 -0
@@ -0,0 +1,255 @@
1
+ /**
2
+ * An operation as a matrix, and as the path the structure takes to get there.
3
+ *
4
+ * A proper rotation and a screw have a rigid path from the identity, so they
5
+ * are turned through it and the molecule visibly lands back on itself. The
6
+ * improper ones have none: no continuous rigid motion carries a body onto its
7
+ * mirror image. Pretending otherwise would teach the wrong thing, so instead the
8
+ * structure passes *through* the plane or the centre — flat at the halfway
9
+ * point, which is exactly where the operation's fixed set is.
10
+ */
11
+
12
+ import type { Mat3 } from './mat3.ts';
13
+ import {
14
+ IDENTITY_MATRIX,
15
+ INVERSION_MATRIX,
16
+ applyMatrix,
17
+ multiplyMatrices,
18
+ reflectionMatrix,
19
+ rotationMatrix,
20
+ } from './mat3.ts';
21
+ import type { Point3, ViewerOperation } from './types.ts';
22
+ import type { Vec3 } from './vec3.ts';
23
+ import {
24
+ addVectors,
25
+ normalizeVector,
26
+ scaleVector,
27
+ subtractVectors,
28
+ } from './vec3.ts';
29
+
30
+ /** A 4×4 affine matrix, sixteen numbers in **column-major** order. */
31
+ export type Matrix4 = readonly number[];
32
+
33
+ /** The matrix that moves nothing. */
34
+ export const IDENTITY_MATRIX4: Matrix4 = affineMatrix(
35
+ IDENTITY_MATRIX,
36
+ [0, 0, 0],
37
+ );
38
+
39
+ /**
40
+ * The operation itself, as one matrix.
41
+ * @param operation - What to apply.
42
+ * @returns The 4×4 matrix, column-major.
43
+ */
44
+ export function operationMatrix(operation: ViewerOperation): Matrix4 {
45
+ return operationAt(operation, 1);
46
+ }
47
+
48
+ /**
49
+ * The operation part-way through, so a caller can drive it with a clock.
50
+ * @param operation - What to apply.
51
+ * @param fraction - How far through, from 0 (the identity) to 1 (the operation
52
+ * itself). Anything outside that is clamped.
53
+ * @returns The 4×4 matrix, column-major.
54
+ */
55
+ export function operationAt(
56
+ operation: ViewerOperation,
57
+ fraction: number,
58
+ ): Matrix4 {
59
+ const t = Math.min(1, Math.max(0, fraction));
60
+ switch (operation.kind) {
61
+ case 'rotation': {
62
+ return aboutPoint(turn(operation, t), operation.origin, [0, 0, 0]);
63
+ }
64
+ case 'screw': {
65
+ return aboutPoint(
66
+ turn(operation, t),
67
+ operation.origin,
68
+ scaleVector(operation.translation, t),
69
+ );
70
+ }
71
+ case 'mirror': {
72
+ return aboutPoint(
73
+ blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t),
74
+ operation.point,
75
+ [0, 0, 0],
76
+ );
77
+ }
78
+ case 'glide': {
79
+ return aboutPoint(
80
+ blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t),
81
+ operation.point,
82
+ scaleVector(operation.translation, t),
83
+ );
84
+ }
85
+ case 'inversion': {
86
+ return aboutPoint(
87
+ blend(IDENTITY_MATRIX, INVERSION_MATRIX, t),
88
+ operation.centre,
89
+ [0, 0, 0],
90
+ );
91
+ }
92
+ case 'improperRotation': {
93
+ return twoPhase(operation, t, mirrorOf(operation.axis));
94
+ }
95
+ case 'rotoinversion': {
96
+ return twoPhase(operation, t, INVERSION_MATRIX);
97
+ }
98
+ // no default
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Whether the path from the identity is a rigid motion all the way.
104
+ *
105
+ * A page says so in one line under the button: a proper rotation turns, and an
106
+ * improper one has to pass through its own mirror.
107
+ * @param operation - What is about to be applied.
108
+ * @returns Whether every frame of it is a rotation.
109
+ */
110
+ export function operationIsRigid(operation: ViewerOperation): boolean {
111
+ return operation.kind === 'rotation' || operation.kind === 'screw';
112
+ }
113
+
114
+ /**
115
+ * The fraction of an improper animation spent turning, before the reflection or
116
+ * the inversion begins.
117
+ */
118
+ export const ROTATION_PHASE = 0.6;
119
+
120
+ /**
121
+ * Rotate rigidly, then pass through the plane or the centre.
122
+ * @param operation - The improper rotation or rotoinversion.
123
+ * @param t - How far through, from 0 to 1.
124
+ * @param improper - The reflection or inversion that follows the turn.
125
+ * @returns The 4×4 matrix, column-major.
126
+ */
127
+ function twoPhase(
128
+ operation: Extract<
129
+ ViewerOperation,
130
+ { kind: 'improperRotation' | 'rotoinversion' }
131
+ >,
132
+ t: number,
133
+ improper: Mat3,
134
+ ): Matrix4 {
135
+ if (t <= ROTATION_PHASE) {
136
+ return aboutPoint(
137
+ turn(operation, t / ROTATION_PHASE),
138
+ operation.origin,
139
+ [0, 0, 0],
140
+ );
141
+ }
142
+ const second = (t - ROTATION_PHASE) / (1 - ROTATION_PHASE);
143
+ const rotated = rotationMatrix(
144
+ normalizeVector(operation.axis),
145
+ angleOf(operation),
146
+ );
147
+ return aboutPoint(
148
+ multiplyMatrices(blend(IDENTITY_MATRIX, improper, second), rotated),
149
+ operation.origin,
150
+ [0, 0, 0],
151
+ );
152
+ }
153
+
154
+ /**
155
+ * The rotation of `operation` carried `t` of the way round.
156
+ * @param operation - An operation with an axis.
157
+ * @param t - How far round, from 0 to 1.
158
+ * @returns The rotation matrix.
159
+ */
160
+ function turn(
161
+ operation: Extract<
162
+ ViewerOperation,
163
+ { kind: 'rotation' | 'screw' | 'improperRotation' | 'rotoinversion' }
164
+ >,
165
+ t: number,
166
+ ): Mat3 {
167
+ return rotationMatrix(
168
+ normalizeVector(operation.axis),
169
+ angleOf(operation) * t,
170
+ );
171
+ }
172
+
173
+ /**
174
+ * `2πk/n`, the angle one application turns through.
175
+ * @param operation - An operation with an axis.
176
+ * @param operation.order - n, the order of the axis.
177
+ * @param operation.power - k, how many times it is applied; 1 by default.
178
+ * @returns The angle, in radians.
179
+ */
180
+ function angleOf(operation: { order: number; power?: number }): number {
181
+ return (2 * Math.PI * (operation.power ?? 1)) / operation.order;
182
+ }
183
+
184
+ /**
185
+ * `I − 2 n̂ n̂ᵀ`, from a normal the caller need not have normalised.
186
+ * @param normal - The mirror's normal, Cartesian.
187
+ * @returns The reflection matrix.
188
+ */
189
+ function mirrorOf(normal: Point3): Mat3 {
190
+ return reflectionMatrix(normalizeVector(normal));
191
+ }
192
+
193
+ /**
194
+ * `(1 − t) a + t b`, component by component.
195
+ * @param a - The matrix at t = 0.
196
+ * @param b - The matrix at t = 1.
197
+ * @param t - How far from a towards b.
198
+ * @returns The blended matrix.
199
+ */
200
+ function blend(a: Mat3, b: Mat3, t: number): Mat3 {
201
+ return [
202
+ blendRow(a[0], b[0], t),
203
+ blendRow(a[1], b[1], t),
204
+ blendRow(a[2], b[2], t),
205
+ ];
206
+ }
207
+
208
+ function blendRow(a: Vec3, b: Vec3, t: number): Vec3 {
209
+ return [
210
+ a[0] * (1 - t) + b[0] * t,
211
+ a[1] * (1 - t) + b[1] * t,
212
+ a[2] * (1 - t) + b[2] * t,
213
+ ];
214
+ }
215
+
216
+ /**
217
+ * `x ↦ L(x − p) + p + w`, written as one affine matrix.
218
+ * @param linear - L, the linear part.
219
+ * @param fixed - p, the point L keeps in place.
220
+ * @param shift - w, the translation added after.
221
+ * @returns The 4×4 matrix, column-major.
222
+ */
223
+ function aboutPoint(linear: Mat3, fixed: Point3, shift: Point3): Matrix4 {
224
+ return affineMatrix(
225
+ linear,
226
+ addVectors(subtractVectors(fixed, applyMatrix(linear, fixed)), shift),
227
+ );
228
+ }
229
+
230
+ /**
231
+ * The 3×3 and the translation, laid out the way a GPU reads them.
232
+ * @param linear - The linear part.
233
+ * @param translation - The translation, ångström.
234
+ * @returns The 4×4 matrix, column-major.
235
+ */
236
+ function affineMatrix(linear: Mat3, translation: Point3): Matrix4 {
237
+ return [
238
+ linear[0][0],
239
+ linear[1][0],
240
+ linear[2][0],
241
+ 0,
242
+ linear[0][1],
243
+ linear[1][1],
244
+ linear[2][1],
245
+ 0,
246
+ linear[0][2],
247
+ linear[1][2],
248
+ linear[2][2],
249
+ 0,
250
+ translation[0],
251
+ translation[1],
252
+ translation[2],
253
+ 1,
254
+ ];
255
+ }
@@ -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
+ }