]> _ Git - fluidbook-html5.git/commitdiff
wait #2984 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Aug 2019 15:39:49 +0000 (17:39 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Aug 2019 15:39:49 +0000 (17:39 +0200)
js/libs/fluidbook/fluidbook.3dflip.js

index dfe3720a29807b56ceedea5147259f4ecadfc8b7..17d652c66d7c512b429c87993f7146b22639a7de 100644 (file)
@@ -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;
             }