Compare commits

...

6 Commits

Author SHA1 Message Date
Alexander Rose
4319ae251c 0.7.1-dev.8 2020-05-15 10:25:29 -07:00
Alexander Rose
e5920e29b4 improved presets for coarse-grained structures 2020-05-15 09:58:57 -07:00
Alexander Rose
c376ddfc9d Merge branch 'master' of https://github.com/molstar/molstar 2020-05-14 22:59:46 -07:00
Alexander Rose
8fe2d3f724 Merge branch 'master' of https://github.com/molstar/molstar 2020-05-14 22:58:32 -07:00
Alexander Rose
4d7a128528 clip object support for non mesh geometries
- spheres
- lines
- points
- text
2020-05-14 22:57:57 -07:00
Alexander Rose
663ec9695e fixes for structure focus & selection 2020-05-14 17:18:20 -07:00
16 changed files with 88 additions and 26 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "molstar",
"version": "0.7.1-dev.7",
"version": "0.7.1-dev.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "molstar",
"version": "0.7.1-dev.7",
"version": "0.7.1-dev.8",
"description": "A comprehensive macromolecular library.",
"homepage": "https://github.com/molstar/molstar#readme",
"repository": {

View File

@@ -7,7 +7,7 @@ mat4 modelView = uView * model;
vec3 position = aPosition;
#endif
vec4 position4 = vec4(position, 1.0);
vModelPosition = (model * position4).xyz;
vModelPosition = (model * position4).xyz; // for clipping in frag shader
vec4 mvPosition = modelView * position4;
vViewPosition = mvPosition.xyz;
gl_Position = uProjection * mvPosition;

View File

@@ -5,7 +5,7 @@ export default `
flag = int(floor(vClipping * 255.0 + 0.5));
#endif
vec4 mCenter = model * vec4(uInvariantBoundingSphere.xyz, 1.0);
vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0);
if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w), flag))
// move out of [ -w, +w ] to 'discard' in vert shader
gl_Position.z = 2.0 * gl_Position.w;

View File

@@ -1,11 +1,12 @@
export default `
#if defined(dClipVariant_pixel) && dClipObjectCount != 0
int flag = 0;
#if defined(dClipping)
flag = int(floor(vClipping * 255.0 + 0.5));
int clippingFlag = int(floor(vClipping * 255.0 + 0.5));
#else
int clippingFlag = 0;
#endif
if (clipTest(vec4(vModelPosition, 0.0), flag))
if (clipTest(vec4(vModelPosition, 0.0), clippingFlag))
discard;
#endif
`;

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -11,8 +11,10 @@ precision highp int;
#include common
#include common_frag_params
#include color_frag_params
#include common_clip
void main(){
#include clip_pixel
#include assign_material_color
#if defined(dRenderVariant_pick)

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*
@@ -15,6 +15,7 @@ precision highp int;
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip
uniform float uPixelRatio;
uniform float uViewportHeight;
@@ -42,6 +43,7 @@ void main(){
#include assign_group
#include assign_color_varying
#include assign_marker_varying
#include assign_clipping_varying
#include assign_size
mat4 modelView = uView * uModel * aTransform;
@@ -51,10 +53,12 @@ void main(){
vec4 end = modelView * vec4(aEnd, 1.0);
// assign position
vec3 position = (aMapping.y < 0.5) ? aStart : aEnd;
vec4 mvPosition = modelView * vec4(position, 1.0);
vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0);
vec4 mvPosition = modelView * position4;
vViewPosition = mvPosition.xyz;
vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
@@ -114,5 +118,7 @@ void main(){
offset *= clip.w;
clip.xy += offset;
gl_Position = clip;
#include clip_instance
}
`;

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -11,6 +11,7 @@ precision highp int;
#include common
#include common_frag_params
#include color_frag_params
#include common_clip
#ifdef dPointFilledCircle
uniform float uPointEdgeBleach;
@@ -20,6 +21,7 @@ const vec2 center = vec2(0.5);
const float radius = 0.5;
void main(){
#include clip_pixel
#include assign_material_color
#if defined(dRenderVariant_pick)

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -13,6 +13,7 @@ precision highp int;
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip
uniform float uPixelRatio;
uniform float uViewportHeight;
@@ -26,6 +27,7 @@ void main(){
#include assign_group
#include assign_color_varying
#include assign_marker_varying
#include assign_clipping_varying
#include assign_position
#include assign_size
@@ -36,5 +38,7 @@ void main(){
#endif
gl_Position = uProjection * mvPosition;
#include clip_instance
}
`;

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -12,6 +12,7 @@ precision highp int;
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include common_clip
uniform mat4 uProjection;
@@ -73,6 +74,8 @@ bool Impostor(out vec3 cameraPos, out vec3 cameraNormal){
}
void main(void){
#include clip_pixel
bool flag = Impostor(cameraPos, cameraNormal);
#ifndef dDoubleSided
if (interior)

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -13,6 +13,7 @@ precision highp int;
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip
uniform mat4 uModelView;
uniform mat4 uInvProjection;
@@ -77,11 +78,13 @@ void main(void){
#include assign_group
#include assign_color_varying
#include assign_marker_varying
#include assign_clipping_varying
#include assign_size
vRadius = size * matrixScale(uModelView);
vec4 mvPosition = uModelView * aTransform * vec4(aPosition, 1.0);
vec4 position4 = vec4(aPosition, 1.0);
vec4 mvPosition = uModelView * aTransform * position4;
mvPosition.z -= vRadius; // avoid clipping, added again in fragment shader
gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);
@@ -91,5 +94,9 @@ void main(void){
vec4 vPoint4 = uInvProjection * gl_Position;
vPoint = vPoint4.xyz / vPoint4.w;
vPointViewPosition = -mvPosition.xyz / mvPosition.w;
vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader
#include clip_instance
}
`;

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -11,6 +11,7 @@ precision highp int;
#include common
#include common_frag_params
#include color_frag_params
#include common_clip
uniform sampler2D tFont;
@@ -29,6 +30,7 @@ void main2(){
}
void main(){
#include clip_pixel
#include assign_material_color
if (vTexCoord.x > 1.0) {

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -13,6 +13,7 @@ precision highp int;
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip
uniform mat4 uModelView;
@@ -40,6 +41,7 @@ void main(void){
#include assign_group
#include assign_color_varying
#include assign_marker_varying
#include assign_clipping_varying
#include assign_size
vTexCoord = aTexCoord;
@@ -50,7 +52,10 @@ void main(void){
float offsetY = uOffsetY * scale;
float offsetZ = (uOffsetZ + aDepth * 0.95) * scale;
vec4 mvPosition = uModelView * aTransform * vec4(aPosition, 1.0);
vec4 position4 = vec4(aPosition, 1.0);
vec4 mvPosition = uModelView * aTransform * position4;
vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader
// TODO
// #ifdef FIXED_SIZE
@@ -83,5 +88,7 @@ void main(void){
gl_Position = uProjection * mvCorner;
vViewPosition = -mvCorner.xyz;
#include clip_instance
}
`;

View File

@@ -114,9 +114,14 @@ const polymerAndLigand = StructureRepresentationPresetProvider({
coarse: await presetStaticComponent(plugin, structureCell, 'coarse')
};
const structure = structureCell.obj!.data;
const cartoonProps = {
sizeFactor: structure.isCoarseGrained ? 0.8 : 0.2,
};
const { update, builder, typeParams, color } = reprBuilder(plugin, params);
const representations = {
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color }, { tag: 'polymer' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams: { ...typeParams, ...cartoonProps }, color }, { tag: 'polymer' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams, color }, { tag: 'ligand' }),
nonStandard: builder.buildRepresentation(update, components.nonStandard, { type: 'ball-and-stick', typeParams, color: color || 'polymer-id' }, { tag: 'non-standard' }),
branchedBallAndStick: builder.buildRepresentation(update, components.branched, { type: 'ball-and-stick', typeParams: { ...typeParams, alpha: 0.3 }, color }, { tag: 'branched-ball-and-stick' }),
@@ -147,10 +152,19 @@ const proteinAndNucleic = StructureRepresentationPresetProvider({
nucleic: await presetSelectionComponent(plugin, structureCell, 'nucleic'),
};
const structure = structureCell.obj!.data;
const cartoonProps = {
sizeFactor: structure.isCoarseGrained ? 0.8 : 0.2,
};
const gaussianProps = {
radiusOffset: structure.isCoarseGrained ? 2 : 0,
smoothness: structure.isCoarseGrained ? 0.5 : 1.5,
};
const { update, builder, typeParams, color } = reprBuilder(plugin, params);
const representations = {
protein: builder.buildRepresentation(update, components.protein, { type: 'cartoon', typeParams, color }, { tag: 'protein' }),
nucleic: builder.buildRepresentation(update, components.nucleic, { type: 'gaussian-surface', typeParams, color }, { tag: 'nucleic' })
protein: builder.buildRepresentation(update, components.protein, { type: 'cartoon', typeParams: { ...typeParams, ...cartoonProps }, color }, { tag: 'protein' }),
nucleic: builder.buildRepresentation(update, components.nucleic, { type: 'gaussian-surface', typeParams: { ...typeParams, ...gaussianProps }, color }, { tag: 'nucleic' })
};
await update.commit({ revertOnError: true });
@@ -179,12 +193,18 @@ const coarseSurface = StructureRepresentationPresetProvider({
if (size === Structure.Size.Gigantic) {
Object.assign(gaussianProps, {
traceOnly: true,
radiusOffset: 1,
radiusOffset: 2,
smoothness: 0.5,
visuals: ['structure-gaussian-surface-mesh']
});
} else if(size === Structure.Size.Huge) {
Object.assign(gaussianProps, {
radiusOffset: structure.isCoarseGrained ? 2 : 0,
smoothness: 0.5,
});
} else if(structure.isCoarseGrained) {
Object.assign(gaussianProps, {
radiusOffset: 2,
smoothness: 0.5,
});
}
@@ -214,9 +234,14 @@ const polymerCartoon = StructureRepresentationPresetProvider({
polymer: await presetStaticComponent(plugin, structureCell, 'polymer'),
};
const structure = structureCell.obj!.data;
const cartoonProps = {
sizeFactor: structure.isCoarseGrained ? 0.8 : 0.2
};
const { update, builder, typeParams, color } = reprBuilder(plugin, params);
const representations = {
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color }, { tag: 'polymer' })
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams: { ...typeParams, ...cartoonProps }, color }, { tag: 'polymer' })
};
await update.commit({ revertOnError: true });

View File

@@ -124,7 +124,10 @@ export class StructureFocusManager extends StatefulPluginComponent<StructureFocu
}
setSnapshot(snapshot: StructureFocusSnapshot) {
if (!snapshot.current) return;
if (!snapshot.current) {
this.clear();
return;
}
const { label, ref, bundle, category } = snapshot.current;
const structure = this.plugin.state.data.select(StateSelection.Generators.byRef(ref))[0]?.obj?.data as Structure;

View File

@@ -260,7 +260,7 @@ export class StructureSelectionManager extends StatefulPluginComponent<Structure
if (!structure) return;
// oldObj is not defined for inserts (e.g. TransformStructureConformation)
if (!oldObj || Structure.areUnitAndIndicesEqual(oldObj.data, obj.data)) {
if (!oldObj?.data || Structure.areUnitAndIndicesEqual(oldObj.data, obj.data)) {
this.entries.set(ref, remapSelectionEntry(this.entries.get(ref)!, structure));
// remap referenceLoci & prevHighlight if needed and possible