From 1ba125582f289ea4cb96fc62ad9624602eda619b Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 31 Jan 2021 21:51:09 +0000 Subject: [PATCH] catch missing plugin require in examples --- examples/avalanche.js | 16 ++++++++++------ examples/ballPool.js | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/avalanche.js b/examples/avalanche.js index b85f7701..07eb744a 100644 --- a/examples/avalanche.js +++ b/examples/avalanche.js @@ -1,12 +1,16 @@ var Example = Example || {}; Example.avalanche = function() { - if (typeof MatterWrap !== 'undefined') { - // either use by name from plugin registry (Browser global) - Matter.use('matter-wrap'); - } else { - // or require and use the plugin directly (Node.js, Webpack etc.) - Matter.use(require('matter-wrap')); + try { + if (typeof MatterWrap !== 'undefined') { + // either use by name from plugin registry (Browser global) + Matter.use('matter-wrap'); + } else { + // or require and use the plugin directly (Node.js, Webpack etc.) + Matter.use(require('matter-wrap')); + } + } catch (e) { + // could not require the plugin or install needed } var Engine = Matter.Engine, diff --git a/examples/ballPool.js b/examples/ballPool.js index 75048d6f..7b349065 100644 --- a/examples/ballPool.js +++ b/examples/ballPool.js @@ -1,12 +1,16 @@ var Example = Example || {}; Example.ballPool = function() { - if (typeof MatterWrap !== 'undefined') { - // either use by name from plugin registry (Browser global) - Matter.use('matter-wrap'); - } else { - // or require and use the plugin directly (Node.js, Webpack etc.) - Matter.use(require('matter-wrap')); + try { + if (typeof MatterWrap !== 'undefined') { + // either use by name from plugin registry (Browser global) + Matter.use('matter-wrap'); + } else { + // or require and use the plugin directly (Node.js, Webpack etc.) + Matter.use(require('matter-wrap')); + } + } catch (e) { + // could not require the plugin or install needed } var Engine = Matter.Engine,