Skip to content

Commit

Permalink
fix projection uniform mismatch when using web_mercator_auto_offset a…
Browse files Browse the repository at this point in the history
…nd cartesian
  • Loading branch information
Xiaoji Chen committed Mar 10, 2020
1 parent b1901b1 commit 9affba3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions modules/core/src/shaderlib/project/viewport-uniforms.js
Expand Up @@ -78,6 +78,8 @@ export function getOffsetOrigin(
Math.fround(viewport.center[1]),
0
];
// Geospatial origin (wgs84) must match shaderCoordinateOrigin (common)
geospatialOrigin = viewport.unprojectPosition(shaderCoordinateOrigin);
}
break;

Expand Down
Expand Up @@ -88,7 +88,7 @@ const TEST_CASES = [
viewport: TEST_VIEWPORT,
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN
},
result: [174.15111111111113, -58.11045723102637, 0]
result: [174.15110778808594, -58.11044311523443, 0]
},
{
title: 'LNGLAT_OFFSETS',
Expand Down
5 changes: 3 additions & 2 deletions test/modules/core/shaderlib/project/viewport-uniforms.spec.js
Expand Up @@ -144,9 +144,10 @@ test('project#getUniforms', t => {
});
t.notOk(getUniformsError(uniforms, UNIFORMS), 'Uniforms validated');
t.ok(uniforms.project_uCenter.some(x => x), 'Returned non-trivial projection center');
// CARTESIAN + WEB_MERCATOR_AUTO_OFFSET is rounded in the common space
t.ok(
Math.abs(uniforms.project_uCenter[0]) < EPSILON &&
Math.abs(uniforms.project_uCenter[1]) < EPSILON,
Math.abs(uniforms.project_uCenter[0]) < EPSILON * 10 &&
Math.abs(uniforms.project_uCenter[1]) < EPSILON * 10,
'project center at center of clipspace'
);
t.ok(
Expand Down

0 comments on commit 9affba3

Please sign in to comment.