mirror of
https://github.com/molstar/molstar.git
synced 2026-06-06 14:44:22 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f61ea06b | ||
|
|
3095754817 | ||
|
|
c76c433410 | ||
|
|
347ef3ea7a | ||
|
|
84c47738ac | ||
|
|
fe331ead80 | ||
|
|
77d013b775 | ||
|
|
02a466e8b9 | ||
|
|
3cb65cbe3d |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.2",
|
||||
"description": "A comprehensive macromolecular library.",
|
||||
"homepage": "https://github.com/molstar/molstar#readme",
|
||||
"repository": {
|
||||
|
||||
@@ -237,10 +237,10 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d
|
||||
export const PostprocessingParams = {
|
||||
occlusion: PD.MappedStatic('on', {
|
||||
on: PD.Group({
|
||||
samples: PD.Numeric(64, {min: 1, max: 256, step: 1}),
|
||||
samples: PD.Numeric(32, {min: 1, max: 256, step: 1}),
|
||||
radius: PD.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: 'Final radius is 2^x.' }),
|
||||
bias: PD.Numeric(0.8, { min: 0, max: 3, step: 0.1 }),
|
||||
blurKernelSize: PD.Numeric(20, { min: 1, max: 25, step: 2 }),
|
||||
blurKernelSize: PD.Numeric(15, { min: 1, max: 25, step: 2 }),
|
||||
}),
|
||||
off: PD.Group({})
|
||||
}, { cycle: true, description: 'Darken occluded crevices with the ambient occlusion effect' }),
|
||||
|
||||
@@ -12,13 +12,13 @@ export function setCanvasSize(canvas: HTMLCanvasElement, width: number, height:
|
||||
}
|
||||
|
||||
/** Resize canvas to container element taking `devicePixelRatio` into account */
|
||||
export function resizeCanvas (canvas: HTMLCanvasElement, container: Element, scale = 1) {
|
||||
export function resizeCanvas (canvas: HTMLCanvasElement, container: HTMLElement, scale = 1) {
|
||||
let width = window.innerWidth;
|
||||
let height = window.innerHeight;
|
||||
if (container !== document.body) {
|
||||
let bounds = container.getBoundingClientRect();
|
||||
width = bounds.right - bounds.left;
|
||||
height = bounds.bottom - bounds.top;
|
||||
// fixes issue #molstar/molstar#147, offsetWidth/offsetHeight is correct size when css transform:scale is used
|
||||
width = container.offsetWidth;
|
||||
height = container.offsetHeight;
|
||||
}
|
||||
setCanvasSize(canvas, width, height, scale);
|
||||
}
|
||||
|
||||
@@ -195,17 +195,17 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex
|
||||
export function extractIsosurface(ctx: WebGLContext, volumeData: Texture, gridDim: Vec3, gridTexDim: Vec3, gridTexScale: Vec2, transform: Mat4, isoValue: number, packedGroup: boolean, vertexTexture?: Texture, groupTexture?: Texture, normalTexture?: Texture) {
|
||||
// console.time('calcActiveVoxels');
|
||||
const activeVoxelsTex = calcActiveVoxels(ctx, volumeData, gridDim, gridTexDim, isoValue, gridTexScale);
|
||||
// ctx.webgl.waitForGpuCommandsCompleteSync();
|
||||
// ctx.waitForGpuCommandsCompleteSync();
|
||||
// console.timeEnd('calcActiveVoxels');
|
||||
|
||||
// console.time('createHistogramPyramid');
|
||||
const compacted = createHistogramPyramid(ctx, activeVoxelsTex, gridTexScale, gridTexDim);
|
||||
// ctx.webgl.waitForGpuCommandsCompleteSync();
|
||||
// ctx.waitForGpuCommandsCompleteSync();
|
||||
// console.timeEnd('createHistogramPyramid');
|
||||
|
||||
// console.time('createIsosurfaceBuffers');
|
||||
const gv = createIsosurfaceBuffers(ctx, activeVoxelsTex, volumeData, compacted, gridDim, gridTexDim, transform, isoValue, packedGroup, vertexTexture, groupTexture, normalTexture);
|
||||
// ctx.webgl.waitForGpuCommandsCompleteSync();
|
||||
// ctx.waitForGpuCommandsCompleteSync();
|
||||
// console.timeEnd('createIsosurfaceBuffers');
|
||||
|
||||
return gv;
|
||||
|
||||
@@ -41,6 +41,12 @@ varying vec3 vViewPosition;
|
||||
attribute float aVertex;
|
||||
#define VertexID int(aVertex)
|
||||
#else
|
||||
#define VertexID gl_VertexID
|
||||
// not using gl_VertexID but aVertex to ensure there is an active attribute with divisor 0
|
||||
// since FF 85 this is not needed anymore but lets keep it for backwards compatibility
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
|
||||
// see also note in src/mol-gl/webgl/render-item.ts
|
||||
attribute float aVertex;
|
||||
#define VertexID int(aVertex)
|
||||
// #define VertexID gl_VertexID
|
||||
#endif
|
||||
`;
|
||||
@@ -112,7 +112,12 @@ export function createRenderItem<T extends string>(ctx: WebGLContext, drawMode:
|
||||
const { instancedArrays, vertexArrayObject } = ctx.extensions;
|
||||
|
||||
// emulate gl_VertexID when needed
|
||||
if (!ctx.isWebGL2 && values.uVertexCount) {
|
||||
// if (!ctx.isWebGL2 && values.uVertexCount) {
|
||||
// not using gl_VertexID in WebGL2 but aVertex to ensure there is an active attribute with divisor 0
|
||||
// since FF 85 this is not needed anymore but lets keep it for backwards compatibility
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
|
||||
// see also note in src/mol-gl/shader/chunks/common-vert-params.glsl.ts
|
||||
if (values.uVertexCount) {
|
||||
const vertexCount = values.uVertexCount.ref.value;
|
||||
(values as any).aVertex = ValueCell.create(fillSerial(new Float32Array(vertexCount)));
|
||||
(schema as any).aVertex = AttributeSpec('float32', 1, 0);
|
||||
|
||||
@@ -111,33 +111,41 @@ namespace Spacegroup {
|
||||
|
||||
const _translationRef = Vec3();
|
||||
const _translationRefSymop = Vec3();
|
||||
const _translationRefOffset = Vec3();
|
||||
const _translationSymop = Vec3();
|
||||
export function setOperatorMatrixRef(spacegroup: Spacegroup, index: number, i: number, j: number, k: number, ref: Vec3, target: Mat4) {
|
||||
Vec3.set(_ijkVec, i, j, k);
|
||||
Vec3.floor(_translationRef, ref);
|
||||
|
||||
Mat4.copy(target, spacegroup.operators[index]);
|
||||
|
||||
Vec3.floor(_translationRefSymop, Vec3.transformMat4(_translationRefSymop, ref, target));
|
||||
|
||||
Mat4.getTranslation(_translationSymop, target);
|
||||
Vec3.sub(_translationSymop, _translationSymop, _translationRefSymop);
|
||||
Vec3.add(_translationSymop, _translationSymop, _translationRef);
|
||||
Vec3.add(_translationSymop, _translationSymop, _ijkVec);
|
||||
|
||||
Mat4.setTranslation(target, _translationSymop);
|
||||
Mat4.mul(target, spacegroup.cell.fromFractional, target);
|
||||
Mat4.mul(target, target, spacegroup.cell.toFractional);
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Symmetry operator for transformation around the given
|
||||
* reference point `ref` in fractional coordinates
|
||||
*/
|
||||
export function getSymmetryOperatorRef(spacegroup: Spacegroup, spgrOp: number, i: number, j: number, k: number, ref: Vec3) {
|
||||
const operator = setOperatorMatrixRef(spacegroup, spgrOp, i, j, k, ref, Mat4.zero());
|
||||
return SymmetryOperator.create(`${spgrOp + 1}_${5 + i}${5 + j}${5 + k}`, operator, { hkl: Vec3.create(i, j, k), spgrOp });
|
||||
|
||||
const operator = Mat4.zero();
|
||||
|
||||
Vec3.set(_ijkVec, i, j, k);
|
||||
Vec3.floor(_translationRef, ref);
|
||||
|
||||
Mat4.copy(operator, spacegroup.operators[spgrOp]);
|
||||
|
||||
Vec3.floor(_translationRefSymop, Vec3.transformMat4(_translationRefSymop, ref, operator));
|
||||
|
||||
Mat4.getTranslation(_translationSymop, operator);
|
||||
Vec3.sub(_translationSymop, _translationSymop, _translationRefSymop);
|
||||
Vec3.add(_translationSymop, _translationSymop, _translationRef);
|
||||
Vec3.add(_translationSymop, _translationSymop, _ijkVec);
|
||||
|
||||
Mat4.setTranslation(operator, _translationSymop);
|
||||
Mat4.mul(operator, spacegroup.cell.fromFractional, operator);
|
||||
Mat4.mul(operator, operator, spacegroup.cell.toFractional);
|
||||
|
||||
Vec3.sub(_translationRefOffset, _translationRefSymop, _translationRef);
|
||||
|
||||
const _i = i - _translationRefOffset[0];
|
||||
const _j = j - _translationRefOffset[1];
|
||||
const _k = k - _translationRefOffset[2];
|
||||
|
||||
// const operator = setOperatorMatrixRef(spacegroup, spgrOp, i, j, k, ref, Mat4.zero());
|
||||
return SymmetryOperator.create(`${spgrOp + 1}_${5 + _i}${5 + _j}${5 + _k}`, operator, { hkl: Vec3.create(_i, _j, _k), spgrOp });
|
||||
}
|
||||
|
||||
function getOperatorMatrix(ids: number[]) {
|
||||
|
||||
@@ -50,6 +50,7 @@ const StandardComponents = (function() {
|
||||
{ id: 'ASP', name: 'ASPARTIC ACID', type: 'L-peptide linking' },
|
||||
{ id: 'GLU', name: 'GLUTAMIC ACID', type: 'L-peptide linking' },
|
||||
{ id: 'THR', name: 'THREONINE', type: 'L-peptide linking' },
|
||||
{ id: 'PRO', name: 'PROLINE', type: 'L-peptide linking' },
|
||||
{ id: 'SEC', name: 'SELENOCYSTEINE', type: 'L-peptide linking' },
|
||||
{ id: 'PYL', name: 'PYRROLYSINE', type: 'L-peptide linking' },
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace CustomElementProperty {
|
||||
type: builder.type || 'dynamic',
|
||||
defaultParams: {},
|
||||
getParams: (data: Model) => ({}),
|
||||
isApplicable: (data: Model) => !!builder.isApplicable?.(data),
|
||||
isApplicable: (data: Model) => !builder.isApplicable || !!builder.isApplicable(data),
|
||||
obtain: async (ctx: CustomProperty.Context, data: Model) => {
|
||||
return await builder.getData(data, ctx);
|
||||
}
|
||||
|
||||
@@ -76,11 +76,18 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) {
|
||||
ctx.state.data.events.cell.stateUpdated.subscribe(e => {
|
||||
const cell = e.state.cells.get(e.ref)!;
|
||||
if (!SO.isRepresentation3D(cell.obj)) return;
|
||||
updateVisibility(cell, cell.obj.data.repr);
|
||||
ctx.canvas3d?.syncVisibility();
|
||||
|
||||
if (updateVisibility(cell, cell.obj.data.repr)) {
|
||||
ctx.canvas3d?.syncVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateVisibility(cell: StateObjectCell, r: Representation<any>) {
|
||||
r.setState({ visible: !cell.state.isHidden });
|
||||
if (r.state.visible === cell.state.isHidden) {
|
||||
r.setState({ visible: !cell.state.isHidden });
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user