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
//Utils.consoleMatrix( threeJsMatrix, 3 ) | |
//Utils.consoleMatrix( threeJsMatrix ) | |
var Utils = { | |
consoleMatrix : function( matrix, decimalPlaces ) { | |
var i, j, el, results; |
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
var consoleMatrixElements = function( els, decimalPlaces ) { | |
var i, j, el, results; | |
results = []; | |
j = 0; | |
for( i=0; i < els.length; i++ ) { | |
if( j === 0 ) { |
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
/* | |
* This is an illustration of the new Object() functionality for JavaScript written | |
* as a function. | |
*/ | |
function extend(a, b) { | |
var c = {}, attr; | |
for (attr in a) { | |
if (Object.prototype.hasOwnProperty.call(a, attr)) { | |
c[attr] = a[attr]; |
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
/* | |
Typical prototypical pattern. Store all state, configuration, and functions on the "this" object. | |
*/ | |
var Car = function( engineType ) { | |
this.engine = engineType || "v4"; | |
this.timesRevved = 0; |
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
function pow( number, degree ) { | |
var memo = 1; | |
while( degree-- ) { | |
memo *= number; | |
} | |
return memo; | |
} |
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
/* | |
* Different ways to save state or configure a function | |
* | |
*/ | |
//------------------------------------------------- | |
// Typical prototypical inheritance | |
var Talker = function( phrase ) { | |
this.phrase = phrase; |
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
function extendBind(target, object, state) { | |
var keys = Object.keys(object); | |
var i = keys.length; | |
while (i--) { | |
target[keys[i]] = object[keys[i]].bind(state); | |
} | |
return target; | |
} | |
function identityOrSet( v ) { |
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
function roundTo( value, decimalPlaces ) { | |
if( typeof decimalPlaces === "number" ) { | |
return Math.round( Math.pow(10, decimalPlaces) * value ) / Math.pow(10, decimalPlaces); | |
} else { | |
return value; | |
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
function helloWorld1() { | |
}; // jshint warning | |
var helloWorld2 = function() { | |
}; // no jshint warning | |
function helloWorld3() { |
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
var ringFunction = function( geometry, radius, segments ) { | |
var rStep = 2 * Math.PI / segments; | |
return { | |
create : function( height, skinIndex, skinWeight ) { | |
for( var i=0; i < segments; i++ ) { |
OlderNewer