-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
85 lines (71 loc) · 2.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { GLmol } from 'Lib/GLmol';
/* global AFRAME */
if (typeof AFRAME === 'undefined') {
throw new Error('Component attempted to register before AFRAME was available.');
}
/**
* GLMol component for A-Frame.
*/
AFRAME.registerComponent('glmol', {
schema: {
width: {type: 'number', default: 1},
height: {type: 'number', default: 1},
depth: {type: 'number', default: 1},
color: {type: 'color', default: '#AAA'},
molId: {type: 'string', default: 'pdb:2POR'},
color: {type: 'string', default: 'chainbow'}, //Color by: chainbow, chain, ss, b, polarity
mainchain: {type: 'string', default: 'thickRibbon'}, //Main chain as: thickRibbon, ribbon, strand, cylinderHelix, chain, tube, bonds, none
base: {type: 'string', default: 'nuclLine'}, //Nucleic acid bases as: nuclStick, nuclLine, nuclPolygon
line: {type: 'boolean', default: false}, //Side chains as lines: true, false
doNotSmoothen: {type: 'boolean', default: true}, //Don't smooth beta-sheets in ribbons: true, false
nb: {type: 'string', default: 'none'}, //Non-bonded atoms as: nb_sphere, nb_cross, none
hetatmMode: {type: 'string', default: 'sphere'}, //Small molecules (HETATMS) as: stick, ballAndStick, ballAndStick2, sphere, icosahedron, line, none
cell: {type: 'boolean', default: false}, //Unit cell: true, false
biomt: {type: 'boolean', default: false}, //Biological assembly: true, false
packing: {type: 'boolean', default: false}, //Crystal packing: true, false
symopHetatms: {type: 'boolean', default: false} //Show HETATMS in symmetry mates: true, false
},
/**
* Set if component needs multiple instancing.
*/
multiple: true,
/**
* Called once when component is attached. Generally for initial setup.
*/
init: function () {
var data = this.data;
var el = this.el;
},
/**
* Called when component is attached and when component data changes.
* Generally modifies the entity based on the data.
*/
update: function (oldData) {
this.glmol= new GLmol(this.data);
// Set mesh on entity.
this.glmol.returnModelGroup().then(
(modelGroup)=>{
this.el.setObject3D('mesh', modelGroup);
this.el.setAttribute('scale', `${1/this.glmol.largestSideLength} ${1/this.glmol.largestSideLength} ${1/this.glmol.largestSideLength}`);
})
},
/**
* Called when a component is removed (e.g., via removeAttribute).
* Generally undoes all modifications to the entity.
*/
remove: function () { },
/**
* Called on each scene tick.
*/
tick: function (t) { },
/**
* Called when entity pauses.
* Use to stop or remove any dynamic or background behavior such as events.
*/
pause: function () { },
/**
* Called when entity resumes.
* Use to continue or add any dynamic or background behavior such as events.
*/
play: function () { }
});