diff --git a/Source/Core/QuantizedMeshTerrainData.js b/Source/Core/QuantizedMeshTerrainData.js index 00cf63cbbcc1..6d2f4a737156 100644 --- a/Source/Core/QuantizedMeshTerrainData.js +++ b/Source/Core/QuantizedMeshTerrainData.js @@ -501,17 +501,17 @@ define([ function isPointInsideUVTriangle(u, v, u0, v0, u1, v1, u2, v2) { var inside = false; - var intersect = ((v0 > v) !== (v1 > v)) && (u < (u1 - u0) * (v - v0) / (v1 - v0) + u0); + var intersect = ((v0 > v) !== (v1 >= v)) && (u <= (u1 - u0) * (v - v0) / (v1 - v0) + u0); if (intersect) { inside = !inside; } - intersect = ((v1 > v) !== (v2 > v)) && (u < (u2 - u1) * (v - v1) / (v2 - v1) + u1); + intersect = ((v1 > v) !== (v2 >= v)) && (u <= (u2 - u1) * (v - v1) / (v2 - v1) + u1); if (intersect) { inside = !inside; } - intersect = ((v2 > v) !== (v0 > v)) && (u < (u0 - u2) * (v - v2) / (v0 - v2) + u2); + intersect = ((v2 > v) !== (v0 >= v)) && (u <= (u0 - u2) * (v - v2) / (v0 - v2) + u2); if (intersect) { inside = !inside; } diff --git a/Specs/Core/sampleTerrainMostDetailedSpec.js b/Specs/Core/sampleTerrainMostDetailedSpec.js index b85013ead263..a6a1eaad0ac0 100644 --- a/Specs/Core/sampleTerrainMostDetailedSpec.js +++ b/Specs/Core/sampleTerrainMostDetailedSpec.js @@ -74,7 +74,7 @@ defineSuite([ }); it('works for a dodgy point right near the edge of a tile', function() { - var positions = [new Cartographic(0.33179290856829535, 0.7363107781851076)]; + var positions = [new Cartographic(0.33179290856829535, 0.7363107781851078)]; return sampleTerrainMostDetailed(worldTerrain, positions).then(function() { expect(positions[0].height).toBeDefined(); diff --git a/Specs/Core/sampleTerrainSpec.js b/Specs/Core/sampleTerrainSpec.js index 7d69157ffa02..a11d19359e9d 100644 --- a/Specs/Core/sampleTerrainSpec.js +++ b/Specs/Core/sampleTerrainSpec.js @@ -93,7 +93,7 @@ defineSuite([ }); it('works for a dodgy point right near the edge of a tile', function() { - var positions = [new Cartographic(0.33179290856829535, 0.7363107781851076)]; + var positions = [new Cartographic(0.33179290856829535, 0.7363107781851078)]; return sampleTerrain(worldTerrain, 12, positions).then(function() { expect(positions[0].height).toBeDefined();