Compare commits

...

4 Commits

Author SHA1 Message Date
dsehnal
903f06bab6 2.3.3 2021-10-01 17:56:26 +02:00
dsehnal
13f2810f90 fix direct volume shader 2021-10-01 17:54:33 +02:00
dsehnal
ee8cae16d2 2.3.2 2021-10-01 17:12:42 +02:00
dsehnal
feaf6f7fd4 (temporarily) prefer webgl1 on iOS 2021-10-01 17:10:49 +02:00
8 changed files with 35 additions and 8 deletions

View File

@@ -6,6 +6,16 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased]
## [v2.3.3] - 2021-10-01
- Fix direct volume shader
## [v2.3.2] - 2021-10-01
- Prefer WebGL1 on iOS devices until WebGL2 support has stabilized.
## [v2.3.1] - 2021-09-28
- Add Charmm saccharide names

4
package-lock.json generated
View File

@@ -1,11 +1,11 @@
{
"name": "molstar",
"version": "2.3.1",
"version": "2.3.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "2.3.1",
"version": "2.3.3",
"license": "MIT",
"dependencies": {
"@types/argparse": "^2.0.10",

View File

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

View File

@@ -115,19 +115,21 @@ namespace Canvas3DContext {
preserveDrawingBuffer: true,
pixelScale: 1,
pickScale: 0.25,
enableWboit: true
enableWboit: true,
preferWebGl1: false
};
export type Attribs = typeof DefaultAttribs
export function fromCanvas(canvas: HTMLCanvasElement, attribs: Partial<Attribs> = {}): Canvas3DContext {
const a = { ...DefaultAttribs, ...attribs };
const { antialias, preserveDrawingBuffer, pixelScale } = a;
const { antialias, preserveDrawingBuffer, pixelScale, preferWebGl1 } = a;
const gl = getGLContext(canvas, {
antialias,
preserveDrawingBuffer,
alpha: true, // the renderer requires an alpha channel
depth: true, // the renderer requires a depth buffer
premultipliedAlpha: true, // the renderer outputs PMA
preferWebGl1
});
if (gl === null) throw new Error('Could not create a WebGL rendering context');

View File

@@ -55,6 +55,7 @@ uniform vec3 uHighlightColor;
uniform vec3 uSelectColor;
uniform float uHighlightStrength;
uniform float uSelectStrength;
uniform int uMarkerPriority;
#if defined(dMarkerType_uniform)
uniform float uMarker;

View File

@@ -18,7 +18,7 @@ import { now } from '../../mol-util/now';
import { Texture, TextureFilter } from './texture';
import { ComputeRenderable } from '../renderable';
export function getGLContext(canvas: HTMLCanvasElement, attribs?: WebGLContextAttributes): GLRenderingContext | null {
export function getGLContext(canvas: HTMLCanvasElement, attribs?: WebGLContextAttributes & { preferWebGl1?: boolean }): GLRenderingContext | null {
function get(id: 'webgl' | 'experimental-webgl' | 'webgl2') {
try {
return canvas.getContext(id, attribs) as GLRenderingContext | null;
@@ -26,7 +26,7 @@ export function getGLContext(canvas: HTMLCanvasElement, attribs?: WebGLContextAt
return null;
}
}
const gl = get('webgl2') || get('webgl') || get('experimental-webgl');
const gl = (attribs?.preferWebGl1 ? null : get('webgl2')) || get('webgl') || get('experimental-webgl');
if (isDebugMode) console.log(`isWebgl2: ${isWebGL2(gl)}`);
return gl;
}

View File

@@ -19,6 +19,16 @@ export class PluginConfigItem<T = any> {
function item<T>(key: string, defaultValue?: T) { return new PluginConfigItem(key, defaultValue); }
// adapted from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
function is_iOS() {
if (typeof navigator === 'undefined' || typeof window === 'undefined') return false;
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
const isAppleDevice = navigator.userAgent.includes('Macintosh');
const isTouchScreen = navigator.maxTouchPoints >= 4; // true for iOS 13 (and hopefully beyond)
return !(window as any).MSStream && (isIOS || (isAppleDevice && isTouchScreen));
}
export const PluginConfig = {
item,
General: {
@@ -28,6 +38,9 @@ export const PluginConfig = {
PixelScale: item('plugin-config.pixel-scale', 1),
PickScale: item('plugin-config.pick-scale', 0.25),
EnableWboit: item('plugin-config.enable-wboit', true),
// as of Oct 1 2021, WebGL 2 doesn't work on iOS 15.
// TODO: check back in a few weeks to see if it was fixed
PreferWebGl1: item('plugin-config.prefer-webgl1', is_iOS()),
},
State: {
DefaultServer: item('plugin-state.server', 'https://webchem.ncbr.muni.cz/molstar-state'),

View File

@@ -197,7 +197,8 @@ export class PluginContext {
const pixelScale = this.config.get(PluginConfig.General.PixelScale) || 1;
const pickScale = this.config.get(PluginConfig.General.PickScale) || 0.25;
const enableWboit = this.config.get(PluginConfig.General.EnableWboit) || false;
(this.canvas3dContext as Canvas3DContext) = Canvas3DContext.fromCanvas(canvas, { antialias, preserveDrawingBuffer, pixelScale, pickScale, enableWboit });
const preferWebGl1 = this.config.get(PluginConfig.General.PreferWebGl1) || false;
(this.canvas3dContext as Canvas3DContext) = Canvas3DContext.fromCanvas(canvas, { antialias, preserveDrawingBuffer, pixelScale, pickScale, enableWboit, preferWebGl1 });
}
(this.canvas3d as Canvas3D) = Canvas3D.create(this.canvas3dContext!);
this.canvas3dInit.next(true);