Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Triangles #1142

Merged
merged 3 commits into from
Sep 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Beta Releases
* Added `heading` and `tilt` properties to `CameraController`.
* Made sun size accurate.
* Added `Scene.sunBloom` to enable/disable the bloom filter on the sun. The bloom filter should be disabled for better frame rates on mobile devices.
* Fix geometries no closing completely. [#1093](https://github.com/AnalyticalGraphicsInc/cesium/issues/1093)

### b20 - 2013-09-03

Expand Down
65 changes: 23 additions & 42 deletions Source/Core/Cartesian2.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,6 @@ define([
this.y = defaultValue(y, 0.0);
};

/**
* Creates a Cartesian2 from two consecutive elements in an array.
* @memberof Cartesian2
*
* @param {Array} values The array whose two consecutive elements correspond to the x and y components, respectively.
* @param {Number} [offset=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian2} [result] The object onto which to store the result.
*
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
*
* @exception {DeveloperError} values is required.
* @exception {DeveloperError} offset + 2 is greater than the length of the array.
*
* @example
* // Create a Cartesian2 with (1.0, 2.0)
* var v = [1.0, 2.0];
* var p = Cartesian2.fromArray(v);
*
* // Create a Cartesian2 with (1.0, 2.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0];
* var p2 = Cartesian2.fromArray(v2, 2);
*/
Cartesian2.fromArray = function(values, offset, result) {
if (!defined(values)) {
throw new DeveloperError('values is required.');
}

if (offset + 2 > values.length) {
throw new DeveloperError('offset + 2 is greater than the length of the array.');
}

offset = defaultValue(offset, 0);

if (!defined(result)) {
result = new Cartesian2();
}

result.x = values[offset + 0];
result.y = values[offset + 1];
return result;
};

/**
* Creates a Cartesian2 instance from x and y coordinates.
* @memberof Cartesian2
Expand Down Expand Up @@ -206,6 +164,29 @@ define([
return result;
};

/**
* Creates a Cartesian2 from two consecutive elements in an array.
* @memberof Cartesian2
*
* @param {Array} array The array whose two consecutive elements correspond to the x and y components, respectively.
* @param {Number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian2} [result] The object onto which to store the result.
*
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
*
* @exception {DeveloperError} array is required.
*
* @example
* // Create a Cartesian2 with (1.0, 2.0)
* var v = [1.0, 2.0];
* var p = Cartesian2.fromArray(v);
*
* // Create a Cartesian2 with (1.0, 2.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0];
* var p2 = Cartesian2.fromArray(v2, 2);
*/
Cartesian2.fromArray = Cartesian2.unpack;

/**
* Computes the value of the maximum component for the supplied Cartesian.
* @memberof Cartesian2
Expand Down
66 changes: 23 additions & 43 deletions Source/Core/Cartesian3.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,6 @@ define([
return result;
};

/**
* Creates a Cartesian3 from three consecutive elements in an array.
* @memberof Cartesian3
*
* @param {Array} values The array whose three consecutive elements correspond to the x, y, and z components, respectively.
* @param {Number} [offset=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian3} [result] The object onto which to store the result.
*
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
*
* @exception {DeveloperError} values is required.
* @exception {DeveloperError} offset + 3 is greater than the length of the array.
*
* @example
* // Create a Cartesian3 with (1.0, 2.0, 3.0)
* var v = [1.0, 2.0, 3.0];
* var p = Cartesian3.fromArray(v);
*
* // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0, 3.0];
* var p2 = Cartesian3.fromArray(v2, 2);
*/
Cartesian3.fromArray = function(values, offset, result) {
if (!defined(values)) {
throw new DeveloperError('values is required.');
}

if (offset + 3 > values.length) {
throw new DeveloperError('offset + 3 is greater than the length of the array.');
}

offset = defaultValue(offset, 0);

if (!defined(result)) {
result = new Cartesian3();
}

result.x = values[offset + 0];
result.y = values[offset + 1];
result.z = values[offset + 2];
return result;
};

/**
* Creates a Cartesian3 instance from x, y and z coordinates.
* @memberof Cartesian3
Expand Down Expand Up @@ -233,6 +190,29 @@ define([
return result;
};

/**
* Creates a Cartesian3 from three consecutive elements in an array.
* @memberof Cartesian3
*
* @param {Array} array The array whose three consecutive elements correspond to the x, y, and z components, respectively.
* @param {Number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian3} [result] The object onto which to store the result.
*
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
*
* @exception {DeveloperError} array is required.
*
* @example
* // Create a Cartesian3 with (1.0, 2.0, 3.0)
* var v = [1.0, 2.0, 3.0];
* var p = Cartesian3.fromArray(v);
*
* // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0, 3.0];
* var p2 = Cartesian3.fromArray(v2, 2);
*/
Cartesian3.fromArray = Cartesian3.unpack;

/**
* Computes the value of the maximum component for the supplied Cartesian.
* @memberof Cartesian3
Expand Down
69 changes: 25 additions & 44 deletions Source/Core/Cartesian4.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,6 @@ define([
this.w = defaultValue(w, 0.0);
};

/**
* Creates a Cartesian4 from four consecutive elements in an array.
* @memberof Cartesian4
*
* @param {Array} values The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
* @param {Number} [offset=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian4} [result] The object onto which to store the result.
*
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*
* @exception {DeveloperError} values is required.
* @exception {DeveloperError} offset + 4 is greater than the length of the array.
*
* @example
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
* var v = [1.0, 2.0, 3.0, 4.0];
* var p = Cartesian4.fromArray(v);
*
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
* var p2 = Cartesian4.fromArray(v2, 2);
*/
Cartesian4.fromArray = function(values, offset, result) {
if (!defined(values)) {
throw new DeveloperError('values is required.');
}

if (offset + 4 > values.length) {
throw new DeveloperError('offset + 4 is greater than the length of the array.');
}

offset = defaultValue(offset, 0);

if (!defined(result)) {
result = new Cartesian4();
}

result.x = values[offset + 0];
result.y = values[offset + 1];
result.z = values[offset + 2];
result.w = values[offset + 3];
return result;
};

/**
* Creates a Cartesian4 instance from x, y, z and w coordinates.
* @memberof Cartesian4
Expand Down Expand Up @@ -208,6 +164,31 @@ define([
return result;
};



/**
* Creates a Cartesian4 from four consecutive elements in an array.
* @memberof Cartesian4
*
* @param {Array} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
* @param {Number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian4} [result] The object onto which to store the result.
*
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*
* @exception {DeveloperError} array is required.
*
* @example
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
* var v = [1.0, 2.0, 3.0, 4.0];
* var p = Cartesian4.fromArray(v);
*
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
* var p2 = Cartesian4.fromArray(v2, 2);
*/
Cartesian4.fromArray = Cartesian4.unpack;

/**
* Computes the value of the maximum component for the supplied Cartesian.
* @memberof Cartesian4
Expand Down
19 changes: 8 additions & 11 deletions Source/Core/GeometryPipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,18 +743,17 @@ define([
return geometry;
};

var scratch = new Cartesian3();
var scratchCartesian3 = new Cartesian3();
var scratchCartesian4 = new Cartesian4();

function transformPoint(matrix, attribute) {
if (defined(attribute)) {
var values = attribute.values;
var length = values.length;
for (var i = 0; i < length; i += 3) {
Cartesian3.fromArray(values, i, scratch);
Matrix4.multiplyByPoint(matrix, scratch, scratch);
values[i] = scratch.x;
values[i + 1] = scratch.y;
values[i + 2] = scratch.z;
Cartesian3.unpack(values, i, scratchCartesian3);
Matrix4.multiplyByPoint(matrix, scratchCartesian3, scratchCartesian4);
Cartesian3.pack(scratchCartesian4, values, i);
}
}
}
Expand All @@ -764,11 +763,9 @@ define([
var values = attribute.values;
var length = values.length;
for (var i = 0; i < length; i += 3) {
Cartesian3.fromArray(values, i, scratch);
Matrix3.multiplyByVector(matrix, scratch, scratch);
values[i] = scratch.x;
values[i + 1] = scratch.y;
values[i + 2] = scratch.z;
Cartesian3.unpack(values, i, scratchCartesian3);
Matrix3.multiplyByVector(matrix, scratchCartesian3, scratchCartesian4);
Cartesian3.pack(scratchCartesian4, values, i);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/BillboardCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ define([
var length = sixteenK * 6;
var indices = new Uint16Array(length);
for (var i = 0, j = 0; i < length; i += 6, j += 4) {
indices[i + 0] = j + 0;
indices[i] = j;
indices[i + 1] = j + 1;
indices[i + 2] = j + 2;

Expand Down
6 changes: 3 additions & 3 deletions Source/Scene/CustomSensorVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ define([
var distance = r / Math.cos(theta * 0.5);
var p = n1.multiplyByScalar(distance);

positions[(j * 3) + 0] = p.x;
positions[(j * 3)] = p.x;
positions[(j * 3) + 1] = p.y;
positions[(j * 3) + 2] = p.z;

Expand All @@ -292,8 +292,8 @@ define([

var k = 0;
for ( var i = length - 1, j = 0; j < length; i = j++) {
var p0 = new Cartesian3(positions[(i * 3) + 0], positions[(i * 3) + 1], positions[(i * 3) + 2]);
var p1 = new Cartesian3(positions[(j * 3) + 0], positions[(j * 3) + 1], positions[(j * 3) + 2]);
var p0 = new Cartesian3(positions[(i * 3)], positions[(i * 3) + 1], positions[(i * 3) + 2]);
var p1 = new Cartesian3(positions[(j * 3)], positions[(j * 3) + 1], positions[(j * 3) + 2]);
var n = p1.cross(p0).normalize(); // Per-face normals

vertices[k++] = 0.0; // Sensor vertex
Expand Down
6 changes: 0 additions & 6 deletions Specs/Core/Cartesian2Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ defineSuite([
}).toThrow();
});

it('fromArray throws with an invalid offset', function() {
expect(function() {
Cartesian2.fromArray([0.0, 0.0], 1);
}).toThrow();
});

it('clone without a result parameter', function() {
var cartesian = new Cartesian2(1.0, 2.0);
var result = cartesian.clone();
Expand Down
6 changes: 0 additions & 6 deletions Specs/Core/Cartesian3Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ defineSuite([
}).toThrow();
});

it('fromArray throws with an invalid offset', function() {
expect(function() {
Cartesian3.fromArray([0.0, 0.0, 0.0], 1);
}).toThrow();
});

it('clone without a result parameter', function() {
var cartesian = new Cartesian3(1.0, 2.0, 3.0);
var result = cartesian.clone();
Expand Down
6 changes: 0 additions & 6 deletions Specs/Core/Cartesian4Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ defineSuite([
}).toThrow();
});

it('fromArray throws with an invalid offset', function() {
expect(function() {
Cartesian4.fromArray([0.0, 0.0, 0.0, 0.0], 1);
}).toThrow();
});

it('clone without a result parameter', function() {
var cartesian = new Cartesian4(1.0, 2.0, 3.0, 4.0);
var result = cartesian.clone();
Expand Down