This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts nested arrays into one-dimensional flattening array (recursively) | |
* @param {Array} arr Input nested arrays | |
* @param {Array} result Output one-dimensional flattening array | |
* @return Output one-dimensional flattening array | |
*/ | |
function flattenNestedArrays(arr, result = []) { | |
const length = arr.length; | |
for (let i = 0; i < length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit goes to https://gist.github.com/cbranch/260224a7e4699552d2dc | |
// Gets a JSDraw instance which renders to a PIXI graphics object. | |
// graphics: an instance of PIXI.Graphics | |
// scale: the scaling factor to convert from Box2D coordinates to screen pixels | |
function getPIXIDebugDraw(graphics, scale) { | |
function getColorFromDebugDrawCallback(color) { | |
var col = Box2D.wrapPointer(color, Box2D.b2Color); | |
var red = (col.get_r() * 255 * 255 * 255)|0; | |
var green = (col.get_g() * 255 * 255)|0; | |
var blue = (col.get_b() * 255)|0; |