Skip to content

Commit

Permalink
Merge pull request CesiumGS#1716 from AnalyticalGraphicsInc/readonly
Browse files Browse the repository at this point in the history
Use getters for @readonly properties
  • Loading branch information
shunter committed May 20, 2014
2 parents 62b4822 + 4ffd439 commit 1046925
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 77 deletions.
53 changes: 45 additions & 8 deletions Source/Core/CatmullRomSpline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'./Cartesian4',
'./defaultValue',
'./defined',
'./defineProperties',
'./DeveloperError',
'./HermiteSpline',
'./Matrix4',
Expand All @@ -13,6 +14,7 @@ define([
Cartesian4,
defaultValue,
defined,
defineProperties,
DeveloperError,
HermiteSpline,
Matrix4,
Expand Down Expand Up @@ -174,37 +176,72 @@ define([
}
}

this._times = times;
this._points = points;
this._firstTangent = Cartesian3.clone(firstTangent);
this._lastTangent = Cartesian3.clone(lastTangent);

this._evaluateFunction = createEvaluateFunction(this);
this._lastTimeIndex = 0;
};

defineProperties(CatmullRomSpline.prototype, {
/**
* An array of times for the control points.
*
* @memberof CatmullRomSpline.prototype
*
* @type {Array}
* @readonly
*/
this.times = times;
times : {
get : function() {
return this._times;
}
},

/**
* An array of {@link Cartesian3} control points.
*
* @memberof CatmullRomSpline.prototype
*
* @type {Array}
* @readonly
*/
this.points = points;
points : {
get : function() {
return this._points;
}
},

/**
* The tangent at the first control point.
*
* @memberof CatmullRomSpline.prototype
*
* @type {Cartesian3}
* @readonly
*/
this.firstTangent = Cartesian3.clone(firstTangent);
firstTangent : {
get : function() {
return this._firstTangent;
}
},

/**
* The tangent at the last control point.
*
* @memberof CatmullRomSpline.prototype
*
* @type {Cartesian3}
* @readonly
*/
this.lastTangent = Cartesian3.clone(lastTangent);

this._evaluateFunction = createEvaluateFunction(this);
this._lastTimeIndex = 0;
};
lastTangent : {
get : function() {
return this._lastTangent;
}
}
});

/**
* @private
Expand Down
71 changes: 45 additions & 26 deletions Source/Core/ColorGeometryInstanceAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ define([
'./ComponentDatatype',
'./defaultValue',
'./defined',
'./defineProperties',
'./DeveloperError'
], function(
Color,
ComponentDatatype,
defaultValue,
defined,
defineProperties,
DeveloperError) {
"use strict";

Expand Down Expand Up @@ -46,56 +48,73 @@ define([
blue = defaultValue(blue, 1.0);
alpha = defaultValue(alpha, 1.0);

/**
* The values for the attributes stored in a typed array.
*
* @type Uint8Array
*
* @default [255, 255, 255, 255]
*/
this.value = new Uint8Array([
Color.floatToByte(red),
Color.floatToByte(green),
Color.floatToByte(blue),
Color.floatToByte(alpha)
]);
};

defineProperties(ColorGeometryInstanceAttribute.prototype, {
/**
* The datatype of each component in the attribute, e.g., individual elements in
* {@link ColorGeometryInstanceAttribute#value}.
*
* @type ComponentDatatype
*
* @default {@link ComponentDatatype.UNSIGNED_BYTE}
* @memberof ColorGeometryInstanceAttribute.prototype
*
* @type {ComponentDatatype}
* @readonly
*
* @default {@link ComponentDatatype.UNSIGNED_BYTE}
*/
this.componentDatatype = ComponentDatatype.UNSIGNED_BYTE;
componentDatatype : {
get : function() {
return ComponentDatatype.UNSIGNED_BYTE;
}
},

/**
* The number of components in the attributes, i.e., {@link ColorGeometryInstanceAttribute#value}.
*
* @type Number
*
* @default 4
* @memberof ColorGeometryInstanceAttribute.prototype
*
* @type {Number}
* @readonly
*
* @default 4
*/
this.componentsPerAttribute = 4;
componentsPerAttribute : {
get : function() {
return 4;
}
},

/**
* When <code>true</code> and <code>componentDatatype</code> is an integer format,
* indicate that the components should be mapped to the range [0, 1] (unsigned)
* or [-1, 1] (signed) when they are accessed as floating-point for rendering.
*
* @type Boolean
*
* @default true
* @memberof ColorGeometryInstanceAttribute.prototype
*
* @type {Boolean}
* @readonly
*/
this.normalize = true;

/**
* The values for the attributes stored in a typed array.
*
* @type Uint8Array
*
* @default [255, 255, 255, 255]
* @default true
*/
this.value = new Uint8Array([
Color.floatToByte(red),
Color.floatToByte(green),
Color.floatToByte(blue),
Color.floatToByte(alpha)
]);
};
normalize : {
get : function() {
return true;
}
}
});

/**
* Creates a new {@link ColorGeometryInstanceAttribute} instance given the provided {@link Color}.
Expand Down
51 changes: 44 additions & 7 deletions Source/Core/HermiteSpline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'./Cartesian4',
'./defaultValue',
'./defined',
'./defineProperties',
'./DeveloperError',
'./LinearSpline',
'./Matrix4',
Expand All @@ -14,6 +15,7 @@ define([
Cartesian4,
defaultValue,
defined,
defineProperties,
DeveloperError,
LinearSpline,
Matrix4,
Expand Down Expand Up @@ -199,36 +201,71 @@ define([
}
//>>includeEnd('debug');

this._times = times;
this._points = points;
this._inTangents = inTangents;
this._outTangents = outTangents;

this._lastTimeIndex = 0;
};

defineProperties(HermiteSpline.prototype, {
/**
* An array of times for the control points.
*
* @memberof HermiteSpline.prototype
*
* @type {Array}
* @readonly
*/
this.times = times;
times : {
get : function() {
return this._times;
}
},

/**
* An array of {@link Cartesian3} control points.
*
* @memberof HermiteSpline.prototype
*
* @type {Array}
* @readonly
*/
this.points = points;
points : {
get : function() {
return this._points;
}
},

/**
* An array of {@link Cartesian3} incoming tangents at each control point.
*
* @memberof HermiteSpline.prototype
*
* @type {Array}
* @readonly
*/
this.inTangents = inTangents;
inTangents : {
get : function() {
return this._inTangents;
}
},

/**
* An array of {@link Cartesian3} outgoing tangents at each control point.
*
* @memberof HermiteSpline.prototype
*
* @type {Array}
* @readonly
*/
this.outTangents = outTangents;

this._lastTimeIndex = 0;
};
outTangents : {
get : function() {
return this._outTangents;
}
}
});

/**
* Creates a spline where the tangents at each control point are the same.
Expand Down
31 changes: 26 additions & 5 deletions Source/Core/LinearSpline.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ define([
'./Cartesian3',
'./defaultValue',
'./defined',
'./defineProperties',
'./DeveloperError',
'./Spline'
], function(
Cartesian3,
defaultValue,
defined,
defineProperties,
DeveloperError,
Spline) {
"use strict";
Expand Down Expand Up @@ -65,22 +67,41 @@ define([
}
//>>includeEnd('debug');

this._times = times;
this._points = points;

this._lastTimeIndex = 0;
};

defineProperties(LinearSpline.prototype, {
/**
* An array of times for the control points.
*
* @memberof LinearSpline.prototype
*
* @type {Array}
* @readonly
*/
this.times = times;
times : {
get : function() {
return this._times;
}
},

/**
* An array of {@link Cartesian3} control points.
*
* @memberof LinearSpline.prototype
*
* @type {Array}
* @readonly
*/
this.points = points;

this._lastTimeIndex = 0;
};
points : {
get : function() {
return this._points;
}
}
});

/**
* Finds an index <code>i</code> in <code>times</code> such that the parameter
Expand Down
Loading

0 comments on commit 1046925

Please sign in to comment.