0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-12 16:08:50 -05:00

catch missing plugin require in examples

This commit is contained in:
liabru 2021-01-31 21:51:09 +00:00
parent 2ade78fb75
commit 1ba125582f
2 changed files with 20 additions and 12 deletions

View file

@ -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,

View file

@ -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,