From 8cf481ec49c4ba5db829add25aecee590db1b5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 13 Jan 2021 18:39:28 +0100 Subject: [PATCH] Fixing bug when no WebGL is available The switch to Phaser 3.50 introduced a bug when WebGL is not available in a browser. The changes in this commit prevent calls to the WebGL pipeline if the pipeline is not available. --- front/src/Phaser/Items/ActionableItem.ts | 6 ++++-- front/src/index.ts | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index a1548f41..e32bad1a 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -42,8 +42,10 @@ export class ActionableItem { return; } this.isSelectable = true; - this.sprite.setPipeline(OutlinePipeline.KEY); - this.sprite.pipeline.set2f('uTextureSize', this.sprite.texture.getSourceImage().width, this.sprite.texture.getSourceImage().height); + if (this.sprite.pipeline) { + this.sprite.setPipeline(OutlinePipeline.KEY); + this.sprite.pipeline.set2f('uTextureSize', this.sprite.texture.getSourceImage().width, this.sprite.texture.getSourceImage().height); + } } /** diff --git a/front/src/index.ts b/front/src/index.ts index 46d38a3b..abca6036 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -73,9 +73,10 @@ const config: GameConfig = { }, callbacks: { postBoot: game => { - // FIXME: we should fore WebGL in the config. - const renderer = game.renderer as WebGLRenderer; - renderer.pipelines.add(OutlinePipeline.KEY, new OutlinePipeline(game)); + const renderer = game.renderer; + if (renderer instanceof WebGLRenderer) { + renderer.pipelines.add(OutlinePipeline.KEY, new OutlinePipeline(game)); + } } } };