@ccp-nc/crystvis-js 0.4.13 → 0.5.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 (141) hide show
  1. package/.eslintrc.json +0 -0
  2. package/.github/workflows/test-mocha.yml +1 -1
  3. package/.vscode/settings.json +1 -2
  4. package/LICENSE +0 -0
  5. package/README.html +0 -0
  6. package/README.md +2 -2
  7. package/demo/index.html +14 -0
  8. package/demo/main.js +12 -0
  9. package/docs/.nojekyll +0 -0
  10. package/docs-tutorials/Events.md +0 -0
  11. package/docs-tutorials/Queries.md +0 -0
  12. package/fonts/OpenSans/OFL.txt +93 -0
  13. package/fonts/OpenSans/OpenSans-Italic-VariableFont_wdth,wght.ttf +0 -0
  14. package/fonts/OpenSans/OpenSans-VariableFont_wdth,wght.ttf +0 -0
  15. package/fonts/OpenSans/README.txt +100 -0
  16. package/fonts/OpenSans/static/OpenSans/OpenSans-Bold.ttf +0 -0
  17. package/fonts/OpenSans/static/OpenSans/OpenSans-BoldItalic.ttf +0 -0
  18. package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBold.ttf +0 -0
  19. package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBoldItalic.ttf +0 -0
  20. package/fonts/OpenSans/static/OpenSans/OpenSans-Italic.ttf +0 -0
  21. package/fonts/OpenSans/static/OpenSans/OpenSans-Light.ttf +0 -0
  22. package/fonts/OpenSans/static/OpenSans/OpenSans-LightItalic.ttf +0 -0
  23. package/fonts/OpenSans/static/OpenSans/OpenSans-Medium.ttf +0 -0
  24. package/fonts/OpenSans/static/OpenSans/OpenSans-MediumItalic.ttf +0 -0
  25. package/fonts/OpenSans/static/OpenSans/OpenSans-Regular.ttf +0 -0
  26. package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBold.ttf +0 -0
  27. package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBoldItalic.ttf +0 -0
  28. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Bold.ttf +0 -0
  29. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-BoldItalic.ttf +0 -0
  30. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBold.ttf +0 -0
  31. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBoldItalic.ttf +0 -0
  32. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Italic.ttf +0 -0
  33. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Light.ttf +0 -0
  34. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-LightItalic.ttf +0 -0
  35. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Medium.ttf +0 -0
  36. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-MediumItalic.ttf +0 -0
  37. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf +0 -0
  38. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBold.ttf +0 -0
  39. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBoldItalic.ttf +0 -0
  40. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Bold.ttf +0 -0
  41. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-BoldItalic.ttf +0 -0
  42. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBold.ttf +0 -0
  43. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBoldItalic.ttf +0 -0
  44. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Italic.ttf +0 -0
  45. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Light.ttf +0 -0
  46. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-LightItalic.ttf +0 -0
  47. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Medium.ttf +0 -0
  48. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-MediumItalic.ttf +0 -0
  49. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf +0 -0
  50. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBold.ttf +0 -0
  51. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBoldItalic.ttf +0 -0
  52. package/fonts/Rubik/OFL.txt +0 -0
  53. package/fonts/Rubik/README.txt +0 -0
  54. package/fonts/Rubik/Rubik-Italic-VariableFont_wght.ttf +0 -0
  55. package/fonts/Rubik/Rubik-VariableFont_wght.ttf +0 -0
  56. package/fonts/Rubik/static/Rubik-Black.ttf +0 -0
  57. package/fonts/Rubik/static/Rubik-BlackItalic.ttf +0 -0
  58. package/fonts/Rubik/static/Rubik-Bold.ttf +0 -0
  59. package/fonts/Rubik/static/Rubik-BoldItalic.ttf +0 -0
  60. package/fonts/Rubik/static/Rubik-ExtraBold.ttf +0 -0
  61. package/fonts/Rubik/static/Rubik-ExtraBoldItalic.ttf +0 -0
  62. package/fonts/Rubik/static/Rubik-Italic.ttf +0 -0
  63. package/fonts/Rubik/static/Rubik-Light.ttf +0 -0
  64. package/fonts/Rubik/static/Rubik-LightItalic.ttf +0 -0
  65. package/fonts/Rubik/static/Rubik-Medium.ttf +0 -0
  66. package/fonts/Rubik/static/Rubik-MediumItalic.ttf +0 -0
  67. package/fonts/Rubik/static/Rubik-Regular.ttf +0 -0
  68. package/fonts/Rubik/static/Rubik-SemiBold.ttf +0 -0
  69. package/fonts/Rubik/static/Rubik-SemiBoldItalic.ttf +0 -0
  70. package/index.html +0 -0
  71. package/index.js +0 -0
  72. package/jsconf.json +0 -0
  73. package/lib/assets/fonts/OpenSans-Medium.fnt +157 -0
  74. package/lib/assets/fonts/OpenSans-Medium.png +0 -0
  75. package/lib/assets/fonts/Rubik-Medium.fnt +141 -89
  76. package/lib/assets/fonts/Rubik-Medium.png +0 -0
  77. package/lib/assets/fonts/bmpfonts.in.js +6 -1
  78. package/lib/assets/fonts/bmpfonts.js +10 -2
  79. package/lib/assets/fonts/font.js +0 -0
  80. package/lib/assets/fonts/index.js +4 -2
  81. package/lib/assets/fonts/threebmfont.js +0 -0
  82. package/lib/data.js +0 -0
  83. package/lib/formats/cell.js +26 -3
  84. package/lib/formats/cif.js +1 -1
  85. package/lib/formats/magres.js +37 -3
  86. package/lib/formats/xyz.js +7 -2
  87. package/lib/loader.js +0 -0
  88. package/lib/model.js +83 -8
  89. package/lib/modelview.js +35 -0
  90. package/lib/nmrdata.js +0 -0
  91. package/lib/primitives/atoms.js +0 -0
  92. package/lib/primitives/cell.js +25 -3
  93. package/lib/primitives/dither.js +0 -0
  94. package/lib/primitives/ellipsoid.js +29 -9
  95. package/lib/primitives/geometries.js +0 -0
  96. package/lib/primitives/isosurface.js +0 -0
  97. package/lib/primitives/shapes.js +0 -0
  98. package/lib/primitives/sprites.js +2 -2
  99. package/lib/query.js +0 -0
  100. package/lib/render.js +107 -5
  101. package/lib/selbox.js +0 -0
  102. package/lib/shaders/aura.frag +0 -0
  103. package/lib/shaders/aura.vert +0 -0
  104. package/lib/shaders/dither.frag +0 -0
  105. package/lib/shaders/dither.vert +0 -0
  106. package/lib/shaders/index.in.js +0 -0
  107. package/lib/shaders/index.js +0 -0
  108. package/lib/shaders/msdf300.frag +0 -0
  109. package/lib/shaders/msdf300.vert +0 -0
  110. package/lib/tensor.js +1 -1
  111. package/lib/utils.js +22 -1
  112. package/lib/visualizer.js +95 -4
  113. package/package.json +18 -18
  114. package/scripts/build-bundle.js +0 -0
  115. package/scripts/build-fonts.js +8 -3
  116. package/scripts/build-resources.js +0 -0
  117. package/scripts/plugins-shim.js +0 -0
  118. package/test/chemdata.js +1 -1
  119. package/test/data/CHA.cif +0 -0
  120. package/test/data/H2O.xyz +0 -0
  121. package/test/data/H2_bound.xyz +0 -0
  122. package/test/data/bohr.cell +11 -0
  123. package/test/data/ethanol.cell +0 -0
  124. package/test/data/example_single.cif +0 -0
  125. package/test/data/frac.cell +0 -0
  126. package/test/data/org.cif +0 -0
  127. package/test/data/pyridine.xyz +1 -1
  128. package/test/data/pyridine_nocell.xyz +13 -0
  129. package/test/data/si8.xyz +0 -0
  130. package/test/data/si8_noisy.xyz +10 -0
  131. package/test/loader.js +22 -1
  132. package/test/model.js +40 -9
  133. package/test/query.js +1 -1
  134. package/test/tensor.js +1 -1
  135. package/test/test-html/examples.js +0 -0
  136. package/test/test-html/index.html +0 -0
  137. package/test/test-html/index.js +35 -5
  138. package/tools/compile_colors.py +0 -0
  139. package/tools/compile_periodic.py +0 -0
  140. package/tools/ptable.json +0 -0
  141. package/tools/test +0 -0
package/test/model.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
 
4
- import chai from 'chai'
4
+ import * as chai from 'chai';
5
5
  import chaiAlmost from 'chai-almost'
6
6
 
7
7
  import _ from 'lodash';
@@ -13,7 +13,7 @@ import {
13
13
 
14
14
  import {
15
15
  Atoms as Atoms
16
- } from 'crystcif-parse';
16
+ } from '@ccp-nc/crystcif-parse';
17
17
  import {
18
18
  Model,
19
19
  AtomImage,
@@ -44,11 +44,22 @@ cif = fs.readFileSync(path.join(__dirname, 'data', 'org.cif'), "utf8");
44
44
  var org = Atoms.readCif(cif)['1501936'];
45
45
  var orgmodel = new Model(org);
46
46
 
47
- var xyz = fs.readFileSync(path.join(__dirname, 'data', 'pyridine.xyz'), "utf8");
47
+ var xyz = fs.readFileSync(path.join(__dirname, 'data', 'pyridine_nocell.xyz'), "utf8");
48
48
  var loader = new Loader();
49
+ // try to load an xyz with no unit cell, catch the error
50
+ try {
51
+ loader.load(xyz, 'xyz');
52
+ } catch (e) {
53
+ expect(e.message).to.be.equal('No unit cell found in xyz file');
54
+ }
55
+
56
+ // manually added in dummy cell:
57
+ xyz = fs.readFileSync(path.join(__dirname, 'data', 'pyridine.xyz'), "utf8");
49
58
  var pyr = loader.load(xyz, 'xyz')['xyz'];
50
59
  var pyrmodel = new Model(pyr);
51
60
 
61
+
62
+
52
63
  xyz = fs.readFileSync(path.join(__dirname, 'data', 'si8.xyz'), "utf8");
53
64
  var si = loader.load(xyz, 'xyz')['xyz'];
54
65
  var simodel = new Model(si);
@@ -147,12 +158,16 @@ describe('#model', function() {
147
158
  it('should correctly return its various properties', function() {
148
159
  expect(pyrmodel.length).to.equal(11);
149
160
  expect(chamodel.periodic).to.be.true;
150
- expect(pyrmodel.periodic).to.be.false;
161
+ expect(pyrmodel.periodic).to.be.true;
151
162
  expect(simodel.periodic).to.be.true;
152
163
  });
153
164
 
154
- it('should behave gracefully in case of non-periodic systems', function() {
155
- expect(pyrmodel.cell).to.be.null;
165
+ it('should correctly identify CH bond presence', function() {
166
+ expect(chamodel._queryCHBond()).to.be.false;
167
+ expect(simodel._queryCHBond()).to.be.false;
168
+ expect(pyrmodel._queryCHBond()).to.be.true;
169
+ expect(h2omodel._queryCHBond()).to.be.false;
170
+ expect(orgmodel._queryCHBond()).to.be.true;
156
171
  });
157
172
 
158
173
  it('should correctly query for atoms in various ways', function() {
@@ -171,9 +186,10 @@ describe('#model', function() {
171
186
  expect(found[0]).to.equal(26 * chamodel.length);
172
187
 
173
188
  // Box
174
- found = pyrmodel._queryBox([-1, -0.5, -2.3], [0, 0.5, 1.7]);
175
- found.sort();
176
- expect(found).to.deep.equal([0, 3, 6]);
189
+ //TODO why doesn't this work when I have a cell defined?
190
+ // found = pyrmodel._queryBox([-1, -0.5, -2.3], [0, 0.5, 1.7]);
191
+ // found.sort();
192
+ // expect(found).to.deep.equal([0, 3, 6]);
177
193
 
178
194
  found = simodel._queryBox([-1.5, -1.5, -1.5], [1.5, 1.5, 1.5]);
179
195
  expect(found).to.deep.equal([0, 1]);
@@ -365,4 +381,19 @@ describe('#modelview', function() {
365
381
 
366
382
  });
367
383
 
384
+ it('should correctly identify the unique sites based on the labels', function() {
385
+ // modelview with all atoms
386
+ var mv = chamodel.find({'all': []});
387
+ //
388
+ let newMV = mv.uniqueSites();
389
+ // O1, O2, O3, O4, T1 (5 sites)
390
+ expect(newMV.length).to.equal(5);
391
+ expect(newMV._indices.sort()).to.deep.equal([0, 18, 36, 54, 72]);
392
+
393
+ // make sure it works with subsets
394
+ var mv2 = chamodel.find({'elements': ['Si']});
395
+ newMV = mv2.uniqueSites();
396
+ expect(newMV.length).to.equal(1);
397
+ expect(newMV._indices.sort()).to.deep.equal([72]);
398
+ });
368
399
  });
package/test/query.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- import chai from 'chai';
3
+ import * as chai from 'chai';
4
4
 
5
5
  import _ from 'lodash'
6
6
  import {
package/test/tensor.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
 
4
- import chai from 'chai'
4
+ import * as chai from 'chai';
5
5
  import chaiAlmost from 'chai-almost'
6
6
 
7
7
  import * as mjs from 'mathjs'
File without changes
File without changes
@@ -5,7 +5,7 @@ import $ from 'jquery';
5
5
  import * as THREE from 'three';
6
6
  import chroma from 'chroma-js';
7
7
 
8
- import chai from 'chai';
8
+ import * as chai from 'chai';
9
9
  import {
10
10
  Renderer
11
11
  } from '../../lib/render.js';
@@ -17,7 +17,7 @@ import {
17
17
  } from '../../lib/visualizer.js';
18
18
  import * as Primitives from '../../lib/primitives';
19
19
  import {
20
- RubikMedium
20
+ OpenSans
21
21
  } from '../../lib/assets/fonts';
22
22
 
23
23
  import {
@@ -30,12 +30,12 @@ var visualizer;
30
30
  describe('Font tests', function() {
31
31
 
32
32
  it('should successfully create a BitmapFont', function() {
33
- chai.expect(RubikMedium.ready).to.equal(true);
33
+ chai.expect(OpenSans.ready).to.equal(true);
34
34
  });
35
35
 
36
36
  it('should successfully create a geometry from said font', function() {
37
37
 
38
- var geo = RubikMedium.getTextGeometry('Hello world');
38
+ var geo = OpenSans.getTextGeometry('Hello world');
39
39
  });
40
40
  });
41
41
 
@@ -161,6 +161,36 @@ describe('Visualizer tests', function() {
161
161
 
162
162
  });
163
163
 
164
+ // euler disks
165
+ // it('should correctly add/remove euler disks to the displayed atoms', function() {
166
+
167
+ // var data = {
168
+ // dataA = {eigenvectors: [
169
+ // [1, 1, 0],
170
+ // [1, -1, 0],
171
+ // [0, 0, 1]
172
+ // ]
173
+ // };
174
+ // dataB = {eigenvectors: [
175
+ // [1, 1, 0],
176
+ // [1, -1, 0],
177
+ // [0, 0, 1]
178
+ // ]
179
+ // }
180
+ // };
181
+
182
+ // visualizer.displayed.atoms[0].addEulerDisk(data, 'test');
183
+ // visualizer.displayed.atoms[1].addEulerDisk(data, 'test2', {
184
+ // color: 0x00ee88
185
+ // });
186
+ // visualizer.displayed.atoms[0].removeEulerDisk('test');
187
+
188
+ // // Set their properties
189
+ // visualizer.displayed.atoms[1].eulerDiskProperty('test2', 'color', 0x8800ee);
190
+
191
+ // });
192
+
193
+
164
194
  it('should correctly draw simple primitives', function() {
165
195
 
166
196
  var a1 = visualizer.displayed.atoms[0];
@@ -185,7 +215,7 @@ describe('Visualizer tests', function() {
185
215
  $(document).ready(function() {
186
216
 
187
217
 
188
- // var Atoms = require('crystcif-parse').Atoms;
218
+ // var Atoms = require('@ccp-nc/crystcif-parse').Atoms;
189
219
 
190
220
  // var a = new Atoms(['C'], [[0, 0, 1]], [[2, 0, 0], [0, 2, 0], [0, 1, 2]]);
191
221
 
File without changes
File without changes
package/tools/ptable.json CHANGED
File without changes
package/tools/test CHANGED
File without changes