mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
fix Matter.Demo for node
This commit is contained in:
parent
75af920f1d
commit
06eea3ec3a
2 changed files with 19 additions and 19 deletions
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
if (!_isBrowser) {
|
if (!_isBrowser) {
|
||||||
module.exports = Demo;
|
module.exports = Demo;
|
||||||
|
window = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matter aliases
|
// Matter aliases
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
Svg = Matter.Svg;
|
Svg = Matter.Svg;
|
||||||
|
|
||||||
// MatterTools aliases
|
// MatterTools aliases
|
||||||
if (_isBrowser && window.MatterTools) {
|
if (window.MatterTools) {
|
||||||
var Gui = MatterTools.Gui,
|
var Gui = MatterTools.Gui,
|
||||||
Inspector = MatterTools.Inspector;
|
Inspector = MatterTools.Inspector;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
_sceneEvents = [],
|
_sceneEvents = [],
|
||||||
_useInspector = _isBrowser && window.location.hash.indexOf('-inspect') !== -1,
|
_useInspector = _isBrowser && window.location.hash.indexOf('-inspect') !== -1,
|
||||||
_isMobile = _isBrowser && /(ipad|iphone|ipod|android)/gi.test(navigator.userAgent),
|
_isMobile = _isBrowser && /(ipad|iphone|ipod|android)/gi.test(navigator.userAgent),
|
||||||
_isAutomatedTest = _isBrowser ? false : true;
|
_isAutomatedTest = !_isBrowser || window._phantom;
|
||||||
|
|
||||||
// initialise the demo
|
// initialise the demo
|
||||||
|
|
||||||
|
@ -95,13 +96,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// call init when the page has loaded fully
|
// call init when the page has loaded fully
|
||||||
|
|
||||||
if (_isBrowser) {
|
if (window.addEventListener) {
|
||||||
if (window.addEventListener) {
|
window.addEventListener('load', Demo.init);
|
||||||
window.addEventListener('load', Demo.init);
|
} else if (window.attachEvent) {
|
||||||
} else if (window.attachEvent) {
|
window.attachEvent('load', Demo.init);
|
||||||
window.attachEvent('load', Demo.init);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// each demo scene is set up in its own function, see below
|
// each demo scene is set up in its own function, see below
|
||||||
|
@ -690,9 +689,6 @@
|
||||||
var renderOptions = _engine.render.options;
|
var renderOptions = _engine.render.options;
|
||||||
renderOptions.wireframes = false;
|
renderOptions.wireframes = false;
|
||||||
renderOptions.showAngleIndicator = false;
|
renderOptions.showAngleIndicator = false;
|
||||||
|
|
||||||
if (window.chrome)
|
|
||||||
renderOptions.showShadows = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Demo.chains = function() {
|
Demo.chains = function() {
|
||||||
|
@ -1728,7 +1724,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Demo.reset = function() {
|
Demo.reset = function() {
|
||||||
var _world = _engine.world;
|
var _world = _engine.world,
|
||||||
|
i;
|
||||||
|
|
||||||
World.clear(_world);
|
World.clear(_world);
|
||||||
Engine.clear(_engine);
|
Engine.clear(_engine);
|
||||||
|
@ -1741,8 +1738,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all scene events
|
// clear all scene events
|
||||||
for (var i = 0; i < _sceneEvents.length; i++)
|
if (_engine.events) {
|
||||||
Events.off(_engine, _sceneEvents[i]);
|
for (i = 0; i < _sceneEvents.length; i++)
|
||||||
|
Events.off(_engine, _sceneEvents[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (_mouseConstraint && _mouseConstraint.events) {
|
if (_mouseConstraint && _mouseConstraint.events) {
|
||||||
for (i = 0; i < _sceneEvents.length; i++)
|
for (i = 0; i < _sceneEvents.length; i++)
|
||||||
|
@ -1814,10 +1813,11 @@
|
||||||
renderOptions.showInternalEdges = false;
|
renderOptions.showInternalEdges = false;
|
||||||
renderOptions.showSeparations = false;
|
renderOptions.showSeparations = false;
|
||||||
renderOptions.background = '#fff';
|
renderOptions.background = '#fff';
|
||||||
}
|
|
||||||
|
|
||||||
if (_isMobile)
|
if (_isMobile) {
|
||||||
renderOptions.showDebug = true;
|
renderOptions.showDebug = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -55,7 +55,7 @@ var Events = {};
|
||||||
var callbacks = object.events[names[i]],
|
var callbacks = object.events[names[i]],
|
||||||
newCallbacks = [];
|
newCallbacks = [];
|
||||||
|
|
||||||
if (callback) {
|
if (callback && callbacks) {
|
||||||
for (var j = 0; j < callbacks.length; j++) {
|
for (var j = 0; j < callbacks.length; j++) {
|
||||||
if (callbacks[j] !== callback)
|
if (callbacks[j] !== callback)
|
||||||
newCallbacks.push(callbacks[j]);
|
newCallbacks.push(callbacks[j]);
|
||||||
|
|
Loading…
Reference in a new issue