Skip to content

Commit

Permalink
Build and tests now work. Renamed some of objects, see tests for exam…
Browse files Browse the repository at this point in the history
…ples.
  • Loading branch information
Alan Kligman committed Oct 9, 2011
1 parent 22ba5a2 commit 6d5ce77
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 77 deletions.
66 changes: 44 additions & 22 deletions src/Math.js
Expand Up @@ -25,7 +25,8 @@ var _Math = function( options ) {
Object.defineProperty( this, 'ARRAY_TYPE', {
get: function() {
return FLOAT_ARRAY_TYPE;
}
},
enumerable: true
});

// ** Vector Functions **
Expand Down Expand Up @@ -383,124 +384,142 @@ var _Math = function( options ) {
Object.defineProperty( this.vector2, 'x', {
get: function() {
return that.Vector2( [1, 0] );
}
},
enumerable: true
});
Object.defineProperty( this.vector2, 'u', {
get: function() {
return that.Vector2( [1, 0] );
}
},
enumerable: true
});

// Y-Axis
Object.defineProperty( this.vector2, 'y', {
get: function() {
return that.Vector2( [0, 1] );
}
},
enumerable: true
});
Object.defineProperty( this.vector2, 'v', {
get: function() {
return that.Vector2( [0, 1] );
}
},
enumerable: true
});

// Zero
Object.defineProperty( this.vector2, 'zero', {
get: function() {
return that.Vector2( [0, 0] );
}
},
enumerable: true
});

// Unit
Object.defineProperty( this.vector2, 'one', {
get: function() {
return that.Vector2( [1, 1] );
}
},
enumerable: true
});

// *** Vector3 Constants ***
// X-Axis
Object.defineProperty( this.vector3, 'x', {
get: function() {
return that.Vector3( [1, 0, 0] );
}
},
enumerable: true
});

// Y-Axis
Object.defineProperty( this.vector3, 'y', {
get: function() {
return that.Vector3( [0, 1, 0] );
}
},
enumerable: true
});

// Z-Axis
Object.defineProperty( this.vector3, 'z', {
get: function() {
return that.Vector3( [0, 0, 1] );
}
},
enumerable: true
});

// Zero
Object.defineProperty( this.vector3, 'zero', {
get: function() {
return that.Vector3( [0, 0, 0] );
}
},
enumerable: true
});

// Unit
Object.defineProperty( this.vector3, 'one', {
get: function() {
return that.Vector3( [1, 1, 1] );
}
},
enumerable: true
});

// *** Vector4 Constants ***
// X-Axis
Object.defineProperty( this.vector4, 'x', {
get: function() {
return that.Vector4( [1, 0, 0, 0] );
}
},
enumerable: true
});

// Y-Axis
Object.defineProperty( this.vector4, 'y', {
get: function() {
return that.Vector4( [0, 1, 0, 0] );
}
},
enumerable: true
});

// Z-Axis
Object.defineProperty( this.vector4, 'z', {
get: function() {
return that.Vector4( [0, 0, 1, 0] );
}
},
enumerable: true
});

// W-Axis
Object.defineProperty( this.vector4, 'w', {
get: function() {
return that.Vector4( [0, 0, 0, 1] );
}
},
enumerable: true
});

// Zero
Object.defineProperty( this.vector4, 'zero', {
get: function() {
return that.Vector4( [0, 0, 0, 0] );
}
},
enumerable: true
});

// Unit
Object.defineProperty( this.vector4, 'one', {
get: function() {
return that.Vector4( [1, 1, 1, 1] );
}
},
enumerable: true
});

// Identity Quaternion
Object.defineProperty( this.quaternion, 'identity', {
get: function() {
return that.Quaternion( [0, 0, 0, 1] );
}
},
enumerable: true
});
// ** End Vector Functions **

Expand Down Expand Up @@ -1098,19 +1117,22 @@ var _Math = function( options ) {
Object.defineProperty( this.matrix4, 'identity', {
get: function() {
return _matrix4_identity;
}
},
enumerable: true
});

Object.defineProperty( this.matrix3, 'identity', {
get: function() {
return _matrix3_identity;
}
},
enumerable: true
});

Object.defineProperty( this.matrix2, 'identity', {
get: function() {
return _matrix2_identity;
}
},
enumerable: true
});
// ** End Matrix Functions **

Expand Down
6 changes: 3 additions & 3 deletions src/math-src.js
Expand Up @@ -5,13 +5,13 @@ define( function ( require ) {
var lang = require( './lang' ),
Implementation = require( './Math' ),

math, i, args,
_math, i, args,

// Expose the API on the global object. Part of if may already
// exist, mainly gladius.ready from gladius.js. Check tools/wrap.start
// for protections against overwriting an existing gladius in the page,
// for when gladius is built for deployment.
global = window.math || ( window.math = {} );
global = window._math || ( window._math = {} );

/***
* _Math
Expand All @@ -30,7 +30,7 @@ define( function ( require ) {

lang.extend( this, new Implementation() );

// Let caller know the engine instance is ready.
// Let caller know the math instance is ready.
if (callback) {
callback(this);
}
Expand Down
10 changes: 5 additions & 5 deletions src/math.js
Expand Up @@ -41,13 +41,13 @@
'requirejs(["math-src"])</' + 'script>');
}

var math = this.math || ( this.math = {} );
var _math = this._math || ( this._math = {} );

if ( !math.create ) {
math.create = function () {
if ( !_math.create ) {
_math.create = function () {
// Hold on to callback, code in math will call it.
( math._waitingCreates ||
( math._waitingCreates = [] ) ).push( arguments );
( _math._waitingCreates ||
( _math._waitingCreates = [] ) ).push( arguments );
};
}

Expand Down
27 changes: 0 additions & 27 deletions test/Basic.js

This file was deleted.

6 changes: 4 additions & 2 deletions test/Math.Matrix2.js
Expand Up @@ -11,8 +11,10 @@
module( 'Math/Matrix', {
setup: function () {
stop();
math = new _Math();
start();
_math.create( {}, function( instance ) {
math = instance;
start();
});
},

teardown: function () {
Expand Down
6 changes: 4 additions & 2 deletions test/Math.Vector2.js
Expand Up @@ -11,8 +11,10 @@
module( 'Vector2 Tests', {
setup: function () {
stop();
math = new _Math();
start();
_math.create( {}, function( instance ) {
math = instance;
start();
});
},

teardown: function () {
Expand Down
8 changes: 5 additions & 3 deletions test/Math.Vector3.js
Expand Up @@ -11,9 +11,11 @@
module( 'Vector3 Tests', {
setup: function () {
stop();
math = new _Math();
start();
},
_math.create( {}, function( instance ) {
math = instance;
start();
});
},

teardown: function () {
math = null;
Expand Down
6 changes: 4 additions & 2 deletions test/Math.Vector4.js
Expand Up @@ -11,8 +11,10 @@
module( 'Vector4 Tests', {
setup: function () {
stop();
math = new _Math();
start();
_math.create( {}, function( instance ) {
math = instance;
start();
});
},

teardown: function () {
Expand Down
6 changes: 4 additions & 2 deletions test/Math.js
Expand Up @@ -10,8 +10,10 @@
module( 'Math', {
setup: function () {
stop();
math = new _Math();
start();
_math.create( {}, function( instance ) {
math = instance;
start();
});
},

teardown: function () {
Expand Down
7 changes: 3 additions & 4 deletions test/index.html
Expand Up @@ -5,13 +5,12 @@
<link rel="stylesheet" href="../tools/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../tools/qunit/qunit/qunit.js"></script>
<script src="../src/math.js"></script>
<script src="Basic.js"></script>
<!--script src="Math.js"></script>

<script src="Math.js"></script>
<script src="Math.Vector2.js"></script>
<script src="Math.Vector3.js"></script>
<script src="Math.Vector4.js"></script>
<script src="Math.Matrix2.js"></script-->
<script src="Math.Matrix2.js"></script>


<style>
Expand Down
7 changes: 3 additions & 4 deletions test/index.html.dist
Expand Up @@ -5,13 +5,12 @@
<link rel="stylesheet" href="../tools/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../tools/qunit/qunit/qunit.js"></script>
<script src="../math.js"></script>
<script src="Basic.js"></script>
<!--script src="Math.js"></script>


<script src="Math.js"></script>
<script src="Math.Vector2.js"></script>
<script src="Math.Vector3.js"></script>
<script src="Math.Vector4.js"></script>
<script src="Math.Matrix2.js"></script-->
<script src="Math.Matrix2.js"></script>


<style>
Expand Down
2 changes: 1 addition & 1 deletion tools/wrap.start
Expand Up @@ -15,6 +15,6 @@
(function () {

// Bail if there is already a gladius in the page.
if ( this.gladius ) {
if ( this._math ) {
return;
}

0 comments on commit 6d5ce77

Please sign in to comment.