Skip to content

Commit 1918281

Browse files
authored
Merge pull request #6766 from AnalyticalGraphicsInc/fixSomeTestFailures
fixes for some test failures on IE and Firefox
2 parents 258e657 + 93f5992 commit 1918281

File tree

5 files changed

+37
-33
lines changed

5 files changed

+37
-33
lines changed

Source/Core/GroundPolylineGeometry.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ define([
648648
var absStartLon = Math.abs(start.longitude);
649649
var absEndLon = Math.abs(end.longitude);
650650
if (CesiumMath.equalsEpsilon(absStartLon, CesiumMath.PI, CesiumMath.EPSILON11)) {
651-
var endSign = Math.sign(end.longitude);
651+
var endSign = CesiumMath.sign(end.longitude);
652652
start.longitude = endSign * (absStartLon - CesiumMath.EPSILON11);
653653
return 1;
654654
} else if (CesiumMath.equalsEpsilon(absEndLon, CesiumMath.PI, CesiumMath.EPSILON11)) {
655-
var startSign = Math.sign(start.longitude);
655+
var startSign = CesiumMath.sign(start.longitude);
656656
end.longitude = startSign * (absEndLon - CesiumMath.EPSILON11);
657657
return 2;
658658
}
@@ -861,15 +861,15 @@ define([
861861
startGeometryNormal2D.x = 0.0;
862862
// If start longitude is negative and end longitude is less negative, relative right is unit -Y
863863
// If start longitude is positive and end longitude is less positive, relative right is unit +Y
864-
startGeometryNormal2D.y = Math.sign(startCartographic.longitude - Math.abs(endCartographic.longitude));
864+
startGeometryNormal2D.y = CesiumMath.sign(startCartographic.longitude - Math.abs(endCartographic.longitude));
865865
startGeometryNormal2D.z = 0.0;
866866
} else {
867867
// End is close to IDL - snap end normal to align with IDL
868868
startGeometryNormal2D = projectNormal(projection, startCartographic, startGeometryNormal, start2D, segmentStartNormal2DScratch);
869869
endGeometryNormal2D.x = 0.0;
870870
// If end longitude is negative and start longitude is less negative, relative right is unit Y
871871
// If end longitude is positive and start longitude is less positive, relative right is unit -Y
872-
endGeometryNormal2D.y = Math.sign(startCartographic.longitude - endCartographic.longitude);
872+
endGeometryNormal2D.y = CesiumMath.sign(startCartographic.longitude - endCartographic.longitude);
873873
endGeometryNormal2D.z = 0.0;
874874
}
875875
}

Specs/Core/CircleGeometrySpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ defineSuite([
158158
});
159159

160160
var r = ellipse.rectangle;
161-
expect(r.north).toEqual(0.698966597893341);
162-
expect(r.south).toEqual(0.698652226072367);
163-
expect(r.east).toEqual(-1.3192254919753026);
164-
expect(r.west).toEqual(-1.3196344953554853);
161+
expect(r.north).toEqualEpsilon(0.698966597893341, CesiumMath.EPSILON15);
162+
expect(r.south).toEqualEpsilon(0.698652226072367, CesiumMath.EPSILON15);
163+
expect(r.east).toEqualEpsilon(-1.3192254919753026, CesiumMath.EPSILON15);
164+
expect(r.west).toEqualEpsilon(-1.3196344953554853, CesiumMath.EPSILON15);
165165
});
166166

167167
it('computing textureCoordinateRotationPoints property', function() {

Specs/Core/GeometryPipelineSpec.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defineSuite([
22
'Core/GeometryPipeline',
3+
'Core/arraySlice',
34
'Core/AttributeCompression',
45
'Core/BoundingSphere',
56
'Core/BoxGeometry',
@@ -22,6 +23,7 @@ defineSuite([
2223
'Core/VertexFormat'
2324
], function(
2425
GeometryPipeline,
26+
arraySlice,
2527
AttributeCompression,
2628
BoundingSphere,
2729
BoxGeometry,
@@ -1739,7 +1741,7 @@ defineSuite([
17391741
minimum : new Cartesian3(-250000.0, -250000.0, -250000.0)
17401742
}));
17411743
expect(geometry.attributes.normal).toBeDefined();
1742-
var originalNormals = Array.prototype.slice.call(geometry.attributes.normal.values);
1744+
var originalNormals = arraySlice(geometry.attributes.normal.values);
17431745

17441746
geometry = GeometryPipeline.compressVertices(geometry);
17451747

@@ -1763,7 +1765,7 @@ defineSuite([
17631765
minimum : new Cartesian3(-250000.0, -250000.0, -250000.0)
17641766
}));
17651767
expect(geometry.attributes.st).toBeDefined();
1766-
var originalST = Array.prototype.slice.call(geometry.attributes.st.values);
1768+
var originalST = arraySlice(geometry.attributes.st.values);
17671769

17681770
geometry = GeometryPipeline.compressVertices(geometry);
17691771

@@ -1794,8 +1796,8 @@ defineSuite([
17941796
}));
17951797
expect(geometry.attributes.normal).toBeDefined();
17961798
expect(geometry.attributes.st).toBeDefined();
1797-
var originalNormals = Array.prototype.slice.call(geometry.attributes.normal.values);
1798-
var originalST = Array.prototype.slice.call(geometry.attributes.st.values);
1799+
var originalNormals = arraySlice(geometry.attributes.normal.values);
1800+
var originalST = arraySlice(geometry.attributes.st.values);
17991801

18001802
geometry = GeometryPipeline.compressVertices(geometry);
18011803

@@ -1826,9 +1828,9 @@ defineSuite([
18261828
expect(geometry.attributes.normal).toBeDefined();
18271829
expect(geometry.attributes.tangent).toBeDefined();
18281830
expect(geometry.attributes.bitangent).toBeDefined();
1829-
var originalNormals = Array.prototype.slice.call(geometry.attributes.normal.values);
1830-
var originalTangents = Array.prototype.slice.call(geometry.attributes.tangent.values);
1831-
var originalBitangents = Array.prototype.slice.call(geometry.attributes.bitangent.values);
1831+
var originalNormals = arraySlice(geometry.attributes.normal.values);
1832+
var originalTangents = arraySlice(geometry.attributes.tangent.values);
1833+
var originalBitangents = arraySlice(geometry.attributes.bitangent.values);
18321834

18331835
geometry = GeometryPipeline.compressVertices(geometry);
18341836

@@ -1949,10 +1951,10 @@ defineSuite([
19491951
var index;
19501952

19511953
// Expect eastern hemisphere vertices to all be 255 or 127 at the end of the value
1952-
expect(newScalars.indexOf(127)).not.toBe(-1);
1953-
expect(newVec4s.indexOf(127)).not.toBe(-1);
1954-
expect(newVec3s.indexOf(127)).not.toBe(-1);
1955-
expect(newVec2s.indexOf(127)).not.toBe(-1);
1954+
expect(Array.prototype.indexOf.call(newScalars, 127)).not.toBe(-1);
1955+
expect(Array.prototype.indexOf.call(newVec4s, 127)).not.toBe(-1);
1956+
expect(Array.prototype.indexOf.call(newVec3s, 127)).not.toBe(-1);
1957+
expect(Array.prototype.indexOf.call(newVec2s, 127)).not.toBe(-1);
19561958
for (i = 0; i < 3; i++) {
19571959
expect(newScalars[i] === 255 || newScalars[i] === 127).toBe(true);
19581960

@@ -1981,10 +1983,10 @@ defineSuite([
19811983
newScalars = westHemisphereGeometry.attributes.scalars.values;
19821984

19831985
// Expect eastern hemisphere vertices to all be 0 or 127 at the end of the value
1984-
expect(newScalars.indexOf(127)).not.toBe(-1);
1985-
expect(newVec4s.indexOf(127)).not.toBe(-1);
1986-
expect(newVec3s.indexOf(127)).not.toBe(-1);
1987-
expect(newVec2s.indexOf(127)).not.toBe(-1);
1986+
expect(Array.prototype.indexOf.call(newScalars, 127)).not.toBe(-1);
1987+
expect(Array.prototype.indexOf.call(newVec4s, 127)).not.toBe(-1);
1988+
expect(Array.prototype.indexOf.call(newVec3s, 127)).not.toBe(-1);
1989+
expect(Array.prototype.indexOf.call(newVec2s, 127)).not.toBe(-1);
19881990
for (i = 0; i < 4; i++) {
19891991
expect(newScalars[i] === 0 || newScalars[i] === 127).toBe(true);
19901992

Specs/Core/GroundPolylineGeometrySpec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defineSuite([
22
'Core/GroundPolylineGeometry',
33
'Core/ApproximateTerrainHeights',
4+
'Core/arraySlice',
45
'Core/Cartesian3',
56
'Core/Cartographic',
67
'Core/Math',
@@ -11,6 +12,7 @@ defineSuite([
1112
], function(
1213
GroundPolylineGeometry,
1314
ApproximateTerrainHeights,
15+
arraySlice,
1416
Cartesian3,
1517
Cartographic,
1618
CesiumMath,
@@ -33,11 +35,11 @@ defineSuite([
3335
var values = attribute.values;
3436
var componentsPerAttribute = attribute.componentsPerAttribute;
3537
var vertexCount = values.length / componentsPerAttribute;
36-
var firstVertex = values.slice(0, componentsPerAttribute);
38+
var firstVertex = arraySlice(values, 0, componentsPerAttribute);
3739
var identical = true;
3840
for (var i = 1; i < vertexCount; i++) {
3941
var index = i * componentsPerAttribute;
40-
var vertex = values.slice(index, index + componentsPerAttribute);
42+
var vertex = arraySlice(values, index, index + componentsPerAttribute);
4143
for (var j = 0; j < componentsPerAttribute; j++) {
4244
if (vertex[j] !== firstVertex[j]) {
4345
identical = false;
@@ -89,21 +91,21 @@ defineSuite([
8991
var values = endNormalAndTextureCoordinateNormalizationX.values;
9092
for (i = 0; i < 4; i++) {
9193
index = i * 4 + 3;
92-
expect(Math.sign(values[index])).toEqual(1.0);
94+
expect(CesiumMath.sign(values[index])).toEqual(1.0);
9395
}
9496
for (i = 4; i < 8; i++) {
9597
index = i * 4 + 3;
96-
expect(Math.sign(values[index])).toEqual(-1.0);
98+
expect(CesiumMath.sign(values[index])).toEqual(-1.0);
9799
}
98100

99101
values = texcoordNormalization2D.values;
100102
for (i = 0; i < 4; i++) {
101103
index = i * 2;
102-
expect(Math.sign(values[index])).toEqual(1.0);
104+
expect(CesiumMath.sign(values[index])).toEqual(1.0);
103105
}
104106
for (i = 4; i < 8; i++) {
105107
index = i * 2;
106-
expect(Math.sign(values[index])).toEqual(-1.0);
108+
expect(CesiumMath.sign(values[index])).toEqual(-1.0);
107109
}
108110

109111
// Expect rightNormalAndTextureCoordinateNormalizationY and texcoordNormalization2D.y to encode if the vertex is on the bottom

Specs/Core/RectangleGeometrySpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ defineSuite([
380380
});
381381

382382
var r = geometry.rectangle;
383-
expect(CesiumMath.toDegrees(r.north)).toEqual(1.414213562373095);
384-
expect(CesiumMath.toDegrees(r.south)).toEqual(-1.414213562373095);
385-
expect(CesiumMath.toDegrees(r.east)).toEqual(1.414213562373095);
386-
expect(CesiumMath.toDegrees(r.west)).toEqual(-1.4142135623730951);
383+
expect(CesiumMath.toDegrees(r.north)).toEqualEpsilon(1.414213562373095, CesiumMath.EPSILON15);
384+
expect(CesiumMath.toDegrees(r.south)).toEqualEpsilon(-1.414213562373095, CesiumMath.EPSILON15);
385+
expect(CesiumMath.toDegrees(r.east)).toEqualEpsilon(1.414213562373095, CesiumMath.EPSILON15);
386+
expect(CesiumMath.toDegrees(r.west)).toEqualEpsilon(-1.4142135623730951, CesiumMath.EPSILON15);
387387
});
388388

389389
it('computing textureCoordinateRotationPoints property', function() {

0 commit comments

Comments
 (0)