molstar 3.3.0 → 3.3.1
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/build/viewer/molstar.js +1 -1
- package/lib/commonjs/extensions/rcsb/validation-report/representation.js +19 -2
- package/lib/commonjs/mol-model/structure/structure/structure.js +4 -1
- package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -0
- package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.js +4 -2
- package/lib/commonjs/mol-model/structure/structure/unit.js +1 -18
- package/lib/commonjs/mol-model-props/computed/representations/interactions-inter-unit-cylinder.js +9 -3
- package/lib/commonjs/mol-model-props/computed/representations/interactions-intra-unit-cylinder.js +10 -5
- package/lib/commonjs/mol-model-props/integrative/cross-link-restraint/representation.js +10 -1
- package/lib/commonjs/mol-plugin-state/helpers/root-structure.js +1 -1
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +1 -1
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.js +20 -10
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -1
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.js +10 -5
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-cylinder.js +16 -6
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-line.js +8 -3
- package/lib/commonjs/mol-repr/structure/visual/carbohydrate-link-cylinder.js +10 -1
- package/lib/commonjs/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.js +10 -1
- package/lib/commonjs/mol-repr/structure/visual/element-point.d.ts +1 -1
- package/lib/commonjs/mol-repr/structure/visual/element-point.js +22 -3
- package/lib/commonjs/mol-repr/structure/visual/util/element.js +36 -2
- package/lib/commonjs/mol-repr/structure/visual/util/link.d.ts +13 -3
- package/lib/commonjs/mol-repr/structure/visual/util/link.js +55 -6
- package/lib/extensions/rcsb/validation-report/representation.js +19 -2
- package/lib/mol-model/structure/structure/structure.js +4 -1
- package/lib/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -0
- package/lib/mol-model/structure/structure/unit/bonds/inter-compute.js +4 -2
- package/lib/mol-model/structure/structure/unit.js +1 -18
- package/lib/mol-model-props/computed/representations/interactions-inter-unit-cylinder.js +9 -3
- package/lib/mol-model-props/computed/representations/interactions-intra-unit-cylinder.js +10 -5
- package/lib/mol-model-props/integrative/cross-link-restraint/representation.js +10 -1
- package/lib/mol-plugin/version.js +2 -2
- package/lib/mol-plugin-state/helpers/root-structure.js +1 -1
- package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +1 -1
- package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.js +20 -10
- package/lib/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -1
- package/lib/mol-repr/structure/visual/bond-inter-unit-line.js +10 -5
- package/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.js +16 -6
- package/lib/mol-repr/structure/visual/bond-intra-unit-line.js +8 -3
- package/lib/mol-repr/structure/visual/carbohydrate-link-cylinder.js +10 -1
- package/lib/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.js +10 -1
- package/lib/mol-repr/structure/visual/element-point.d.ts +1 -1
- package/lib/mol-repr/structure/visual/element-point.js +22 -3
- package/lib/mol-repr/structure/visual/util/element.js +36 -2
- package/lib/mol-repr/structure/visual/util/link.d.ts +13 -3
- package/lib/mol-repr/structure/visual/util/link.js +55 -6
- package/package.json +1 -1
|
@@ -17,6 +17,8 @@ import { Spheres } from '../../../../mol-geo/geometry/spheres/spheres';
|
|
|
17
17
|
import { SpheresBuilder } from '../../../../mol-geo/geometry/spheres/spheres-builder';
|
|
18
18
|
import { isTrace, isH } from './common';
|
|
19
19
|
import { Sphere3D } from '../../../../mol-math/geometry';
|
|
20
|
+
// avoiding namespace lookup improved performance in Chrome (Aug 2020)
|
|
21
|
+
var v3add = Vec3.add;
|
|
20
22
|
export function makeElementIgnoreTest(structure, unit, props) {
|
|
21
23
|
var ignoreHydrogens = props.ignoreHydrogens, traceOnly = props.traceOnly;
|
|
22
24
|
var atomicNumber = unit.model.atomicHierarchy.derived.atom.atomicNumber;
|
|
@@ -48,20 +50,36 @@ export function createElementSphereMesh(ctx, unit, structure, theme, props, mesh
|
|
|
48
50
|
var ignore = makeElementIgnoreTest(structure, unit, props);
|
|
49
51
|
var l = StructureElement.Location.create(structure, unit);
|
|
50
52
|
var themeSize = theme.size.size;
|
|
53
|
+
var center = Vec3();
|
|
51
54
|
var maxSize = 0;
|
|
55
|
+
var count = 0;
|
|
52
56
|
for (var i = 0; i < elementCount; i++) {
|
|
53
57
|
if (ignore && ignore(elements[i]))
|
|
54
58
|
continue;
|
|
55
59
|
l.element = elements[i];
|
|
56
60
|
pos(elements[i], v);
|
|
61
|
+
v3add(center, center, v);
|
|
62
|
+
count += 1;
|
|
57
63
|
builderState.currentGroup = i;
|
|
58
64
|
var size = themeSize(l);
|
|
59
65
|
if (size > maxSize)
|
|
60
66
|
maxSize = size;
|
|
61
67
|
addSphere(builderState, v, size * sizeFactor, detail);
|
|
62
68
|
}
|
|
69
|
+
var oldBoundingSphere = mesh ? Sphere3D.clone(mesh.boundingSphere) : undefined;
|
|
63
70
|
var m = MeshBuilder.getMesh(builderState);
|
|
64
|
-
|
|
71
|
+
if (count === 0)
|
|
72
|
+
return m;
|
|
73
|
+
// re-use boundingSphere if it has not changed much
|
|
74
|
+
var boundingSphere;
|
|
75
|
+
Vec3.scale(center, center, 1 / count);
|
|
76
|
+
if (oldBoundingSphere && Vec3.distance(center, oldBoundingSphere.center) / oldBoundingSphere.radius < 1.0) {
|
|
77
|
+
boundingSphere = oldBoundingSphere;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
boundingSphere = Sphere3D.expand(Sphere3D(), (childUnit !== null && childUnit !== void 0 ? childUnit : unit).boundary.sphere, maxSize * sizeFactor + 0.05);
|
|
81
|
+
}
|
|
82
|
+
m.setBoundingSphere(boundingSphere);
|
|
65
83
|
return m;
|
|
66
84
|
}
|
|
67
85
|
export function createElementSphereImpostor(ctx, unit, structure, theme, props, spheres) {
|
|
@@ -77,19 +95,35 @@ export function createElementSphereImpostor(ctx, unit, structure, theme, props,
|
|
|
77
95
|
var ignore = makeElementIgnoreTest(structure, unit, props);
|
|
78
96
|
var l = StructureElement.Location.create(structure, unit);
|
|
79
97
|
var themeSize = theme.size.size;
|
|
98
|
+
var center = Vec3();
|
|
80
99
|
var maxSize = 0;
|
|
100
|
+
var count = 0;
|
|
81
101
|
for (var i = 0; i < elementCount; i++) {
|
|
82
102
|
if (ignore === null || ignore === void 0 ? void 0 : ignore(elements[i]))
|
|
83
103
|
continue;
|
|
84
104
|
pos(elements[i], v);
|
|
85
105
|
builder.add(v[0], v[1], v[2], i);
|
|
106
|
+
v3add(center, center, v);
|
|
107
|
+
count += 1;
|
|
86
108
|
l.element = elements[i];
|
|
87
109
|
var size = themeSize(l);
|
|
88
110
|
if (size > maxSize)
|
|
89
111
|
maxSize = size;
|
|
90
112
|
}
|
|
113
|
+
var oldBoundingSphere = spheres ? Sphere3D.clone(spheres.boundingSphere) : undefined;
|
|
91
114
|
var s = builder.getSpheres();
|
|
92
|
-
|
|
115
|
+
if (count === 0)
|
|
116
|
+
return s;
|
|
117
|
+
// re-use boundingSphere if it has not changed much
|
|
118
|
+
var boundingSphere;
|
|
119
|
+
Vec3.scale(center, center, 1 / count);
|
|
120
|
+
if (oldBoundingSphere && Vec3.distance(center, oldBoundingSphere.center) / oldBoundingSphere.radius < 1.0) {
|
|
121
|
+
boundingSphere = oldBoundingSphere;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
boundingSphere = Sphere3D.expand(Sphere3D(), (childUnit !== null && childUnit !== void 0 ? childUnit : unit).boundary.sphere, maxSize * props.sizeFactor + 0.05);
|
|
125
|
+
}
|
|
126
|
+
s.setBoundingSphere(boundingSphere);
|
|
93
127
|
return s;
|
|
94
128
|
}
|
|
95
129
|
export function eachElement(loci, structureGroup, apply) {
|
|
@@ -9,6 +9,7 @@ import { Mesh } from '../../../../mol-geo/geometry/mesh/mesh';
|
|
|
9
9
|
import { VisualContext } from '../../../visual';
|
|
10
10
|
import { Lines } from '../../../../mol-geo/geometry/lines/lines';
|
|
11
11
|
import { Cylinders } from '../../../../mol-geo/geometry/cylinders/cylinders';
|
|
12
|
+
import { Sphere3D } from '../../../../mol-math/geometry/primitives/sphere3d';
|
|
12
13
|
export declare const LinkCylinderParams: {
|
|
13
14
|
linkScale: PD.Numeric;
|
|
14
15
|
linkSpacing: PD.Numeric;
|
|
@@ -75,14 +76,23 @@ export declare const enum LinkStyle {
|
|
|
75
76
|
* Each edge is included twice to allow for coloring/picking
|
|
76
77
|
* the half closer to the first vertex, i.e. vertex a.
|
|
77
78
|
*/
|
|
78
|
-
export declare function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkCylinderProps, mesh?: Mesh):
|
|
79
|
+
export declare function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkCylinderProps, mesh?: Mesh): {
|
|
80
|
+
mesh: Mesh;
|
|
81
|
+
boundingSphere?: Sphere3D;
|
|
82
|
+
};
|
|
79
83
|
/**
|
|
80
84
|
* Each edge is included twice to allow for coloring/picking
|
|
81
85
|
* the half closer to the first vertex, i.e. vertex a.
|
|
82
86
|
*/
|
|
83
|
-
export declare function createLinkCylinderImpostors(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkCylinderProps, cylinders?: Cylinders):
|
|
87
|
+
export declare function createLinkCylinderImpostors(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkCylinderProps, cylinders?: Cylinders): {
|
|
88
|
+
cylinders: Cylinders;
|
|
89
|
+
boundingSphere?: Sphere3D;
|
|
90
|
+
};
|
|
84
91
|
/**
|
|
85
92
|
* Each edge is included twice to allow for coloring/picking
|
|
86
93
|
* the half closer to the first vertex, i.e. vertex a.
|
|
87
94
|
*/
|
|
88
|
-
export declare function createLinkLines(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkLineProps, lines?: Lines):
|
|
95
|
+
export declare function createLinkLines(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkLineProps, lines?: Lines): {
|
|
96
|
+
lines: Lines;
|
|
97
|
+
boundingSphere?: Sphere3D;
|
|
98
|
+
};
|
|
@@ -13,6 +13,7 @@ import { Lines } from '../../../../mol-geo/geometry/lines/lines';
|
|
|
13
13
|
import { LinesBuilder } from '../../../../mol-geo/geometry/lines/lines-builder';
|
|
14
14
|
import { Cylinders } from '../../../../mol-geo/geometry/cylinders/cylinders';
|
|
15
15
|
import { CylindersBuilder } from '../../../../mol-geo/geometry/cylinders/cylinders-builder';
|
|
16
|
+
import { Sphere3D } from '../../../../mol-math/geometry/primitives/sphere3d';
|
|
16
17
|
export var LinkCylinderParams = {
|
|
17
18
|
linkScale: PD.Numeric(0.45, { min: 0, max: 1, step: 0.01 }),
|
|
18
19
|
linkSpacing: PD.Numeric(1, { min: 0, max: 2, step: 0.01 }),
|
|
@@ -75,13 +76,15 @@ var v3dot = Vec3.dot;
|
|
|
75
76
|
export function createLinkCylinderMesh(ctx, linkBuilder, props, mesh) {
|
|
76
77
|
var linkCount = linkBuilder.linkCount, referencePosition = linkBuilder.referencePosition, position = linkBuilder.position, style = linkBuilder.style, radius = linkBuilder.radius, ignore = linkBuilder.ignore, stub = linkBuilder.stub;
|
|
77
78
|
if (!linkCount)
|
|
78
|
-
return Mesh.createEmpty(mesh);
|
|
79
|
+
return { mesh: Mesh.createEmpty(mesh) };
|
|
79
80
|
var linkScale = props.linkScale, linkSpacing = props.linkSpacing, radialSegments = props.radialSegments, linkCap = props.linkCap, aromaticScale = props.aromaticScale, aromaticSpacing = props.aromaticSpacing, aromaticDashCount = props.aromaticDashCount, dashCount = props.dashCount, dashScale = props.dashScale, dashCap = props.dashCap, stubCap = props.stubCap;
|
|
80
81
|
var vertexCountEstimate = radialSegments * 2 * linkCount * 2;
|
|
81
82
|
var builderState = MeshBuilder.createState(vertexCountEstimate, vertexCountEstimate / 4, mesh);
|
|
82
83
|
var va = Vec3();
|
|
83
84
|
var vb = Vec3();
|
|
84
85
|
var vShift = Vec3();
|
|
86
|
+
var center = Vec3();
|
|
87
|
+
var count = 0;
|
|
85
88
|
var cylinderProps = {
|
|
86
89
|
radiusTop: 1,
|
|
87
90
|
radiusBottom: 1,
|
|
@@ -94,6 +97,9 @@ export function createLinkCylinderMesh(ctx, linkBuilder, props, mesh) {
|
|
|
94
97
|
if (ignore && ignore(edgeIndex))
|
|
95
98
|
continue;
|
|
96
99
|
position(va, vb, edgeIndex);
|
|
100
|
+
v3add(center, center, va);
|
|
101
|
+
v3add(center, center, vb);
|
|
102
|
+
count += 2;
|
|
97
103
|
v3sub(tmpV12, vb, va);
|
|
98
104
|
var dirFlag = v3dot(tmpV12, up) > 0;
|
|
99
105
|
var linkRadius = radius(edgeIndex);
|
|
@@ -181,7 +187,18 @@ export function createLinkCylinderMesh(ctx, linkBuilder, props, mesh) {
|
|
|
181
187
|
addCylinder(builderState, va, vb, 0.5, cylinderProps);
|
|
182
188
|
}
|
|
183
189
|
}
|
|
184
|
-
|
|
190
|
+
var oldBoundingSphere = mesh ? Sphere3D.clone(mesh.boundingSphere) : undefined;
|
|
191
|
+
var m = MeshBuilder.getMesh(builderState);
|
|
192
|
+
if (count === 0)
|
|
193
|
+
return { mesh: m };
|
|
194
|
+
// re-use boundingSphere if it has not changed much
|
|
195
|
+
Vec3.scale(center, center, 1 / count);
|
|
196
|
+
if (oldBoundingSphere && Vec3.distance(center, oldBoundingSphere.center) / oldBoundingSphere.radius < 1.0) {
|
|
197
|
+
return { mesh: m, boundingSphere: oldBoundingSphere };
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
return { mesh: m };
|
|
201
|
+
}
|
|
185
202
|
}
|
|
186
203
|
/**
|
|
187
204
|
* Each edge is included twice to allow for coloring/picking
|
|
@@ -190,7 +207,7 @@ export function createLinkCylinderMesh(ctx, linkBuilder, props, mesh) {
|
|
|
190
207
|
export function createLinkCylinderImpostors(ctx, linkBuilder, props, cylinders) {
|
|
191
208
|
var linkCount = linkBuilder.linkCount, referencePosition = linkBuilder.referencePosition, position = linkBuilder.position, style = linkBuilder.style, radius = linkBuilder.radius, ignore = linkBuilder.ignore, stub = linkBuilder.stub;
|
|
192
209
|
if (!linkCount)
|
|
193
|
-
return Cylinders.createEmpty(cylinders);
|
|
210
|
+
return { cylinders: Cylinders.createEmpty(cylinders) };
|
|
194
211
|
var linkScale = props.linkScale, linkSpacing = props.linkSpacing, linkCap = props.linkCap, aromaticScale = props.aromaticScale, aromaticSpacing = props.aromaticSpacing, aromaticDashCount = props.aromaticDashCount, dashCount = props.dashCount, dashScale = props.dashScale, dashCap = props.dashCap, stubCap = props.stubCap;
|
|
195
212
|
var cylindersCountEstimate = linkCount * 2;
|
|
196
213
|
var builder = CylindersBuilder.create(cylindersCountEstimate, cylindersCountEstimate / 4, cylinders);
|
|
@@ -198,6 +215,8 @@ export function createLinkCylinderImpostors(ctx, linkBuilder, props, cylinders)
|
|
|
198
215
|
var vb = Vec3();
|
|
199
216
|
var vm = Vec3();
|
|
200
217
|
var vShift = Vec3();
|
|
218
|
+
var center = Vec3();
|
|
219
|
+
var count = 0;
|
|
201
220
|
// automatically adjust length for evenly spaced dashed cylinders
|
|
202
221
|
var segmentCount = dashCount % 2 === 1 ? dashCount : dashCount + 1;
|
|
203
222
|
var lengthScale = 0.5 - (0.5 / 2 / segmentCount);
|
|
@@ -207,6 +226,9 @@ export function createLinkCylinderImpostors(ctx, linkBuilder, props, cylinders)
|
|
|
207
226
|
if (ignore && ignore(edgeIndex))
|
|
208
227
|
continue;
|
|
209
228
|
position(va, vb, edgeIndex);
|
|
229
|
+
v3add(center, center, va);
|
|
230
|
+
v3add(center, center, vb);
|
|
231
|
+
count += 2;
|
|
210
232
|
var linkRadius = radius(edgeIndex);
|
|
211
233
|
var linkStyle = style ? style(edgeIndex) : 0 /* Solid */;
|
|
212
234
|
var linkStub = stubCap && (stub ? stub(edgeIndex) : false);
|
|
@@ -269,7 +291,18 @@ export function createLinkCylinderImpostors(ctx, linkBuilder, props, cylinders)
|
|
|
269
291
|
builder.add(va[0], va[1], va[2], vb[0], vb[1], vb[2], 1, linkCap, linkStub, edgeIndex);
|
|
270
292
|
}
|
|
271
293
|
}
|
|
272
|
-
|
|
294
|
+
var oldBoundingSphere = cylinders ? Sphere3D.clone(cylinders.boundingSphere) : undefined;
|
|
295
|
+
var c = builder.getCylinders();
|
|
296
|
+
if (count === 0)
|
|
297
|
+
return { cylinders: c };
|
|
298
|
+
// re-use boundingSphere if it has not changed much
|
|
299
|
+
Vec3.scale(center, center, 1 / count);
|
|
300
|
+
if (oldBoundingSphere && Vec3.distance(center, oldBoundingSphere.center) / oldBoundingSphere.radius < 1.0) {
|
|
301
|
+
return { cylinders: c, boundingSphere: oldBoundingSphere };
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
return { cylinders: c };
|
|
305
|
+
}
|
|
273
306
|
}
|
|
274
307
|
/**
|
|
275
308
|
* Each edge is included twice to allow for coloring/picking
|
|
@@ -278,7 +311,7 @@ export function createLinkCylinderImpostors(ctx, linkBuilder, props, cylinders)
|
|
|
278
311
|
export function createLinkLines(ctx, linkBuilder, props, lines) {
|
|
279
312
|
var linkCount = linkBuilder.linkCount, referencePosition = linkBuilder.referencePosition, position = linkBuilder.position, style = linkBuilder.style, ignore = linkBuilder.ignore;
|
|
280
313
|
if (!linkCount)
|
|
281
|
-
return Lines.createEmpty(lines);
|
|
314
|
+
return { lines: Lines.createEmpty(lines) };
|
|
282
315
|
var linkScale = props.linkScale, linkSpacing = props.linkSpacing, aromaticDashCount = props.aromaticDashCount, dashCount = props.dashCount;
|
|
283
316
|
var linesCountEstimate = linkCount * 2;
|
|
284
317
|
var builder = LinesBuilder.create(linesCountEstimate, linesCountEstimate / 4, lines);
|
|
@@ -286,6 +319,8 @@ export function createLinkLines(ctx, linkBuilder, props, lines) {
|
|
|
286
319
|
var vb = Vec3();
|
|
287
320
|
var vm = Vec3();
|
|
288
321
|
var vShift = Vec3();
|
|
322
|
+
var center = Vec3();
|
|
323
|
+
var count = 0;
|
|
289
324
|
// automatically adjust length for evenly spaced dashed lines
|
|
290
325
|
var segmentCount = dashCount % 2 === 1 ? dashCount : dashCount + 1;
|
|
291
326
|
var lengthScale = 0.5 - (0.5 / 2 / segmentCount);
|
|
@@ -297,6 +332,9 @@ export function createLinkLines(ctx, linkBuilder, props, lines) {
|
|
|
297
332
|
if (ignore && ignore(edgeIndex))
|
|
298
333
|
continue;
|
|
299
334
|
position(va, vb, edgeIndex);
|
|
335
|
+
v3add(center, center, va);
|
|
336
|
+
v3add(center, center, vb);
|
|
337
|
+
count += 2;
|
|
300
338
|
var linkStyle = style ? style(edgeIndex) : 0 /* Solid */;
|
|
301
339
|
if (linkStyle === 0 /* Solid */) {
|
|
302
340
|
v3scale(vm, v3add(vm, va, vb), 0.5);
|
|
@@ -354,5 +392,16 @@ export function createLinkLines(ctx, linkBuilder, props, lines) {
|
|
|
354
392
|
builder.add(va[0], va[1], va[2], vb[0], vb[1], vb[2], edgeIndex);
|
|
355
393
|
}
|
|
356
394
|
}
|
|
357
|
-
|
|
395
|
+
var oldBoundingSphere = lines ? Sphere3D.clone(lines.boundingSphere) : undefined;
|
|
396
|
+
var l = builder.getLines();
|
|
397
|
+
if (count === 0)
|
|
398
|
+
return { lines: l };
|
|
399
|
+
// re-use boundingSphere if it has not changed much
|
|
400
|
+
Vec3.scale(center, center, 1 / count);
|
|
401
|
+
if (oldBoundingSphere && Vec3.distance(center, oldBoundingSphere.center) / oldBoundingSphere.radius < 1.0) {
|
|
402
|
+
return { lines: l, boundingSphere: oldBoundingSphere };
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
return { lines: l };
|
|
406
|
+
}
|
|
358
407
|
}
|