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) {
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;
this.pixelRatio = window.devicePixelRatio * this.qualityRatio;
this.frames = 0;
-
return this.initThree();
},
this.bendForceMultiplicator = 1.2;
}
-
this.bend = new Bend(0, this.bendOffset, this.bendAngle * 0.0174533);
this.bend.constraint = -1;
this.modifier.reset();
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);
}
height: Math.abs(min.y - max.y)
};
- if (rect.width == 0 || rect.width > 100000) {
+ if (rect.width === 0 || rect.width > 100000) {
continue;
}