From 5922e1f780c06f74d2993a9fe9160bb2ec912032 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 28 Aug 2019 17:39:49 +0200 Subject: [PATCH] wait #2984 @0:20 --- js/libs/fluidbook/fluidbook.3dflip.js | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.3dflip.js b/js/libs/fluidbook/fluidbook.3dflip.js index dfe3720a..17d652c6 100644 --- a/js/libs/fluidbook/fluidbook.3dflip.js +++ b/js/libs/fluidbook/fluidbook.3dflip.js @@ -37,14 +37,21 @@ function Fluidbook3DFlip(fluidbook) { this.pi2 = Math.PI * 2; this.deg2rad = this.pi2 / 360; - this.testBenchmark(function () { - $this.init(); - }); + this.errorInitWebGL = false; + + try { + this.testBenchmark(function () { + $this.init(); + }); + } catch (e) { + this.errorInitWebGL = true; + this.init(); + } } Fluidbook3DFlip.prototype = { webglEnabled: function () { - return this.fluidbook.support.IE === 0 && Modernizr.webgl; + return !this.errorInitWebGL && this.fluidbook.support.IE === 0 && Modernizr.webgl; }, testBenchmark: function (cb) { @@ -213,6 +220,9 @@ Fluidbook3DFlip.prototype = { if (this.fluidbook.support.android || this.fluidbook.support.iOS) { this.renderEngine = 'webgl'; } + if (!this.webglEnabled()) { + this.renderEngine = 'canvas'; + } this.enableLight = !this.lowPerf && this.renderEngine === 'webgl'; this.enableShadow = !this.lowPerf && this.enableLight && this.renderEngine === 'webgl'; this.antialias = false; @@ -236,7 +246,6 @@ Fluidbook3DFlip.prototype = { this.pixelRatio = window.devicePixelRatio * this.qualityRatio; this.frames = 0; - return this.initThree(); }, @@ -348,7 +357,6 @@ Fluidbook3DFlip.prototype = { this.bendForceMultiplicator = 1.2; } - this.bend = new Bend(0, this.bendOffset, this.bendAngle * 0.0174533); this.bend.constraint = -1; this.modifier.reset(); @@ -356,7 +364,12 @@ Fluidbook3DFlip.prototype = { var rendererOptions = {antialias: this.antialias, alpha: true}; if (this.renderEngine === 'webgl') { - this.renderer = new THREE.WebGLRenderer(rendererOptions); + try { + this.renderer = new THREE.WebGLRenderer(rendererOptions); + } catch (e) { + this.errorInitWebGL = true; + return this.init3D('performancesTest'); + } } else if (this.renderEngine === 'canvas') { this.renderer = new THREE.CanvasRenderer(rendererOptions); } @@ -738,7 +751,7 @@ Fluidbook3DFlip.prototype = { height: Math.abs(min.y - max.y) }; - if (rect.width == 0 || rect.width > 100000) { + if (rect.width === 0 || rect.width > 100000) { continue; } -- 2.39.5