@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.
- package/.eslintrc.json +0 -0
- package/.github/workflows/test-mocha.yml +1 -1
- package/.vscode/settings.json +1 -2
- package/LICENSE +0 -0
- package/README.html +0 -0
- package/README.md +2 -2
- package/demo/index.html +14 -0
- package/demo/main.js +12 -0
- package/docs/.nojekyll +0 -0
- package/docs-tutorials/Events.md +0 -0
- package/docs-tutorials/Queries.md +0 -0
- package/fonts/OpenSans/OFL.txt +93 -0
- package/fonts/OpenSans/OpenSans-Italic-VariableFont_wdth,wght.ttf +0 -0
- package/fonts/OpenSans/OpenSans-VariableFont_wdth,wght.ttf +0 -0
- package/fonts/OpenSans/README.txt +100 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-Bold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-BoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-Italic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-Light.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-LightItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-Medium.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-MediumItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-Regular.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Bold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-BoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Italic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Light.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-LightItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Medium.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-MediumItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Bold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-BoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBoldItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Italic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Light.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-LightItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Medium.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-MediumItalic.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBold.ttf +0 -0
- package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBoldItalic.ttf +0 -0
- package/fonts/Rubik/OFL.txt +0 -0
- package/fonts/Rubik/README.txt +0 -0
- package/fonts/Rubik/Rubik-Italic-VariableFont_wght.ttf +0 -0
- package/fonts/Rubik/Rubik-VariableFont_wght.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Black.ttf +0 -0
- package/fonts/Rubik/static/Rubik-BlackItalic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Bold.ttf +0 -0
- package/fonts/Rubik/static/Rubik-BoldItalic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-ExtraBold.ttf +0 -0
- package/fonts/Rubik/static/Rubik-ExtraBoldItalic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Italic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Light.ttf +0 -0
- package/fonts/Rubik/static/Rubik-LightItalic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Medium.ttf +0 -0
- package/fonts/Rubik/static/Rubik-MediumItalic.ttf +0 -0
- package/fonts/Rubik/static/Rubik-Regular.ttf +0 -0
- package/fonts/Rubik/static/Rubik-SemiBold.ttf +0 -0
- package/fonts/Rubik/static/Rubik-SemiBoldItalic.ttf +0 -0
- package/index.html +0 -0
- package/index.js +0 -0
- package/jsconf.json +0 -0
- package/lib/assets/fonts/OpenSans-Medium.fnt +157 -0
- package/lib/assets/fonts/OpenSans-Medium.png +0 -0
- package/lib/assets/fonts/Rubik-Medium.fnt +141 -89
- package/lib/assets/fonts/Rubik-Medium.png +0 -0
- package/lib/assets/fonts/bmpfonts.in.js +6 -1
- package/lib/assets/fonts/bmpfonts.js +10 -2
- package/lib/assets/fonts/font.js +0 -0
- package/lib/assets/fonts/index.js +4 -2
- package/lib/assets/fonts/threebmfont.js +0 -0
- package/lib/data.js +0 -0
- package/lib/formats/cell.js +26 -3
- package/lib/formats/cif.js +1 -1
- package/lib/formats/magres.js +37 -3
- package/lib/formats/xyz.js +7 -2
- package/lib/loader.js +0 -0
- package/lib/model.js +83 -8
- package/lib/modelview.js +35 -0
- package/lib/nmrdata.js +0 -0
- package/lib/primitives/atoms.js +0 -0
- package/lib/primitives/cell.js +25 -3
- package/lib/primitives/dither.js +0 -0
- package/lib/primitives/ellipsoid.js +29 -9
- package/lib/primitives/geometries.js +0 -0
- package/lib/primitives/isosurface.js +0 -0
- package/lib/primitives/shapes.js +0 -0
- package/lib/primitives/sprites.js +2 -2
- package/lib/query.js +0 -0
- package/lib/render.js +107 -5
- package/lib/selbox.js +0 -0
- package/lib/shaders/aura.frag +0 -0
- package/lib/shaders/aura.vert +0 -0
- package/lib/shaders/dither.frag +0 -0
- package/lib/shaders/dither.vert +0 -0
- package/lib/shaders/index.in.js +0 -0
- package/lib/shaders/index.js +0 -0
- package/lib/shaders/msdf300.frag +0 -0
- package/lib/shaders/msdf300.vert +0 -0
- package/lib/tensor.js +1 -1
- package/lib/utils.js +22 -1
- package/lib/visualizer.js +95 -4
- package/package.json +18 -18
- package/scripts/build-bundle.js +0 -0
- package/scripts/build-fonts.js +8 -3
- package/scripts/build-resources.js +0 -0
- package/scripts/plugins-shim.js +0 -0
- package/test/chemdata.js +1 -1
- package/test/data/CHA.cif +0 -0
- package/test/data/H2O.xyz +0 -0
- package/test/data/H2_bound.xyz +0 -0
- package/test/data/bohr.cell +11 -0
- package/test/data/ethanol.cell +0 -0
- package/test/data/example_single.cif +0 -0
- package/test/data/frac.cell +0 -0
- package/test/data/org.cif +0 -0
- package/test/data/pyridine.xyz +1 -1
- package/test/data/pyridine_nocell.xyz +13 -0
- package/test/data/si8.xyz +0 -0
- package/test/data/si8_noisy.xyz +10 -0
- package/test/loader.js +22 -1
- package/test/model.js +40 -9
- package/test/query.js +1 -1
- package/test/tensor.js +1 -1
- package/test/test-html/examples.js +0 -0
- package/test/test-html/index.html +0 -0
- package/test/test-html/index.js +35 -5
- package/tools/compile_colors.py +0 -0
- package/tools/compile_periodic.py +0 -0
- package/tools/ptable.json +0 -0
- 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', '
|
|
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.
|
|
161
|
+
expect(pyrmodel.periodic).to.be.true;
|
|
151
162
|
expect(simodel.periodic).to.be.true;
|
|
152
163
|
});
|
|
153
164
|
|
|
154
|
-
it('should
|
|
155
|
-
expect(
|
|
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
|
-
|
|
175
|
-
found.
|
|
176
|
-
|
|
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
package/test/tensor.js
CHANGED
|
File without changes
|
|
File without changes
|
package/test/test-html/index.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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 =
|
|
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
|
|
package/tools/compile_colors.py
CHANGED
|
File without changes
|
|
File without changes
|
package/tools/ptable.json
CHANGED
|
File without changes
|
package/tools/test
CHANGED
|
File without changes
|