Skip to content

Commit

Permalink
fix #2872
Browse files Browse the repository at this point in the history
  • Loading branch information
hpinkos committed Jul 7, 2015
1 parent b711ce0 commit 3b8b2ae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Source/Core/WallGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ define([
var recomputeNormal = true;
length /= 3;
var i;
var s = 0;
for (i = 0; i < length; ++i) {
var i3 = i * 3;
var topPosition = Cartesian3.fromArray(topPositions, i3, scratchCartesian3Position1);
Expand All @@ -405,6 +406,14 @@ define([
positions[positionIndex++] = topPosition.z;
}

if (vertexFormat.st) {
textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 0.0;

textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 1.0;
}

if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
var nextPosition;
var nextTop = Cartesian3.clone(Cartesian3.ZERO, scratchCartesian3Position5);
Expand All @@ -424,6 +433,7 @@ define([
if (Cartesian3.equalsEpsilon(nextPosition, groundPosition, CesiumMath.EPSILON6)) {
recomputeNormal = true;
} else {
s += 1/(wallPositions.length - 1);
if (vertexFormat.tangent) {
tangent = Cartesian3.normalize(Cartesian3.subtract(nextPosition, groundPosition, tangent), tangent);
}
Expand Down Expand Up @@ -462,16 +472,6 @@ define([
binormals[binormalIndex++] = binormal.z;
}
}

if (vertexFormat.st) {
var s = i / (length - 1);

textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 0.0;

textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 1.0;
}
}

var attributes = new GeometryAttributes();
Expand Down
23 changes: 23 additions & 0 deletions Specs/Core/WallGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,29 @@ defineSuite([
expect(w.indices.length).toEqual((4 * 2 - 2) * 3);
});

it('creates correct texture coordinates', function() {
var w = WallGeometry.createGeometry(new WallGeometry({
vertexFormat : VertexFormat.ALL,
positions : Cartesian3.fromDegreesArrayHeights([
49.0, 18.0, 1000.0,
50.0, 18.0, 1000.0,
51.0, 18.0, 1000.0
])
}));

expect(w.attributes.st.values.length).toEqual(4 * 2 * 2);
expect(w.attributes.st.values).toEqual([
0.0, 0.0,
0.0, 1.0,
0.5, 0.0,
0.5, 1.0,
0.5, 0.0,
0.5, 1.0,
1.0, 0.0,
1.0, 1.0
]);
});

it('fromConstantHeights throws without positions', function() {
expect(function() {
return WallGeometry.fromConstantHeights();
Expand Down

0 comments on commit 3b8b2ae

Please sign in to comment.