Skip to content

Commit

Permalink
Merge branch 'master' into axisAlignedBoundingBox
Browse files Browse the repository at this point in the history
  • Loading branch information
mramato committed Aug 31, 2012
2 parents b604e73 + f40b3d6 commit 458e7e8
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 253 deletions.
25 changes: 14 additions & 11 deletions Source/Core/Cartesian2.js
@@ -1,8 +1,12 @@
/*global define*/
define([
'./DeveloperError'
],function(
DeveloperError) {
'./defaultValue',
'./DeveloperError',
'./freezeObject'
], function(
defaultValue,
DeveloperError,
freezeObject) {
"use strict";

/**
Expand All @@ -17,18 +21,17 @@ define([
* @see Cartesian4
*/
var Cartesian2 = function(x, y) {

/**
* The Y component.
* @type Number
*/
this.x = (typeof x !== 'undefined') ? x : 0.0;
this.x = defaultValue(x, 0.0);

/**
* The X component.
* @type Number
*/
this.y = (typeof y !== 'undefined') ? y : 0.0;
this.y = defaultValue(y, 0.0);
};

/**
Expand Down Expand Up @@ -288,7 +291,7 @@ define([
throw new DeveloperError('scalar is required and must be a number.');
}
if (typeof result === 'undefined') {
return new Cartesian2(cartesian.x * scalar, cartesian.y * scalar);
return new Cartesian2(cartesian.x * scalar, cartesian.y * scalar);
}
result.x = cartesian.x * scalar;
result.y = cartesian.y * scalar;
Expand Down Expand Up @@ -466,19 +469,19 @@ define([
* An immutable Cartesian2 instance initialized to (0.0, 0.0).
* @memberof Cartesian2
*/
Cartesian2.ZERO = Object.freeze(new Cartesian2(0.0, 0.0));
Cartesian2.ZERO = freezeObject(new Cartesian2(0.0, 0.0));

/**
* An immutable Cartesian2 instance initialized to (1.0, 0.0).
* @memberof Cartesian2
*/
Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1.0, 0.0));
Cartesian2.UNIT_X = freezeObject(new Cartesian2(1.0, 0.0));

/**
* An immutable Cartesian2 instance initialized to (0.0, 1.0).
* @memberof Cartesian2
*/
Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0.0, 1.0));
Cartesian2.UNIT_Y = freezeObject(new Cartesian2(0.0, 1.0));

/**
* Computes the value of the maximum component for this Cartesian.
Expand Down Expand Up @@ -717,4 +720,4 @@ define([
};

return Cartesian2;
});
});
30 changes: 17 additions & 13 deletions Source/Core/Cartesian3.js
@@ -1,7 +1,12 @@
/*global define*/
define(['./DeveloperError'
], function(
DeveloperError) {
define([
'./defaultValue',
'./DeveloperError',
'./freezeObject'
], function(
defaultValue,
DeveloperError,
freezeObject) {
"use strict";

/**
Expand All @@ -17,24 +22,23 @@ define(['./DeveloperError'
* @see Cartesian4
*/
var Cartesian3 = function(x, y, z) {

/**
* The X component.
* @type Number
*/
this.x = (typeof x !== 'undefined') ? x : 0.0;
this.x = defaultValue(x, 0.0);

/**
* The Y component.
* @type Number
*/
this.y = (typeof y !== 'undefined') ? y : 0.0;
this.y = defaultValue(y, 0.0);

/**
* The Z component.
* @type Number
*/
this.z = (typeof z !== 'undefined') ? z : 0.0;
this.z = defaultValue(z, 0.0);
};

/**
Expand All @@ -56,7 +60,7 @@ define(['./DeveloperError'
}
var clock = spherical.clock;
var cone = spherical.cone;
var magnitude = typeof spherical.magnitude === 'undefined' ? 1.0 : spherical.magnitude;
var magnitude = defaultValue(spherical.magnitude, 1.0);
var radial = magnitude * Math.sin(cone);
result.x = radial * Math.cos(clock);
result.y = radial * Math.sin(clock);
Expand Down Expand Up @@ -537,25 +541,25 @@ define(['./DeveloperError'
* An immutable Cartesian3 instance initialized to (0.0, 0.0, 0.0).
* @memberof Cartesian3
*/
Cartesian3.ZERO = Object.freeze(new Cartesian3(0.0, 0.0, 0.0));
Cartesian3.ZERO = freezeObject(new Cartesian3(0.0, 0.0, 0.0));

/**
* An immutable Cartesian3 instance initialized to (1.0, 0.0, 0.0).
* @memberof Cartesian3
*/
Cartesian3.UNIT_X = Object.freeze(new Cartesian3(1.0, 0.0, 0.0));
Cartesian3.UNIT_X = freezeObject(new Cartesian3(1.0, 0.0, 0.0));

/**
* An immutable Cartesian3 instance initialized to (0.0, 1.0, 0.0).
* @memberof Cartesian3
*/
Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0.0, 1.0, 0.0));
Cartesian3.UNIT_Y = freezeObject(new Cartesian3(0.0, 1.0, 0.0));

/**
* An immutable Cartesian3 instance initialized to (0.0, 0.0, 1.0).
* @memberof Cartesian3
*/
Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0.0, 0.0, 1.0));
Cartesian3.UNIT_Z = freezeObject(new Cartesian3(0.0, 0.0, 1.0));

/**
* Computes the value of the maximum component for this Cartesian.
Expand Down Expand Up @@ -807,4 +811,4 @@ define(['./DeveloperError'
};

return Cartesian3;
});
});
36 changes: 20 additions & 16 deletions Source/Core/Cartesian4.js
@@ -1,7 +1,12 @@
/*global define*/
define(['./DeveloperError'
], function(
DeveloperError) {
define([
'./defaultValue',
'./DeveloperError',
'./freezeObject'
], function(
defaultValue,
DeveloperError,
freezeObject) {
"use strict";

/**
Expand All @@ -18,30 +23,29 @@ define(['./DeveloperError'
* @see Cartesian3
*/
var Cartesian4 = function(x, y, z, w) {

/**
* The X component.
* @type Number
*/
this.x = (typeof x !== 'undefined') ? x : 0.0;
this.x = defaultValue(x, 0.0);

/**
* The Y component.
* @type Number
*/
this.y = (typeof y !== 'undefined') ? y : 0.0;
this.y = defaultValue(y, 0.0);

/**
* The Z component.
* @type Number
*/
this.z = (typeof z !== 'undefined') ? z : 0.0;
this.z = defaultValue(z, 0.0);

/**
* The W component.
* @type Number
*/
this.w = (typeof w !== 'undefined') ? w : 0.0;
this.w = defaultValue(w, 0.0);
};

/**
Expand Down Expand Up @@ -115,7 +119,7 @@ define(['./DeveloperError'
if (typeof cartesian === 'undefined') {
throw new DeveloperError('cartesian is required');
}
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z+ cartesian.w * cartesian.w;
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
};

/**
Expand Down Expand Up @@ -284,7 +288,7 @@ define(['./DeveloperError'
throw new DeveloperError('scalar is required and must be a number.');
}
if (typeof result === 'undefined') {
return new Cartesian4(cartesian.x * scalar, cartesian.y * scalar, cartesian.z * scalar, cartesian.w * scalar);
return new Cartesian4(cartesian.x * scalar, cartesian.y * scalar, cartesian.z * scalar, cartesian.w * scalar);
}
result.x = cartesian.x * scalar;
result.y = cartesian.y * scalar;
Expand Down Expand Up @@ -449,31 +453,31 @@ define(['./DeveloperError'
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).
* @memberof Cartesian4
*/
Cartesian4.ZERO = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 0.0));
Cartesian4.ZERO = freezeObject(new Cartesian4(0.0, 0.0, 0.0, 0.0));

/**
* An immutable Cartesian4 instance initialized to (1.0, 0.0, 0.0, 0.0).
* @memberof Cartesian4
*/
Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1.0, 0.0, 0.0, 0.0));
Cartesian4.UNIT_X = freezeObject(new Cartesian4(1.0, 0.0, 0.0, 0.0));

/**
* An immutable Cartesian4 instance initialized to (0.0, 1.0, 0.0, 0.0).
* @memberof Cartesian4
*/
Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0.0, 1.0, 0.0, 0.0));
Cartesian4.UNIT_Y = freezeObject(new Cartesian4(0.0, 1.0, 0.0, 0.0));

/**
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 1.0, 0.0).
* @memberof Cartesian4
*/
Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0.0, 0.0, 1.0, 0.0));
Cartesian4.UNIT_Z = freezeObject(new Cartesian4(0.0, 0.0, 1.0, 0.0));

/**
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 1.0).
* @memberof Cartesian4
*/
Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 1.0));
Cartesian4.UNIT_W = freezeObject(new Cartesian4(0.0, 0.0, 0.0, 1.0));

/**
* Computes the value of the maximum component for this Cartesian.
Expand Down Expand Up @@ -698,4 +702,4 @@ define(['./DeveloperError'
};

return Cartesian4;
});
});
6 changes: 4 additions & 2 deletions Source/Core/Cartographic.js
Expand Up @@ -2,10 +2,12 @@
define([
'./defaultValue',
'./DeveloperError',
'./freezeObject',
'./Math'
], function(
defaultValue,
DeveloperError,
freezeObject,
CesiumMath) {
"use strict";

Expand Down Expand Up @@ -154,7 +156,7 @@ define([
*
* @memberof Cartographic
*/
Cartographic.ZERO = Object.freeze(new Cartographic(0.0, 0.0, 0.0));
Cartographic.ZERO = freezeObject(new Cartographic(0.0, 0.0, 0.0));

/**
* Duplicates this instance.
Expand Down Expand Up @@ -206,4 +208,4 @@ define([
};

return Cartographic;
});
});
22 changes: 12 additions & 10 deletions Source/Core/Color.js
@@ -1,8 +1,10 @@
/*global define*/
define([
'./defaultValue'
'./defaultValue',
'./freezeObject'
], function(
defaultValue) {
defaultValue,
freezeObject) {
"use strict";

/**
Expand Down Expand Up @@ -183,49 +185,49 @@ define([
* An immutable Color instance initialized to white, RGBA (1.0, 1.0, 1.0, 1.0).
* @memberof Color
*/
Color.WHITE = Object.freeze(new Color(1.0, 1.0, 1.0, 1.0));
Color.WHITE = freezeObject(new Color(1.0, 1.0, 1.0, 1.0));

/**
* An immutable Color instance initialized to black, RGBA (0.0, 0.0, 0.0, 1.0).
* @memberof Color
*/
Color.BLACK = Object.freeze(new Color(0.0, 0.0, 0.0, 1.0));
Color.BLACK = freezeObject(new Color(0.0, 0.0, 0.0, 1.0));

/**
* An immutable Color instance initialized to red, RGBA (1.0, 0.0, 0.0, 1.0).
* @memberof Color
*/
Color.RED = Object.freeze(new Color(1.0, 0.0, 0.0, 1.0));
Color.RED = freezeObject(new Color(1.0, 0.0, 0.0, 1.0));

/**
* An immutable Color instance initialized to green, RGBA (0.0, 1.0, 0.0, 1.0).
* @memberof Color
*/
Color.GREEN = Object.freeze(new Color(0.0, 1.0, 0.0, 1.0));
Color.GREEN = freezeObject(new Color(0.0, 1.0, 0.0, 1.0));

/**
* An immutable Color instance initialized to blue, RGBA (0.0, 0.0, 1.0, 1.0).
* @memberof Color
*/
Color.BLUE = Object.freeze(new Color(0.0, 0.0, 1.0, 1.0));
Color.BLUE = freezeObject(new Color(0.0, 0.0, 1.0, 1.0));

/**
* An immutable Color instance initialized to yellow, RGBA (1.0, 1.0, 0.0, 1.0).
* @memberof Color
*/
Color.YELLOW = Object.freeze(new Color(1.0, 1.0, 0.0, 1.0));
Color.YELLOW = freezeObject(new Color(1.0, 1.0, 0.0, 1.0));

/**
* An immutable Color instance initialized to magenta, RGBA (1.0, 0.0, 1.0, 1.0).
* @memberof Color
*/
Color.MAGENTA = Object.freeze(new Color(1.0, 0.0, 1.0, 1.0));
Color.MAGENTA = freezeObject(new Color(1.0, 0.0, 1.0, 1.0));

/**
* An immutable Color instance initialized to cyan, RGBA (0.0, 1.0, 1.0, 1.0).
* @memberof Color
*/
Color.CYAN = Object.freeze(new Color(0.0, 1.0, 1.0, 1.0));
Color.CYAN = freezeObject(new Color(0.0, 1.0, 1.0, 1.0));

return Color;
});

0 comments on commit 458e7e8

Please sign in to comment.