mirror of
https://github.com/molstar/molstar.git
synced 2026-06-07 23:34:23 +08:00
Compare commits
6 Commits
v0.7.1-dev
...
v0.7.1-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4319ae251c | ||
|
|
e5920e29b4 | ||
|
|
c376ddfc9d | ||
|
|
8fe2d3f724 | ||
|
|
4d7a128528 | ||
|
|
663ec9695e |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "0.7.1-dev.7",
|
||||
"version": "0.7.1-dev.8",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
`;
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
`;
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
`;
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
`;
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
`;
|
||||
@@ -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 });
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user