Skip to content

Instantly share code, notes, and snippets.

@gregtatum
Created July 21, 2014 13:56
Show Gist options
  • Save gregtatum/5ce3a3aface226e5eba8 to your computer and use it in GitHub Desktop.
Save gregtatum/5ce3a3aface226e5eba8 to your computer and use it in GitHub Desktop.
console.table for a three.js matrix4
//Utils.consoleMatrix( threeJsMatrix, 3 )
//Utils.consoleMatrix( threeJsMatrix )
var Utils = {
consoleMatrix : function( matrix, decimalPlaces ) {
var i, j, el, results;
results = [ [], [], [], [] ];
j = 0;
for( i=0; i < matrix.elements.length; i++ ) {
el = matrix.elements[i];
if( typeof decimalPlaces === "number" ) {
el = Math.round( Math.pow(10, decimalPlaces) * el ) / Math.pow(10, decimalPlaces);
}
results[j].push( el );
j++;
j %= 4;
}
console.table( results );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment