molstar 3.26.0 → 3.28.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 (499) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +202 -202
  3. package/build/viewer/embedded.html +52 -52
  4. package/build/viewer/index.html +115 -115
  5. package/build/viewer/molstar.css +1 -1
  6. package/build/viewer/molstar.js +1 -1
  7. package/lib/apps/docking-viewer/index.html +36 -36
  8. package/lib/apps/docking-viewer/viewport.d.ts +2 -0
  9. package/lib/apps/docking-viewer/viewport.js +1 -0
  10. package/lib/apps/viewer/app.d.ts +3 -1
  11. package/lib/apps/viewer/app.js +4 -0
  12. package/lib/apps/viewer/embedded.html +52 -52
  13. package/lib/apps/viewer/index.html +115 -115
  14. package/lib/cli/structure-info/volume.js +1 -1
  15. package/lib/commonjs/apps/docking-viewer/viewport.d.ts +2 -0
  16. package/lib/commonjs/apps/docking-viewer/viewport.js +1 -0
  17. package/lib/commonjs/apps/viewer/app.d.ts +3 -1
  18. package/lib/commonjs/apps/viewer/app.js +4 -0
  19. package/lib/commonjs/cli/structure-info/volume.js +1 -1
  20. package/lib/commonjs/examples/lighting/index.js +1 -1
  21. package/lib/commonjs/extensions/anvil/behavior.d.ts +1 -0
  22. package/lib/commonjs/extensions/cellpack/model.js +2 -1
  23. package/lib/commonjs/extensions/dnatco/confal-pyramids/behavior.d.ts +1 -0
  24. package/lib/commonjs/extensions/meshes/choice.d.ts +26 -0
  25. package/lib/commonjs/extensions/meshes/choice.js +31 -0
  26. package/lib/commonjs/extensions/meshes/examples.d.ts +26 -0
  27. package/lib/commonjs/extensions/meshes/examples.js +337 -0
  28. package/lib/commonjs/extensions/meshes/mesh-cif-schema.d.ts +29 -0
  29. package/lib/commonjs/extensions/meshes/mesh-cif-schema.js +34 -0
  30. package/lib/commonjs/extensions/meshes/mesh-extension.d.ts +66 -0
  31. package/lib/commonjs/extensions/meshes/mesh-extension.js +221 -0
  32. package/lib/commonjs/extensions/meshes/mesh-streaming/behavior.d.ts +105 -0
  33. package/lib/commonjs/extensions/meshes/mesh-streaming/behavior.js +379 -0
  34. package/lib/commonjs/extensions/meshes/mesh-streaming/server-info.d.ts +54 -0
  35. package/lib/commonjs/extensions/meshes/mesh-streaming/server-info.js +30 -0
  36. package/lib/commonjs/extensions/meshes/mesh-streaming/transformers.d.ts +42 -0
  37. package/lib/commonjs/extensions/meshes/mesh-streaming/transformers.js +273 -0
  38. package/lib/commonjs/extensions/meshes/mesh-utils.d.ts +41 -0
  39. package/lib/commonjs/extensions/meshes/mesh-utils.js +357 -0
  40. package/lib/commonjs/extensions/meshes/metadata.d.ts +108 -0
  41. package/lib/commonjs/extensions/meshes/metadata.js +72 -0
  42. package/lib/commonjs/extensions/model-archive/quality-assessment/behavior.d.ts +2 -0
  43. package/lib/commonjs/extensions/model-archive/quality-assessment/prop.d.ts +1 -0
  44. package/lib/commonjs/extensions/model-archive/quality-assessment/prop.js +16 -4
  45. package/lib/commonjs/extensions/rcsb/assembly-symmetry/behavior.d.ts +4 -2
  46. package/lib/commonjs/extensions/rcsb/validation-report/behavior.d.ts +3 -0
  47. package/lib/commonjs/extensions/volumes-and-segmentations/entry-meshes.d.ts +17 -0
  48. package/lib/commonjs/extensions/volumes-and-segmentations/entry-meshes.js +156 -0
  49. package/lib/commonjs/extensions/volumes-and-segmentations/entry-models.d.ts +12 -0
  50. package/lib/commonjs/extensions/volumes-and-segmentations/entry-models.js +96 -0
  51. package/lib/commonjs/extensions/volumes-and-segmentations/entry-root.d.ts +122 -0
  52. package/lib/commonjs/extensions/volumes-and-segmentations/entry-root.js +576 -0
  53. package/lib/commonjs/extensions/volumes-and-segmentations/entry-segmentation.d.ts +20 -0
  54. package/lib/commonjs/extensions/volumes-and-segmentations/entry-segmentation.js +200 -0
  55. package/lib/commonjs/extensions/volumes-and-segmentations/entry-state.d.ts +88 -0
  56. package/lib/commonjs/extensions/volumes-and-segmentations/entry-state.js +32 -0
  57. package/lib/commonjs/extensions/volumes-and-segmentations/entry-volume.d.ts +35 -0
  58. package/lib/commonjs/extensions/volumes-and-segmentations/entry-volume.js +234 -0
  59. package/lib/commonjs/extensions/volumes-and-segmentations/external-api.d.ts +11 -0
  60. package/lib/commonjs/extensions/volumes-and-segmentations/external-api.js +85 -0
  61. package/lib/commonjs/extensions/volumes-and-segmentations/global-state.d.ts +51 -0
  62. package/lib/commonjs/extensions/volumes-and-segmentations/global-state.js +83 -0
  63. package/lib/commonjs/extensions/volumes-and-segmentations/helpers.d.ts +56 -0
  64. package/lib/commonjs/extensions/volumes-and-segmentations/helpers.js +171 -0
  65. package/lib/commonjs/extensions/volumes-and-segmentations/index.d.ts +20 -0
  66. package/lib/commonjs/extensions/volumes-and-segmentations/index.js +130 -0
  67. package/lib/commonjs/extensions/volumes-and-segmentations/transformers.d.ts +33 -0
  68. package/lib/commonjs/extensions/volumes-and-segmentations/transformers.js +85 -0
  69. package/lib/commonjs/extensions/volumes-and-segmentations/ui.d.ts +29 -0
  70. package/lib/commonjs/extensions/volumes-and-segmentations/ui.js +232 -0
  71. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/api.d.ts +22 -0
  72. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/api.js +83 -0
  73. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/data.d.ts +92 -0
  74. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/data.js +7 -0
  75. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/utils.d.ts +23 -0
  76. package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/utils.js +78 -0
  77. package/lib/commonjs/mol-canvas3d/canvas3d.d.ts +2 -0
  78. package/lib/commonjs/mol-canvas3d/passes/draw.js +3 -3
  79. package/lib/commonjs/mol-canvas3d/passes/image.d.ts +1 -0
  80. package/lib/commonjs/mol-canvas3d/passes/postprocessing.d.ts +2 -1
  81. package/lib/commonjs/mol-canvas3d/passes/postprocessing.js +27 -13
  82. package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.d.ts +2 -1
  83. package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.js +3 -2
  84. package/lib/commonjs/mol-geo/geometry/lines/lines.d.ts +0 -1
  85. package/lib/commonjs/mol-geo/geometry/points/points.d.ts +1 -1
  86. package/lib/commonjs/mol-geo/geometry/spheres/spheres.d.ts +1 -0
  87. package/lib/commonjs/mol-geo/geometry/spheres/spheres.js +3 -2
  88. package/lib/commonjs/mol-gl/compute/histogram-pyramid/reduction.js +1 -2
  89. package/lib/commonjs/mol-gl/compute/marching-cubes/isosurface.js +4 -6
  90. package/lib/commonjs/mol-gl/renderable/cylinders.d.ts +1 -0
  91. package/lib/commonjs/mol-gl/renderable/cylinders.js +1 -1
  92. package/lib/commonjs/mol-gl/renderable/spheres.d.ts +1 -0
  93. package/lib/commonjs/mol-gl/renderable/spheres.js +1 -1
  94. package/lib/commonjs/mol-gl/shader/chunks/apply-light-color.glsl.d.ts +1 -1
  95. package/lib/commonjs/mol-gl/shader/chunks/apply-light-color.glsl.js +1 -1
  96. package/lib/commonjs/mol-gl/shader/chunks/clip-instance.glsl.d.ts +1 -1
  97. package/lib/commonjs/mol-gl/shader/chunks/clip-instance.glsl.js +1 -1
  98. package/lib/commonjs/mol-gl/shader/chunks/clip-pixel.glsl.d.ts +1 -1
  99. package/lib/commonjs/mol-gl/shader/chunks/clip-pixel.glsl.js +1 -1
  100. package/lib/commonjs/mol-gl/shader/chunks/common-clip.glsl.d.ts +2 -2
  101. package/lib/commonjs/mol-gl/shader/chunks/common-clip.glsl.js +2 -2
  102. package/lib/commonjs/mol-gl/shader/cylinders.frag.d.ts +1 -1
  103. package/lib/commonjs/mol-gl/shader/cylinders.frag.js +1 -1
  104. package/lib/commonjs/mol-gl/shader/cylinders.vert.d.ts +2 -2
  105. package/lib/commonjs/mol-gl/shader/cylinders.vert.js +2 -2
  106. package/lib/commonjs/mol-gl/shader/direct-volume.frag.d.ts +1 -1
  107. package/lib/commonjs/mol-gl/shader/direct-volume.frag.js +1 -1
  108. package/lib/commonjs/mol-gl/shader/outlines.frag.d.ts +1 -1
  109. package/lib/commonjs/mol-gl/shader/outlines.frag.js +1 -1
  110. package/lib/commonjs/mol-gl/shader/postprocessing.frag.d.ts +1 -1
  111. package/lib/commonjs/mol-gl/shader/postprocessing.frag.js +1 -1
  112. package/lib/commonjs/mol-gl/shader/spheres.frag.d.ts +1 -1
  113. package/lib/commonjs/mol-gl/shader/spheres.frag.js +1 -1
  114. package/lib/commonjs/mol-gl/shader/spheres.vert.d.ts +2 -2
  115. package/lib/commonjs/mol-gl/shader/spheres.vert.js +2 -2
  116. package/lib/commonjs/mol-gl/webgl/renderbuffer.d.ts +1 -1
  117. package/lib/commonjs/mol-gl/webgl/renderbuffer.js +15 -0
  118. package/lib/commonjs/mol-gl/webgl/state.d.ts +12 -0
  119. package/lib/commonjs/mol-gl/webgl/state.js +136 -0
  120. package/lib/commonjs/mol-io/reader/cif/schema/segmentation.d.ts +38 -0
  121. package/lib/commonjs/mol-io/reader/cif/schema/segmentation.js +22 -0
  122. package/lib/commonjs/mol-io/reader/cif.d.ts +3 -1
  123. package/lib/commonjs/mol-io/reader/cif.js +3 -1
  124. package/lib/commonjs/mol-model/location.d.ts +2 -1
  125. package/lib/commonjs/mol-model/loci.d.ts +11 -11
  126. package/lib/commonjs/mol-model/loci.js +13 -1
  127. package/lib/commonjs/mol-model/sequence/alignment/sequence.d.ts +4 -1
  128. package/lib/commonjs/mol-model/sequence/alignment/sequence.js +4 -1
  129. package/lib/commonjs/mol-model/structure/model/properties/atomic/hierarchy.d.ts +6 -0
  130. package/lib/commonjs/mol-model/structure/model/properties/utils/atomic-index.js +8 -0
  131. package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -5
  132. package/lib/commonjs/mol-model/structure/structure/util/superposition.d.ts +1 -0
  133. package/lib/commonjs/mol-model/structure/structure/util/superposition.js +2 -1
  134. package/lib/commonjs/mol-model/volume/volume.d.ts +35 -2
  135. package/lib/commonjs/mol-model/volume/volume.js +77 -2
  136. package/lib/commonjs/mol-model-formats/volume/segmentation.d.ts +23 -0
  137. package/lib/commonjs/mol-model-formats/volume/segmentation.js +138 -0
  138. package/lib/commonjs/mol-plugin/behavior/dynamic/representation.d.ts +2 -2
  139. package/lib/commonjs/mol-plugin/behavior/dynamic/selection/structure-focus-representation.d.ts +1 -0
  140. package/lib/commonjs/mol-plugin/behavior/dynamic/selection/structure-focus-representation.js +2 -1
  141. package/lib/commonjs/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +2 -3
  142. package/lib/commonjs/mol-plugin/commands.d.ts +1 -0
  143. package/lib/commonjs/mol-plugin-state/animation/built-in/model-index.js +4 -1
  144. package/lib/commonjs/mol-plugin-state/builder/structure/hierarchy-preset.d.ts +2 -0
  145. package/lib/commonjs/mol-plugin-state/builder/structure/hierarchy.d.ts +1 -0
  146. package/lib/commonjs/mol-plugin-state/builder/structure/representation-preset.d.ts +13 -4
  147. package/lib/commonjs/mol-plugin-state/builder/structure/representation-preset.js +6 -1
  148. package/lib/commonjs/mol-plugin-state/builder/structure/representation.d.ts +1 -0
  149. package/lib/commonjs/mol-plugin-state/formats/provider.d.ts +2 -2
  150. package/lib/commonjs/mol-plugin-state/formats/provider.js +11 -3
  151. package/lib/commonjs/mol-plugin-state/formats/registry.js +6 -5
  152. package/lib/commonjs/mol-plugin-state/formats/volume.d.ts +27 -0
  153. package/lib/commonjs/mol-plugin-state/formats/volume.js +65 -1
  154. package/lib/commonjs/mol-plugin-state/manager/structure/component.d.ts +1 -1
  155. package/lib/commonjs/mol-plugin-state/manager/structure/component.js +18 -13
  156. package/lib/commonjs/mol-plugin-state/transforms/representation.d.ts +1 -2
  157. package/lib/commonjs/mol-plugin-state/transforms/representation.js +5 -6
  158. package/lib/commonjs/mol-plugin-state/transforms/volume.d.ts +11 -1
  159. package/lib/commonjs/mol-plugin-state/transforms/volume.js +55 -2
  160. package/lib/commonjs/mol-plugin-ui/controls/line-graph/line-graph-component.d.ts +1 -0
  161. package/lib/commonjs/mol-plugin-ui/controls/line-graph/line-graph-component.js +33 -13
  162. package/lib/commonjs/mol-plugin-ui/controls/parameters.d.ts +1 -0
  163. package/lib/commonjs/mol-plugin-ui/controls/parameters.js +22 -5
  164. package/lib/commonjs/mol-plugin-ui/sequence/sequence.d.ts +25 -17
  165. package/lib/commonjs/mol-plugin-ui/sequence.d.ts +19 -1
  166. package/lib/commonjs/mol-plugin-ui/sequence.js +8 -1
  167. package/lib/commonjs/mol-plugin-ui/state/apply-action.d.ts +2 -10
  168. package/lib/commonjs/mol-plugin-ui/state/apply-action.js +2 -2
  169. package/lib/commonjs/mol-plugin-ui/structure/quick-styles.js +2 -2
  170. package/lib/commonjs/mol-plugin-ui/structure/superposition.d.ts +1 -1
  171. package/lib/commonjs/mol-plugin-ui/structure/volume.d.ts +1 -1
  172. package/lib/commonjs/mol-plugin-ui/structure/volume.js +3 -2
  173. package/lib/commonjs/mol-repr/structure/complex-visual.d.ts +1 -0
  174. package/lib/commonjs/mol-repr/structure/params.d.ts +2 -0
  175. package/lib/commonjs/mol-repr/structure/registry.d.ts +12 -0
  176. package/lib/commonjs/mol-repr/structure/representation/backbone.d.ts +3 -0
  177. package/lib/commonjs/mol-repr/structure/representation/ball-and-stick.d.ts +6 -0
  178. package/lib/commonjs/mol-repr/structure/representation/ellipsoid.d.ts +6 -0
  179. package/lib/commonjs/mol-repr/structure/representation/gaussian-surface.d.ts +3 -0
  180. package/lib/commonjs/mol-repr/structure/representation/gaussian-volume.d.ts +3 -0
  181. package/lib/commonjs/mol-repr/structure/representation/line.d.ts +3 -0
  182. package/lib/commonjs/mol-repr/structure/representation/molecular-surface.d.ts +3 -0
  183. package/lib/commonjs/mol-repr/structure/representation/point.d.ts +3 -0
  184. package/lib/commonjs/mol-repr/structure/representation/spacefill.d.ts +6 -0
  185. package/lib/commonjs/mol-repr/structure/units-visual.d.ts +2 -0
  186. package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +4 -0
  187. package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.js +2 -0
  188. package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -0
  189. package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.js +1 -0
  190. package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-cylinder.d.ts +4 -0
  191. package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-cylinder.js +2 -0
  192. package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-line.d.ts +1 -0
  193. package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-line.js +1 -0
  194. package/lib/commonjs/mol-repr/structure/visual/element-cross.d.ts +1 -0
  195. package/lib/commonjs/mol-repr/structure/visual/element-cross.js +2 -1
  196. package/lib/commonjs/mol-repr/structure/visual/element-point.d.ts +1 -0
  197. package/lib/commonjs/mol-repr/structure/visual/element-point.js +2 -1
  198. package/lib/commonjs/mol-repr/structure/visual/element-sphere.d.ts +4 -0
  199. package/lib/commonjs/mol-repr/structure/visual/element-sphere.js +3 -1
  200. package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -0
  201. package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.js +6 -2
  202. package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-mesh.d.ts +4 -0
  203. package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-mesh.js +9 -1
  204. package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-wireframe.d.ts +1 -0
  205. package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-wireframe.js +3 -1
  206. package/lib/commonjs/mol-repr/structure/visual/molecular-surface-mesh.d.ts +1 -0
  207. package/lib/commonjs/mol-repr/structure/visual/molecular-surface-mesh.js +4 -0
  208. package/lib/commonjs/mol-repr/structure/visual/molecular-surface-wireframe.d.ts +1 -0
  209. package/lib/commonjs/mol-repr/structure/visual/molecular-surface-wireframe.js +2 -0
  210. package/lib/commonjs/mol-repr/structure/visual/polymer-backbone-cylinder.d.ts +2 -0
  211. package/lib/commonjs/mol-repr/structure/visual/polymer-backbone-sphere.d.ts +2 -0
  212. package/lib/commonjs/mol-repr/structure/visual/util/bond.d.ts +7 -0
  213. package/lib/commonjs/mol-repr/structure/visual/util/bond.js +18 -7
  214. package/lib/commonjs/mol-repr/structure/visual/util/common.d.ts +4 -1
  215. package/lib/commonjs/mol-repr/structure/visual/util/common.js +10 -6
  216. package/lib/commonjs/mol-repr/structure/visual/util/element.d.ts +1 -0
  217. package/lib/commonjs/mol-repr/structure/visual/util/element.js +2 -3
  218. package/lib/commonjs/mol-repr/structure/visual/util/gaussian.d.ts +2 -0
  219. package/lib/commonjs/mol-repr/volume/direct-volume.d.ts +4 -4
  220. package/lib/commonjs/mol-repr/volume/direct-volume.js +8 -6
  221. package/lib/commonjs/mol-repr/volume/isosurface.d.ts +4 -4
  222. package/lib/commonjs/mol-repr/volume/isosurface.js +17 -16
  223. package/lib/commonjs/mol-repr/volume/registry.d.ts +54 -1
  224. package/lib/commonjs/mol-repr/volume/registry.js +3 -1
  225. package/lib/commonjs/mol-repr/volume/representation.d.ts +11 -7
  226. package/lib/commonjs/mol-repr/volume/representation.js +142 -47
  227. package/lib/commonjs/mol-repr/volume/segment.d.ts +291 -0
  228. package/lib/commonjs/mol-repr/volume/segment.js +289 -0
  229. package/lib/commonjs/mol-repr/volume/slice.d.ts +2 -2
  230. package/lib/commonjs/mol-repr/volume/slice.js +5 -5
  231. package/lib/commonjs/mol-repr/volume/util.d.ts +12 -3
  232. package/lib/commonjs/mol-repr/volume/util.js +72 -6
  233. package/lib/commonjs/mol-script/language/builder.d.ts +1 -0
  234. package/lib/commonjs/mol-theme/color/volume-segment.d.ts +41 -0
  235. package/lib/commonjs/mol-theme/color/volume-segment.js +58 -0
  236. package/lib/commonjs/mol-theme/color/volume-value.js +2 -1
  237. package/lib/commonjs/mol-theme/color.d.ts +15 -0
  238. package/lib/commonjs/mol-theme/color.js +2 -0
  239. package/lib/commonjs/mol-theme/label.d.ts +1 -1
  240. package/lib/commonjs/mol-theme/label.js +13 -1
  241. package/lib/commonjs/mol-util/param-definition.d.ts +4 -1
  242. package/lib/commonjs/mol-util/param-definition.js +5 -2
  243. package/lib/examples/alpha-orbitals/index.html +72 -72
  244. package/lib/examples/basic-wrapper/index.html +137 -137
  245. package/lib/examples/lighting/index.html +88 -88
  246. package/lib/examples/lighting/index.js +1 -1
  247. package/lib/examples/proteopedia-wrapper/index.html +236 -236
  248. package/lib/extensions/anvil/behavior.d.ts +1 -0
  249. package/lib/extensions/cellpack/model.js +2 -1
  250. package/lib/extensions/dnatco/confal-pyramids/behavior.d.ts +1 -0
  251. package/lib/extensions/meshes/choice.d.ts +26 -0
  252. package/lib/extensions/meshes/choice.js +28 -0
  253. package/lib/extensions/meshes/examples.d.ts +26 -0
  254. package/lib/extensions/meshes/examples.js +325 -0
  255. package/lib/extensions/meshes/mesh-cif-schema.d.ts +29 -0
  256. package/lib/extensions/meshes/mesh-cif-schema.js +30 -0
  257. package/lib/extensions/meshes/mesh-extension.d.ts +66 -0
  258. package/lib/extensions/meshes/mesh-extension.js +218 -0
  259. package/lib/extensions/meshes/mesh-streaming/behavior.d.ts +105 -0
  260. package/lib/extensions/meshes/mesh-streaming/behavior.js +375 -0
  261. package/lib/extensions/meshes/mesh-streaming/server-info.d.ts +54 -0
  262. package/lib/extensions/meshes/mesh-streaming/server-info.js +26 -0
  263. package/lib/extensions/meshes/mesh-streaming/transformers.d.ts +42 -0
  264. package/lib/extensions/meshes/mesh-streaming/transformers.js +270 -0
  265. package/lib/extensions/meshes/mesh-utils.d.ts +41 -0
  266. package/lib/extensions/meshes/mesh-utils.js +346 -0
  267. package/lib/extensions/meshes/metadata.d.ts +108 -0
  268. package/lib/extensions/meshes/metadata.js +69 -0
  269. package/lib/extensions/model-archive/quality-assessment/behavior.d.ts +2 -0
  270. package/lib/extensions/model-archive/quality-assessment/prop.d.ts +1 -0
  271. package/lib/extensions/model-archive/quality-assessment/prop.js +16 -4
  272. package/lib/extensions/rcsb/assembly-symmetry/behavior.d.ts +4 -2
  273. package/lib/extensions/rcsb/validation-report/behavior.d.ts +3 -0
  274. package/lib/extensions/volumes-and-segmentations/entry-meshes.d.ts +17 -0
  275. package/lib/extensions/volumes-and-segmentations/entry-meshes.js +153 -0
  276. package/lib/extensions/volumes-and-segmentations/entry-models.d.ts +12 -0
  277. package/lib/extensions/volumes-and-segmentations/entry-models.js +93 -0
  278. package/lib/extensions/volumes-and-segmentations/entry-root.d.ts +122 -0
  279. package/lib/extensions/volumes-and-segmentations/entry-root.js +571 -0
  280. package/lib/extensions/volumes-and-segmentations/entry-segmentation.d.ts +20 -0
  281. package/lib/extensions/volumes-and-segmentations/entry-segmentation.js +197 -0
  282. package/lib/extensions/volumes-and-segmentations/entry-state.d.ts +88 -0
  283. package/lib/extensions/volumes-and-segmentations/entry-state.js +29 -0
  284. package/lib/extensions/volumes-and-segmentations/entry-volume.d.ts +35 -0
  285. package/lib/extensions/volumes-and-segmentations/entry-volume.js +231 -0
  286. package/lib/extensions/volumes-and-segmentations/external-api.d.ts +11 -0
  287. package/lib/extensions/volumes-and-segmentations/external-api.js +80 -0
  288. package/lib/extensions/volumes-and-segmentations/global-state.d.ts +51 -0
  289. package/lib/extensions/volumes-and-segmentations/global-state.js +80 -0
  290. package/lib/extensions/volumes-and-segmentations/helpers.d.ts +56 -0
  291. package/lib/extensions/volumes-and-segmentations/helpers.js +163 -0
  292. package/lib/extensions/volumes-and-segmentations/index.d.ts +20 -0
  293. package/lib/extensions/volumes-and-segmentations/index.js +127 -0
  294. package/lib/extensions/volumes-and-segmentations/transformers.d.ts +33 -0
  295. package/lib/extensions/volumes-and-segmentations/transformers.js +82 -0
  296. package/lib/extensions/volumes-and-segmentations/ui.d.ts +29 -0
  297. package/lib/extensions/volumes-and-segmentations/ui.js +229 -0
  298. package/lib/extensions/volumes-and-segmentations/volseg-api/api.d.ts +22 -0
  299. package/lib/extensions/volumes-and-segmentations/volseg-api/api.js +80 -0
  300. package/lib/extensions/volumes-and-segmentations/volseg-api/data.d.ts +92 -0
  301. package/lib/extensions/volumes-and-segmentations/volseg-api/data.js +6 -0
  302. package/lib/extensions/volumes-and-segmentations/volseg-api/utils.d.ts +23 -0
  303. package/lib/extensions/volumes-and-segmentations/volseg-api/utils.js +75 -0
  304. package/lib/mol-canvas3d/canvas3d.d.ts +2 -0
  305. package/lib/mol-canvas3d/passes/draw.js +3 -3
  306. package/lib/mol-canvas3d/passes/image.d.ts +1 -0
  307. package/lib/mol-canvas3d/passes/postprocessing.d.ts +2 -1
  308. package/lib/mol-canvas3d/passes/postprocessing.js +27 -13
  309. package/lib/mol-geo/geometry/cylinders/cylinders.d.ts +2 -1
  310. package/lib/mol-geo/geometry/cylinders/cylinders.js +3 -2
  311. package/lib/mol-geo/geometry/lines/lines.d.ts +0 -1
  312. package/lib/mol-geo/geometry/points/points.d.ts +1 -1
  313. package/lib/mol-geo/geometry/spheres/spheres.d.ts +1 -0
  314. package/lib/mol-geo/geometry/spheres/spheres.js +3 -2
  315. package/lib/mol-gl/compute/histogram-pyramid/reduction.js +1 -2
  316. package/lib/mol-gl/compute/marching-cubes/isosurface.js +4 -6
  317. package/lib/mol-gl/renderable/cylinders.d.ts +1 -0
  318. package/lib/mol-gl/renderable/cylinders.js +1 -1
  319. package/lib/mol-gl/renderable/spheres.d.ts +1 -0
  320. package/lib/mol-gl/renderable/spheres.js +1 -1
  321. package/lib/mol-gl/shader/chunks/apply-light-color.glsl.d.ts +1 -1
  322. package/lib/mol-gl/shader/chunks/apply-light-color.glsl.js +1 -1
  323. package/lib/mol-gl/shader/chunks/clip-instance.glsl.d.ts +1 -1
  324. package/lib/mol-gl/shader/chunks/clip-instance.glsl.js +1 -1
  325. package/lib/mol-gl/shader/chunks/clip-pixel.glsl.d.ts +1 -1
  326. package/lib/mol-gl/shader/chunks/clip-pixel.glsl.js +1 -1
  327. package/lib/mol-gl/shader/chunks/common-clip.glsl.d.ts +2 -2
  328. package/lib/mol-gl/shader/chunks/common-clip.glsl.js +2 -2
  329. package/lib/mol-gl/shader/cylinders.frag.d.ts +1 -1
  330. package/lib/mol-gl/shader/cylinders.frag.js +1 -1
  331. package/lib/mol-gl/shader/cylinders.vert.d.ts +2 -2
  332. package/lib/mol-gl/shader/cylinders.vert.js +2 -2
  333. package/lib/mol-gl/shader/direct-volume.frag.d.ts +1 -1
  334. package/lib/mol-gl/shader/direct-volume.frag.js +1 -1
  335. package/lib/mol-gl/shader/outlines.frag.d.ts +1 -1
  336. package/lib/mol-gl/shader/outlines.frag.js +1 -1
  337. package/lib/mol-gl/shader/postprocessing.frag.d.ts +1 -1
  338. package/lib/mol-gl/shader/postprocessing.frag.js +1 -1
  339. package/lib/mol-gl/shader/spheres.frag.d.ts +1 -1
  340. package/lib/mol-gl/shader/spheres.frag.js +1 -1
  341. package/lib/mol-gl/shader/spheres.vert.d.ts +2 -2
  342. package/lib/mol-gl/shader/spheres.vert.js +2 -2
  343. package/lib/mol-gl/webgl/renderbuffer.d.ts +1 -1
  344. package/lib/mol-gl/webgl/renderbuffer.js +15 -0
  345. package/lib/mol-gl/webgl/state.d.ts +12 -0
  346. package/lib/mol-gl/webgl/state.js +136 -0
  347. package/lib/mol-io/reader/cif/schema/segmentation.d.ts +38 -0
  348. package/lib/mol-io/reader/cif/schema/segmentation.js +19 -0
  349. package/lib/mol-io/reader/cif.d.ts +3 -1
  350. package/lib/mol-io/reader/cif.js +3 -1
  351. package/lib/mol-model/location.d.ts +2 -1
  352. package/lib/mol-model/loci.d.ts +11 -11
  353. package/lib/mol-model/loci.js +13 -1
  354. package/lib/mol-model/sequence/alignment/sequence.d.ts +4 -1
  355. package/lib/mol-model/sequence/alignment/sequence.js +3 -2
  356. package/lib/mol-model/structure/model/properties/atomic/hierarchy.d.ts +6 -0
  357. package/lib/mol-model/structure/model/properties/utils/atomic-index.js +8 -0
  358. package/lib/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -5
  359. package/lib/mol-model/structure/structure/util/superposition.d.ts +1 -0
  360. package/lib/mol-model/structure/structure/util/superposition.js +1 -1
  361. package/lib/mol-model/volume/volume.d.ts +35 -2
  362. package/lib/mol-model/volume/volume.js +79 -4
  363. package/lib/mol-model-formats/volume/segmentation.d.ts +23 -0
  364. package/lib/mol-model-formats/volume/segmentation.js +135 -0
  365. package/lib/mol-plugin/behavior/dynamic/representation.d.ts +2 -2
  366. package/lib/mol-plugin/behavior/dynamic/selection/structure-focus-representation.d.ts +1 -0
  367. package/lib/mol-plugin/behavior/dynamic/selection/structure-focus-representation.js +2 -1
  368. package/lib/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +2 -3
  369. package/lib/mol-plugin/commands.d.ts +1 -0
  370. package/lib/mol-plugin/version.js +2 -2
  371. package/lib/mol-plugin-state/animation/built-in/model-index.js +4 -1
  372. package/lib/mol-plugin-state/builder/structure/hierarchy-preset.d.ts +2 -0
  373. package/lib/mol-plugin-state/builder/structure/hierarchy.d.ts +1 -0
  374. package/lib/mol-plugin-state/builder/structure/representation-preset.d.ts +13 -4
  375. package/lib/mol-plugin-state/builder/structure/representation-preset.js +6 -1
  376. package/lib/mol-plugin-state/builder/structure/representation.d.ts +1 -0
  377. package/lib/mol-plugin-state/formats/provider.d.ts +2 -2
  378. package/lib/mol-plugin-state/formats/provider.js +11 -3
  379. package/lib/mol-plugin-state/formats/registry.js +6 -5
  380. package/lib/mol-plugin-state/formats/volume.d.ts +27 -0
  381. package/lib/mol-plugin-state/formats/volume.js +64 -0
  382. package/lib/mol-plugin-state/manager/structure/component.d.ts +1 -1
  383. package/lib/mol-plugin-state/manager/structure/component.js +18 -13
  384. package/lib/mol-plugin-state/transforms/representation.d.ts +1 -2
  385. package/lib/mol-plugin-state/transforms/representation.js +5 -6
  386. package/lib/mol-plugin-state/transforms/volume.d.ts +11 -1
  387. package/lib/mol-plugin-state/transforms/volume.js +54 -1
  388. package/lib/mol-plugin-ui/controls/line-graph/line-graph-component.d.ts +1 -0
  389. package/lib/mol-plugin-ui/controls/line-graph/line-graph-component.js +33 -13
  390. package/lib/mol-plugin-ui/controls/parameters.d.ts +1 -0
  391. package/lib/mol-plugin-ui/controls/parameters.js +22 -5
  392. package/lib/mol-plugin-ui/sequence/sequence.d.ts +25 -17
  393. package/lib/mol-plugin-ui/sequence.d.ts +19 -1
  394. package/lib/mol-plugin-ui/sequence.js +7 -7
  395. package/lib/mol-plugin-ui/skin/base/base.scss +32 -32
  396. package/lib/mol-plugin-ui/skin/base/components/controls-base.scss +333 -333
  397. package/lib/mol-plugin-ui/skin/base/components/controls.scss +418 -418
  398. package/lib/mol-plugin-ui/skin/base/components/help.scss +27 -27
  399. package/lib/mol-plugin-ui/skin/base/components/line-graph.scss +67 -67
  400. package/lib/mol-plugin-ui/skin/base/components/log.scss +100 -100
  401. package/lib/mol-plugin-ui/skin/base/components/misc.scss +643 -643
  402. package/lib/mol-plugin-ui/skin/base/components/sequence.scss +125 -125
  403. package/lib/mol-plugin-ui/skin/base/components/slider.scss +165 -165
  404. package/lib/mol-plugin-ui/skin/base/components/tasks.scss +99 -99
  405. package/lib/mol-plugin-ui/skin/base/components/toast.scss +83 -83
  406. package/lib/mol-plugin-ui/skin/base/components/transformer.scss +163 -163
  407. package/lib/mol-plugin-ui/skin/base/components/viewport.scss +137 -128
  408. package/lib/mol-plugin-ui/skin/base/layout/common.scss +71 -71
  409. package/lib/mol-plugin-ui/skin/base/layout/controls-landscape.scss +89 -89
  410. package/lib/mol-plugin-ui/skin/base/layout/controls-outside.scss +98 -98
  411. package/lib/mol-plugin-ui/skin/base/layout/controls-portrait.scss +108 -108
  412. package/lib/mol-plugin-ui/skin/base/layout.scss +40 -40
  413. package/lib/mol-plugin-ui/skin/base/logo.scss +12 -12
  414. package/lib/mol-plugin-ui/skin/base/normalize.scss +209 -209
  415. package/lib/mol-plugin-ui/skin/base/ui.scss +40 -40
  416. package/lib/mol-plugin-ui/skin/base/variables.scss +85 -85
  417. package/lib/mol-plugin-ui/skin/blue.scss +1 -1
  418. package/lib/mol-plugin-ui/skin/colors/blue.scss +23 -23
  419. package/lib/mol-plugin-ui/skin/colors/dark.scss +23 -23
  420. package/lib/mol-plugin-ui/skin/colors/light.scss +29 -29
  421. package/lib/mol-plugin-ui/skin/dark.scss +1 -1
  422. package/lib/mol-plugin-ui/skin/light.scss +1 -1
  423. package/lib/mol-plugin-ui/state/apply-action.d.ts +2 -10
  424. package/lib/mol-plugin-ui/state/apply-action.js +2 -2
  425. package/lib/mol-plugin-ui/structure/quick-styles.js +2 -2
  426. package/lib/mol-plugin-ui/structure/superposition.d.ts +1 -1
  427. package/lib/mol-plugin-ui/structure/volume.d.ts +1 -1
  428. package/lib/mol-plugin-ui/structure/volume.js +3 -2
  429. package/lib/mol-repr/structure/complex-visual.d.ts +1 -0
  430. package/lib/mol-repr/structure/params.d.ts +2 -0
  431. package/lib/mol-repr/structure/registry.d.ts +12 -0
  432. package/lib/mol-repr/structure/representation/backbone.d.ts +3 -0
  433. package/lib/mol-repr/structure/representation/ball-and-stick.d.ts +6 -0
  434. package/lib/mol-repr/structure/representation/ellipsoid.d.ts +6 -0
  435. package/lib/mol-repr/structure/representation/gaussian-surface.d.ts +3 -0
  436. package/lib/mol-repr/structure/representation/gaussian-volume.d.ts +3 -0
  437. package/lib/mol-repr/structure/representation/line.d.ts +3 -0
  438. package/lib/mol-repr/structure/representation/molecular-surface.d.ts +3 -0
  439. package/lib/mol-repr/structure/representation/point.d.ts +3 -0
  440. package/lib/mol-repr/structure/representation/spacefill.d.ts +6 -0
  441. package/lib/mol-repr/structure/units-visual.d.ts +2 -0
  442. package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +4 -0
  443. package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.js +2 -0
  444. package/lib/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -0
  445. package/lib/mol-repr/structure/visual/bond-inter-unit-line.js +1 -0
  446. package/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.d.ts +4 -0
  447. package/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.js +2 -0
  448. package/lib/mol-repr/structure/visual/bond-intra-unit-line.d.ts +1 -0
  449. package/lib/mol-repr/structure/visual/bond-intra-unit-line.js +1 -0
  450. package/lib/mol-repr/structure/visual/element-cross.d.ts +1 -0
  451. package/lib/mol-repr/structure/visual/element-cross.js +2 -1
  452. package/lib/mol-repr/structure/visual/element-point.d.ts +1 -0
  453. package/lib/mol-repr/structure/visual/element-point.js +2 -1
  454. package/lib/mol-repr/structure/visual/element-sphere.d.ts +4 -0
  455. package/lib/mol-repr/structure/visual/element-sphere.js +3 -1
  456. package/lib/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -0
  457. package/lib/mol-repr/structure/visual/gaussian-density-volume.js +6 -2
  458. package/lib/mol-repr/structure/visual/gaussian-surface-mesh.d.ts +4 -0
  459. package/lib/mol-repr/structure/visual/gaussian-surface-mesh.js +9 -1
  460. package/lib/mol-repr/structure/visual/gaussian-surface-wireframe.d.ts +1 -0
  461. package/lib/mol-repr/structure/visual/gaussian-surface-wireframe.js +3 -1
  462. package/lib/mol-repr/structure/visual/molecular-surface-mesh.d.ts +1 -0
  463. package/lib/mol-repr/structure/visual/molecular-surface-mesh.js +4 -0
  464. package/lib/mol-repr/structure/visual/molecular-surface-wireframe.d.ts +1 -0
  465. package/lib/mol-repr/structure/visual/molecular-surface-wireframe.js +2 -0
  466. package/lib/mol-repr/structure/visual/polymer-backbone-cylinder.d.ts +2 -0
  467. package/lib/mol-repr/structure/visual/polymer-backbone-sphere.d.ts +2 -0
  468. package/lib/mol-repr/structure/visual/util/bond.d.ts +7 -0
  469. package/lib/mol-repr/structure/visual/util/bond.js +19 -8
  470. package/lib/mol-repr/structure/visual/util/common.d.ts +4 -1
  471. package/lib/mol-repr/structure/visual/util/common.js +10 -6
  472. package/lib/mol-repr/structure/visual/util/element.d.ts +1 -0
  473. package/lib/mol-repr/structure/visual/util/element.js +3 -4
  474. package/lib/mol-repr/structure/visual/util/gaussian.d.ts +2 -0
  475. package/lib/mol-repr/volume/direct-volume.d.ts +4 -4
  476. package/lib/mol-repr/volume/direct-volume.js +8 -6
  477. package/lib/mol-repr/volume/isosurface.d.ts +4 -4
  478. package/lib/mol-repr/volume/isosurface.js +17 -16
  479. package/lib/mol-repr/volume/registry.d.ts +54 -1
  480. package/lib/mol-repr/volume/registry.js +3 -1
  481. package/lib/mol-repr/volume/representation.d.ts +11 -7
  482. package/lib/mol-repr/volume/representation.js +144 -49
  483. package/lib/mol-repr/volume/segment.d.ts +291 -0
  484. package/lib/mol-repr/volume/segment.js +279 -0
  485. package/lib/mol-repr/volume/slice.d.ts +2 -2
  486. package/lib/mol-repr/volume/slice.js +5 -5
  487. package/lib/mol-repr/volume/util.d.ts +12 -3
  488. package/lib/mol-repr/volume/util.js +71 -6
  489. package/lib/mol-script/language/builder.d.ts +1 -0
  490. package/lib/mol-theme/color/volume-segment.d.ts +41 -0
  491. package/lib/mol-theme/color/volume-segment.js +53 -0
  492. package/lib/mol-theme/color/volume-value.js +2 -1
  493. package/lib/mol-theme/color.d.ts +15 -0
  494. package/lib/mol-theme/color.js +2 -0
  495. package/lib/mol-theme/label.d.ts +1 -1
  496. package/lib/mol-theme/label.js +13 -1
  497. package/lib/mol-util/param-definition.d.ts +4 -1
  498. package/lib/mol-util/param-definition.js +5 -2
  499. package/package.json +169 -168
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ *
4
+ * @author Adam Midlik <midlik@gmail.com>
5
+ */
6
+ import { __assign, __awaiter, __generator } from "tslib";
7
+ import { Mesh } from '../../../mol-geo/geometry/mesh/mesh';
8
+ import { PluginStateObject } from '../../../mol-plugin-state/objects';
9
+ import { ShapeRepresentation } from '../../../mol-repr/shape/representation';
10
+ import { StateAction, StateTransformer } from '../../../mol-state';
11
+ import { Task } from '../../../mol-task';
12
+ import { shallowEqualObjects } from '../../../mol-util';
13
+ import { ParamDefinition as PD } from '../../../mol-util/param-definition';
14
+ import { VolsegTransform, MeshlistData } from '../mesh-extension';
15
+ import { MeshStreaming, NO_SEGMENT } from './behavior';
16
+ import { MeshServerInfo } from './server-info';
17
+ export var BACKGROUND_OPACITY = 0.2;
18
+ export var FOREROUND_OPACITY = 1;
19
+ // // // // // // // // // // // // // // // // // // // // // // // //
20
+ export var MeshServerTransformer = VolsegTransform({
21
+ name: 'mesh-server-info',
22
+ from: PluginStateObject.Root,
23
+ to: MeshServerInfo,
24
+ params: MeshServerInfo.Params,
25
+ })({
26
+ apply: function (_a, plugin) {
27
+ var a = _a.a, params = _a.params;
28
+ params.serverUrl = params.serverUrl.replace(/\/*$/, ''); // trim trailing slash
29
+ var description = params.entryId;
30
+ return new MeshServerInfo(__assign({}, params), { label: 'Mesh Server', description: description });
31
+ }
32
+ });
33
+ // // // // // // // // // // // // // // // // // // // // // // // //
34
+ export var MeshStreamingTransformer = VolsegTransform({
35
+ name: 'mesh-streaming-from-server-info',
36
+ display: { name: 'Mesh Streaming' },
37
+ from: MeshServerInfo,
38
+ to: MeshStreaming,
39
+ params: function (a) { return MeshStreaming.Params.create(a.data); },
40
+ })({
41
+ canAutoUpdate: function () { return true; },
42
+ apply: function (_a, plugin) {
43
+ var _this = this;
44
+ var a = _a.a, params = _a.params;
45
+ return Task.create('Mesh Streaming', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
46
+ var behavior;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ behavior = new MeshStreaming.Behavior(plugin, a.data, params);
51
+ return [4 /*yield*/, behavior.update(params)];
52
+ case 1:
53
+ _a.sent();
54
+ return [2 /*return*/, new MeshStreaming(behavior, { label: 'Mesh Streaming', description: behavior.getDescription() })];
55
+ }
56
+ });
57
+ }); });
58
+ },
59
+ update: function (_a) {
60
+ var _this = this;
61
+ var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams;
62
+ return Task.create('Update Mesh Streaming', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ if (a.data.source !== b.data.parentData.source || a.data.entryId !== b.data.parentData.entryId) {
67
+ return [2 /*return*/, StateTransformer.UpdateResult.Recreate];
68
+ }
69
+ b.data.parentData = a.data;
70
+ return [4 /*yield*/, b.data.update(newParams)];
71
+ case 1:
72
+ _a.sent();
73
+ b.description = b.data.getDescription();
74
+ return [2 /*return*/, StateTransformer.UpdateResult.Updated];
75
+ }
76
+ });
77
+ }); });
78
+ }
79
+ });
80
+ // export type MeshVisualGroupTransformer = typeof MeshVisualGroupTransformer;
81
+ export var MeshVisualGroupTransformer = VolsegTransform({
82
+ name: 'mesh-visual-group-from-streaming',
83
+ display: { name: 'Mesh Visuals for a Segment' },
84
+ from: MeshStreaming,
85
+ to: PluginStateObject.Group,
86
+ params: {
87
+ /** Shown on the node in GUI */
88
+ label: PD.Text('', { isHidden: true }),
89
+ /** Shown on the node in GUI (gray letters) */
90
+ description: PD.Text(''),
91
+ segmentId: PD.Numeric(NO_SEGMENT, {}, { isHidden: true }),
92
+ opacity: PD.Numeric(-1, { min: 0, max: 1, step: 0.01 }),
93
+ }
94
+ })({
95
+ apply: function (_a, plugin) {
96
+ var a = _a.a, params = _a.params;
97
+ trySetAutoOpacity(params, a);
98
+ return new PluginStateObject.Group({ opacity: params.opacity }, params);
99
+ },
100
+ update: function (_a, plugin) {
101
+ var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams;
102
+ if (shallowEqualObjects(oldParams, newParams)) {
103
+ return StateTransformer.UpdateResult.Unchanged;
104
+ }
105
+ newParams.label || (newParams.label = oldParams.label); // Protect against resetting params to invalid defaults
106
+ if (newParams.segmentId === NO_SEGMENT)
107
+ newParams.segmentId = oldParams.segmentId; // Protect against resetting params to invalid defaults
108
+ trySetAutoOpacity(newParams, a);
109
+ b.label = newParams.label;
110
+ b.description = newParams.description;
111
+ b.data.opacity = newParams.opacity;
112
+ return StateTransformer.UpdateResult.Updated;
113
+ },
114
+ canAutoUpdate: function (_a, plugin) {
115
+ var oldParams = _a.oldParams, newParams = _a.newParams;
116
+ return newParams.description === oldParams.description;
117
+ },
118
+ });
119
+ function trySetAutoOpacity(params, parent) {
120
+ if (params.opacity === -1) {
121
+ var isBgSegment = parent.data.backgroundSegments[params.segmentId];
122
+ if (isBgSegment !== undefined) {
123
+ params.opacity = isBgSegment ? BACKGROUND_OPACITY : FOREROUND_OPACITY;
124
+ }
125
+ }
126
+ }
127
+ // // // // // // // // // // // // // // // // // // // // // // // //
128
+ export var MeshVisualTransformer = VolsegTransform({
129
+ name: 'mesh-visual-from-streaming',
130
+ display: { name: 'Mesh Visual from Streaming' },
131
+ from: MeshStreaming,
132
+ to: PluginStateObject.Shape.Representation3D,
133
+ params: {
134
+ /** Must be set to PluginStateObject reference to self */
135
+ ref: PD.Text('', { isHidden: true, isEssential: true }),
136
+ /** Identification of the mesh visual, e.g. 'low-2' */
137
+ tag: PD.Text('', { isHidden: true, isEssential: true }),
138
+ /** Opacity of the visual (not to be set directly, but controlled by the opacity of the parent Group, and by VisualInfo.visible) */
139
+ opacity: PD.Numeric(-1, { min: 0, max: 1, step: 0.01 }, { isHidden: true }),
140
+ }
141
+ })({
142
+ apply: function (_a, plugin) {
143
+ var _this = this;
144
+ var a = _a.a, params = _a.params, spine = _a.spine;
145
+ return Task.create('Mesh Visual', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
146
+ var visualInfo, groupData, props, repr;
147
+ var _a, _b, _c;
148
+ return __generator(this, function (_d) {
149
+ switch (_d.label) {
150
+ case 0:
151
+ visualInfo = a.data.visuals[params.tag];
152
+ if (!visualInfo)
153
+ throw new Error("VisualInfo with tag '".concat(params.tag, "' is missing."));
154
+ groupData = (_a = spine.getAncestorOfType(PluginStateObject.Group)) === null || _a === void 0 ? void 0 : _a.data;
155
+ params.opacity = visualInfo.visible ? ((_b = groupData === null || groupData === void 0 ? void 0 : groupData.opacity) !== null && _b !== void 0 ? _b : FOREROUND_OPACITY) : 0.0;
156
+ props = PD.getDefaultValues(Mesh.Params);
157
+ props.flatShaded = true; // `flatShaded: true` is to see the real mesh vertices and triangles (default: false)
158
+ props.alpha = params.opacity;
159
+ repr = ShapeRepresentation(function (ctx, meshlist) { return MeshlistData.getShape(meshlist, visualInfo.color); }, Mesh.Utils);
160
+ return [4 /*yield*/, repr.createOrUpdate(props, (_c = visualInfo.data) !== null && _c !== void 0 ? _c : MeshlistData.empty()).runInContext(ctx)];
161
+ case 1:
162
+ _d.sent();
163
+ return [2 /*return*/, new PluginStateObject.Shape.Representation3D({ repr: repr, sourceData: visualInfo.data }, { label: 'Mesh Visual', description: params.tag })];
164
+ }
165
+ });
166
+ }); });
167
+ },
168
+ update: function (_a, plugin) {
169
+ var _this = this;
170
+ var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams, spine = _a.spine;
171
+ return Task.create('Update Mesh Visual', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
172
+ var visualInfo, oldData, groupData, newOpacity;
173
+ var _a, _b, _c;
174
+ return __generator(this, function (_d) {
175
+ switch (_d.label) {
176
+ case 0:
177
+ newParams.ref || (newParams.ref = oldParams.ref); // Protect against resetting params to invalid defaults
178
+ newParams.tag || (newParams.tag = oldParams.tag); // Protect against resetting params to invalid defaults
179
+ visualInfo = a.data.visuals[newParams.tag];
180
+ if (!visualInfo)
181
+ throw new Error("VisualInfo with tag '".concat(newParams.tag, "' is missing."));
182
+ oldData = b.data.sourceData;
183
+ if (((_a = visualInfo.data) === null || _a === void 0 ? void 0 : _a.detail) !== (oldData === null || oldData === void 0 ? void 0 : oldData.detail)) {
184
+ return [2 /*return*/, StateTransformer.UpdateResult.Recreate];
185
+ }
186
+ groupData = (_b = spine.getAncestorOfType(PluginStateObject.Group)) === null || _b === void 0 ? void 0 : _b.data;
187
+ newOpacity = visualInfo.visible ? ((_c = groupData === null || groupData === void 0 ? void 0 : groupData.opacity) !== null && _c !== void 0 ? _c : FOREROUND_OPACITY) : 0.0;
188
+ if (!(newOpacity !== oldParams.opacity)) return [3 /*break*/, 2];
189
+ newParams.opacity = newOpacity;
190
+ return [4 /*yield*/, b.data.repr.createOrUpdate({ alpha: newParams.opacity }).runInContext(ctx)];
191
+ case 1:
192
+ _d.sent();
193
+ return [2 /*return*/, StateTransformer.UpdateResult.Updated];
194
+ case 2: return [2 /*return*/, StateTransformer.UpdateResult.Unchanged];
195
+ }
196
+ });
197
+ }); });
198
+ },
199
+ canAutoUpdate: function (params, globalCtx) {
200
+ return true;
201
+ },
202
+ dispose: function (_a, plugin) {
203
+ var b = _a.b, params = _a.params;
204
+ b === null || b === void 0 ? void 0 : b.data.repr.destroy(); // QUESTION is this correct?
205
+ },
206
+ });
207
+ // // // // // // // // // // // // // // // // // // // // // // // //
208
+ export var InitMeshStreaming = StateAction.build({
209
+ display: { name: 'Mesh Streaming' },
210
+ from: PluginStateObject.Root,
211
+ params: MeshServerInfo.Params,
212
+ isApplicable: function (a, _, plugin) { return true; }
213
+ })(function (p, plugin) {
214
+ var _this = this;
215
+ return Task.create('Mesh Streaming', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
216
+ var params, serverNode, streamingNode, visuals, bgSegments, segmentGroups, _a, _b, _c, _i, tag, segid, description, group, visualsUpdate, tag, ref, segid;
217
+ var _d, _e, _f, _g;
218
+ return __generator(this, function (_h) {
219
+ switch (_h.label) {
220
+ case 0:
221
+ params = p.params;
222
+ return [4 /*yield*/, plugin.build().to(p.ref).apply(MeshServerTransformer, params).commit()];
223
+ case 1:
224
+ serverNode = _h.sent();
225
+ return [4 /*yield*/, plugin.build().to(serverNode).apply(MeshStreamingTransformer, {}).commit()];
226
+ case 2:
227
+ streamingNode = _h.sent();
228
+ visuals = (_e = (_d = streamingNode.data) === null || _d === void 0 ? void 0 : _d.visuals) !== null && _e !== void 0 ? _e : {};
229
+ bgSegments = (_g = (_f = streamingNode.data) === null || _f === void 0 ? void 0 : _f.backgroundSegments) !== null && _g !== void 0 ? _g : {};
230
+ segmentGroups = {};
231
+ _a = visuals;
232
+ _b = [];
233
+ for (_c in _a)
234
+ _b.push(_c);
235
+ _i = 0;
236
+ _h.label = 3;
237
+ case 3:
238
+ if (!(_i < _b.length)) return [3 /*break*/, 6];
239
+ _c = _b[_i];
240
+ if (!(_c in _a)) return [3 /*break*/, 5];
241
+ tag = _c;
242
+ segid = visuals[tag].segmentId;
243
+ if (!!segmentGroups[segid]) return [3 /*break*/, 5];
244
+ description = visuals[tag].segmentName;
245
+ if (bgSegments[segid])
246
+ description += ' (background)';
247
+ return [4 /*yield*/, plugin.build().to(streamingNode).apply(MeshVisualGroupTransformer, { label: "Segment ".concat(segid), description: description, segmentId: segid }, { state: { isCollapsed: true } }).commit()];
248
+ case 4:
249
+ group = _h.sent();
250
+ segmentGroups[segid] = group.ref;
251
+ _h.label = 5;
252
+ case 5:
253
+ _i++;
254
+ return [3 /*break*/, 3];
255
+ case 6:
256
+ visualsUpdate = plugin.build();
257
+ for (tag in visuals) {
258
+ ref = "".concat(streamingNode.ref, "-").concat(tag);
259
+ segid = visuals[tag].segmentId;
260
+ visualsUpdate.to(segmentGroups[segid]).apply(MeshVisualTransformer, { ref: ref, tag: tag }, { ref: ref }); // ref - hack to allow the node make itself invisible
261
+ }
262
+ return [4 /*yield*/, plugin.state.data.updateTree(visualsUpdate).runInContext(ctx)];
263
+ case 7:
264
+ _h.sent(); // QUESTION what is really the difference between this and `visualsUpdate.commit()`?
265
+ return [2 /*return*/];
266
+ }
267
+ });
268
+ }); });
269
+ });
270
+ // TODO make available in GUI, in left panel or in right panel like Volume Streaming in src/mol-plugin-ui/structure/volume.tsx?
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ *
4
+ * @author Adam Midlik <midlik@gmail.com>
5
+ */
6
+ /** Helper functions for manipulation with mesh data. */
7
+ import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
8
+ import { CifFile } from '../../mol-io/reader/cif';
9
+ import { Box3D } from '../../mol-math/geometry';
10
+ import { Mat4 } from '../../mol-math/linear-algebra';
11
+ type MeshModificationParams = {
12
+ scale?: [number, number, number];
13
+ shift?: [number, number, number];
14
+ matrix?: Mat4;
15
+ group?: number;
16
+ invertSides?: boolean;
17
+ };
18
+ /** Modify mesh in-place */
19
+ export declare function modify(m: Mesh, params: MeshModificationParams): void;
20
+ /** Create a copy a mesh, possibly modified */
21
+ export declare function copy(m: Mesh, modification?: MeshModificationParams): Mesh;
22
+ /** Join more meshes into one */
23
+ export declare function concat(...meshes: Mesh[]): Mesh;
24
+ /** Return Mesh from CIF data and mesh IDs (group IDs).
25
+ * Assume the CIF contains coords in grid space,
26
+ * transform the output mesh to `space` */
27
+ export declare function meshFromCif(data: CifFile, invertSides?: boolean | undefined, outSpace?: 'grid' | 'fractional' | 'cartesian'): Promise<{
28
+ mesh: Mesh;
29
+ meshIds: number[];
30
+ }>;
31
+ /** Return bounding box */
32
+ export declare function bbox(mesh: Mesh): Box3D | null;
33
+ /** Example mesh - 1 triangle */
34
+ export declare function fakeFakeMesh1(): Mesh;
35
+ /** Example mesh - irregular tetrahedron */
36
+ export declare function fakeMesh4(): Mesh;
37
+ /** Return a box-shaped mesh */
38
+ export declare function meshFromBox(box: [[number, number, number], [number, number, number]], group?: number): Mesh;
39
+ /** Generate random colors (in a cycle) */
40
+ export declare const ColorGenerator: Generator<import("../../mol-util/color").Color, never, unknown>;
41
+ export {};
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ *
4
+ * @author Adam Midlik <midlik@gmail.com>
5
+ */
6
+ import { __awaiter, __generator } from "tslib";
7
+ /** Helper functions for manipulation with mesh data. */
8
+ import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
9
+ import { CIF } from '../../mol-io/reader/cif';
10
+ import { Box3D } from '../../mol-math/geometry';
11
+ import { Vec3 } from '../../mol-math/linear-algebra';
12
+ import { volumeFromDensityServerData } from '../../mol-model-formats/volume/density-server';
13
+ import { Grid } from '../../mol-model/volume';
14
+ import { ColorNames } from '../../mol-util/color/names';
15
+ import { CIF_schema_mesh } from './mesh-cif-schema';
16
+ /** Modify mesh in-place */
17
+ export function modify(m, params) {
18
+ if (params.scale !== undefined) {
19
+ var _a = params.scale, qx = _a[0], qy = _a[1], qz = _a[2];
20
+ var vertices = m.vertexBuffer.ref.value;
21
+ for (var i = 0; i < vertices.length; i += 3) {
22
+ vertices[i] *= qx;
23
+ vertices[i + 1] *= qy;
24
+ vertices[i + 2] *= qz;
25
+ }
26
+ }
27
+ if (params.shift !== undefined) {
28
+ var _b = params.shift, dx = _b[0], dy = _b[1], dz = _b[2];
29
+ var vertices = m.vertexBuffer.ref.value;
30
+ for (var i = 0; i < vertices.length; i += 3) {
31
+ vertices[i] += dx;
32
+ vertices[i + 1] += dy;
33
+ vertices[i + 2] += dz;
34
+ }
35
+ }
36
+ if (params.matrix !== undefined) {
37
+ var r = m.vertexBuffer.ref.value;
38
+ var matrix = params.matrix;
39
+ var size = 3 * m.vertexCount;
40
+ for (var i = 0; i < size; i += 3) {
41
+ Vec3.transformMat4Offset(r, r, matrix, i, i, 0);
42
+ }
43
+ }
44
+ if (params.group !== undefined) {
45
+ var groups = m.groupBuffer.ref.value;
46
+ for (var i = 0; i < groups.length; i++) {
47
+ groups[i] = params.group;
48
+ }
49
+ }
50
+ if (params.invertSides) {
51
+ var indices = m.indexBuffer.ref.value;
52
+ var tmp = void 0;
53
+ for (var i = 0; i < indices.length; i += 3) {
54
+ tmp = indices[i];
55
+ indices[i] = indices[i + 1];
56
+ indices[i + 1] = tmp;
57
+ }
58
+ var normals = m.normalBuffer.ref.value;
59
+ for (var i = 0; i < normals.length; i++) {
60
+ normals[i] *= -1;
61
+ }
62
+ }
63
+ }
64
+ /** Create a copy a mesh, possibly modified */
65
+ export function copy(m, modification) {
66
+ var nVertices = m.vertexCount;
67
+ var nTriangles = m.triangleCount;
68
+ var vertices = new Float32Array(m.vertexBuffer.ref.value);
69
+ var indices = new Uint32Array(m.indexBuffer.ref.value);
70
+ var normals = new Float32Array(m.normalBuffer.ref.value);
71
+ var groups = new Float32Array(m.groupBuffer.ref.value);
72
+ var result = Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
73
+ if (modification) {
74
+ modify(result, modification);
75
+ }
76
+ return result;
77
+ }
78
+ /** Join more meshes into one */
79
+ export function concat() {
80
+ var meshes = [];
81
+ for (var _i = 0; _i < arguments.length; _i++) {
82
+ meshes[_i] = arguments[_i];
83
+ }
84
+ var nVertices = sum(meshes.map(function (m) { return m.vertexCount; }));
85
+ var nTriangles = sum(meshes.map(function (m) { return m.triangleCount; }));
86
+ var vertices = concatArrays(Float32Array, meshes.map(function (m) { return m.vertexBuffer.ref.value; }));
87
+ var normals = concatArrays(Float32Array, meshes.map(function (m) { return m.normalBuffer.ref.value; }));
88
+ var groups = concatArrays(Float32Array, meshes.map(function (m) { return m.groupBuffer.ref.value; }));
89
+ var newIndices = [];
90
+ var offset = 0;
91
+ for (var _a = 0, meshes_1 = meshes; _a < meshes_1.length; _a++) {
92
+ var m = meshes_1[_a];
93
+ newIndices.push(m.indexBuffer.ref.value.map(function (i) { return i + offset; }));
94
+ offset += m.vertexCount;
95
+ }
96
+ var indices = concatArrays(Uint32Array, newIndices);
97
+ return Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
98
+ }
99
+ /** Return Mesh from CIF data and mesh IDs (group IDs).
100
+ * Assume the CIF contains coords in grid space,
101
+ * transform the output mesh to `space` */
102
+ export function meshFromCif(data, invertSides, outSpace) {
103
+ if (invertSides === void 0) { invertSides = undefined; }
104
+ if (outSpace === void 0) { outSpace = 'cartesian'; }
105
+ return __awaiter(this, void 0, void 0, function () {
106
+ var volumeInfoBlock, meshesBlock, volumeInfoCif, meshCif, nVertices, nTriangles, mesh_id, vertex_meshId, x, y, z, triangle_meshId, triangle_vertexId, indices, offsets, i, offset, vertices, normals, groups, mesh, volume, gridToCartesian, gridSize, originFract, dimensionFract, scale;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ volumeInfoBlock = data.blocks.find(function (b) { return b.header === 'VOLUME_INFO'; });
111
+ meshesBlock = data.blocks.find(function (b) { return b.header === 'MESHES'; });
112
+ if (!volumeInfoBlock || !meshesBlock)
113
+ throw new Error('Missing VOLUME_INFO or MESHES block in mesh CIF file');
114
+ volumeInfoCif = CIF.schema.densityServer(volumeInfoBlock);
115
+ meshCif = CIF_schema_mesh(meshesBlock);
116
+ nVertices = meshCif.mesh_vertex._rowCount;
117
+ nTriangles = Math.floor(meshCif.mesh_triangle._rowCount / 3);
118
+ mesh_id = meshCif.mesh.id.toArray();
119
+ vertex_meshId = meshCif.mesh_vertex.mesh_id.toArray();
120
+ x = meshCif.mesh_vertex.x.toArray();
121
+ y = meshCif.mesh_vertex.y.toArray();
122
+ z = meshCif.mesh_vertex.z.toArray();
123
+ triangle_meshId = meshCif.mesh_triangle.mesh_id.toArray();
124
+ triangle_vertexId = meshCif.mesh_triangle.vertex_id.toArray();
125
+ indices = new Uint32Array(3 * nTriangles);
126
+ offsets = offsetMap(vertex_meshId);
127
+ for (i = 0; i < 3 * nTriangles; i++) {
128
+ offset = offsets.get(triangle_meshId[i]);
129
+ indices[i] = offset + triangle_vertexId[i];
130
+ }
131
+ vertices = flattenCoords(x, y, z);
132
+ normals = new Float32Array(3 * nVertices);
133
+ groups = new Float32Array(vertex_meshId);
134
+ mesh = Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
135
+ invertSides !== null && invertSides !== void 0 ? invertSides : (invertSides = isInverted(mesh));
136
+ if (invertSides) {
137
+ modify(mesh, { invertSides: true }); // Vertex orientation convention is opposite in Volseg API and in MolStar
138
+ }
139
+ if (!(outSpace === 'cartesian')) return [3 /*break*/, 2];
140
+ return [4 /*yield*/, volumeFromDensityServerData(volumeInfoCif).run()];
141
+ case 1:
142
+ volume = _a.sent();
143
+ gridToCartesian = Grid.getGridToCartesianTransform(volume.grid);
144
+ modify(mesh, { matrix: gridToCartesian });
145
+ return [3 /*break*/, 3];
146
+ case 2:
147
+ if (outSpace === 'fractional') {
148
+ gridSize = volumeInfoCif.volume_data_3d_info.sample_count.value(0);
149
+ originFract = volumeInfoCif.volume_data_3d_info.origin.value(0);
150
+ dimensionFract = volumeInfoCif.volume_data_3d_info.dimensions.value(0);
151
+ if (dimensionFract[0] !== 1 || dimensionFract[1] !== 1 || dimensionFract[2] !== 1)
152
+ throw new Error("Asserted the fractional dimensions are [1,1,1], but are actually [".concat(dimensionFract, "]"));
153
+ scale = [1 / gridSize[0], 1 / gridSize[1], 1 / gridSize[2]];
154
+ modify(mesh, { scale: scale, shift: Array.from(originFract) });
155
+ }
156
+ _a.label = 3;
157
+ case 3:
158
+ Mesh.computeNormals(mesh); // normals only necessary if flatShaded==false
159
+ // const boxMesh = makeMeshFromBox([[0,0,0], [1,1,1]], 1);
160
+ // const gridSize = volumeInfoCif.volume_data_3d_info.sample_count.value(0); const boxMesh = makeMeshFromBox([[0,0,0], Array.from(gridSize)] as any, 1);
161
+ // const cellSize = volumeInfoCif.volume_data_3d_info.spacegroup_cell_size.value(0); const boxMesh = makeMeshFromBox([[0, 0, 0], Array.from(cellSize)] as any, 1);
162
+ // mesh = concat(mesh, boxMesh); // debug
163
+ return [2 /*return*/, { mesh: mesh, meshIds: Array.from(mesh_id) }];
164
+ }
165
+ });
166
+ });
167
+ }
168
+ function isInverted(mesh) {
169
+ var vertices = mesh.vertexBuffer.ref.value;
170
+ var indices = mesh.indexBuffer.ref.value;
171
+ var center = meshCenter(mesh);
172
+ var center3 = Vec3.create(3 * center[0], 3 * center[1], 3 * center[2]);
173
+ var dirMetric = 0.0;
174
+ var _a = [Vec3(), Vec3(), Vec3(), Vec3(), Vec3(), Vec3(), Vec3()], a = _a[0], b = _a[1], c = _a[2], u = _a[3], v = _a[4], normal = _a[5], radius = _a[6];
175
+ for (var i = 0; i < indices.length; i += 3) {
176
+ Vec3.fromArray(a, vertices, 3 * indices[i]);
177
+ Vec3.fromArray(b, vertices, 3 * indices[i + 1]);
178
+ Vec3.fromArray(c, vertices, 3 * indices[i + 2]);
179
+ Vec3.sub(u, b, a);
180
+ Vec3.sub(v, c, b);
181
+ Vec3.cross(normal, u, v); // direction of the surface
182
+ Vec3.add(radius, a, b);
183
+ Vec3.add(radius, radius, c);
184
+ Vec3.sub(radius, radius, center3); // direction center -> this triangle
185
+ dirMetric += Vec3.dot(radius, normal);
186
+ }
187
+ return dirMetric < 0;
188
+ }
189
+ function meshCenter(mesh) {
190
+ var vertices = mesh.vertexBuffer.ref.value;
191
+ var n = vertices.length;
192
+ var x = 0.0;
193
+ var y = 0.0;
194
+ var z = 0.0;
195
+ for (var i = 0; i < vertices.length; i += 3) {
196
+ x += vertices[i];
197
+ y += vertices[i + 1];
198
+ z += vertices[i + 2];
199
+ }
200
+ return Vec3.create(x / n, y / n, z / n);
201
+ }
202
+ function flattenCoords(x, y, z) {
203
+ var n = x.length;
204
+ var out = new Float32Array(3 * n);
205
+ for (var i = 0; i < n; i++) {
206
+ out[3 * i] = x[i];
207
+ out[3 * i + 1] = y[i];
208
+ out[3 * i + 2] = z[i];
209
+ }
210
+ return out;
211
+ }
212
+ /** Get mapping of unique values to the position of their first occurrence */
213
+ function offsetMap(values) {
214
+ var result = new Map();
215
+ for (var i = 0; i < values.length; i++) {
216
+ if (!result.has(values[i])) {
217
+ result.set(values[i], i);
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+ /** Return bounding box */
223
+ export function bbox(mesh) {
224
+ var nVertices = mesh.vertexCount;
225
+ var coords = mesh.vertexBuffer.ref.value;
226
+ if (nVertices === 0) {
227
+ return null;
228
+ }
229
+ var minX = coords[0], minY = coords[1], minZ = coords[2];
230
+ var maxX = minX, maxY = minY, maxZ = minZ;
231
+ for (var i = 0; i < 3 * nVertices; i += 3) {
232
+ var x = coords[i], y = coords[i + 1], z = coords[i + 2];
233
+ if (x < minX)
234
+ minX = x;
235
+ if (y < minY)
236
+ minY = y;
237
+ if (z < minZ)
238
+ minZ = z;
239
+ if (x > maxX)
240
+ maxX = x;
241
+ if (y > maxY)
242
+ maxY = y;
243
+ if (z > maxZ)
244
+ maxZ = z;
245
+ }
246
+ return Box3D.create(Vec3.create(minX, minY, minZ), Vec3.create(maxX, maxY, maxZ));
247
+ }
248
+ /** Example mesh - 1 triangle */
249
+ export function fakeFakeMesh1() {
250
+ var nVertices = 3;
251
+ var nTriangles = 1;
252
+ var vertices = new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0]);
253
+ var indices = new Uint32Array([0, 1, 2]);
254
+ var normals = new Float32Array([0, 0, 1]);
255
+ var groups = new Float32Array([0]);
256
+ return Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
257
+ }
258
+ /** Example mesh - irregular tetrahedron */
259
+ export function fakeMesh4() {
260
+ var nVertices = 4;
261
+ var nTriangles = 4;
262
+ var vertices = new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]);
263
+ var indices = new Uint32Array([0, 2, 1, 0, 1, 3, 1, 2, 3, 2, 0, 3]);
264
+ var normals = new Float32Array([-1, -1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1]);
265
+ var groups = new Float32Array([0, 1, 2, 3]);
266
+ return Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
267
+ }
268
+ /** Return a box-shaped mesh */
269
+ export function meshFromBox(box, group) {
270
+ if (group === void 0) { group = 0; }
271
+ var _a = box[0], x0 = _a[0], y0 = _a[1], z0 = _a[2], _b = box[1], x1 = _b[0], y1 = _b[1], z1 = _b[2];
272
+ var vertices = new Float32Array([
273
+ x0, y0, z0,
274
+ x1, y0, z0,
275
+ x0, y1, z0,
276
+ x1, y1, z0,
277
+ x0, y0, z1,
278
+ x1, y0, z1,
279
+ x0, y1, z1,
280
+ x1, y1, z1,
281
+ ]);
282
+ var indices = new Uint32Array([
283
+ 2, 1, 0, 1, 2, 3,
284
+ 1, 4, 0, 4, 1, 5,
285
+ 3, 5, 1, 5, 3, 7,
286
+ 2, 7, 3, 7, 2, 6,
287
+ 0, 6, 2, 6, 0, 4,
288
+ 4, 7, 6, 7, 4, 5,
289
+ ]);
290
+ var groups = new Float32Array([group, group, group, group, group, group, group, group]);
291
+ var normals = new Float32Array(8);
292
+ var mesh = Mesh.create(vertices, indices, normals, groups, 8, 12);
293
+ Mesh.computeNormals(mesh); // normals only necessary if flatShaded==false
294
+ return mesh;
295
+ }
296
+ function sum(array) {
297
+ return array.reduce(function (a, b) { return a + b; }, 0);
298
+ }
299
+ function concatArrays(t, arrays) {
300
+ var totalLength = arrays.map(function (a) { return a.length; }).reduce(function (a, b) { return a + b; }, 0);
301
+ var result = new t(totalLength);
302
+ var offset = 0;
303
+ for (var _i = 0, arrays_1 = arrays; _i < arrays_1.length; _i++) {
304
+ var array = arrays_1[_i];
305
+ result.set(array, offset);
306
+ offset += array.length;
307
+ }
308
+ return result;
309
+ }
310
+ /** Generate random colors (in a cycle) */
311
+ export var ColorGenerator = function () {
312
+ var colors, i;
313
+ return __generator(this, function (_a) {
314
+ switch (_a.label) {
315
+ case 0:
316
+ colors = shuffleArray(Object.values(ColorNames));
317
+ i = 0;
318
+ _a.label = 1;
319
+ case 1:
320
+ if (!true) return [3 /*break*/, 3];
321
+ return [4 /*yield*/, colors[i]];
322
+ case 2:
323
+ _a.sent();
324
+ i++;
325
+ if (i >= colors.length)
326
+ i = 0;
327
+ return [3 /*break*/, 1];
328
+ case 3: return [2 /*return*/];
329
+ }
330
+ });
331
+ }();
332
+ function shuffleArray(array) {
333
+ // Stealed from https://www.w3docs.com/snippets/javascript/how-to-randomize-shuffle-a-javascript-array.html
334
+ var curId = array.length;
335
+ // There remain elements to shuffle
336
+ while (0 !== curId) {
337
+ // Pick a remaining element
338
+ var randId = Math.floor(Math.random() * curId);
339
+ curId -= 1;
340
+ // Swap it with the current element.
341
+ var tmp = array[curId];
342
+ array[curId] = array[randId];
343
+ array[randId] = tmp;
344
+ }
345
+ return array;
346
+ }