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,121 @@
1
+ /**
2
+ * The symmetry elements over the structure — the reason a symmetry page has a viewer
3
+ * of its own at all.
4
+ *
5
+ * The shapes come from `elementDrawing.ts`, which knows no molstar. This module
6
+ * hands them to **three** layers, which is what keeps a cell holding ten of
7
+ * them readable: the planes are drawn nearly transparent, the rods, rims and
8
+ * balls that outline them stay solid, and the names sit in a third layer so
9
+ * they can be switched off without rebuilding anything.
10
+ *
11
+ * Drawing the whole of an element at one opacity is what makes a stack of
12
+ * mirror planes a wash of colour with the structure lost somewhere inside it.
13
+ */
14
+
15
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
16
+
17
+ import type { ElementGroup } from '../core/elementDrawing.ts';
18
+ import { elementGroups } from '../core/elementDrawing.ts';
19
+ import { LABEL_COLOUR } from '../core/palette.ts';
20
+ import type {
21
+ ElementStyle,
22
+ MeshPrimitive,
23
+ TextItem,
24
+ } from '../core/primitives.ts';
25
+ import type { SymmetryDrawing } from '../core/types.ts';
26
+
27
+ import { clearShapeLayer } from './layerRegistry.ts';
28
+ import type { ShapeGroup } from './shapeLayer.ts';
29
+ import { renderShapeLayer } from './shapeLayer.ts';
30
+ import { renderTextLayer } from './textLayer.ts';
31
+
32
+ /** How the elements are drawn. */
33
+ export interface ElementLayerStyle {
34
+ /** Sizes; the defaults of `primitives.ts` are used for anything left out. */
35
+ style?: ElementStyle;
36
+ /**
37
+ * Whether each element's name floats beside it.
38
+ * @default true
39
+ */
40
+ labels?: boolean;
41
+ /**
42
+ * Opacity of a plane's face. Low on purpose: the structure has to be read
43
+ * through however many planes cut the cell.
44
+ * @default 0.1
45
+ */
46
+ faceAlpha?: number;
47
+ /**
48
+ * Opacity of the rods, rims, arrows and balls.
49
+ * @default 0.9
50
+ */
51
+ lineAlpha?: number;
52
+ }
53
+
54
+ /**
55
+ * Replace the drawn symmetry elements.
56
+ * @param plugin - The molstar context.
57
+ * @param drawings - The elements; an empty list clears them.
58
+ * @param style - See {@link ElementLayerStyle}.
59
+ * @returns The groups that were drawn, so a caller can measure them without
60
+ * building them a second time.
61
+ * @throws {Error} When the canvas is not initialised yet.
62
+ */
63
+ export async function renderSymmetryElements(
64
+ plugin: PluginContext,
65
+ drawings: readonly SymmetryDrawing[],
66
+ style: ElementLayerStyle = {},
67
+ ): Promise<ElementGroup[]> {
68
+ const groups = elementGroups(drawings, {
69
+ style: style.style,
70
+ labels: style.labels ?? true,
71
+ });
72
+ const faces: ShapeGroup[] = [];
73
+ const lines: ShapeGroup[] = [];
74
+ const labels: TextItem[] = [];
75
+ for (const group of groups) {
76
+ const solid: MeshPrimitive[] = [];
77
+ const flat: MeshPrimitive[] = [];
78
+ for (const primitive of group.primitives) {
79
+ const target =
80
+ primitive.shape === 'face' || primitive.shape === 'plate'
81
+ ? flat
82
+ : solid;
83
+ target.push(primitive);
84
+ }
85
+ const { label, colour } = group;
86
+ if (flat.length > 0) faces.push({ label, colour, primitives: flat });
87
+ if (solid.length > 0) lines.push({ label, colour, primitives: solid });
88
+ for (const item of group.labels) labels.push({ ...item, colour });
89
+ }
90
+ await renderShapeLayer(plugin, FACE_LAYER, 'Symmetry planes', faces, {
91
+ alpha: style.faceAlpha ?? 0.1,
92
+ // A face seen edge-on would otherwise darken to nothing.
93
+ ignoreLight: true,
94
+ });
95
+ await renderShapeLayer(plugin, ELEMENT_LAYER, 'Symmetry elements', lines, {
96
+ alpha: style.lineAlpha ?? 0.9,
97
+ ignoreLight: true,
98
+ });
99
+ await renderTextLayer(
100
+ plugin,
101
+ ELEMENT_LABEL_LAYER,
102
+ 'Symmetry element labels',
103
+ labels,
104
+ LABEL_COLOUR,
105
+ );
106
+ return groups;
107
+ }
108
+
109
+ /**
110
+ * Remove the symmetry elements and their labels.
111
+ * @param plugin - The molstar context.
112
+ */
113
+ export function clearSymmetryElements(plugin: PluginContext): void {
114
+ clearShapeLayer(plugin, FACE_LAYER);
115
+ clearShapeLayer(plugin, ELEMENT_LAYER);
116
+ clearShapeLayer(plugin, ELEMENT_LABEL_LAYER);
117
+ }
118
+
119
+ const FACE_LAYER = 'symmetry-element-faces';
120
+ const ELEMENT_LAYER = 'symmetry-elements';
121
+ const ELEMENT_LABEL_LAYER = 'symmetry-element-labels';
@@ -0,0 +1,209 @@
1
+ /**
2
+ * The atoms on screen.
3
+ *
4
+ * They arrive already expanded and already repeated over the lattice, as
5
+ * Cartesian ångström, and go in as XYZ — the one format that carries elements
6
+ * and coordinates and invites molstar to apply nothing of its own.
7
+ */
8
+
9
+ import type { Structure } from 'molstar/lib/mol-model/structure.js';
10
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
11
+ import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects.js';
12
+ import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms.js';
13
+ import type { Representation } from 'molstar/lib/mol-repr/representation.js';
14
+ import type { BallAndStickParams } from 'molstar/lib/mol-repr/structure/representation/ball-and-stick.js';
15
+ import type { ParamDefinition } from 'molstar/lib/mol-util/param-definition.js';
16
+
17
+ import type { CrystalBonds } from '../core/crystalView.ts';
18
+ import { toXyzText } from '../core/structureText.ts';
19
+ import type { ViewerAtom } from '../core/types.ts';
20
+
21
+ /** How the atoms are drawn. */
22
+ export interface StructureStyle {
23
+ /**
24
+ * Balls and sticks, or space-filling spheres.
25
+ * @default 'ball-and-stick'
26
+ */
27
+ representation?: 'ball-and-stick' | 'spacefill';
28
+ /**
29
+ * Ball and stick radius multiplier. A handful of atoms reads better slightly
30
+ * thinner than molstar's protein-oriented default.
31
+ * @default 0.25
32
+ */
33
+ sizeFactor?: number;
34
+ /**
35
+ * Which bonds the balls and sticks draw.
36
+ * @default 'all'
37
+ */
38
+ bonds?: CrystalBonds;
39
+ }
40
+
41
+ /**
42
+ * Replace the atoms on screen.
43
+ * @param plugin - The molstar context.
44
+ * @param atoms - The whole scene, Cartesian ångström; an empty list clears it.
45
+ * @param style - See {@link StructureStyle}.
46
+ * @throws {Error} When molstar parses the file to no atoms at all.
47
+ */
48
+ export async function renderStructure(
49
+ plugin: PluginContext,
50
+ atoms: readonly ViewerAtom[],
51
+ style: StructureStyle = {},
52
+ ): Promise<void> {
53
+ await clearStructure(plugin);
54
+ if (atoms.length === 0) return;
55
+ const {
56
+ representation = 'ball-and-stick',
57
+ sizeFactor = 0.25,
58
+ bonds = 'all',
59
+ } = style;
60
+
61
+ const data = await plugin.builders.data.rawData(
62
+ { data: toXyzText(atoms) },
63
+ { ref: STRUCTURE_DATA_REF, state: { isGhost: true } },
64
+ );
65
+ const trajectory = await plugin.builders.structure.parseTrajectory(
66
+ data,
67
+ 'xyz',
68
+ );
69
+ const model = await plugin.builders.structure.createModel(trajectory);
70
+ if ((model.data?.atomicHierarchy.atoms._rowCount ?? 0) !== atoms.length) {
71
+ await clearStructure(plugin);
72
+ throw new Error(
73
+ `molstar read ${model.data?.atomicHierarchy.atoms._rowCount ?? 0} of the ${atoms.length} atoms it was given.`,
74
+ );
75
+ }
76
+ const structure = await plugin.builders.structure.createStructure(model);
77
+ structureRefs.set(plugin, structure.ref);
78
+ const drawn =
79
+ await plugin.builders.structure.representation.addRepresentation(
80
+ structure,
81
+ representation === 'spacefill'
82
+ ? {
83
+ type: 'spacefill',
84
+ typeParams: { sizeFactor: 1 },
85
+ color: 'element-symbol',
86
+ }
87
+ : {
88
+ type: 'ball-and-stick',
89
+ // A benzene drawn with molstar's dashed aromatic bond already shows
90
+ // the π cloud, which is a different lesson from the one here.
91
+ typeParams: {
92
+ sizeFactor,
93
+ sizeAspectRatio: 2 / 3,
94
+ aromaticBonds: false,
95
+ ...bondParams(bonds),
96
+ },
97
+ color: 'element-symbol',
98
+ colorParams: {
99
+ carbonColor: { name: 'element-symbol', params: {} },
100
+ },
101
+ },
102
+ );
103
+ representationRefs.set(plugin, drawn.ref);
104
+ }
105
+
106
+ /**
107
+ * Draw other bonds between the atoms on screen, in place: the camera, the
108
+ * measurements and an operation half applied all stay where they are.
109
+ * @param plugin - The molstar context.
110
+ * @param bonds - Which bonds are drawn.
111
+ */
112
+ export async function setStructureBonds(
113
+ plugin: PluginContext,
114
+ bonds: CrystalBonds,
115
+ ): Promise<void> {
116
+ const ref = representationRefs.get(plugin);
117
+ if (ref === undefined) return;
118
+ await plugin
119
+ .build()
120
+ .to(ref)
121
+ .update(StateTransforms.Representation.StructureRepresentation3D, (old) =>
122
+ old.type.name === 'ball-and-stick'
123
+ ? {
124
+ ...old,
125
+ type: {
126
+ ...old.type,
127
+ params: { ...old.type.params, ...bondParams(bonds) },
128
+ },
129
+ }
130
+ : old,
131
+ )
132
+ .commit();
133
+ }
134
+
135
+ /**
136
+ * The ball-and-stick parameters that draw these bonds. A metal's bonds are
137
+ * molstar's metal coordination, which it draws dashed.
138
+ * @param bonds - Which bonds are drawn.
139
+ * @returns The parameters to merge into the representation's own.
140
+ */
141
+ export function bondParams(bonds: CrystalBonds): BondParams {
142
+ return {
143
+ visuals:
144
+ bonds === 'none'
145
+ ? ['element-sphere']
146
+ : ['element-sphere', 'intra-bond', 'inter-bond'],
147
+ excludeTypes: bonds === 'noMetal' ? ['metal-coordination'] : [],
148
+ };
149
+ }
150
+
151
+ /**
152
+ * Remove the atoms, leaving every drawn layer in place.
153
+ * @param plugin - The molstar context.
154
+ */
155
+ export async function clearStructure(plugin: PluginContext): Promise<void> {
156
+ representationRefs.delete(plugin);
157
+ structureRefs.delete(plugin);
158
+ if (!plugin.state.data.cells.has(STRUCTURE_DATA_REF)) return;
159
+ await plugin.build().delete(STRUCTURE_DATA_REF).commit();
160
+ }
161
+
162
+ /**
163
+ * The representation the atoms are drawn by, which is what an operation moves.
164
+ *
165
+ * It is resolved from the state tree rather than kept, because a rebuild
166
+ * replaces the object behind the same address.
167
+ * @param plugin - The molstar context.
168
+ * @returns The representation, or `undefined` when nothing is drawn.
169
+ */
170
+ export function structureRepresentation(
171
+ plugin: PluginContext,
172
+ ): Representation.Any | undefined {
173
+ const ref = representationRefs.get(plugin);
174
+ if (ref === undefined) return undefined;
175
+ const object = plugin.state.data.cells.get(ref)?.obj;
176
+ if (!PluginStateObject.Molecule.Structure.Representation3D.is(object)) {
177
+ return undefined;
178
+ }
179
+ return object.data.repr;
180
+ }
181
+
182
+ /**
183
+ * The structure the atoms on screen were built into, which is what a
184
+ * measurement names its atoms in.
185
+ * @param plugin - The molstar context.
186
+ * @returns The structure, or `undefined` when nothing is drawn.
187
+ */
188
+ export function crystalStructure(plugin: PluginContext): Structure | undefined {
189
+ const ref = structureRefs.get(plugin);
190
+ if (ref === undefined) return undefined;
191
+ const object = plugin.state.data.cells.get(ref)?.obj;
192
+ if (!PluginStateObject.Molecule.Structure.is(object)) return undefined;
193
+ return object.data;
194
+ }
195
+
196
+ /** The ball-and-stick parameters that say which bonds are drawn. */
197
+ type BondParams = Pick<
198
+ ParamDefinition.Values<BallAndStickParams>,
199
+ 'visuals' | 'excludeTypes'
200
+ >;
201
+
202
+ /** Deleting this ref deletes the model and the representation under it. */
203
+ const STRUCTURE_DATA_REF = 'crystal3d-structure-data';
204
+
205
+ /** Where the structure the atoms were built into sits, per plugin. */
206
+ const structureRefs = new WeakMap<PluginContext, string>();
207
+
208
+ /** Where the drawn representation sits in the state tree, per plugin. */
209
+ const representationRefs = new WeakMap<PluginContext, string>();
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Drawing a part of the scene and telling the camera how far it reaches, in one
3
+ * call, so the two can never disagree.
4
+ */
5
+
6
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
7
+
8
+ import { cellEdges } from '../core/cellGeometry.ts';
9
+ import type { ElementGroup } from '../core/elementDrawing.ts';
10
+ import {
11
+ boundingSphereOf,
12
+ primitivesExtent,
13
+ unionSpheres,
14
+ } from '../core/framing.ts';
15
+ import type { MeshPrimitive } from '../core/primitives.ts';
16
+ import type {
17
+ CellRepeat,
18
+ Point3,
19
+ SymmetryDrawing,
20
+ UnitCell,
21
+ ViewerAtom,
22
+ } from '../core/types.ts';
23
+
24
+ import { setSceneExtent } from './camera.ts';
25
+ import type { CellStyle } from './renderCell.ts';
26
+ import { renderUnitCell } from './renderCell.ts';
27
+ import type { ElementLayerStyle } from './renderElements.ts';
28
+ import { renderSymmetryElements } from './renderElements.ts';
29
+ import type { StructureStyle } from './renderStructure.ts';
30
+ import { renderStructure } from './renderStructure.ts';
31
+
32
+ /**
33
+ * Replace the atoms, and record how far they reach.
34
+ * @param plugin - The molstar context.
35
+ * @param atoms - The whole scene, Cartesian ångström.
36
+ * @param style - See {@link StructureStyle}.
37
+ */
38
+ export async function drawStructure(
39
+ plugin: PluginContext,
40
+ atoms: readonly ViewerAtom[],
41
+ style?: StructureStyle,
42
+ ): Promise<void> {
43
+ await renderStructure(plugin, atoms, style);
44
+ if (atoms.length === 0) {
45
+ setSceneExtent(plugin, 'atoms', null);
46
+ return;
47
+ }
48
+ const positions: Point3[] = [];
49
+ for (const atom of atoms) positions.push(atom.position);
50
+ // The largest van der Waals radius an ordinary structure carries is about
51
+ // 2 Å, and the representation draws a ball of that times the size factor.
52
+ setSceneExtent(plugin, 'atoms', boundingSphereOf(positions, ATOM_PADDING));
53
+ }
54
+
55
+ /**
56
+ * Replace the cell, and record how far it reaches.
57
+ * @param plugin - The molstar context.
58
+ * @param cell - The six cell parameters, or `null` to draw none.
59
+ * @param repeat - Cells along a, b and c.
60
+ * @param style - See {@link CellStyle}.
61
+ */
62
+ export async function drawCell(
63
+ plugin: PluginContext,
64
+ cell: UnitCell | null,
65
+ repeat: CellRepeat = [1, 1, 1],
66
+ style?: CellStyle,
67
+ ): Promise<void> {
68
+ await renderUnitCell(plugin, cell, repeat, style);
69
+ if (cell === null) {
70
+ setSceneExtent(plugin, 'cell', null);
71
+ return;
72
+ }
73
+ const corners: Point3[] = [];
74
+ for (const edge of cellEdges(cell, repeat)) {
75
+ corners.push(edge.start, edge.end);
76
+ }
77
+ setSceneExtent(plugin, 'cell', boundingSphereOf(corners));
78
+ }
79
+
80
+ /**
81
+ * Replace the symmetry elements, and record how far they reach.
82
+ * @param plugin - The molstar context.
83
+ * @param drawings - The elements.
84
+ * @param style - See {@link ElementLayerStyle}.
85
+ */
86
+ export async function drawElements(
87
+ plugin: PluginContext,
88
+ drawings: readonly SymmetryDrawing[],
89
+ style?: ElementLayerStyle,
90
+ ): Promise<void> {
91
+ const groups: ElementGroup[] = await renderSymmetryElements(
92
+ plugin,
93
+ drawings,
94
+ style,
95
+ );
96
+ if (groups.length === 0) {
97
+ setSceneExtent(plugin, 'elements', null);
98
+ return;
99
+ }
100
+ const primitives: MeshPrimitive[] = [];
101
+ // A name sits past the end of the element it names, so the elements reach
102
+ // further than their shapes do and framing the shapes alone cuts the names
103
+ // off at the edge of the canvas.
104
+ const names: Point3[] = [];
105
+ for (const group of groups) {
106
+ primitives.push(...group.primitives);
107
+ for (const item of group.labels) names.push(item.position);
108
+ }
109
+ const shapes = primitivesExtent(primitives);
110
+ setSceneExtent(
111
+ plugin,
112
+ 'elements',
113
+ names.length === 0
114
+ ? shapes
115
+ : unionSpheres([shapes, boundingSphereOf(names)]),
116
+ );
117
+ }
118
+
119
+ const ATOM_PADDING = 0.5;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * A layer of shapes: one mesh with one group per item, so every item picks up
3
+ * its own colour and its own hover label while the whole layer is added and
4
+ * removed in one call.
5
+ */
6
+
7
+ import { MeshBuilder } from 'molstar/lib/mol-geo/geometry/mesh/mesh-builder.js';
8
+ import { Mesh } from 'molstar/lib/mol-geo/geometry/mesh/mesh.js';
9
+ import { Shape } from 'molstar/lib/mol-model/shape.js';
10
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
11
+ // Lowercased on import: it is a factory, not a constructor.
12
+ import { ShapeRepresentation as createShapeRepresentation } from 'molstar/lib/mol-repr/shape/representation.js';
13
+ import { Color } from 'molstar/lib/mol-util/color/color.js';
14
+
15
+ import type { MeshPrimitive } from '../core/primitives.ts';
16
+
17
+ import { clearShapeLayer, storeLayer } from './layerRegistry.ts';
18
+ import { addMeshPrimitive } from './meshPrimitives.ts';
19
+
20
+ /** One pickable, labelled item of a layer. */
21
+ export interface ShapeGroup {
22
+ /** What the pointer reads. */
23
+ readonly label: string;
24
+ /** `#rrggbb`. */
25
+ readonly colour: string;
26
+ /** Its shapes. */
27
+ readonly primitives: readonly MeshPrimitive[];
28
+ }
29
+
30
+ /** How solid a layer looks. */
31
+ export interface ShapeLayerStyle {
32
+ /**
33
+ * Opacity.
34
+ * @default 1
35
+ */
36
+ alpha?: number;
37
+ /**
38
+ * Draw it flat, so a square reads as one even surface whatever angle it is
39
+ * seen from.
40
+ * @default false
41
+ */
42
+ ignoreLight?: boolean;
43
+ }
44
+
45
+ /**
46
+ * Replace a layer of shapes.
47
+ * @param plugin - The molstar context.
48
+ * @param key - Which layer; a second call with the same key replaces it.
49
+ * @param name - What the layer is called in a picking label.
50
+ * @param groups - The items; an empty list clears the layer.
51
+ * @param style - See {@link ShapeLayerStyle}.
52
+ * @throws {Error} When the canvas is not initialised yet.
53
+ */
54
+ export async function renderShapeLayer(
55
+ plugin: PluginContext,
56
+ key: string,
57
+ name: string,
58
+ groups: readonly ShapeGroup[],
59
+ style: ShapeLayerStyle = {},
60
+ ): Promise<void> {
61
+ const canvas3d = plugin.canvas3d;
62
+ if (canvas3d === undefined) {
63
+ throw new Error(
64
+ `renderShapeLayer: the molstar canvas is not ready (${key}).`,
65
+ );
66
+ }
67
+ clearShapeLayer(plugin, key);
68
+ if (groups.length === 0) return;
69
+
70
+ const state = MeshBuilder.createState(4096, 2048);
71
+ const colours: Color[] = [];
72
+ const labels: string[] = [];
73
+ for (const group of groups) {
74
+ state.currentGroup = colours.length;
75
+ colours.push(Color.fromHexStyle(group.colour));
76
+ labels.push(group.label);
77
+ for (const primitive of group.primitives) {
78
+ addMeshPrimitive(state, primitive);
79
+ }
80
+ }
81
+ const mesh = MeshBuilder.getMesh(state);
82
+ Mesh.computeNormals(mesh);
83
+ const shape = Shape.create(
84
+ name,
85
+ {},
86
+ mesh,
87
+ (group: number) => colours[group] ?? BLACK,
88
+ () => 1,
89
+ (group: number) => labels[group] ?? name,
90
+ );
91
+ const representation = createShapeRepresentation(() => shape, Mesh.Utils);
92
+ await plugin.runTask(
93
+ representation.createOrUpdate(
94
+ {
95
+ alpha: style.alpha ?? 1,
96
+ doubleSided: true,
97
+ ignoreLight: style.ignoreLight ?? false,
98
+ },
99
+ shape,
100
+ ),
101
+ );
102
+ storeLayer(plugin, key, representation);
103
+ canvas3d.add(representation);
104
+ // add() only queues; nothing appears until the queue is committed.
105
+ canvas3d.commit();
106
+ }
107
+
108
+ const BLACK = Color.fromHexStyle('#000000'); // tokens-ok: the fallback ink of a picking label.
@@ -0,0 +1,85 @@
1
+ /**
2
+ * A layer of text floating in the scene: an element's name, a cell's a, b and c.
3
+ *
4
+ * The text is written on a pale card rather than straight onto the scene: a
5
+ * name over a dark atom, or over three translucent planes, is otherwise read
6
+ * as part of them.
7
+ */
8
+
9
+ import { TextBuilder } from 'molstar/lib/mol-geo/geometry/text/text-builder.js';
10
+ import { Text } from 'molstar/lib/mol-geo/geometry/text/text.js';
11
+ import { Shape } from 'molstar/lib/mol-model/shape.js';
12
+ import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
13
+ // Lowercased on import: it is a factory, not a constructor.
14
+ import { ShapeRepresentation as createShapeRepresentation } from 'molstar/lib/mol-repr/shape/representation.js';
15
+ import { Color } from 'molstar/lib/mol-util/color/color.js';
16
+
17
+ import { LABEL_CARD_COLOUR } from '../core/palette.ts';
18
+ import type { TextItem } from '../core/primitives.ts';
19
+
20
+ import { clearShapeLayer, storeLayer } from './layerRegistry.ts';
21
+
22
+ /**
23
+ * Replace a layer of floating text.
24
+ * @param plugin - The molstar context.
25
+ * @param key - Which layer; a second call with the same key replaces it.
26
+ * @param name - What the layer is called in a picking label.
27
+ * @param items - The lines; an empty list clears the layer.
28
+ * @param colour - What a line with no colour of its own is written in,
29
+ * `#rrggbb`.
30
+ * @throws {Error} When the canvas is not initialised yet.
31
+ */
32
+ export async function renderTextLayer(
33
+ plugin: PluginContext,
34
+ key: string,
35
+ name: string,
36
+ items: readonly TextItem[],
37
+ colour: string,
38
+ ): Promise<void> {
39
+ const canvas3d = plugin.canvas3d;
40
+ if (canvas3d === undefined) {
41
+ throw new Error(
42
+ `renderTextLayer: the molstar canvas is not ready (${key}).`,
43
+ );
44
+ }
45
+ clearShapeLayer(plugin, key);
46
+ if (items.length === 0) return;
47
+
48
+ const builder = TextBuilder.create({}, items.length * 4, items.length * 4);
49
+ const fallback = Color.fromHexStyle(colour);
50
+ const inks: Color[] = [];
51
+ for (let index = 0; index < items.length; index++) {
52
+ const item = items[index];
53
+ if (item === undefined) continue;
54
+ const [x, y, z] = item.position;
55
+ builder.add(item.text, x, y, z, item.size, item.size, index);
56
+ inks.push(
57
+ item.colour === undefined ? fallback : Color.fromHexStyle(item.colour),
58
+ );
59
+ }
60
+ const shape = Shape.create(
61
+ name,
62
+ {},
63
+ builder.getText(),
64
+ (group: number) => inks[group] ?? fallback,
65
+ () => 1,
66
+ (group: number) => items[group]?.text ?? name,
67
+ );
68
+ const representation = createShapeRepresentation(() => shape, Text.Utils);
69
+ await plugin.runTask(
70
+ representation.createOrUpdate(
71
+ {
72
+ attachment: 'middle-center',
73
+ background: true,
74
+ backgroundMargin: 0.25,
75
+ backgroundColor: Color.fromHexStyle(LABEL_CARD_COLOUR),
76
+ backgroundOpacity: 0.85,
77
+ fontWeight: 'bold',
78
+ },
79
+ shape,
80
+ ),
81
+ );
82
+ storeLayer(plugin, key, representation);
83
+ canvas3d.add(representation);
84
+ canvas3d.commit();
85
+ }